home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / gcc / !GCC / patches / DeskLib / h / Str < prev    next >
Encoding:
Text File  |  1994-05-29  |  6.5 KB  |  205 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Str.h
  12.     Author:  Copyright © 1992, 1993 Jason Williams
  13.     Version: 1.12 (17 May 1993)
  14.     Purpose: Useful string functions not provided by ANSI, including functions
  15.                to deal with CR-terminated strings, as used by the RISC OS Wimp.
  16. */
  17.  
  18. #ifndef __dl_str_h
  19. #define __dl_str_h
  20.  
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24.  
  25. /* We need size_t from stddef.h */
  26. #include <stddef.h>
  27.  
  28.  
  29.   /*  strlencr() == strlen()
  30.    *  NOTE **** With release 2 of DeskLib this has been changed to return
  31.    *  the length of the string EXCLUDING the terminator (i.e. it now returns
  32.    *  1 less than it used to in Desklib 1)
  33.    */
  34. extern int strlencr(char *s);
  35.  
  36.   /*  strcmpcr() == strcmp)
  37.    *  Returns 0 if the strings match
  38.    *  Returns -1 if s1 < s2  (alphabetically less than, and/or shorter)
  39.    *  Returns +1 if s1 > s2  (alphabetcally greater than, and/or longer)
  40.    */
  41. extern int strcmpcr(char *s1, char *s2);
  42.  
  43.  
  44.   /*  strcatcr() == strcat
  45.    *  Concatenates s2 onto the end of s1. Returns s1.
  46.    *  The returned string will be zero terminated.
  47.    */
  48. extern char *strcatcr(char *s1, char *s2);
  49.  
  50.  
  51.   /*  strcpycr() == strcpy
  52.    *  Copies s2 into s1. Returns s1.
  53.    *  The returned string will be zero terminated.
  54.    */
  55. extern char *strcpycr(char *s1, char *s2);
  56.  
  57.  
  58.   /*  strncpycr() == strncpy
  59.    *  Copies at most n chars of s2 into s1. Returns s1.
  60.    *  NOTE that this will NOT terminate the string if s2 is longer than 'n'
  61.    *  characters in length. If it is shorter, s1 will be zero-terminated.
  62.    */
  63. extern char *strncpycr(char *s1, char *s2, int n);
  64.  
  65.  
  66.   /*  LeafName()
  67.    *  Return a pointer to the leaf of 'FullPath'.
  68.    *  Note that this pointer is within the 'FullPath' string.
  69.    *  If no '.' is encountered in FullPath, then the pointer FullPath
  70.    *  is returned
  71.    */
  72. extern char *LeafName(char *FullPath);
  73.  
  74.  
  75.  
  76. /****************************************************************************
  77.  
  78.     int stricmp(char *s1, char *s2);
  79.  
  80.     Purpose:  As ANSI strcmp() function, but case insensitive.
  81.  
  82. ****************************************************************************/
  83.  
  84. extern int stricmp(char *s1, char *s2);
  85.  
  86.  
  87. /****************************************************************************
  88.  
  89.     int strnicmp(char *s1, char *s2, size_t n);
  90.  
  91.     Purpose:  As ANSI strncmp() function, but case insensitive.
  92.  
  93. ****************************************************************************/
  94.  
  95. extern int strnicmp(char *s1, char *s2, size_t n);
  96.  
  97. /****************************************************************************
  98.  
  99.     int stricmpcr(char *s1, char *s2);
  100.  
  101.     Purpose:  As stricmp() function, but works on CR-terminated strings.
  102.  
  103. ****************************************************************************/
  104.  
  105. extern int stricmp(char *s1, char *s2);
  106.  
  107.  
  108. /****************************************************************************
  109.  
  110.     int strnicmpcr(char *s1, char *s2, size_t n);
  111.  
  112.     Purpose:  As strnicmp() function, but works on CR-terminated strings.
  113.  
  114. ****************************************************************************/
  115.  
  116. extern int strnicmpcr(char *s1, char *s2, size_t n);
  117.  
  118.  
  119. /****************************************************************************
  120.  
  121.     char *strdup(const char *s);
  122.  
  123.     Inputs:   s - the string to copy
  124.     Returns:  Address of new string, or NULL if out of memory.
  125.     Purpose:  Allocate memory for a copy of the string, and copy the string
  126.                 into this memory.
  127.  
  128. ****************************************************************************/
  129.  
  130. extern char *strdup(const char *s);
  131.  
  132.  
  133. /****************************************************************************
  134.  
  135.     void Str_MakeCR(char *s, int max_len);
  136.  
  137.     Inputs:   s - pointer to the string to change to a CR-terminated string.
  138.                 max_len - the number of characters to look for the null
  139.                               terminator in before giving up (in which case it is
  140.                               terminated at the max_len'th character).
  141.     Purpose:  Converts a CR-terminated string into a 0-terminated (ASCIIZ)
  142.                 string.
  143.     SeeAlso:  Str_MakeASCIIZ()
  144.  
  145. ****************************************************************************/
  146.  
  147. extern void Str_MakeCR(char *s, int max_len);
  148.  
  149.  
  150. /****************************************************************************
  151.  
  152.     void Str_MakeASCIIZ(char *s, int max_len);
  153.  
  154.     Inputs:   s - pointer to the string to change to a 0-terminated string.
  155.                 max_len - the number of characters to look for the null
  156.                               terminator in before giving up (in which case it is
  157.                               terminated at the max_len'th character).
  158.     Purpose:  Converts a 0-terminated string (ASCIIZ) into a CR-terminated
  159.                 string.
  160.     SeeAlso:  Str_MakeCR()
  161.  
  162. ****************************************************************************/
  163.  
  164. extern void Str_MakeASCIIZ(char *s, int max_len);
  165.  
  166.  
  167. /****************************************************************************
  168.  
  169.     char Str_MakeHex(int n);
  170.  
  171.     Inputs:   n - the digit to convert to hexadecimal (n should be in the
  172.                       range 0-15).
  173.     Returns:  The character representing the digit; '0'..'9', 'A'..'Z'.
  174.     Purpose:  Converts an integer in the range 0 to 15 to a character that
  175.                 represents it in hexadecimal.
  176.                 If n is outside the range, '?' is returned.
  177.     SeeAlso:  Str_DecodeHex()
  178.  
  179. ****************************************************************************/
  180.  
  181. extern char Str_MakeHex(int n);
  182.  
  183.  
  184. /****************************************************************************
  185.  
  186.     int Str_DecodeHex(char digit);
  187.  
  188.     Inputs:   digit - character representing the hex digit to convert.
  189.     Returns:  The integer value of 'digit', or -1 for error.
  190.     Purpose:  Convert a hexadecimal digit of the form '0'..'9', 'A'..'Z'
  191.                 into an integer.
  192.                 If the character is not a legal hexadecimal digit, -1 is
  193.                 returned.
  194.     SeeAlso:  HexDigit()
  195.  
  196. ****************************************************************************/
  197.  
  198. extern int Str_DecodeHex(char digit);
  199.  
  200. #ifdef __cplusplus
  201. }
  202. #endif
  203.  
  204. #endif
  205.