SkillAgentSearch skills...

Sdsutils

Collection of C utils based on Redis SDSlib string library.

Install / Use

/learn @paulc/Sdsutils
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Collection of C utils based on the excellent Redis SDSlib string library (https://github.com/antirez/redis).

This is intended to be used in standalone C programs and has no dependencies other than libc. This is mostly for the benefit of people who dislike dynamic library depenencies.

The library supports the normal SDSlib functions and also adds a number of utility functions based around these including basic file reading, regex searching (using SLRE), compression (using LZF), encryption (using Blowfish), and functional list-processing utilities (map/reduce/apply)

There isn't (currently( and documentation other tha the sdsutil.c source code and the example programs (readfile.c provides a fairly useful example of use of the library)

NOTE: The library is based on a fairly old version of the zmalloc/sds/list code from Redis. At some point syncing with head would be a good thing.

License: BSD

The additional functions provided are (from sdsutil.h):

int sdscount(sds s,char c); int sdsstartswith(sds s,sds prefix); int64_t sdsgetint(sds s,int len); sds sdscatint(sds s,int64_t num,int len); sds sdsread(FILE *fp,size_t nbyte); sds sdsreadfile(FILE *fp); sds sdsreaddelim(FILE *fp,void *delim,int len); sds sdsreadline(FILE *fp,const char *prompt); list *sdsmatchre(sds s,struct slre *slre,int ncap); list *sdsmatch(sds s,char *re); sds sdssha256(sds s); sds sdscompress(sds s); sds sdsdecompress(sds s); sds sdsencrypt(sds s,sds key,sds iv); sds sdsdecrypt(sds z,sds key); sds sdshex(sds s); sds sdsunhex(sds s); sds sdsrepr(sds s); sds sdsunrepr(sds s); void sdsprintrepr(FILE *fp,char *prefix,sds s,char *suffix); void sdsprinthex(FILE *fp,char *prefix,sds s,char *suffix); sds sdsexec(char *cmd); sds sdspipe(char *cmd,sds input); list *sdssplit(sds s,sds delim); sds listJoin(list *l,sds delim); list *listMap(list *l,void *(*f)(void *data),void (*free)(void *ptr),void *(*dup)(void *)); void listApply(list *l,void *(*f)(void *data)); void listReduce(list *l,void *init,void (*f)(void *acc,void *val)); list *listRange(list *l,int start,int end); list *listRangeDup(list *l,int start,int end); list *listFilter(list *l,int (*f)(void *data)); list *listFilterDup(list *l,int (*f)(void *data));

Related Skills

View on GitHub
GitHub Stars12
CategoryDevelopment
Updated2y ago
Forks1

Languages

C

Security Score

60/100

Audited on Jan 10, 2024

No findings