Files
sics/tecs/util.h
2000-03-15 11:29:50 +00:00

74 lines
2.0 KiB
C

char *str_ntrim(char *dest, int ldest, const char *src, int lsrc);
/*
copy characters 0 to lsrc-1 from src to dest (max ldest chars).
*/
char *str_split1(char *str, char separator);
/*
trims text before separator in *str and returns
a pointer to the first character after separator
*/
char *str_split(char *str, char sep, char *list[], int *n);
/*
split string into *n strings using separator sep.
spaces at the end of the elements are trimmed
attention: *str is modified ('\0' placed at the end of the elements)
if *n separators are found, result points to string after *n-th separator
else result is NULL
*n contains number of elements stored in list
*/
char *str_read_arg(char *file, char *args[], int nargs);
/*
return one string containing the contents of file *file
the contents are treated in the following way:
- #0,#1,...#n is replaced by the corresponding argument *args[n] (n=0..nargs-1, nargs<10)
- at the end of each line spaces and comments separated by ! are trimmed
*/
void str_replace_char(char *str, char ch, char rep);
/*
replace all occurences of character ch by character rep in string *str
*/
void str_upcase(char *str);
/*
convert *str to uppercase
*/
int str_cmp(const char *str1, const char *str2);
/*
compare *str1 with *str2
the comparison is not case sensitive
if result=0: strings are equal
else
result>0 <==> *str1>*str2
first different character is at position abs(result)-1
*/
int str_ncpy(char *dst, const char *src, int maxdest);
/*
copy *src to *dest, maximal maxdest characters,
it is guaranteed, that dst contains '\0'
*/
int str_ncat(char *dst, const char *src, int maxdest);
/*
append *src to *dest, maximal maxdest characters,
it is guaranteed, that dst contains '\0'
*/
#define str_copy(DST,SRC) str_ncpy(DST,SRC,sizeof(DST))
#define str_append(DST,SRC) str_ncat(DST,SRC,sizeof(DST))
/*
use these macros if DST is an fixed length character array
*/
void util_delay(int tmo_msec);
/*
usleep is not available on VMS 6
*/