Various helper functions.
More...
Go to the source code of this file.
|
char * | smf_core_strstrip (char *s) |
| Removes leading and trailing whitespace from a string. This function doesn't allocate or reallocate any memory; it modifies string in place. The pointer to string is returned to allow the nesting of functions.
|
|
char * | smf_core_strlwc (char *s) |
| Convert a string to lowercase.
|
|
char * | smf_core_strcat_printf (char **s, const char *fmt,...) |
| Append format string to string and reallocate memory. The pointer to string is returned to allow the nesting of functions.
|
|
char ** | smf_core_strsplit (const char *s, char *sep, int *nelems) |
| Split a given string.
|
|
int | smf_core_gen_queue_file (const char *queue_dir, char **tempname, const char *sid) |
| Generate a new queue file name.
|
|
char * | smf_core_md5sum (const char *data) |
| Generate md5 hexdigest for string.
|
|
char * | smf_core_get_maildir_filename (void) |
| Generates a unique maildir filename.
|
|
int | smf_core_expand_string (const char *format, const char *addr, char **buf) |
| expands placeholders in a user querystring
|
|
int | smf_core_copy_file (const char *source, const char *dest) |
| Copies the content of the source file into dest.
|
|
int | smf_core_copy_to_fd (const char *source, int dest) |
| Copies the content of the source file into an already open file-descriptor. This function is similar to smf_core_copy_file(). But rather than opening the destination file, this function uses an already open file-descriptor as a destination.
|
|
Various helper functions.
int smf_core_copy_file |
( |
const char * |
source, |
|
|
const char * |
dest |
|
) |
| |
Copies the content of the source file into dest.
- Parameters
-
source | Path of the source file |
dest | Path of the destination file. If file already exists, then the current content is replaced with the content of the source file. |
- Returns
- the number of bytes copied
int smf_core_copy_to_fd |
( |
const char * |
source, |
|
|
int |
dest |
|
) |
| |
Copies the content of the source file into an already open file-descriptor. This function is similar to smf_core_copy_file(). But rather than opening the destination file, this function uses an already open file-descriptor as a destination.
- Parameters
-
source | Path of the source file |
dest | On open file-descriptior, where the content is written into. |
- Returns
- the number of bytes copied
int smf_core_expand_string |
( |
const char * |
format, |
|
|
const char * |
addr, |
|
|
char ** |
buf |
|
) |
| |
expands placeholders in a user querystring
- Parameters
-
format | format string to use as input |
addr | email address to use for replacements |
buf | pointer to unallocated buffer for expanded format string, needs to free'd by caller if not required anymore |
- Returns
- the number of replacements made or -1 in case of error
int smf_core_gen_queue_file |
( |
const char * |
queue_dir, |
|
|
char ** |
tempname, |
|
|
const char * |
sid |
|
) |
| |
Generate a new queue file name.
- Parameters
-
queue_dir | path to queue directory |
tempname | pointer to unallocated buffer for filename, needs to free'd by caller if not required anymore |
sid | current session id |
- Returns
- 0 on success or -1 in case of error
char* smf_core_get_maildir_filename |
( |
void |
| ) |
|
Generates a unique maildir filename.
- Returns
- newly allocated pointer with generated filename or NULL in case of error
char* smf_core_md5sum |
( |
const char * |
data | ) |
|
Generate md5 hexdigest for string.
- Parameters
-
data | String to generate md5sum for |
- Returns
- Pointer to hexdigest string on success, NULL on error
char* smf_core_strcat_printf |
( |
char ** |
s, |
|
|
const char * |
fmt, |
|
|
|
... |
|
) |
| |
Append format string to string and reallocate memory. The pointer to string is returned to allow the nesting of functions.
- Parameters
-
s | string to append to |
fmt | format string |
- Returns
- new appended string
char* smf_core_strlwc |
( |
char * |
s | ) |
|
Convert a string to lowercase.
- Parameters
-
- Returns
- ptr to string
char** smf_core_strsplit |
( |
const char * |
s, |
|
|
char * |
sep, |
|
|
int * |
nelems |
|
) |
| |
Split a given string.
- Parameters
-
s | String to split |
sep | separator |
nelems | If set to non-NULL, then the function stores here the number of elements in the resulting array. |
- Returns
- a newly-allocated NULL-terminated array of strings.
char* smf_core_strstrip |
( |
char * |
s | ) |
|
Removes leading and trailing whitespace from a string. This function doesn't allocate or reallocate any memory; it modifies string in place. The pointer to string is returned to allow the nesting of functions.
- Parameters
-
- Returns
- intput string