home *** CD-ROM | disk | FTP | other *** search
- /*
- #### # # # #
- # # # # # The FreeWare C library for
- # # ## ### # # # # ### RISC OS machines
- # # # # # # # # # # # ___________________________________
- # # #### ### ## # # # #
- # # # # # # # # # # Please refer to the accompanying
- #### ### #### # # ##### # ### documentation for conditions of use
- ________________________________________________________________________
-
- File: Str.h
- Author: Copyright © 1992, 1993 Jason Williams
- Version: 1.12 (17 May 1993)
- Purpose: Useful string functions not provided by ANSI, including functions
- to deal with CR-terminated strings, as used by the RISC OS Wimp.
- */
-
- #ifndef __dl_str_h
- #define __dl_str_h
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- /* We need size_t from stddef.h */
- #include <stddef.h>
-
-
- /* strlencr() == strlen()
- * NOTE **** With release 2 of DeskLib this has been changed to return
- * the length of the string EXCLUDING the terminator (i.e. it now returns
- * 1 less than it used to in Desklib 1)
- */
- extern int strlencr(char *s);
-
- /* strcmpcr() == strcmp)
- * Returns 0 if the strings match
- * Returns -1 if s1 < s2 (alphabetically less than, and/or shorter)
- * Returns +1 if s1 > s2 (alphabetcally greater than, and/or longer)
- */
- extern int strcmpcr(char *s1, char *s2);
-
-
- /* strcatcr() == strcat
- * Concatenates s2 onto the end of s1. Returns s1.
- * The returned string will be zero terminated.
- */
- extern char *strcatcr(char *s1, char *s2);
-
-
- /* strcpycr() == strcpy
- * Copies s2 into s1. Returns s1.
- * The returned string will be zero terminated.
- */
- extern char *strcpycr(char *s1, char *s2);
-
-
- /* strncpycr() == strncpy
- * Copies at most n chars of s2 into s1. Returns s1.
- * NOTE that this will NOT terminate the string if s2 is longer than 'n'
- * characters in length. If it is shorter, s1 will be zero-terminated.
- */
- extern char *strncpycr(char *s1, char *s2, int n);
-
-
- /* LeafName()
- * Return a pointer to the leaf of 'FullPath'.
- * Note that this pointer is within the 'FullPath' string.
- * If no '.' is encountered in FullPath, then the pointer FullPath
- * is returned
- */
- extern char *LeafName(char *FullPath);
-
-
-
- /****************************************************************************
-
- int stricmp(char *s1, char *s2);
-
- Purpose: As ANSI strcmp() function, but case insensitive.
-
- ****************************************************************************/
-
- extern int stricmp(char *s1, char *s2);
-
-
- /****************************************************************************
-
- int strnicmp(char *s1, char *s2, size_t n);
-
- Purpose: As ANSI strncmp() function, but case insensitive.
-
- ****************************************************************************/
-
- extern int strnicmp(char *s1, char *s2, size_t n);
-
- /****************************************************************************
-
- int stricmpcr(char *s1, char *s2);
-
- Purpose: As stricmp() function, but works on CR-terminated strings.
-
- ****************************************************************************/
-
- extern int stricmp(char *s1, char *s2);
-
-
- /****************************************************************************
-
- int strnicmpcr(char *s1, char *s2, size_t n);
-
- Purpose: As strnicmp() function, but works on CR-terminated strings.
-
- ****************************************************************************/
-
- extern int strnicmpcr(char *s1, char *s2, size_t n);
-
-
- /****************************************************************************
-
- char *strdup(const char *s);
-
- Inputs: s - the string to copy
- Returns: Address of new string, or NULL if out of memory.
- Purpose: Allocate memory for a copy of the string, and copy the string
- into this memory.
-
- ****************************************************************************/
-
- extern char *strdup(const char *s);
-
-
- /****************************************************************************
-
- void Str_MakeCR(char *s, int max_len);
-
- Inputs: s - pointer to the string to change to a CR-terminated string.
- max_len - the number of characters to look for the null
- terminator in before giving up (in which case it is
- terminated at the max_len'th character).
- Purpose: Converts a CR-terminated string into a 0-terminated (ASCIIZ)
- string.
- SeeAlso: Str_MakeASCIIZ()
-
- ****************************************************************************/
-
- extern void Str_MakeCR(char *s, int max_len);
-
-
- /****************************************************************************
-
- void Str_MakeASCIIZ(char *s, int max_len);
-
- Inputs: s - pointer to the string to change to a 0-terminated string.
- max_len - the number of characters to look for the null
- terminator in before giving up (in which case it is
- terminated at the max_len'th character).
- Purpose: Converts a 0-terminated string (ASCIIZ) into a CR-terminated
- string.
- SeeAlso: Str_MakeCR()
-
- ****************************************************************************/
-
- extern void Str_MakeASCIIZ(char *s, int max_len);
-
-
- /****************************************************************************
-
- char Str_MakeHex(int n);
-
- Inputs: n - the digit to convert to hexadecimal (n should be in the
- range 0-15).
- Returns: The character representing the digit; '0'..'9', 'A'..'Z'.
- Purpose: Converts an integer in the range 0 to 15 to a character that
- represents it in hexadecimal.
- If n is outside the range, '?' is returned.
- SeeAlso: Str_DecodeHex()
-
- ****************************************************************************/
-
- extern char Str_MakeHex(int n);
-
-
- /****************************************************************************
-
- int Str_DecodeHex(char digit);
-
- Inputs: digit - character representing the hex digit to convert.
- Returns: The integer value of 'digit', or -1 for error.
- Purpose: Convert a hexadecimal digit of the form '0'..'9', 'A'..'Z'
- into an integer.
- If the character is not a legal hexadecimal digit, -1 is
- returned.
- SeeAlso: HexDigit()
-
- ****************************************************************************/
-
- extern int Str_DecodeHex(char digit);
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif
-