Utility functions¶
- Utility functions
- smf_core_gen_queue_file()
- smf_core_get_substring()
- smf_core_get_maildir_filename()
- smf_core_expand_string()
- smf_core_object_unref()
- smf_md5sum()
- smf_core_valid_address()
- TRACE
smf_core_gen_queue_file()¶
Generate a new queue file name
1 int smf_core_gen_queue_file(char **tempanme);
Parameter
- tempname - pointer to unallocated buffer for filename, needs to free'd by caller if not required anymore
Return value
- returns 0 on success or -1 in case of error
smf_core_get_substring()¶
Extract a substring from given string
1 char* smf_core_get_substring(const char *pattern, const char *haystack, int pos);
Parameter
- pattern - regular expression pattern
- haystack - string to search in
- pos - position to extract
Return value
- returns extracted string
smf_core_get_maildir_filename()¶
Generates a unique maildir filename
1 char *smf_core_get_maildir_filename(void);
Return value
- returns generated filename or NULL in case of error
smf_core_expand_string()¶
Expands placeholders in a querystring
1 int smf_core_expand_string(char *format, char *addr, char **buf);
Parameter
- 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
Return value
- returns the number of replacements made or -1 in case of error
smf_core_object_unref()¶
Decreases the reference count of object (SMFMessage_T, SMFMimePart_T and SMFMultiPart_T). When its reference count drops to 0, the object is finalized (i.e. its memory is freed).
1 void smf_core_object_unref(void *object);
Parameter
- object - pointer to object
smf_md5sum()¶
Generate md5 hexdigest for string
1 char *smf_md5sum(const char *data);
Parameter
- data - String to generate md5sum for
Return value
- returns Pointer to hexdigest string on success, NULL on error
smf_core_valid_address()¶
Check if given string is a valid email address (since 0.4.2)
Parameter
- addr - String to check
Return value
- returns 0 on success or -1 in case of error
TRACE¶
Convenience macro for logging.
1 #define TRACE(level, fmt...) trace(level, THIS_MODULE, __func__, __LINE__, fmt)
Parameter
- level - loglevel, see SMFTrace_T
- fmt - format string
- args - format string arguments