Utility APIs¶
List of helpful utility functions
Header File¶
Source: include/utils.h
#include <utils.h>
Functions¶
-
char *strreplace(char *str, char s, char r)¶
Replace occurrence of character in string
- Parameters
str – [in] input string
s – [in] Search character
r – [in] Replace character
- Returns
Final string after replacement (same as input str pointer)
-
char *strcasestr(const char *str, const char *pattern)¶
Case insensitive string search
- Parameters
str – [in] Input string
pattern – [in] Search pattern
- Returns
Returns pointer to the beginning of the located substring, NULL if not found.
-
time_t timegm(struct tm *tm)¶
Inverse of gmtime and localtime
- Parameters
tm – [in] Broken down time structure
- Returns
On success, these functions return the calendar time (seconds since the Epoch). On error, they return the value (time_t) -1 and set errno to indicate the cause of the error.
-
void msleep(unsigned long ms)¶
Sleep for duration in milliseconds
- Parameters
ms – [in] Sleep duration in ms
-
int print_buffer(unsigned long addr, const void *data, unsigned int width, unsigned int count, unsigned int linelen)¶
Print buffer utility
- Parameters
addr – [in] Start address for display
data – [in] Buffer to display
width – [in] Data width: 1: 8-bit, 2: 16-bit, 4: 32-bit
count – [in] Length of data to display
linelen – [in] Number of values to print per line, 0 for default value of 16
- Returns
-
int load_init(void)¶
Enable load command line utility to load file on device via Xmodem
Load command usage:
#~ Load [/path/to/file]e.g.
#~ load /fs/test.txt- Returns
Always returns 0
-
int wget_init(void)¶
Enable wget command line utility to download file from web
File download status will be returned via URC response: URC_FILE_DOWNLOAD_STATUS to URC response handler function.
Wget command usage:
#~ wget [/path/to/file] [URL]See also
e.g.
#~ wget /fs/test.txt http://example.com/test.txt
- Returns
Always returns 0
