C Interface

Defines

yggOutput_t

Pointer to an output comm.

yggInput_t

Pointer to an input comm.

ygg_free

Aliases to method for freeing comms.

yggComm

Initialize a comm object.

yggSend

Send arguments as a small formatted message to an output queue. Use the associated data type to format the message from the input arguments.

Formatted IO

Output Usage:

  1. One-time: Create output channel with format specifier.

    yggOutput_t output_channel = yggOutputFmt("out_name", "a=%d, b=%d");
    

  2. Send:

    ret = yggSend(output_channel, 1, 2);
    

  3. Free:

    ygg_free(&output_channel);
    

Input Usage:

  1. One-time: Create output channel with format specifier.

    yggInput_t input_channel = yggInput("in_name", "a=%d, b=%d");
    

  2. Prepare: Allocate space for recovered variables.

    int a, b;
    

  3. Receive:

    int ret = yggRecv(input_channel, &a, &b);
    

Parameters:
  • yggQ[in] Output or RPC comm structure that queue should be sent to.

  • ...[in] Variables to be formatted into a message based on the data type associated with the comm.

Returns:

int 0 if send succesfull, -1 if send unsuccessful.

yggRecv

Receive a message from a comm into variables passed as arguments. If received message data will exceed the bounds of provided variables, an error will be returned.

Parameters:
  • yggQ[in] yggOutput_t structure that message should be sent to.

  • ...[out] Pointers to variables that should be assigned by parsing the received message using the associated data type. If no data type has been added to the comm, one will be created from the data types of the first received message. As these are being assigned, they should be pointers to memory that has already been allocated (heap or stack).

Returns:

int -1 if message could not be received or could not be parsed, length of the received message if message was received and parsed.

yggRecvRealloc

Receive a message from a comm into variables passed as arguments. If received message data will exceed the bounds of provided variables, the variables will be reallocated.

Parameters:
  • yggQ[in] yggOutput_t structure that message should be sent to.

  • ...[out] Pointers to variables that should be assigned to by parsing the received message using the associated data type. If no data type has been added to the comm, one will be created from the data types of the first received message. As these are being assigned and possibly reallocated, they should be pointers to memory addresses that can be reallocated (heap).

Returns:

int -1 if message could not be received or could not be parsed, length of the received message if the message was received and parsed.

yggRpc_t

Remote Procedure Call (RPC) alias for a comm_t pointer. Contains information required to coordinate sending/receiving response/requests from/to an RPC server/client.

Remote Procedure Call (RPC) IO

Handle IO case of a server receiving input from clients, performing some calculation, and then sending a response back to the client.

Server Usage:

  1. One-time: Create server channels with format specifiers for input and output.

    yggRpc_t srv = yggRpcServer("srv_name", "%d", "%d %d");
    

  2. Prepare: Allocate space for recovered variables from request.

    int a;
    

  3. Receive request:

    int ret = rpcRecv(srv, &a);
    

  4. Process: Do tasks the server should do with input to produce output.

        int b = 2*a;
    int c = 3*a;
    

  5. Send response:

    ret = rpcSend(srv, b, c);
    

Client Usage:

  1. One-time: Create client channels to desired server with format specifiers for output and input (should be the same arguments as for the server except for name).

    yggRpc_t cli = yggRpcClient("cli_name", "%d", "%d %d"); 
    

  2. Prepare: Allocate space for recovered variables from response.

    int b, c;
    

  3. Call server:

    int ret = rpcCall(cli, 1, &b, &c);
    

Clients can also send several requests at once before receiving any responses. This allows the server to be processing the next requests while the client handles the previous response, thereby increasing efficiency. The responses are assumed to be in the same order as the generating requests (i.e. first come, first served).

vrpcSend

Format and send a message to an RPC output queue. Format provided arguments list using the output queue format string and then sends it to the output queue under the assumption that it is larger than the maximum message size.

Parameters:
  • rpc[in] yggRpc_t structure with RPC information.

  • ap[in] va_list variable list of arguments for formatting.

Returns:

integer specifying if the send was succesful. Values >= 0 indicate success.

vrpcRecv(rpc, ap)

Receive a message from a comm into variables in a variable argument list. If received message data will exceed the bounds of provided variables, an error will be returned.

Parameters:
  • rpc[in] RPC comm structure that message should be sent to.

  • ap[out] Variable list of arguments that should be assigned parameters extracted using the associated data type. Since these will be assigned, they should be pointers to memory that has already been allocated (heap or stack).

Returns:

integer specifying if the receive was succesful. Values >= 0 indicate success.

vrpcRecvRealloc(rpc, ap)

Receive a message from a comm into variables in a variable argument list. If received message data will exceed the bounds of provided variables, the variables will be reallocated.

Parameters:
  • rpc[in] RPC comm structure that message should be sent to.

  • ap[out] Variable list of arguments that should be assigned parameters extracted using the associated data type. Since these will be assigned and possibly reallocated, they should be pointers to memory addresses that can be reallocated (heap).

Returns:

integer specifying if the receive was succesful. Values >= 0 indicate success.

rpcSend

Format and send a message to an RPC output queue. Format provided arguments using the output queue format string and then sends it to the output queue under the assumption that it is larger than the maximum message size.

Parameters:
  • rpc[in] yggRpc_t structure with RPC information.

  • ...[in] arguments for formatting.

Returns:

integer specifying if the send was succesful. Values >= 0 indicate success.

rpcRecv

Receive and parse a message from an RPC input queue. Receive a message from the input queue under the assumption that it is larger than the maximum message size. Then parse the message using the input queue format string to extract parameters and assign them to the arguments.

Parameters:
  • rpc[in] RPC comm structure that message should be sent to.

  • ...[out] mixed arguments that should be assigned parameters extracted using the format string. Since these will be assigned, they should be pointers to memory that has already been allocated.

Returns:

integer specifying if the receive was succesful. Values >= 0 indicate success.

rpcRecvRealloc

Receive a message from a comm into variables passed as arguments. If received message data will exceed the bounds of provided variables, the variables will be reallocated.

Parameters:
  • rpc[in] RPC comm structure that message should be sent to.

  • ...[out] Pointers to variables that should be assigned to by parsing the received message using the associated data type. If no data type has been added to the comm, one will be created from the data types of the first received message. As these are being assigned and possibly reallocated, they should be pointers to memory addresses that can be reallocated (heap).

Returns:

int -1 if message could not be received or could not be parsed, length of the received message if the message was received and parsed.

rpcCall(rpc, ...)

Macro to call nrpcCallBase with allow_realloc=0 and the argument count.

rpcCallRealloc(rpc, ...)

Macro to call nrpcCallBase with allow_realloc=1 and the argument count.

yggAsciiFileInput_t

Pointer to an input comm for an ASCII file.

File IO

Handle I/O from/to a file line by line.

Input Usage:

  1. One-time: Create file interface by providing a channel name.

    comm_t* fin = yggAsciiFileInput("file_channel");
    

  2. Prepare: Get pointer for line.

    char *line;
    

  3. Receive each line, terminating when receive returns -1 (EOF or channel closed).

    int ret = 1;
    while (ret > 0) {
      ret = yggRecv(fin, &line); // line will be realloced to fit message
      // Do something with the line
    }
    

  4. Cleanup. Call functions to deallocate structures.

    free(line);
    

Output Usage:

  1. One-time: Create file interface by providing a channel name.

    comm_t* fout = yggAsciiFileOutput("file_channel");
    

  2. Send lines to the file. If return value is not 0, the send was not succesfull.

    int ret;
    ret = yggSend(fin, "Line 1\n");
    ret = yggSend(fout, "Line 1\n");
    ret = yggSend(fout, "Line 2\n");
    

yggAsciiFileOutput_t

Pointer to an output comm for an ASCII file.

yggAsciiTableInput_t

Pointer to an input comm for an ASCII table.

Table IO

Handle I/O from/to an ASCII table either line-by-line or as an array.

Row-by-Row

Input by Row Usage:

  1. One-time: Create file interface by providing a channel name.

    comm_t* fin = yggAsciiTableInput("file_channel");
    

  2. Prepare: Allocate space for variables in row (the format in this example is “%5s %d %f\n” like the output example below).

    char a[5];
    int b;
    double c;
    

  3. Receive each row, terminating when receive returns -1 (EOF or channel closed).

    int ret = 1;
    while (ret > 0) {
      ret = yggRecv(fin, &a, &b, &c);
      // Do something with the row
    }
    

Output by Row Usage:

  1. One-time: Create file interface by providing a channel name and a format string for rows.

    comm_t* fout = yggAsciiTableOutput("file_channel", "%5s %d %f\n");
    

  2. Send rows to the file by providing entries. Formatting is handled by the interface. If return value is not 0, the send was not succesful.

    int ret;
    ret = yggSend(fout, "one", 1, 1.0);
    ret = yggSend(fout, "two", 2, 2.0);
    

Array

Input by Array Usage:

  1. One-time: Create file interface by providing a channel name. comm_t* fin = yggAsciiArrayInput(“file_channel”);

  2. Prepare: Declare pointers for table columns (they will be allocated by the interface once the number of rows is known).

    char *aCol;
    int *bCol;
    double *cCol;
    

  3. Receive entire table as columns. Return value will be the number of elements in each column (the number of table rows). Negative values indicate errors.

    int ret = yggRecv(fin, &a, &b, &c);
    

  4. Cleanup. Call functions to deallocate structures.

    free(a);
    free(b);
    free(c);
    

Output by Array Usage:

  1. One-time: Create file interface by providing a channel name and a format string for rows.

    comm_t* fout = yggAsciiArrayOutput("file_channel", "%5s %d %f\n");
    

  2. Send columns to the file by providing pointers (or arrays). Formatting is handled by the interface. If return value is not 0, the send was not succesful.

    char aCol[] = {"one  ", "two  ", "three"}; \\ Each str is of len 5
    int bCol[3] = {1, 2, 3};
    float cCol[3] = {1.0, 2.0, 3.0};
        int ret = yggSend(fout, a, b, c);
    

yggAsciiTableOutput_t

Pointer to an output comm for an ASCII table.

yggAsciiArrayInput_t

Pointer to an input comm for an ASCII table passed as arrays.

yggAsciiArrayOutput_t

Pointer to an output comm for an ASCII table passed as arrays.

yggPlyInput_t

Pointer to an input comm for ply meshes.

Ply IO

Handle I/O from/to a Ply file.

Input Usage:

  1. One-time: Create file interface by providing a channel name.

    comm_t* fin = yggPlyInput("file_channel");  // channel
    

  2. Prepare: Allocate ply structure.

    ply_t p;
    

  3. Receive each structure, terminating when receive returns -1 (EOF or channel closed).

    int ret = 1;
    while (ret > 0) {
      ret = yggRecv(fin, &p);
      // Do something with the ply structure
    }
    

Output by Usage:

  1. One-time: Create file interface by providing a channel name.

    comm_t* fout = yggPlyOutput("file_channel");  // channel
    

  2. Send structure to the file by providing entries. Formatting is handled by the interface. If return value is not 0, the send was not succesful.

    int ret;
    ply_t p;
    // Populate the structure
    ret = yggSend(fout, p);
    ret = yggSend(fout, p);
    

yggPlyOutput_t

Pointer to an output comm for ply meshes.

yggObjInput_t

Pointer to an input comm for obj meshes.

Obj IO

Handle I/O from/to a Obj file.

Input Usage:

  1. One-time: Create file interface by providing a channel name.

    comm_t* fin = yggObjInput("file_channel");  // channel
    

  2. Prepare: Allocate obj structure.

    obj_t p;
    

  3. Receive each structure, terminating when receive returns -1 (EOF or channel closed).

    int ret = 1;
    while (ret > 0) {
      ret = yggRecv(fin, &p);
      // Do something with the obj structure
    }
    

Output by Usage:

  1. One-time: Create file interface by providing a channel name.

    comm_t* fout = yggObjOutput("file_channel");  // channel
    

  2. Send structure to the file by providing entries. Formatting is handled by the interface. If return value is not 0, the send was not succesful.

    int ret;
    obj_t p;
    // Populate the structure
    ret = yggSend(fout, p);
    ret = yggSend(fout, p);
    

yggObjOutput_t

Pointer to an output comm for obj meshes.

yggVectorOutput

An alias for yggJSONArrayOutput.

yggVectorInput

An alias for yggJSONArrayInput.

yggMapOutput

An alias for yggJSONObjectOutput.

yggMapInput

An alias for yggJSONObjectInput.

Functions

static inline comm_t *yggRpcServerType_global(const char *name, dtype_t *inType, dtype_t *outType)

Constructor for server side RPC structure w/ explicit type info. Creates an instance of yggRpc_t with provided information after first checking for a pre-existing global comm of the same name. If one doesn’t exist, one is created.

Parameters:
  • name[in] constant character pointer to name for queues.

  • inType[in] Pointer to a dtype_t data structure containing type info for data that will be received by the server.

  • outType[in] Pointer to a dtype_t data structure containing type info for data that will be sent by the server.

Returns:

yggRpc_t structure with provided info.

static inline yggOutput_t yggOutputType(const char *name, dtype_t *datatype)

Constructor for yggOutput_t structure with explicit data type. Create a yggOutput_t structure based on a provided name that is used to locate a particular comm address stored in the environment variable name and a structure definining the datatype of outgoing messages for the queue.

Basic IO

Output Usage:

  1. One-time: Create output channel (store in named variables)

    yggOutput_t output_channel = yggOutput("out_name");
    

  2. Prepare: Format data to a character array buffer.

        char buffer[YGG_MSG_BUF]; 
    snprintf(buffer, YGG_MSG_BUF, "a=%d, b=%d", 1, 2);
    

  3. Send:

    ret = ygg_send(output_channel, buffer, strlen(buffer));
    

Input Usage:

  1. One-time: Create output channel (store in named variables)

    yggInput_t input_channel = yggInput("in_name");
    

  2. Prepare: Allocate a character array buffer.

    char buffer[YGG_MSG_BUF];
    

  3. Receive:

    int ret = ygg_recv(input_channel, buffer, YGG_MSG_BUF);
    

Parameters:
  • name[in] constant character pointer to name of queue.

  • datatype[in] Pointer to a dtype_t data structure containing type informaiton.

Returns:

yggOutput_t output queue structure.

static inline yggInput_t yggInputType(const char *name, dtype_t *datatype)

Constructor for yggInput_t structure with explicit data type. Create a yggInput_t structure based on a provided name that is used to locate a particular comm address stored in the environment variable name and a structure defining the expected datatype of received messages.

Parameters:
  • name[in] constant character pointer to name of queue.

  • datatype[in] Pointer to a dtype_t data structure containing type informaiton.

Returns:

yggInput_t input queue structure.

static inline yggOutput_t yggOutputFmt(const char *name, const char *fmtString)

Constructor for yggOutput_t structure with format. Create a yggOutput_t structure based on a provided name that is used to locate a particular comm address stored in the environment variable name and a format string that can be used to format arguments into outgoing messages for the queue.

Parameters:
  • name[in] constant character pointer to name of queue.

  • fmtString[in] character pointer to format string.

Returns:

yggOutput_t output queue structure.

static inline yggInput_t yggInputFmt(const char *name, const char *fmtString)

Constructor for yggInput_t structure with format. Create a yggInput_t structure based on a provided name that is used to locate a particular comm address stored in the environment variable name and a format stirng that can be used to extract arguments from received messages.

Parameters:
  • name[in] constant character pointer to name of queue.

  • fmtString[in] character pointer to format string.

Returns:

yggInput_t input queue structure.

static inline yggOutput_t yggOutput(const char *name)

Constructor for yggOutput_t output structure. Create a yggOutput_t structure based on a provided name that is used to locate a particular comm address stored in the environment variable name.

Parameters:

name[in] constant character pointer to name of queue.

Returns:

yggOutput_t output queue structure.

static inline yggInput_t yggInput(const char *name)

Constructor for yggInput_t structure. Create a yggInput_t structure based on a provided name that is used to locate a particular comm address stored in the environment variable name.

Parameters:

name[in] constant character pointer to name of queue.

Returns:

yggInput_t input queue structure.

static inline int ygg_send(const yggOutput_t yggQ, const char *data, const size_t len)

Send a message to an output queue. Send a message smaller than YGG_MSG_MAX bytes to an output queue. If the message is larger, it will not be sent.

Parameters:
  • yggQ[in] yggOutput_t structure that queue should be sent to.

  • data[in] character pointer to message that should be sent.

  • len[in] size_t length of message to be sent.

Returns:

int 0 if send succesfull, -1 if send unsuccessful.

static inline int ygg_send_eof(const yggOutput_t yggQ)

Send EOF message to the output queue.

Parameters:

yggQ[in] yggOutput_t structure that message should be sent to.

Returns:

int 0 if send successfull, -1 if unsuccessful.

static inline int ygg_recv(yggInput_t yggQ, char *data, const size_t len)

Receive a message from an input queue. Receive a message smaller than YGG_MSG_MAX bytes from an input queue.

Parameters:
  • yggQ[in] yggOutput_t structure that message should be sent to.

  • data[out] character pointer to allocated buffer where the message should be saved.

  • len[in] const size_t length of the allocated message buffer in bytes.

Returns:

int -1 if message could not be received. Length of the received message if message was received.

static inline int ygg_send_nolimit(const yggOutput_t yggQ, const char *data, const size_t len)

Send a large message to an output queue. Send a message larger than YGG_MSG_MAX bytes to an output queue by breaking it up between several smaller messages and sending initial message with the size of the message that should be expected. Must be partnered with ygg_recv_nolimit for communication to make sense.

Parameters:
  • yggQ[in] yggOutput_t structure that message should be sent to.

  • data[in] character pointer to message that should be sent.

  • len[in] size_t length of message to be sent.

Returns:

int 0 if send succesfull, -1 if send unsuccessful.

static inline int ygg_send_nolimit_eof(const yggOutput_t yggQ)

Send EOF message to the output queue.

Parameters:

yggQ[in] yggOutput_t structure that message should be sent to.

Returns:

int 0 if send successfull, -1 if unsuccessful.

static inline int ygg_recv_nolimit(yggInput_t yggQ, char **data, const size_t len)

Receive a large message from an input queue. Receive a message larger than YGG_MSG_MAX bytes from an input queue by receiving it in parts. This expects the first message to be the size of the total message.

Parameters:
  • yggQ[in] yggOutput_t structure that message should be sent to.

  • data[out] character pointer to pointer for allocated buffer where the message should be stored. A pointer to a pointer is used so that the buffer may be reallocated as necessary for the incoming message.

  • len[in] size_t length of the initial allocated message buffer in bytes.

Returns:

int -1 if message could not be received. Length of the received message if message was received.

static inline comm_t *yggRpcClient(const char *name, const char *outFormat, const char *inFormat)

Constructor for client side RPC structure. Creates an instance of yggRpc_t with provided information.

Parameters:
  • name[in] constant character pointer to name for queues.

  • outFormat[in] character pointer to format that should be used for formatting output.

  • inFormat[in] character pointer to format that should be used for parsing input.

Returns:

yggRpc_t structure with provided info.

static inline comm_t *yggRpcServer(const char *name, const char *inFormat, const char *outFormat)

Constructor for server side RPC structure. Creates an instance of yggRpc_t with provided information.

Parameters:
  • name[in] constant character pointer to name for queues.

  • inFormat[in] character pointer to format that should be used for parsing input.

  • outFormat[in] character pointer to format that should be used for formatting output.

Returns:

yggRpc_t structure with provided info.

static inline comm_t *yggRpcClientType(const char *name, dtype_t *outType, dtype_t *inType)

Constructor for client side RPC structure w/ explicit type info. Creates an instance of yggRpc_t with provided information.

Parameters:
  • name[in] constant character pointer to name for queues.

  • outType[in] Pointer to a dtype_t data structure containing type info for data that will be sent by the client.

  • inType[in] Pointer to a dtype_t data structure containing type info for data that will be received by the client.

Returns:

yggRpc_t structure with provided info.

static inline comm_t *yggRpcServerType(const char *name, dtype_t *inType, dtype_t *outType)

Constructor for server side RPC structure w/ explicit type info. Creates an instance of yggRpc_t with provided information.

Parameters:
  • name[in] constant character pointer to name for queues.

  • inType[in] Pointer to a dtype_t data structure containing type info for data that will be received by the server.

  • outType[in] Pointer to a dtype_t data structure containing type info for data that will be sent by the server.

Returns:

yggRpc_t structure with provided info.

static inline comm_t *yggTimesync(const char *name, const char *t_units)

Constructor for client side timestep synchronization calls. Creates an instance of comm_t with provided information.

Parameters:
  • name[in] constant character pointer to name for queues.

  • t_units[in] const char* Units that should be used for the timestep. “” indicates no units.

Returns:

comm_t structure with provided info.

static inline int vrpcCallBase(yggRpc_t rpc, va_list_t ap)

Send request to an RPC server from the client and wait for a response. Format arguments using the output queue format string, send the message to the output queue, receive a response from the input queue, and assign arguments from the message using the input queue format string to parse it.

Parameters:
  • rpc[in] yggRpc_t structure with RPC information.

  • ap[inout] va_list mixed arguments that include those that should be formatted using the output format string, followed by those that should be assigned parameters extracted using the input format string. These that will be assigned should be pointers to memory that has already been allocated.

Returns:

integer specifying if the receive was succesful. Values >= 0 indicate success.

static inline int nrpcCallBase(yggRpc_t rpc, const int allow_realloc, size_t nargs, ...)

Send request to an RPC server from the client and wait for a response. Format arguments using the output queue format string, send the message to the output queue, receive a response from the input queue, and assign arguments from the message using the input queue format string to parse it.

Parameters:
  • rpc[in] yggRpc_t structure with RPC information.

  • allow_realloc[in] int If 1, output arguments are assumed to be pointers to pointers such that they can be reallocated as necessary to receive incoming data. If 0, output arguments are assumed to be preallocated.

  • nargs[in] size_t Number of arguments contained in ap including both input and output arguments.

  • ...[inout] mixed arguments that include those that should be formatted using the output format string, followed by those that should be assigned parameters extracted using the input format string. If allow_realloc is 0, those arguments that will be assigned should be pointers to memory that has already been allocated. If allow_realloc is 1, those arguments that will be assigned should be pointers to pointers for memory that can be reallocated.

Returns:

integer specifying if the receive was succesful. Values >= 0 indicate success.

static inline comm_t *yggAsciiFileOutput(const char *name)

Constructor for AsciiFile output comm to channel.

Parameters:

name[in] constant character pointer to name of an output channel.

Returns:

comm_t* for line-by-line output to a file or channel.

static inline comm_t *yggAsciiFileInput(const char *name)

Constructor for AsciiFile input comm from channel.

Parameters:

name[in] constant character pointer to name of an input channel.

Returns:

comm_t* for line-by-line input from a file or channel.

static inline comm_t *yggAsciiTableOutput(const char *name, const char *format_str)

Constructor for table output comm to an output channel.

Parameters:
  • name[in] constant character pointer to output channel name.

  • format_str[in] character pointer to format string that should be used to format rows into table lines.

Returns:

comm_t* output structure.

static inline comm_t *yggAsciiTableInput(const char *name)

Constructor for AsciiTable input comm from an input channel.

Parameters:

name[in] constant character pointer to input channel name.

Returns:

comm_t* input structure.

static inline comm_t *yggAsciiArrayOutput(const char *name, const char *format_str)

Constructor for table output comm with array output.

Parameters:
  • name[in] constant character pointer to an output channel name.

  • format_str[in] character pointer to format string that should be used to format rows into table lines.

Returns:

comm_t* output structure.

static inline comm_t *yggAsciiArrayInput(const char *name)

Constructor for AsciiTable input comm with array input.

Parameters:

name[in] constant character pointer to an input channel name.

Returns:

comm_t* input structure.

static inline comm_t *yggPlyOutput(const char *name)

Constructor for ply output comm to an output channel.

Parameters:

name[in] constant character pointer to output channel name.

Returns:

comm_t* output structure.

static inline comm_t *yggPlyInput(const char *name)

Constructor for ply input comm from an input channel.

Parameters:

name[in] constant character pointer to input channel name.

Returns:

comm_t* input structure.

static inline comm_t *yggObjOutput(const char *name)

Constructor for obj output comm to an output channel.

Parameters:

name[in] constant character pointer to output channel name.

Returns:

comm_t* output structure.

static inline comm_t *yggObjInput(const char *name)

Constructor for obj input comm from an input channel.

Parameters:

name[in] constant character pointer to input channel name.

Returns:

comm_t* input structure.

static inline comm_t *yggGenericOutput(const char *name)

Constructor for generic output comm to an output channel.

Generic object I/O.

Handle I/O from/to a generic object.

Input Usage:

  1. One-time: Create interface by providing a channel name.

    comm_t* fin = yggGenericInput("file_channel");  // channel
    

  2. Prepare: Allocate generic structure.

    generic_t p;
    

  3. Receive each structure, terminating when receive returns -1 (EOF or channel closed).

    int ret = 1;
    while (ret > 0) {
      ret = yggRecv(fin, &p);
      // Do something with the generic structure
    }
    

Output by Usage:

  1. One-time: Create file interface by providing a channel name.

    comm_t* fout = yggGenericOutput("file_channel");  // channel
    

  2. Send structure to the file by providing entries. Formatting is handled by the interface. If return value is not 0, the send was not succesful.

    int ret;
    generic_t p;
    // Populate the structure
    ret = yggSend(fout, p);
    

Parameters:

name[in] constant character pointer to output channel name.

Returns:

comm_t* output structure.

static inline comm_t *yggGenericInput(const char *name)

Constructor for generic input comm from an input channel.

Parameters:

name[in] constant character pointer to input channel name.

Returns:

comm_t* input structure.

static inline comm_t *yggAnyOutput(const char *name)

Constructor for generic output comm to an output channel.

Generic object I/O of any type.

Handle I/O from/to a generic object of any type.

Input Usage:

  1. One-time: Create interface by providing a channel name.

    comm_t* fin = yggAnyInput("file_channel");  // channel
    

  2. Prepare: Allocate generic structure.

    generic_t p;
    

  3. Receive each structure, terminating when receive returns -1 (EOF or channel closed).

    int ret = 1;
    while (ret > 0) {
      ret = yggRecv(fin, &p);
      // Do something with the generic structure
    }
    

Output by Usage:

  1. One-time: Create file interface by providing a channel name.

    comm_t* fout = yggAnyOutput("file_channel");  // channel
    

  2. Send structure to the file by providing entries. Formatting is handled by the interface. If return value is not 0, the send was not succesful.

    int ret;
    generic_t p;
    // Populate the structure
    ret = yggSend(fout, p);
    

Parameters:

name[in] constant character pointer to output channel name.

Returns:

comm_t* output structure.

static inline comm_t *yggAnyInput(const char *name)

Constructor for generic input comm from an input channel.

Parameters:

name[in] constant character pointer to input channel name.

Returns:

comm_t* input structure.

static inline comm_t *yggJSONArrayOutput(const char *name)

Constructor for vector output comm to an output channel.

JSON array IO

Handle I/O from/to a JSON array.

Input Usage:

  1. One-time: Create interface by providing a channel name.

    comm_t* fin = yggJSONArrayInput("file_channel");  // channel
    

  2. Prepare: Allocate vector structure.

    json_array_t p;
    

  3. Receive each structure, terminating when receive returns -1 (EOF or channel closed).

    int ret = 1;
    while (ret > 0) {
      ret = yggRecv(fin, &p);
      // Do something with the vector structure
    }
    

Output Usage:

  1. One-time: Create file interface by providing a channel name.

    comm_t* fout = yggJSONArrayOutput("file_channel");  // channel
    

  2. Send structure to the file by providing entries. Formatting is handled by the interface. If return value is not 0, the send was not succesful.

    int ret;
    json_array_t p;
    // Populate the structure
    ret = yggSend(fout, p);
    

Parameters:

name[in] constant character pointer to output channel name.

Returns:

comm_t* output structure.

static inline comm_t *yggJSONArrayInput(const char *name)

Constructor for vector input comm from an input channel.

Parameters:

name[in] constant character pointer to input channel name.

Returns:

comm_t* input structure.

static inline comm_t *yggJSONObjectOutput(const char *name)

Constructor for map output comm to an output channel.

JSON object IO

Handle I/O from/to a JSON object.

Input Usage:

  1. One-time: Create interface by providing a channel name.

    comm_t* fin = yggJSONObjectInput("file_channel");  // channel
    

  2. Prepare: Allocate map structure.

    json_object_t p;
    

  3. Receive each structure, terminating when receive returns -1 (EOF or channel closed).

    int ret = 1;
    while (ret > 0) {
      ret = yggRecv(fin, &p);
      // Do something with the map structure
    }
    

Output by Usage:

  1. One-time: Create file interface by providing a channel name.

    comm_t* fout = yggJSONObjectOutput("file_channel");  // channel
    

  2. Send structure to the file by providing entries. Formatting is handled by the interface. If return value is not 0, the send was not succesful.

    int ret;
    json_object_t p;
    // Populate the structure
    ret = yggSend(fout, p);
    

Parameters:

name[in] constant character pointer to output channel name.

Returns:

comm_t* output structure.

static inline comm_t *yggJSONObjectInput(const char *name)

Constructor for map input comm from an input channel.

Parameters:

name[in] constant character pointer to input channel name.

Returns:

comm_t* input structure.