poser
A C framework for POsix SERvices
|
generic utility functions More...
#include <poser/decl.h>
#include <stddef.h>
Go to the source code of this file.
Functions | |
void * | PSC_malloc (size_t size) |
Allocate memory. | |
void * | PSC_realloc (void *ptr, size_t size) |
Re-allocate memory. | |
char * | PSC_copystr (const char *src) |
Copy a string. | |
char * | PSC_lowerstr (const char *src) |
Lowercase a string. | |
char * | PSC_joinstr (const char *delim, char **strings) |
Join multiple strings. | |
const char * | PSC_basename (const char *path) |
Get base filename from full path. | |
generic utility functions
const char * PSC_basename | ( | const char * | path | ) |
Get base filename from full path.
This looks for the last path separator ('/') in the given string and returns a pointer to the first character after it. If no separator is found, the original string is returned. If the returned string would be empty, a pointer to the string "." is returned instead.
path | the full path string |
char * PSC_copystr | ( | const char * | src | ) |
Copy a string.
This is similar to strdup(), but uses PSC_malloc() internally.
src | the string to copy |
char * PSC_joinstr | ( | const char * | delim, |
char ** | strings | ||
) |
Join multiple strings.
This joins an array of strings into a new string, putting a delimeter between all the elements.
delim | the delimeter |
strings | the strings to join, array must end with a NULL pointer |
char * PSC_lowerstr | ( | const char * | src | ) |
Lowercase a string.
This creates a copy of the string in all lowercase.
src | the string to copy |
void * PSC_malloc | ( | size_t | size | ) |
Allocate memory.
This is a wrapper around malloc() that ensures only valid pointers are returned. In case of an allocation error, PSC_Service_panic() is called.
size | size of the memory to allocate |
void * PSC_realloc | ( | void * | ptr, |
size_t | size | ||
) |
Re-allocate memory.
This is a wrapper around realloc() that ensures only valid pointers are returned. In case of an allocation error, PSC_Service_panic() is called.
ptr | the previously allocated memory |
size | new size for the allocated memory |