cdk_misc(3)
π cdk_misc π
okay bestie, welcome to cdk_misc(3) β the Cdk miscellaneous routines page, from the Library calls section of the manual. yes it's the grab-bag drawer of the Cdk widget set, and yes it ate. let's go π«Ά
β¨ NAME β¨
cdk_misc β Cdk miscellaneous routines π
β¨ SYNOPSIS β¨
cc [ flag ... ] file ... -lcdk [ library ... ]
#include <cdk.h>
void Beep(void);
unsigned CDKallocStrings(
char ***list/,
char *item/,
unsigned length/,
unsigned used/);
unsigned CDKcountStrings (
CDK_CONST char **list);
void CDKfreeChtypes(
chtype **list);
void CDKfreeStrings (
char **list);
char ** CDKsplitString (
const char *string,
int splitChar);
char * baseName (
char *string);
int ceilCDK( doublevalue);
int chlen ( const chtype *string);
void chstrncpy(
char *dest,
const chtype *src,
int maxcount);
char *chtype2Char (
const chtype *string);
void cleanChar (
char *string,
int length,
char character);
void cleanChtype (
chtype *string,
int length,
chtype character);
int cmpStrChstr(
const char *str,
const chtype *chstr);
char *copyChar (
const char *string);
char **copyCharList (
const char **list);
chtype *copyChtype (
const chtype *string);
chtype **copyChtypeList (
const chtype **list);
char *dirName (
char *filename);
int floorCDK( double value);
void freeChar (
char *string);
void freeCharList (
char **list,
unsigned size);
void freeChtype (
chtype *string);
void freeChtypeList ("
chtype **list,
unsigned size);
int intlen ( int value);
int lenCharList (
const char **list);
int lenChtypeList (
const chtype **list);
int mode2Char (
char *string,
mode_t fileMode);
int searchList (
CDK_CONST char * CDK_CONST *list,
int listSize,
const char *pattern);
void sortList (
CDK_CONST char **list,
int length);
no cap, copy that block exactly like that. i do not make the rules, the header file does. π
β¨ DESCRIPTION β¨
so basically these are the miscellaneous functions that come in handy when you're working with the Cdk widget set. little helpers. string wranglers. the support squad behind the main characters. π
β¨ AVAILABLE FUNCTIONS β¨
π Beep
makes an audible beep. here's the tea tho: the standard curses beep() does not flush the stream, so it will only beep until a force is made. this one forces a flush after issuing the beep command. so it actually beeps when you need it to. iconic.
π CDKallocStrings
add a new string item to a list. it keeps a null pointer on the end, so you can use CDKfreeStrings() to deallocate the whole entire list later. π«Ά
heads up bestie: the caller is responsible for updating the length of the list. the return value is the updated number of chars used.
π CDKcountStrings
counts the number of items in a null-terminated list of character strings. returns the count. simple. slay. β¨
π CDKfreeChtypes
frees a list of chtype-strings which is terminated by a null pointer. bye bye π
π CDKfreeStrings
frees a list of character strings which is terminated by a null pointer. and β plot twist β it also frees list itself. it really said "i'll take it from here".
π CDKsplitString
splits the string at each occurrence of separator, returning a pointer to a dynamically allocated array of the pieces. π° the original string is unmodified, so no worries about your input getting messed up.
the caller is responsible for freeing the result. don't leave it hanging, that's rude.
π baseName
returns a pointer to the first character of the filename in the given pathname. β¨
the result should be freed by the caller. periodt.
π ceilCDK
returns an integer, just like the math library ceil(), which returns a double. so yeah, it's ceil() but it's giving integer energy. π
π chlen
returns the length of the (null-terminated) string of chtype's. π
π chstrncpy
extracts the characters from a null-terminated array of chtype's src. the size of the destination dest is given in maxcount. π
π chtype2Char
extracts the characters from a null-terminated array of chtype's string. a dynamically allocated string is returned. πΈ
the caller is responsible for freeing the result. (seeing a pattern here? yeah. free your stuff.)
π cleanChar
is analogous to memset. sets the characters in string to the given character. the length of string is given by length. and character is, well, the character which will be written. βοΈ
π cleanChtype
is analogous to memset too. sets the chtype's in string to the given character. the length of string is given by length. π§Ό
π cmpStrChstr
compares a char string str to a chtype string chstr. returns -1, 0 or 1 according to whether str is less than, equal to or greater than chstr. three possible answers, one very decisive function. π
π copyChar
copies the string passed in. and here's the upgrade over strdup: it checks to see if the string is NULL before copying. safety first bestie π¦
π copyCharList
copies the given list. that's it, that's the whole vibe.
π copyChtype
copies the string passed in, analogous to copyChar, but for chtype strings. same energy, different type. π
π copyChtypeList
copies the given list. (yes, the chtype version. you got it.)
π dirName
returns the directory for the given filename, i.e., the part before the * last slash. π
the return value should be freed by the caller. again!! free it!!
π floorCDK
returns an integer, like the math function floor(), which returns a double. ceilCDK's slightly more grounded sibling. π±
π freeChar
is a wrapper for free. it checks to see if the string is NULL before trying to free the string. so polite. so considerate. π₯Ί
π freeCharList
frees the memory used by the given list of strings. the number of strings to free is given by size. π§Ή
π freeChtype
is a wrapper for free, just like freeChar. twins fr fr.
π freeChtypeList
frees the memory used by the given list of chtype strings. the number of strings to free is given by size. β¨
π intlen
returns the length of an integer, i.e., the number of characters needed to represent it. π’
π lenCharList
returns the length of the given list. π
π lenChtypeList
returns the length of the given list. (chtype edition π )
π mode2Char
given a file protection mode fileMode, it stores a printable version of the permissions in string, formatted as if by "ls -l"). π
it returns the corresponding permissions data, i.e., ignoring the file-type bits.
π searchList
searches the given list of listSize strings for a subset of a word pattern in the given list. returns the index in the list if it is found, or -1 if not found. π
π sortList
performs a quick sort of the given list. it's a wrapper for qsort, used to sort the list of strings. the number of strings in list is given by length. the list is sorted alphabetically in increasing order. organized queen behavior honestly. π
β¨ SEE ALSO β¨
cdk(3), cdk_screen(3), cdk_display(3), cdk_binding(3), cdk_util(3) πΈ
go read those next bestie, the lore is deep.
okay that's the whole page!! this was cdk_misc(3) from the Library calls manual, dated 2025-10-01 π thanks for reading my little infodump, now go free your strings. literally. free them. πβ¨π¦
π¦ where this page comes from
- fedora 43: cdk 5.0.20251014-1.fc43 Β· X11-distribute-modifications-variant
- fedora 43: cdk 5.0.20251014-1.fc43 Β· X11-distribute-modifications-variant
- fedora 44: cdk 5.0.20251014-3.fc44 Β· X11-distribute-modifications-variant
- fedora 44: cdk 5.0.20251014-3.fc44 Β· X11-distribute-modifications-variant
- nixos 26.05: cdk 5.0-20260119
- nixpkgs unstable: cdk 5.0-20260119
- ubuntu resolute: libcdk5-dev 5.0.20251014-1 Β· BSD-4-Clause
- ubuntu stonking: libcdk5-dev 5.0.20260119-1 Β· BSD-4-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms