TPCCLIB
|
Utility functions for processing strings. More...
Go to the source code of this file.
Functions | |
int | strTokenNr (const char *str1, const char *str2) |
int | strTokenNCpy (const char *str1, const char *str2, int i, char *str3, int count) |
char * | strTokenDup (const char *s1, const char *s2, int *next) |
int | strChrCount (const char *str1, const char *str2) |
int | strUppercaseCount (const char *s) |
void | strReplaceChar (char *str, char c1, char c2) |
size_t | strnlen (const char *s, size_t n) |
size_t | strlcat (char *dst, const char *src, size_t dstsize) |
size_t | strlcpy (char *dst, const char *src, size_t dstsize) |
char * | strcasestr (const char *haystack, const char *needle) |
int | strncpyCleanSpaces (char *s1, const char *s2, int maxlen) |
int | strCleanSpaces (char *s) |
char * | strEncodeForXML (const char *s) |
void | strCleanForXML (char *s) |
Utility functions for processing strings.
Definition in file strext.c.
char * strcasestr | ( | const char * | haystack, |
const char * | needle ) |
Case-insensitive version of strstr().
haystack | Pointer to string in which sub-string needle is searched. |
needle | Pointer to sub-string which is searched for in source string haystack. |
Definition at line 279 of file strext.c.
Referenced by cunitFromFilename(), dftFormat(), iftReadValue(), and resWriteHTML_table().
int strChrCount | ( | const char * | str1, |
const char * | str2 ) |
Count how many times specified characters are found in a string. Search is case-sensitive.
str1 | String to search for characters; not modified. |
str2 | String containing characters which are searched for; not modified. |
Definition at line 126 of file strext.c.
Referenced by rnameSplit().
void strCleanForXML | ( | char * | s | ) |
Remove from string those characters that would require encoding in XML. Replaced by character '-'.
s | Pointer to the string to be cleaned. |
Definition at line 402 of file strext.c.
int strCleanSpaces | ( | char * | s | ) |
Removes any initial and trailing space characters from specified string s.
Space characters in the middle of the string are not removed.
s | Pointer to the string. |
Definition at line 343 of file strext.c.
Referenced by csvRead().
char * strEncodeForXML | ( | const char * | s | ) |
Encode special characters for XML, including SVG.
s | Pointer to the string to be encoded. |
Definition at line 364 of file strext.c.
Referenced by dftWriteHTML(), and resWriteHTML_table().
size_t strlcat | ( | char * | dst, |
const char * | src, | ||
size_t | dstsize ) |
Safer version of strncat. At most dstsize-1 characters are appended from the source string to destination string. Destination string will be NUL terminated, unless dstsize <= strlen(dst).
dst | Destination string. |
src | Source string. |
dstsize | The actual length of buffer allocated for the destination string; for example, destination string has been allocated as char dst[dstsize]; |
Definition at line 206 of file strext.c.
Referenced by anaExists(), backupExistingFile(), dftRead(), and hrrtMakeCalHdr().
size_t strlcpy | ( | char * | dst, |
const char * | src, | ||
size_t | dstsize ) |
Safer version of strncpy or strcpy.
At most dstsize-1 characters are copied from the source string to the destination string. Destination string will be NUL terminated.
dst | Destination string. |
src | Source string. |
dstsize | The actual length of buffer allocated for the destination string; for example, destination string has been allocated as char dst[dstsize]; |
Definition at line 245 of file strext.c.
Referenced by anaEditHeader(), anaExists(), backupExistingFile(), csv2dft_b(), csv2dft_mat(), dcmAddItem(), dcmFileRead(), dft_fill_hdr_from_IFT(), dftAllocateWithIMG(), dftRead(), dftWrite(), ecat63AddImg(), ecat63EditMHeader(), ecat63ReadAllToImg(), ecat63ReadPlaneToImg(), ecat63WriteAllImg(), ecat7EditMHeader(), ecat7EditVHeader(), ecatCopy63to7mainheader(), ecatCopy7to63mainheader(), fitRead(), hrrtMakeCalHdr(), img2sif(), imgGetAnalyzeHeader(), imgGetEcat63MHeader(), imgGetEcat7MHeader(), imgGetMicropetSIF(), imgReadAnalyze(), imgReadAnalyzeHeader(), imgReadNiftiHeader(), imgSetEcat63MHeader(), imgSetEcat7MHeader(), imgSetNiftiHeader(), imgWriteAnalyze(), niftiCreateFNames(), niftiExists(), niftiHeaderToIFT(), resRead(), selectEcat931Calibrationfile(), sif2img(), strncpyCleanSpaces(), strTokenDup(), strTokenNCpy(), studynr_from_fname2(), studynr_in_fname(), upetExists(), and xelRead().
int strncpyCleanSpaces | ( | char * | s1, |
const char * | s2, | ||
int | maxlen ) |
Version of strncpy() which as usual copies s2 to s1, but without any space characters or line end characters that may be around the string s2.
s1 | Pointer to pre-allocated result string with length of at least maxlen characters, including NULL character. |
s2 | Pointer to the original string. |
maxlen | Max length of s1, including the trailing zero. |
Definition at line 308 of file strext.c.
Referenced by roi_read(), roiRead(), and strCleanSpaces().
size_t strnlen | ( | const char * | s, |
size_t | n ) |
Safer version of strlen, in case the argument s is not NUL terminated string. Computes the length of string s, but never scans beyond the n first bytes of the string.
s | Pointer to string, or character array, that may not be NULL terminated. |
n | The actual length of buffer allocated for the string; for example, string could have been allocated as char s[n]; |
Definition at line 181 of file strext.c.
Referenced by csv2dft_mat(), dcmAddItem(), dcmDA2intl(), dcmDT2intl(), dcmFileRead(), dcmFileWrite(), dcmSOPIdentify(), dcmSOPUIDName(), dcmTM2intl(), dcmTrUID(), dftWrite(), irdRead(), sifRead(), strlcat(), and tpcHtmlUsage().
void strReplaceChar | ( | char * | str, |
char | c1, | ||
char | c2 ) |
Replace certain characters in string with another character.
str | Pointer to string in which the character is replaced. |
c1 | Character to be replaced. |
c2 | Character to use instead. If NULL, then only the first character is replaced. |
Definition at line 159 of file strext.c.
Referenced by dftWrite(), fitRead(), roi_read(), roiRead(), and strCleanForXML().
char * strTokenDup | ( | const char * | s1, |
const char * | s2, | ||
int * | next ) |
Search the string s1 for the first token. The characters making up the string s2 are the delimiters that determine the tokens.
s1 | String from where tokens are searched; not modified in any way. |
s2 | String containing character delimiters. |
next | Index of s1 where the token ended; set to NULL, if not needed. |
Definition at line 89 of file strext.c.
Referenced by fitRead(), and textfileReadLines().
int strTokenNCpy | ( | const char * | str1, |
const char * | str2, | ||
int | i, | ||
char * | str3, | ||
int | count ) |
The strTokenNCpy() function copies the i'th token in the string pointed to by str1 into string pointed to by str3. The characters making up the string pointed to by str2 are the delimiters that determine the token.
str1 | String from where tokens are searched; not modified in any way. |
str2 | String containing character delimiters. |
i | Token number to copy (1..nr of tokens). |
str3 | String array into where the token is copied; string will be null terminated. |
count | Length of str3, including terminal null |
Definition at line 45 of file strext.c.
Referenced by fitRead(), integerListAddFromString(), integerListExpandFromString(), pxlRead(), resRead(), and roi_read().
int strTokenNr | ( | const char * | str1, |
const char * | str2 ) |
The strTokenNr() function returns the number of tokens in the string pointed to by str1. The characters making up the string pointed to by str2 are the delimiters that determine the token.
str1 | String from where tokens are calculated; not modified in any way. |
str2 | String containing character delimiters. |
Definition at line 17 of file strext.c.
Referenced by fitRead(), integerListAddFromString(), integerListExpandFromString(), pxlRead(), resRead(), and roi_read().
int strUppercaseCount | ( | const char * | s | ) |
Count how many upper case characters are found in string.
s | String to search for upper case characters; not modified. |
Definition at line 146 of file strext.c.
Referenced by rnameSplit().