Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-libxively-6eca970 by
xi_helpers.h File Reference
General helpers used by the library. More...
Go to the source code of this file.
| Functions | |
| char * | xi_str_dup (const char *s) | 
| int | xi_str_copy_untiln (char *dst, size_t dst_size, const char *src, char delim) | 
| Copies `src` string into `dst`, but stops whenever `delim` is reached or the `dst_size` is exceeded. | |
| time_t | xi_mktime (struct tm *t) | 
| Converts from `tm` to `time_t`. | |
| struct tm * | xi_gmtime (time_t *t) | 
| This just wraps system's `gmtime()`, it a facade for future use. | |
| char * | xi_replace_with (char p, char r, char *buffer, size_t max_chars) | 
| Replaces `p` with `r` for every `p` in `buffer`. | |
Detailed Description
General helpers used by the library.
Definition in file xi_helpers.h.
Function Documentation
| struct tm* xi_gmtime | ( | time_t * | t ) |  [read] | 
This just wraps system's `gmtime()`, it a facade for future use.
Definition at line 165 of file xi_helpers.c.
| time_t xi_mktime | ( | struct tm * | t ) | 
Converts from `tm` to `time_t`.
- Note:
- This code assumes that unsigned long can be converted to `time_t`. A `time_t` should not be wider than `unsigned long`, since this would mean that the check for overflow at the end could fail.
- This implementation had been copied from MINIX C library. Which is 100% compatible with our license.
- This function does not take into account the timezone or the `dst`, it just converts `tm` structure using date and time fields (i.e. UTC).
| char* xi_replace_with | ( | char | p, | 
| char | r, | ||
| char * | buffer, | ||
| size_t | max_chars | ||
| ) | 
Replaces `p` with `r` for every `p` in `buffer`.
- Returns:
- Pointer to converted buffer.
- Note:
- This function assumes that the buffer is terminated with `\0`.
Definition at line 170 of file xi_helpers.c.
| int xi_str_copy_untiln | ( | char * | dst, | 
| size_t | dst_size, | ||
| const char * | src, | ||
| char | delim | ||
| ) | 
Copies `src` string into `dst`, but stops whenever `delim` is reached or the `dst_size` is exceeded.
- Returns:
- Number of copied characters or -1 if an error occurred.
Definition at line 31 of file xi_helpers.c.
| char* xi_str_dup | ( | const char * | s ) | 
- Note:
- Needed to avoid using `strdup()` which can cause some problems with `free()`, because of buggy `realloc()` implementations.
- Returns:
- Duplicated string or null in case of memory allocation problem.
Definition at line 19 of file xi_helpers.c.
Generated on Wed Jul 13 2022 02:16:22 by
 1.7.2
 1.7.2 
    