cdk_compat(3)
π cdk_compat π
okay so bestie, we're in the cdk_compat(3) page, and it lives in the Library calls section of the manual β like, it's a library function page, not some command you run in your shell, mmkay? π«Ά
β¨ NAME β¨
cdk_compat β Cdk4 compatibility functions π
She's the little glowy bridge that lets your old Cdk4 code come hang with Cdk5. Not new code, but she's serving her purpose and we respect her. π
π SYNOPSIS π
cc [ flag ... ] file ... -lcdk [ library ... ]
#include <cdk_compat.h>
int getDirectoryContents (
char *directory,
char **list,
int maxListSize);
int readFile ( char *filename,
char **info,
int maxlines);
int splitString (
char *string,
char **items,
char splitChar);
π¦ DESCRIPTION π¦
These functions and macros exist to make it simpler to port applications from the older Cdk4 library to Cdk5. fr fr, that's the whole assignment. π
A few functions are deprecated in Cdk5, because they rely upon the caller to know in advance the size of data which will be returned by the function. Not me trusting you to guess how big the output is gonna be π that's giving chaos energy.
Additionally, some macros are deprecated because they serve no realistic purpose at all: they have direct (standard) equivalents in all modern curses implementations. like why are you even here miss thing π
Finally, a few macro definitions are added to iron out naming inconsistencies across the Cdk4 header files. Tiny little peacekeeping macros. they ate. ποΈ
π₯ AVAILABLE FUNCTIONS π₯
getDirectoryContents
This opens the current directory and reads the contents. Use CDKgetDirectoryContents() in new code. π (yes, in new code you want the CDK-prefixed one, no cap)
readFile
This reads a file and sticks it into the char ** provided. Use CDKreadFile() for new code. π
splitString
This splits a string into one or more parts given the split character. Use CDKsplitString() for new code. β¨
πΈ EXAMPLES πΈ
Start the porting process by changing the #include's to use
#include <cdk_compat.h>
rather than
#include <cdk.h>
Some adjustments of course are needed to make your compiler see the compatibility header file. A separate name was chosen so that it in turn can (by adjusting the include path) include either the old Cdk4 cdk.h or the new. If the old is included, you should link your program against the old library. Likewise, including the new requires that you link against the new library. π got it? one name, two possible vibes, and your linker has to match the vibe.
That is the first step: making your program compile using the compatibility header file using the old headers and library. slay, step one done. π
The next step is to get it to compile against the new headers and library. Most of the changes will require modifying bare references to certain pointers to wrap them with the ObjOf() and ScreenOf() macros. New Cdk uses these to provide functions which are easily shared among the different widget types. Your compiler should be able to tell you where the changes should be made. See the example programs which are included with Cdk as a guide. π§ literally let the compiler be your group chat and point at the problems.
That is the hard part of porting. But even for a large program, the changes can be made simply: there are not that many types of change to make. At the end of this step, you should still be able to build and run your program against the old headers and library. It is reasonably likely that you can do the same with the new headers and library. By using the same source for old/new versions of Cdk, you can test and verify that your program still works properly after these modifications. main character porting strategy honestly. π
Finally, unless this is a purely academic exercise, you will want to remove references to the deprecated functions and macros. π like, them? gone. byeee.
ngl the deprecated stuff is deprecated for a reason β those functions need you to already know how big the returned data is gonna be before it comes back, and the old macros have direct standard equivalents in every modern curses implementation. so don't build new things on them, bestie. π
π SEE ALSO π
ikyk, that's the whole page π this was cdk_compat(3), dated 2024-03-28, in manual-land it's the Library calls girlie. bye bestie, go port something iconic. πβ¨π¦
π¦ where this page comes from
- debian trixie: libcdk5-dev 5.0.20250116-1 Β· BSD-4-Clause
- ubuntu questing: libcdk5-dev 5.0.20250116-1
- 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