/* File: strlib.h
   Desc: string library interface

   StrLib is a simple string library. Strings are defined as an array
   of 256 characters. All strings are null-terminated. Thus a string
   may store up to 255 characters. Indexes are 0-based.

   Cristina Cifuentes
   3 August 1997
*/

#ifndef __strlib_h
#define __strlib_h   		/* prevent multiple includes */

#define MAXSTRING	255	/* maximum size of a string */

typedef char String[MAXSTRING + 1]; /* define string type */


/*** Function Prototypes ***/

void clearString (String s);
/* Desc:    Clears s of all characters.
   Receive: s, the string to clear
   Returns: s, an empty string
*/


int stringLength (String s);
/* Desc:    Returns the length of s
   Receive: s, the string to find the lengh of
   Returns: int, the number of characters in s, not counting the null terminating character.
*/


void stringConcat (String dst, String src);
/* Desc:    Appends src to dst
   Receive: dst, the string to append to
	    src, the string to copy from
   Returns: dst, dst appended with src
*/


void stringCopy (String dst, String src);
/* Desc:    Copies src into dst
   Receive: dst, the string to copy to
	    src, the string to copy from
   Returns: dst, a copy of src
*/


int stringCompare (String s1, String s2);
/* Desc:    Performs character-by-character comparison between s1 and s2
   Receive: s1, s2, the strings to compare
   Returns: int < 0, if s1 comes before s2 alphabetically
	       == 0, if s1 is equal to s2
		> 0, if s1 comes after s2 alphabetically
*/


void subString (String src, unsigned start, unsigned length, String dst);
/* Desc:    Extracts a substring from src and copies it to dst.
   Receive: src, the string to extract from
	    dst, the string to copy the substring to
	    start, the start offset
	    length, the number of characters to copy
   Returns: dst, the extracted string
*/


char charAtPos (String s, int n);
/* Desc:    Extracts character at index n
   Receive: s, the string
	    n, the index (0 <= n < stringLength(s) <= 255)
   Returns: char, the character at index n
*/


void lowerCase (String s);
/* Desc:    Converts s to lowercase
   Receive: s, the string to convert
   Returns: s, string converted to lowercase
*/


void upperCase (String s);
/* Desc:    Converts s to uppercase
   Receive: s, the string to convert
   Returns: s, string converted to uppercase
*/


int findString (String s1, String s2, int start);
/* Desc:    Searches for the first occurence of s2 in s1 and returns the index
            at which it appears or < 0 if no match was found.
   Receive: s1, the string to search
            s2, the string to search for
            start, the index into s1 to start searching from
   Returns: int, the index of the first character of the string found or < 0 if
            no match was found.
*/


int findCharacter (String s, char c, int start);
/* Desc:    Searches for the first occurence of c in s and returns the index
	    at which it appears or < 0 if no match was found.
   Receive: s, the string to search
	    c, the character to search for
	    start, the index into s to start searching from
   Returns: int, the index of the character found or < 0 if no match was found.
*/


#endif /* __strlib_h */


