General Info | |
Interface: StringMan Files: stringman.h Last Change: 10/05/2005 Author: Luiz Henrique Shigunov | Description |
System Functions | |
0x00 - Compare - Compare two strings 0x01 - Concatenate - Concatenate two strings 0x02 - Copy - Copy a string 0x03 - FindChar - Find a char in a string 0x04 - FindLastChar - Find the last char in a string 0x05 - Length - Get a string size 0x06 - NCompare - Compare N chars from two strings 0x07 - NConcatenate - Concatenate N chars from two strings |
0x08 - NCopy - Copy N chars from a string 0x0c - NLength - Get a string size 0x0d - NPrintF - Format a string 0x0a - NPrintFArgs - Format a string passing a parameters array 0x09 - PrintF - Format a string 0x0e - ScanF - Input format conversion 0x0f - ScanFArgs - Input format conversion passing a parameters array 0x0b - StrToInt - Convert a string into a integer |
This page describes the StringMan interface which provides many functions to manipulate strings.
long StringMan_Compare(const char *s1, const char *s2);
This function compares s1 with s2. It's a case sensive comparation.
< 0 - if s1 is less than s2;
= 0 - if s1 is equal to s2;
> 0 - if s1 is greater than s2.
void StringMan_Concatenate(char *dest, const char *src);
This function concatenates src in dest overwriting the last 0 of dest and putting a 0 in the end of dest.
The strings may not overlap and dest must have enough space.
void StringMan_Copy(char *dest, const char *src);
This function copies the string src (including final 0) to the string dest.
The strings may not overlap and dest must have enough space.
char *StringMan_FindChar(const char *s, long c);
This function finds the first ocurrence of the char c in the string s.
A pointer to the matched char;
NULL if not found.
char *StringMan_FindLastChar(const char *s, long c);
This function finds the last ocurrence of the char c in the string s.
A pointer to the matched char;
NULL if not found.
unsigned long StringMan_Length(const char *s);
This function gets the size of the string s not including the last zero.
long StringMan_NCompare(const char *s1, const char *s2, unsigned long count);
This function compares no more than count bytes from s1 with s2. It's a case sensive comparation.
< 0 - if s1 is less than s2;
= 0 - if s1 is equal to s2;
> 0 - if s1 is greater than s2.
void StringMan_NConcatenate(char *dest, const char *src, unsigned long count);
This function concatenates no more than count bytes from src in dest overwriting the final zero from dest.
The strings may not overlap and dest must have enough space.
long StringMan_NCopy(char *dest, const char *src, unsigned long count);
This function copies no more than count minus 1 bytes from the string src to the string dest, ending dest with a zero, that is, dest will always be a valid string.
The strings may not overlap and dest must have enough space.
If count is zero nothing happens and it returns zero.
If count is one, dest will be terminated with zero and it returns zero only if src is an empty string, that is, it copied till the end.
Zero if copied till the end of src other value otherwise.
unsigned long StringMan_NLength(const char *s, unsigned long count);
This function gets the size of the string s not including the terminating zero, but at most count.
This way, s will only be examined at the first count characters.
The number of chars in s or count if the size of s is greater then count.
long StringMan_NPrintF(char *buf, unsigned long size, const char *fmt, ...);
This function puts in buf the formated string according to fmt, but it won't write more than size characters.
fmt accepts the same options as NPrintFArgs.
The number of written bytes or the number of bytes which would have been written in case size is not big enough.
long StringMan_NPrintFArgs(char *buf, unsigned long size, const char *fmt, va_list args);
This function puts in buf the formated string according to fmt, but it won't write more than size characters. args is an array of parameters.
The stdarg.h file must be included. Is in this file that va_list is defined.
This function supports the following flags: #, 0, -, + and ' ' (space), the following length modifier: h, l, ll, L and Z and the following conversion specifier: d, i, o, u, x, X, c, s, p, n and %.
The number of written bytes or the number of bytes which would have been written in case size is not big enough.
long StringMan_PrintF(char *buf, const char *fmt, ...);
This function puts in buf the formated string according to fmt.
fmt accepts the same options as NPrintFArgs.
long StringMan_ScanF(const char *buf, const char *fmt, ...);
This function scans buf according to fmt.
fmt accepts the same options as ScanFArgs.
long StringMan_ScanFArgs(const char *buf, const char *fmt, va_list args);
This function scans buf according to fmt. args is an array of parameters.
The stdarg.h file must be included. Is in this file that va_list is defined.
This function supports the following flags: *, the following length modifier: h, l, L and Z and the following conversion specifier: d, i, o, u, x, X, c, s, n and %.
long StringMan_StrToInt(const char *str, char **endstr, long base, long *error);
This function converts the string in str to a long integer value according to the given base, which must be between 2 and 36 inclusive, or be the special value 0.
The string must begin with an arbitrary amount of white space (' ', '\n', '\t', '\r', '\f', '\v') followed by a single optional '+' or '-' sign. If base is zero or 16, the string may then include a '0x' prefix, and the number will be read in base 16; otherwise, a zero base is taken as 10 (decimal) unless the next character is '0', in which case it is taken as 8 (octal).
The remainder of the string is converted to a long int value in the obvious manner, stopping at the first character which is not a valid digit in the given base. (In bases above 10, the letter 'A' in either upper or lower case represents 10, 'B' represents 11, and so forth, with 'Z' representing 35).
If endstr is not NULL, this function stores the address of the first invalid character in *endstr. If there were no digits at all, this function stores the original value of str in *endstr. (Thus, if *str is not '\0' but **endstr is '\0' on return, the entire string is valid).
error can be NULL.
The converted number;
0 if base is wrong and error is 1;
The biggest positive number if overflow occurs and error is 2;
The smallest negative number if underflow occurs and error is 2.