Public Types
- typedef struct rh_list
- typedef struct rhconfig_t
Public Methods
- void nomem (size_t size) __attribute__ ((noreturn))
- void * rh_xcalloc (size_t s)
- void * rh_xmalloc (size_t s)
- void * rh_xrealloc (void *p, size_t s)
- void * rh_xmemcpy (const void *p, size_t s)
- char * rh_xstrdup (const char *s)
- char * rh_xstrndup (const char *s, size_t n)
- rh_list * rh_list_add (rh_list *first, rh_list *pos, char *data, size_t n)
- void rh_list_delete (rh_list *l, int free_data)
- rh_list * rh_list_delete_node (rh_list *first, rh_list *pos)
- rh_list * rh_list_traverse (int (*func) (rh_list *), rh_list *first, rh_list *pos)
- rh_list * rh_list_dup (rh_list *first)
- char * string_trim (const char *s, size_t n, size_t *m)
- rh_list * string_tok (char *s, size_t *n, const char *delim)
- char * rhcl_title (void)
- int mkdir_p (const char *path, size_t n, mode_t mode)
- int copy (const char *src, const char *dest)
- int WaitFd (int, int, unsigned long)
- int SetBlockFlag (int fd, int block)
- gid_t Gid (const char *name)
- ssize_t Read (int fd, void *buf, size_t len)
- int Write (int, const void *, size_t)
- rhconfig_t * ReadFile (const char *name, uid_t uid, gid_t gid, mode_t mode)
- void FreeFile (rhconfig_t *c)
- int BackupFile (const char *name)
- int NewContent (rhconfig_t *c, char *buf, size_t n)
- int NewContent2 (rhconfig_t *c, rh_list *list)
- int WriteFile (rhconfig_t *c)
- int WriteFile2 (rhconfig_t *c)
- char * GetKeyShell (rh_list *l, rh_list **pos, const char *key)
- char * GetKey (rh_list *l, rh_list **pos, const char *key)
- rh_list * SetKeyShell (rh_list *first, rh_list **pos, const char *key, const char *data)
- void SetKey (rh_list **first, rh_list **pos, const char *key, const char *value)
- void SetKeyPos (rh_list **first, rh_list *pos, const char *key, const char *value)
- rh_list * DeleteAllKey (rh_list **first2, const char *key2)
- rh_list * Buf2List (const char *buffer)
- char * List2Buf (rh_list *l, size_t *)
- void remove_line_continuations (rh_list *l)
- void check_root (void)
- int check_for_write_access (const char *)
- void vLog (const char *fmt, va_list ap)
- void Log (int i, const char *fmt, ...) __attribute__((format(printf, 2, 3)))
- void vError (const char *fmt, va_list ap)
- void Error (const char *fmt, ...) __attribute__((format(printf, 1, 2)))
- int SetError (const char *fmt, ...) __attribute__((format(printf, 1, 2)))
- void ErrorAbort (const char *fmt, ...) __attribute__ ((noreturn,format(printf, 1, 2)))
- int InitDisplay (int *argc, char ***argv, const char *package, const char *version)
- void CloseDisplay (void)
- int ParseYesNo (const char *)
- char * rhcl_replace (const char *str, const char *what, const char *with)
- char * rhcl_strcasestr (char *haystack, const char *needle)
- char * rhcl_trim (const char *line)
- int DoTcpConnect (struct addrinfo *addr, int blocking, unsigned long timeout)
- char * GetNetError (struct addrinfo *addr)
- int TcpConnect (const char *hostname, const char *service, int *fd, int blocking, unsigned long timeout)
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:
path | directory path to make
|
n | length of the path
|
mode | permissions 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:
src | path to the src file
|
dest | path to the dest file
|
Returns: 0 on success, errno otherwise
gid_t Gid (const char *name)
|
Get the group id by name.
Parameters:
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:
return | NULL 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:
s | the string buffer
|
n | the length of the string buffer
|
key | the 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:
s | the string buffer
|
n | the length of the string buffer
|
key | the search key
|
data | the 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
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:
path | the 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:
fmt | a printf style format string
|
Returns: never
int InitDisplay (int *argc, char ***argv, const char *package, const char *version)
|
Initialize a display
Parameters:
argc | parameter count
|
argv | parameters (on some frontends, parameters are used to
handle crap like -geometry)
|
Returns: 0 on success
Close a display
char * rhcl_replace (const char *str, const char *what, const char *with)
|
Replace all occurences of
Parameters:
what | with
|
with | in
|
str | the 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:
line | Line 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. |