ORT_LANG_NODEJS(3) | Library Functions Manual | ORT_LANG_NODEJS(3) |
ort_lang_c_source
—
generate node.js implementation of openradtool
configuration
library “libort-lang-nodejs”
#include
<sys/queue.h>
#include <stdio.h>
#include <ort.h>
#include
<ort-lang-nodejs.h>
int
ort_lang_nodejs
(const struct
ort_lang_nodejs *args, const struct config *cfg,
FILE *f);
Outputs a node.js implementation of the parsed configuration cfg to f. The values in args are as follows:
The following components are output if specified:
ORT_LANG_NODEJS_CORE
ORT_LANG_NODEJS_DB
ORT_LANG_NODEJS_VALID
If args is NULL
, it
defaults to all values being zero.
Returns zero on failure, non-zero on success. Failure only occurs with memory allocation errors or when writing to f.
The following emits a configuration as read from standard input to node.js as written to standard output.
struct config *cfg; struct ort_lang_nodejs args; memset(&args, 0, sizeof(struct ort_lang_nodejs)); args.flags = ORT_LANG_NODEJS_CORE|ORT_LANG_NODEJS_DB; if ((cfg = ort_config_alloc()) == NULL) err(1, NULL); if (!ort_parse_file(cfg, stdin, "<stdin>")) errx(1, "ort_parse_file"); if (!ort_parse_close(cfg)) errx(1, "ort_parse_close"); if (!ort_lang_nodejs(&args, cfg, stdout)) err(1, "ort_lang_nodejs"); ort_config_free(cfg);
Alternatively, this could be converted into a string:
char *buf = NULL; size_t bufsz = 0; /* Read and parse configuration as above... */ if ((stream = open_memstream(&buf, &bufsz)) == NULL) err(1, "open_memstream"); if (!ort_lang_nodejs(&args, cfg, stream)) err(1, "ort_lang_nodejs"); fclose(stream); /* Do something with buf of size bufsz. */ free(buf);
October 25, 2021 | OpenBSD 6.7 |