Menu

C API

Mark R. Bannister

C API

The C API is documented in the online man pages and in the [DBIS Reference Manual]. Here is an example of using the C API, taken from the dbis_lookup(3) man page:

/*
 * Uses DBIS API to lookup the members of a netgroup
 *
 * Either provide a netgroup name, or no arguments
 * to iterate all netgroups
 */
#include <stdio.h>
#include <dbis/api.h>

int main(int argc, char **argv)
{
    DBIS *dbis;
    struct dbis_opts opts;
    char *result;
    const char *netgr=NULL;

    if (argc>1) netgr=argv[1];

    dbis_init_opts(&opts);
    dbis_set_sort(&opts, TRUE);
    dbis_set_getnetgrent_recurse(&opts, TRUE);

    if (!(dbis=dbis_init(&opts, stderr)))
    {
        perror("dbis_init() failed");
        return 1;
    }

    if (!(result=dbis_lookup(dbis, dbis_getnetgrent(netgr))))
    {
        perror("dbis_lookup() failed");
        return 1;
    }
    fputs(result, stdout);
    dbis_free(dbis);
    return 0;
}

For more information on the other components of DBIS, see [Using DBIS].


Related

Wiki: DBIS Reference Manual
Wiki: Using DBIS

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.