class rhclib


Definition#include <rhutil.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

int  mkdir_p (const char *path, size_t n, mode_t mode)

something similar to "mkdir -p": make a complete directory path with permissions 'mode_t'. it might be good to make a similar function that does not allocate memory, but can change the string to make the subdirectories. this function will not return an error if the complete path is a normal file instead of a directory. to check this, you have to call (l)stat() and check for a directory after calling this function.

Parameters:
pathdirectory path to make
nlength of the path
modepermissions of the directory

Returns: 0 on success, -2 if we don't get enough memory and -1 if we cannot create the directories.

int  copy (const char *src, const char *dest)

Copy one file to another.

Parameters:
srcpath to the src file
destpath to the dest file

Returns: 0 on success, errno otherwise

gid_t  Gid (const char *name)

Get the group id by name.

Parameters:
namethe group name

Returns: the group id, 0 if the group name does not exist

ssize_t  Read (int fd, void *buf, size_t len)

read 'len' bytes into 'buf' from filedescriptor 'fd'. restart read() in case of partial/interrupted reads.

Returns: the number of read bytes or -1 in case of error.

int  Write (int, const void *, size_t)

write 'len' bytes starting at 'buf' to the filedescriptor 'fd' restart the write() command in case of partial/interrupted writes

Returns: 0 on success or -1 on error

rhconfig_t * ReadFile (const char *name, uid_t uid, gid_t gid, mode_t mode)

read a complete file into a new buffer. *size contains the complete size.

Parameters:
returnNULL on error or a newly alloced buffer.

int  NewContent (rhconfig_t *c, char *buf, size_t n)

WriteFile writes a file

char * GetKeyShell (rh_list *l, rh_list **pos, const char *key)

parse a file that is supposed to be in shell-syntax for "key=value" entries. we ignore a lot of things that are possible within shell-scripts, but this routine should cope with all real-world config files. please try to keep this routine reasonable simple.

Parameters:
sthe string buffer
nthe length of the string buffer
keythe search key

Returns: ptr to the line containing key, NULL otherwise

rh_list * SetKeyShell (rh_list *first, rh_list **pos, const char *key, const char *data)

set a new value; in place editing

Parameters:
sthe string buffer
nthe length of the string buffer
keythe search key
datathe string to set the key to

Returns: ptr to the line containing key, NULL otherwise

rh_list * Buf2List (const char *buffer)

change buffer into newly malloced lines

void  check_root (void)

Checks if the user is root (euid 0) This exits otherwise, with a dialog informing the user.

int  check_for_write_access (const char *)

Checks if the user has write access to a file or path. This exits otherwise, with a dialog informing the user.

Parameters:
paththe path to the file or directory

Returns: 0 for success

void  ErrorAbort (const char *fmt, ...) __attribute__ ((noreturn,format(printf, 1, 2)))

Display a dialog before aborting the program

Parameters:
fmta printf style format string

Returns: never

int  InitDisplay (int *argc, char ***argv, const char *package, const char *version)

Initialize a display

Parameters:
argcparameter count
argvparameters (on some frontends, parameters are used to handle crap like -geometry)

Returns: 0 on success

void  CloseDisplay (void)

Close a display

char * rhcl_replace (const char *str, const char *what, const char *with)

Replace all occurences of

Parameters:
what with
with in
strthe string

Returns: String with all occurrences replaced.

char * rhcl_strcasestr (char *haystack, const char *needle)

Case-insensitive version of strstr Find the first occurrence of @param haystack in @param needle case insensitive.

Returns: first occurrence

char * rhcl_trim (const char *line)

Remove blanks from beginning and end of line

Parameters:
lineLine you want trimmed

Returns: @param line without blanks at beginning and end


Generated by: laroche@dudweiler.redhat.de on Mon Jun 26 19:25:45 2000, using kdoc 2.0a35.