man cdk_misc (Fonctions bibliothèques) - Curses Development Kit Miscellaneous Routines
NAME
Cdk - Curses Development Kit Miscellaneous Routines
SYNOPSIS
cc [ flag ... ] file ... -lcdk [ library ... ]
#include <cdk.h>
void Beep();
char * baseName (char *pathname);
chtype * char2Chtype (char *string, int *length, int *align);
int chlen (chtype *string);
char *chtype2Char (chtype *string);
void cleanChar (char *string, int length, char character);
void cleanChtype (chtype *string, int length, chtype character);
char *copyChar (char *string);
chtype *copyChtype (chtype *string);
void freeChar (char *string);
void freeChtype (chtype *string);
int getDirectoryContents (char *directory, char **list, int maxListSize);
int intlen (int value);
int mode2Char (char *string, mode_t fileMode);
int popupDialog (CDKSCREEN *screen, char **mesg, int mesgCount, char **buttons, int buttonCount);
void popupLabel (CDKSCREEN *win, char **mesg, int count);
int getListIndex (CDKSCREEN *win, char *title, char **list, int listSize, boolean numbers);
char *getString (CDKSCREEN *win, char *title, char *label, char *inititalValue);
int viewFile (CDKSCREEN *win, char *title, char *filename, char **buttons, int buttonCount);
void quickSort (char **,list, int left, int right);
int readFile (char *filename, char **info, int maxlines);
int searchList (char **list, int listSize, char *pattern);
void stripWhiteSpace (EStripType stripType, char *string);
int splitString (char *string, char **items, char splitChar);
DESCRIPTION
The functions provided in this manual page are miscellaneous functions which may be required when using the Cdk widget set.
AVAILABLE FUNCTIONS
void Beep(); This function makes an audible beep. The difference between this one and the beep function in the curses library is this one flushes the STDOUT stream.
char *baseName (char *pathname); This function returns a pointer to the first character of the filename in the given pathname.
chtype *char2Chtype (char *string, int *length, int *align); This function takes a string in the form of "</X/Y>Blah Blah" and returns a chtype * of the correct type. The length parameter is the length of the chtype * and the align parameter contains justification information.
int chlen (chtype *string); This function returns the length of the chtype * given.
char *chtype2Char (chtype *string); This function takes a chtype * and returns the equivalent char *.
void cleanChar (char *string, int length, char character); This function is analogous to bzero or memcopy. The length parameter states how many characters to write, and character is the character which will be written.
void cleanChtype (chtype *string, int length, chtype character); This function is analogous to bzero or memcopy. The length parameter states how many characters to write, and character is the character which will be written.
char *copyChar (char *string); This function copies the string passed in. It is safer than strdup because it checks to see if the string is NULL before copying, and it forces a NULL character on the end of the string after the copy is complete.
chtype *copyChtype (chtype *string); This function copies the string passed in. It is safer than strdup because it checks to see if the string is NULL before copying, and it forces a NULL character on the end of the string after the copy is complete.
void freeChar (char *string); This function is safer to use than free. It checks to see if the string is NULL before trying to free the string.
void freeChtype (chtype *string); This function is safer to use than free. It checks to see if the string is NULL before trying to free the string.
int getDirectoryContents (char *directory, char **list, int maxListSize); This function opens and reads the contents of the given directory. It fills the array list with the sorted contents of the directory, and the parameter maxListSize states how many entries the array can hold. This function returns the number of files read. If the directory could not be opened then it returns a value of -1.
int intlen (int value); This function returns the length of an integer value.
int mode2Char (char *string, mode_t fileMode); This function takes the file-mode in the fileMode parameter and returns the octal equivalent. The string parameter is a character string of the permissions. (The string looks like the permissions of a file when the command ls -l has been run on the file.)
int popupDialog (CDKSCREEN *screen, char **mesg, int mesgCount, char **buttons, int buttonCount); This function creates a quick pop-up dialog box. Pass in the message in the mesg parameter, the size of the message in the mesgCount parameter, the button labels in the buttons parameter and the number of buttons in the buttonCount parameter. The dialog box will be centered on the screen.
void popupLabel (CDKSCREEN *win, char **mesg, int count); This function creates a quick pop-up label widget. The message and the size of the message are passed in via the mesg and count parameters respectively. The label widget will wait until the user hits a character and will be centered on the screen.
int getListIndex (CDKSCREEN *win, char *title, char **list, int listSize, boolean numbers); This function provides a popup scrolling list filled with the items passed in via the list parameter. It returns the index in the list selected, or -1 if no item was selected.
char *getString (CDKSCREEN *screen, char *title, char *label, char *initialValue); This function pops up an entry widget with a title supplied by the value of the title parameter, a label supplied by the label parameter, and an initial value supplied by the initialValue parameter. This returns a pointer to the value typed in or NULL if the widget was exited early. int viewFile (CDKSCREEN *screen, char *title, char *filename, char **buttons, int buttonCount); This function pops up a viewer widget, with the contents of the viewer being the contents of the file supplied by the filename value. The buttons on the file viewer are supplied by the buttons parameter. This function returns the integer value of the button selected. This function returns -1 if the file does not exist, or the widget was exited early.
void quickSort (char **list, int left, int right); This function performs a quick sort of the given list. The list will be sorted alphabetically in increasing order.
int readFile (char *filename, char **info, int maxlines); This function reads the contents of the given file and stores the contents in the info parameter. The maxlines parameter states how many lines can be stored in the info array. This function returns the number of lines read if the file could be opened, -1 otherwise.
int searchList (char **list, int listSize, char *pattern); This function searches the array list checking to see if each element in the array starts with the given pattern. This function returns the index of the first match or -1 if it can't find one.
void stripWhiteSpace (EStripType stripType, char *string); This function strips the leading/trailing white space off of the given string. The parameter stripType takes the following values.
Strip_Type Result vFRONT This tells the function to remove all of the white space from the front of the given string. vBACK This tells the function to remove all of the white space from the back of the given string. vBOTH This tells the function to remove all of the white space from both the front and the back of the given string.
int splitString (char *string, char **items, char splitChar); This function splits the given string into parts based on the split character in splitChar. The array items will contain each individual segment. The value returned is the number of segments created from the given string.
SEE ALSO
cdk(3), cdk_screen(3), cdk_display(3), cdk_binding(3)
NOTES
The header file <cdk.h> automatically includes the header files <curses.h>, <stdlib.h>, <string.h>, <ctype.h>, <unistd.h>, <dirent.h>, <time.h>, <errno.h>, <pwd.h>, <grp.h>, <sys/stat.h>, and <sys/types.h>. The <curses.h> header file includes <stdio.h> and <unctrl.h>.
If you have Ncurses installed on your machine add -DNCURSES to the compile line to include the Ncurses header files instead.