ORT_LANG_C_HEADER(3)

NAME
ort_lang_c_header - generate C header 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_header(const struct ort_lang_c *args, const struct config *cfg, FILE *f);

DESCRIPTION
Outputs a C header file from the parsed configuration cfg to f with the parameters in args. This function interface is likely to change. Implementation of the header is usually provided by ort_lang_c_source(3). The arguments recgnised in args are as follows:

const char *guard
    If NULL, the header file will not include an ifdef/endif guard for double inclusion. Otherwise, the given string will be used as a guard. It is not checked for being a proper CPP macro.

unsigned int flags
    The bit-field of components to output.

The following components are output if specified:

ORT_LANG_C_CORE
    Core data model structures, enumerations, and bitfields.

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. Include paths for the generated content depend upon the included components: kcgi(3) is required for ORT_LANG_C_JSON_KCGI and ORT_LANG_C_VALID_KCGI.

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.

    struct config *cfg;
    struct ort_lang_c args;
    memset(&args, 0, sizeof(struct ort_lang_c));
    args.flags = ORT_LANG_C_CORE;
    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_header(&args, cfg, stdout))
      errx(1, "failed output");
    ort_config_free(cfg);

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