KWEBAPP-C-SOURCE(1) General Commands Manual KWEBAPP-C-SOURCE(1)


kwebapp-c-sourceimplement web application C API


kwebapp-c-source [-jsv] [-h header[,header...]] [-I djv] [-N d] [config...]


The kwebapp-c-source utility accepts a kwebapp(5) config (defaulting to standard input) and produces an implementation of the C API generated by kwebapp-c-header(1). The configuration may be broken apart into several files. Its arguments are as follows:
-h header[,header...]
Include the set of comma-separated header files header.
-I djv
Indicate that the generated source must include headers for the Database input declarations (d), the JSON export declarations (j), and/or Data validation (v). This allows multiple source files and a single header file. It's safe to duplicate, such as specifying -Ij and -j.
Output JSON output definitions as documented in JSON export.
Output data validator definitions as documented in Data validation.
-N d
Disable production of output, which may currently only be b to suppresses the Database input definitions.
Use split-process mode for the database.
By default, the Database input and Data structures definitions are output with a header file of db.h.
All C code produced by kwebapp-c-source conforms with the style(9) manual of OpenBSD.


The password hashing facility defined in kwebapp(5) is implemented differently on different systems. On OpenBSD, it uses the crypt_newhash(3) and crypt_checkpass(3) functionality. On all other systems, it uses the traditional crypt(3) with an MD5 (“$1”) setting. The seed is generated using random(3), so the calling application should invoke srandom(3).


The code output by kwebapp-c-source is currently not portable between systems. This is due to code being generated that is available on the system where kwebapp-c-source is executed, for example, whether crypt_newhash() or b64_ntop() are usable. Future version of the system may have flags for generating portable code that bundles in all non-portable functions.


The kwebapp-c-source utility exits 0 on success, and >0 if an error occurs.


In the simplest case, put all C sources and headers (for validation, database routines, and JSON output) into one pair of files. Let foo.kwbp be the configuration file.
kwebapp-c-header -jvs foo.kwbp > db.h 
kwebapp-c-source -jvs foo.kwbp > db.c
Breaking up into two header and source files: one for basic database functions, the other for JSON output.
kwebapp-c-header -s foo.kwbp > db.h 
kwebapp-c-header -s -g JSON_H -j -Nbd foo.kwbp > json.h 
kwebapp-c-source -s -h db.h > db.c 
kwebapp-c-source -s -j -Nd -Idj -h db.h,json.h > json.c
In this more complicated snippet, the json.h file is created without structure or database information using -N, -then json.c needs to include both database and JSON headers (in name, -h, and in the headers those stipulated in source, -I) also while inhibiting database routine creation with -N.


August 28, 2018 OpenBSD 6.3