Main Page | Data Structures | File List | Data Fields | Globals

cuf-global.c File Reference

#include "cuf-global.h"
#include "win32lacks.h"

Functions

char getch (int fd)
char ungetch (int fd)
char * getline (int fd)
int putch (int fd, char c)
int putchunk (int fd, char *str)
int putline (int fd, char *str)
void cuf_error (char *module, int fatal, char *fmt,...)
void cuf_warning (char *module, char *fmt,...)
void cuf_message (char *module, int level, char *fmt,...)
void cuf_debug_level_set (int level)
DStringdstring_new (unsigned long len)
void dstring_free (DString *dstr)
char * get_cwd (void)
char ** array_string_explode (char *string, char sep, char pad)
void array_string_free (char **array)
int mkdirp (const char *pathname, mode_t mode)

Variables

int debug_level = -1

Detailed Description

Misc. Everything that didn't fit anywhere else.

Function Documentation

char** array_string_explode char *  string,
char  sep,
char  pad
 

Parameters:
string The string to be exploded.
sep The separating character.
pad A padding character to ignore.
Return values:
char ** Of the newly allocated array of strings.
NULL On error.
Description:
Explodes a delimited string into an array. Escaped literals are supported. Quotes are ignored so you should encode the delimiter even if its wrapped in quotes.

void array_string_free char **  array  ) 
 

Parameters:
array The array to be freed.
Description:
Frees an array of strings. Can be used for other data types that do not contain sub-pointers like structs. Last element in the array MUST be NULL.

void cuf_debug_level_set int  level  ) 
 

Parameters:
level The new debug level to set.
Description:
Allows real-time adjustment of the debug level. This mediates which messages will be printed by cuf_message().

void cuf_error char *  module,
int  fatal,
char *  fmt,
... 
 

Parameters:
module The module name the message is printed from.
fatal If the error is fatal to the program.
fmt The string format.
... Format variables.
Description:
Prints a error message pertaining to the CUF module 'module' with the format string 'fmt'. Optionally 'fatal' can be set to the exit value if the program is to be terminated immediately.

void cuf_message char *  module,
int  level,
char *  fmt,
... 
 

Parameters:
module The module name the message is printed from.
level The debug level of this message.
fmt The string format.
... Format variables.
Description:
Prints a message, usually for debugging, pertaining to the CUF module 'module' with the format string 'fmt'. The option 'level' indicates how high the debug level must be in order for the message to be printed.

void cuf_warning char *  module,
char *  fmt,
... 
 

Parameters:
module The module name the message is printed from.
fmt The string format.
... Format variables.
Description:
Prints a warning message pertaining to the CUF module 'module' with the format string 'fmt'.

void dstring_free DString dstr  ) 
 

Parameters:
dstr The data string to free.
Description:
Frees a DString.

DString* dstring_new unsigned long  len  ) 
 

Parameters:
len The string length to allocate.
Return values:
DString * Of the newly allocated data string.
NULL On zero length or out of memory.
Description:
Generates a new DString of the specified length.

char* get_cwd void   ) 
 

Return values:
A Null terminated string of the current working directory.
NULL if out of memory.
Description:
Gets the current working directory.

char getch int  fd  ) 
 

Parameters:
fd File descriptor.
Return values:
char The next character in the file.
EOF when end of file is reached.
FERR when the read() returns error.
Description:
Gets the next charter from the file specified by the file descriptor 'fd' and advances to the next charter position.

char* getline int  fd  ) 
 

Parameters:
fd File descriptor.
Return values:
char* The line read out.
NULL when at end of file or on error.
Description:
Gets the next line delimited by '
' from the file specified by the file descriptor 'fd'. The stream is positioned after the '
'.

int mkdirp const char *  pathname,
mode_t  mode
 

Description:
Tries to emulate 'mkdir -p'

int putch int  fd,
char  c
 

Parameters:
fd File descriptor.
c Character to put.
Return values:
Returns the number of characters written (should always be 1).
FERR when the write() returns error.
Description:
Puts the charter 'c' into a file specified by the file descriptor 'fd' and advances the stream.

int putchunk int  fd,
char *  str
 

Parameters:
fd File descriptor.
str String to put.
Return values:
Returns the number of characters written (should always be 1).
FERR when the write() returns error.
Description:
Puts the string 'str' that must be null terminated into a file specified by the file descriptor 'fd' and advances the stream.

int putline int  fd,
char *  str
 

Parameters:
fd File descriptor.
str String to put.
Return values:
Returns the number of characters written (should always be 1).
FERR when the write() returns error.
Description:
Puts the string 'str' that must be null terminated and adds a new line (
). Placing it into a file specified by the file descriptor 'fd' and advances the stream.

char ungetch int  fd  ) 
 

Parameters:
fd File descriptor.
Return values:
char The previous character in the file.
EOF when beginning of file is reached.
FERR when the read() returns error.
Description:
Gets the previous character from the file specified by the file descriptor 'fd' and backs up to the charter ahead of the one returned.


Variable Documentation

int debug_level = -1
 

Description:
Default Debug Level


Generated on Fri Jun 4 18:35:18 2004 for cuf by doxygen 1.3.6