![]() |
SCTC
the soundcloud.com terminal client
|
Implements several basic helper functions (mixed purpose) More...
Functions | |
| char * | smprintf (char *fmt,...) |
| printf style function with automated allocation of buffer. More... | |
| void | strcrep (char *str, char s, char r) |
| replace a char with another char in a given string More... | |
| int | snprint_ftime (char *buffer, size_t buffer_size, int time_secs) |
| Write a formated version of time_secs to buffer. More... | |
| char * | strstrp (char *str) |
| bool | yank (char *text) |
| Yank the provided text. More... | |
| void * | _lmalloc (char *srcfile, int srcline, const char *srcfunc, size_t size) |
| void * | _lcalloc (char *srcfile, int srcline, const char *srcfunc, size_t nmemb, size_t size) |
| void * | _lrealloc (char *srcfile, int srcline, const char *srcfunc, void *ptr, size_t size) |
| char * | _lstrdup (char *srcfile, int srcline, const char *srcfunc, const char *s) |
| unsigned int | parse_time_to_sec (char *str) |
| Parse a string to seconds. More... | |
Implements several basic helper functions (mixed purpose)
| void* _lcalloc | ( | char * | srcfile, |
| int | srcline, | ||
| const char * | srcfunc, | ||
| size_t | nmemb, | ||
| size_t | size | ||
| ) |
The internal implementation for lcalloc.
Warning: This function is not intended to be called directly by the user. Use lcalloc() instead, as this macro inserts the correct position of the call to _lcalloc().
| srcfile | The file executing the call to _lcalloc(); filled by macro lcalloc(), do not use "by hand" |
| srcline | The line in the file executing the call to _lcalloc(); filled by macro lcalloc(), do not use "by hand" |
| srcfunc | The function calling _lcallocg(); filled by macro lcalloc(), do not use "by hand" |
| nmemb | The number of elements to be allocated |
| size | The size of each single element to be allocated |
| void* _lmalloc | ( | char * | srcfile, |
| int | srcline, | ||
| const char * | srcfunc, | ||
| size_t | size | ||
| ) |
The internal implementation for lmalloc.
Warning: This function is not intended to be called directly by the user. Use lmalloc() instead, as this macro inserts the correct position of the call to _lmalloc().
| srcfile | The file executing the call to _lmalloc(); filled by macro lmalloc(), do not use "by hand" |
| srcline | The line in the file executing the call to _lmalloc(); filled by macro lmalloc(), do not use "by hand" |
| srcfunc | The function calling _lmalloc(); filled by macro lmalloc(), do not use "by hand" |
| size | The number of bytes to be allocated |
| void* _lrealloc | ( | char * | srcfile, |
| int | srcline, | ||
| const char * | srcfunc, | ||
| void * | ptr, | ||
| size_t | size | ||
| ) |
The internal implementation for lrealloc.
Warning: This function is not intended to be called directly by the user. Use lrealloc() instead, as this macro inserts the correct position of the call to _lrealloc().
| srcfile | The file executing the call to _lrealloc(); filled by macro lrealloc(), do not use "by hand" |
| srcline | The line in the file executing the call to _lrealloc(); filled by macro lrealloc(), do not use "by hand" |
| srcfunc | The function calling _lrealloc(); filled by macro lrealloc(), do not use "by hand" |
| ptr | Pointer to the memory to resize |
| size | The number of bytes to be reallocated |
| char* _lstrdup | ( | char * | srcfile, |
| int | srcline, | ||
| const char * | srcfunc, | ||
| const char * | s | ||
| ) |
The internal implementation for lstrdup.
Warning: This function is not intended to be called directly by the user. Use lstrdup() instead, as this macro inserts the correct position of the call to _lstrdup().
| srcfile | The file executing the call to _lstrdup(); filled by macro lstrdup), do not use "by hand" |
| srcline | The line in the file executing the call to _lstrdup(); filled by macro lstrdup(), do not use "by hand" |
| srcfunc | The function calling _lstrdup(); filled by macro lstrdup(), do not use "by hand" |
| s | The string to be duplicated |
| unsigned int parse_time_to_sec | ( | char * | str | ) |
Parse a string to seconds.
Parses a string in format hour:min:sec, min:sec or sec to a number of seconds. If str does not match any of the formats shown above INVALID_TIME is returned.
| str | The string to be parsed |
| char* smprintf | ( | char * | fmt, |
| ... | |||
| ) |
printf style function with automated allocation of buffer.
| fmt | The formatstring, as known from printf, see man 3 printf |
free'd) or NULL if malloc failed | int snprint_ftime | ( | char * | buffer, |
| size_t | buffer_size, | ||
| int | time_secs | ||
| ) |
Write a formated version of time_secs to buffer.
If time_secs is above one hour the format "%d:%02d:%02d" is used, otherwise "%02d:%02d" is used.
At most buffer_size bytes are written to buffer. If buffer_size - 1 is returned your output is most likely truncated and thus the used buffer should be resized.
| buffer | The buffer receiving the formated time. |
| buffer_size | The size of the buffer. |
| time_secs | The seconds to be formated. |
| void strcrep | ( | char * | str, |
| char | s, | ||
| char | r | ||
| ) |
replace a char with another char in a given string
| str | The string to search in, points to a buffer that will be modified |
| s | The char to search for |
| r | The char to replace with |
| char* strstrp | ( | char * | str | ) |
| bool yank | ( | char * | text | ) |
Yank the provided text.
| text | The text to yank |
true on success, false otherwise
1.8.9.1