Xively Official / mbed-libxively-5d6fdd4

Dependents:   xively-jumpstart-demo

Embed: (wiki syntax)

« Back to documentation index

xi_helpers.c File Reference

xi_helpers.c File Reference

General helpers used by the library [see xi_helpers.h]. 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.
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 [see xi_helpers.h].

Author:
Olgierd Humenczuk

Definition in file xi_helpers.c.


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.

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.