Get the current time as a string
char *SLcurrent_time_string (void)
The SLcurrent_time_string function uses the C library function
ctime to obtain a string representation of the
current date and time in the form
"Wed Dec 10 12:50:28 1997"
However, unlike the ctime function, a newline character is not
present in the string.
The returned value points to a statically allocated memory block which may get overwritten on subsequent function calls.
SLmake_string
Convert a text string to an integer
int SLatoi(unsigned char *str
SLatoi parses the string str to interpret it as an
integer value. Unlike atoi, SLatoi can also parse
strings containing integers expressed in
hexidecimal (e.g., "0x7F") and octal (e.g., "012".)
notation.
SLang_guess_type
Extract a substring of a delimited string
int SLextract_list_element (dlist, nth, delim, buf, buflen)
char *dlist;
unsigned int nth;
char delim;
char *buf;
unsigned int buflen;
SLextract_list_element may be used to obtain the nth
element of a list of strings, dlist, that are delimited by the
character delim. The routine copies the nth element of
dlist to the buffer buf whose size is buflen
characters. It returns zero upon success, or -1 if dlist
does not contain an nth element.
A delimited list of strings may be turned into an array of strings as follows. For conciseness, all malloc error checking has been omitted.
int list_to_array (char *list, char delim, char ***ap)
{
unsigned int nth;
char **a;
char buf[1024];
/* Determine the size of the array */
nth = 0;
while (0 == SLextract_list_element (list, nth, delim, buf, sizeof(buf)))
nth++;
ap = (char **) SLmalloc ((nth + 1) * sizeof (char **));
nth = 0;
while (0 == SLextract_list_element (list, nth, delim, buf, sizeof(buf)))
{
a[nth] = SLmake_string (buf);
nth++;
}
a[nth] = NULL;
*ap = a;
return 0;
}
SLmalloc, SLmake_string