fogen(1)

bofc manual pages

fogen(1)



 

NAME

fogen - generates C code with configured functions to override.  

SYNOPSIS

fogen -d [-l] [-o]  

DESCRIPTION

-d<file>
Path to a database file which contains information about functions that will be overridden in generated C code. For more information about database format, check DATABASE chapter later in this manpage.
-l<file>
Path to a file with new-line separated list of functions that will be overridden in generated C code. This list should be a subset of database file (passed with -d). If this is not passed, C code will be generated using all functions from database file. So if database file contains functions "write, read, close" and function_list (-l argument) contains only "write" function in it, then code will be generated only with overridden function "write". This is usefull when passed database is big and you only need to override a handfull of functions and don't want to generate big file (that will only extend compilation time).
-o<name>
By default, program will generate code in files called fo.c and fo.h. With this option you can pass your own name (without extension). So just pass bar if you want generated files to be called bar.c and bar.h.
 

DATABASE FILE

Database is simple csv file in format:

    include[;list],return-type,function-name,argument-type1[,argument-type2]

include list is a list of all includes files that function requires for compiler to know all argument types and declaration of function itself (to avoid implicit declaration errors). It's if single include file is provided multiple times, fogen will remove any superflous include. Files should be separated with semicolon (;) character.

return type This doesn't need much explanation, it's just return type of original function.

function name Another self explanatory field - name of original function, no prefixes, no suffixes, just funciton name.

argument type list Comma (,) separated list of input arguments of function to override. Obviously must be in order of original function's arguments.

Check out this small example to understand better the format

    unistd.h,int,close,int
    unistd.h,ssize_t,read,int,void *,size_t
    sys/types.h;sys/socket.h,ssize_t,recvmsg,int,struct msghdr *,int
    sys/types.h;sys/socket.h,ssize_t,recv,int,void *,size_t,int

To make this pile of unreadable csv more readable, fogen(1) ignores all trailing and leading spaces in fields, so above example can be written in much, much more readable way as:

    unistd.h,                   int,        close,      int
    unistd.h,                   ssize_t,    read,       int,void *,size_t
    sys/types.h;sys/socket.h,   ssize_t,    recvmsg,    int,struct msghdr *,int
    sys/types.h;sys/socket.h,   ssize_t,    recv,       int,void *,size_t,int

 

RETURN VALUE

Program will return 0 on success, and 1 on errors.  

SEE ALSO

fo_init(3), fo_fail(3), libfo(7).

bofc.pl

7 November 2019 (v0.2.1)

fogen(1)