qlibs:cdbmake(3)
okay so bestie, you found qlibs:cdbmake(3), and it lives in the Library Functions Manual β itβs constant-database time, and weβre gonna be so normal about it π
β¨
π NAME π
cdmake β generate and fill a constant database. Thatβs the name on the tin, fr fr.
β¨ SYNTAX β¨
First, pull in the header exactly like this:
#include "cdmake.h"
Then the three calls, copied exactly:
int cdb_make_start(struct cdb *c,int fd);
int cdb_make_add(struct cdb *c,char *key,unsigned int keylen,
char *data,unsigend int datalen);
int cdb_make_finish(struct cdb *c);
π DESCRIPTION π
cdb_make_start generates and intitialises a brand-new cdb named c, and makes it available through file descriptor fd. New database, who dis π«Ά
cdb_make_add adds entries using the file descriptor fd given as key with length keylen into the cdb, returning the hashed values data with length datalen.
cdb_make_finish finalises the data structure provided as fd. Wrap it up, bestie π
π RETURN CODES π
Usually, the cdb_make_* routines give you a return code of 0 for successful operations, and -1 if anything is going wrong. Simple as that, no cap πβ¨
π¦ EXAMPLE π¦
Hereβs the whole vibe, code copied exactly:
#include <cdbmake.h>
int fd;
stralloc data = {0};
stralloc key = {0};
struct cdb_make c;
if (cdb_make_start(&c,fd) == -1) die_write();
if (cdb_make_add(&c,key.s,key.len,data.s,data.len) == -1)
die_write();
if (cdb_make_finish(&c) == -1) die_write();
if (fsync(fd) == -1) die_write();
π SEE ALSO π
cdbread(3)β go read that next, bestie π«Ά
β from the qlibs manual, page cdbmake(3), source/version sign-off qlibs:cdbmake(3) (the original footer doesnβt give a date, so Iβm not inventing one, periodt πβ¨)
π¦ where this page comes from
- alpine 3.24: fehqlibs-doc 31-r0 Β· Public-Domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms