ORT_LANG_C_SOURCE(3)

NAME
ort_lang_c_source - generate C source from openradtool configuration

LIBRARY
libort-lang-c

SYNOPSIS
#include <sys/queue.h>
#include <stdio.h>
#include <ort.h>
#include <ort-lang-c.h>
int
ort_lang_c_source(const struct ort_lang_c *args, const struct config *cfg, FILE *f);

DESCRIPTION
Outputs a C source file from the parsed configuration cfg to f with the parameters in args. This function interface is likely to change. The header implemented by these sources is usually generated by ort_lang_c_header(3). The arguments recgnised in args are as follows:

const char *header
    If not NULL, a comma-separated list of non-system header files to include. White-space surrounding the commas is discarded.

unsigned int flags
    The bit-field of components to output. Possible values are described in the next section.

unsigned int includes
    A list of components defined in the header files in header, but not generated with flags. This allows for the correct depending headers to be generated. Possible values are described in the next section.

const char *ext_b64_ntop
    The b64_ntop() and b64_pton() functions required for portability.

const char *ext_jsmn
    The JSMN source file required for portability.

const char *ext_gensalt
    The _gensalt() function required for portability.

The following components are output if specified:

ORT_LANG_C_JSON_KCGI
    Functions for outputting content as JSON objects. Uses kcgijson(3) to manage the JSON encoding and output.

ORT_LANG_C_JSON_JSMN
    Functions for parsing JSON objects into content.

ORT_LANG_C_VALID_KCGI
    Functions for validating input from a kcgi(3) context.

ORT_LANG_C_DB_SQLBOX
    Functions for manipulating the database with sqlbox(3).

The generated content is in ISO C.

RETURN VALUES
Returns zero on failure, non-zero on success.

EXAMPLES
A simple scenario of creating a configuration, parsing standard input, linking, then performing some task is as follows. It assumes db.h has been generated by ort_lang_c_header(3).

    struct config *cfg;
    struct ort_lang_c args;
    memset(&args, 0, sizeof(struct ort_lang_c));
    args.header = "db.h";
    args.flags = ORT_LANG_C_DB_SQLBOX;
    if ((cfg = ort_config_alloc()) == NULL)
      err(1, NULL);
    if (!ort_parse_file(cfg, stdin, "<stdin>"))
      errx(1, "failed parsing");
    if (!ort_parse_close(cfg))
      errx(1, "failed linking");
    if (!ort_lang_c_source(&args, cfg, stdout))
      errx(1, "failed output");
    ort_config_free(cfg);

SEE ALSO
ort(3), ort_lang_c_header(3), ort_lang_c_manpage(3)