General Info

Interface: StringMan
Files: lib/stringman.h
Last change: 11/02/2002
Author: Luiz Henrique Shigunov
Description
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
  • 0x09 - BufPrintF - Format a string
  • 0x0a - BufPrintFArgs - Format a string passing a parameters array
  • 0x0b - StrToInt - Convert a string into a integer
  • Description

    This page describes StringMan interface.

    This interface provides many functions to manipulate strings.

    0x00 - Compare

    Syntax

    int Compare(const char *s1, const char *s2);

    Description

    This function compares s1 with s2.

    Return value

    0x01 - Concatenate

    Syntax

    void Concatenate(char *dest, const char *src);

    Description

    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.

    Return value

    Nothing.

    0x02 - Copy

    Syntax

    void Copy(char *dest, const char *src);

    Description

    This function copies the string src (including final 0) to the string dest.

    The strings may not overlap and dest must have enough space.

    Return value

    Nothing.

    0x03 - FindChar

    Syntax

    char *FindChar(const char *s, int c);

    Description

    This function finds the first ocurrence of the char c in the string s.

    Return value

    0x04 - FindLastChar

    Syntax

    char *FindLastChar(const char *s, int c);

    Description

    This function finds the last ocurrence of the char c in the string s.

    Return value

    0x05 - Length

    Syntax

    unsigned int Length(const char *s);

    Description

    This function gets the size of the string s not including the last zero.

    Return value

    The number of chars in s.

    0x06 - NCompare

    Syntax

    int NCompare(const char *s1, const char *s2, unsigned int count);

    Description

    This function compares no more than count bytes from s1 with s2.

    Return value

    0x07 - NConcatenate

    Syntax

    void NConcatenate(char *dest, const char *src, unsigned int count);

    Description

    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.

    Return value

    Nothing.

    0x08 - NCopy

    Syntax

    void NCopy(char *dest, const char *src, unsigned int count);

    Description

    This function copies no more than count bytes from the string src to the string dest.

    The strings may not overlap and dest must have enough space.

    If src is less than count, the rest of dest is filled with zeros.

    Return value

    Nothing.

    0x09 - BufPrintF

    Syntax

    int BufPrintF(char *buf, const char *fmt, ...);

    Description

    This function puts in buf the formated string according to fmt.

    Return value

    The number of written bytes.

    0x0a - BufPrintFArgs

    Syntax

    int BufPrintFArgs(char *buf, const char *fmt, va_list args);

    Description

    This function puts in buf the formated string 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.

    Return value

    The number of written bytes.

    0x0b - StrToInt

    Syntax

    long int StrToInt(const char *str, char **endstr, int base, int *error);

    Description

    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).

    Return value