home *** CD-ROM | disk | FTP | other *** search
/ Oracle Video Server 3.0.3.1 / OVS_3031_NT.iso / win32 / medianet / server / include / ysstr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-24  |  3.5 KB  |  127 lines

  1. /* Copyright (c) 1995 by Oracle Corporation.  All Rights Reserved.
  2.  *
  3.  * ysstr.h - String Manipulation
  4.  *
  5.  * ATTRS: public, external
  6.  */
  7.  
  8. #ifndef YSSTR_ORACLE
  9. #define YSSTR_ORACLE
  10.  
  11. #ifndef SYSX_ORACLE
  12. #include <sysx.h>
  13. #endif
  14. #ifndef YSM_ORACLE
  15. #include <ysm.h>
  16. #endif
  17.  
  18. EXTC_START
  19.  
  20. /*
  21.  * Types & Constants
  22.  */
  23. typedef char ysstr;
  24.  
  25. /*
  26.  * ysStrCreate, ysStrDestroy - create and destroy a string
  27.  *
  28.  * DESCRIPTION
  29.  * ysStrCreate() creates and returns a string, optionally initialized
  30.  * to the given text (if it is not null).  ysStrDestroy() destroys a
  31.  * string.
  32.  */
  33. ysstr *ysStrCreate(CONST char *txt);
  34. void   ysStrDestroy(ysstr *str);
  35.  
  36. /*
  37.  * ysStrDup, ysStrDupWaf - duplicate a text string
  38.  *
  39.  * SYNOPSIS
  40.  * char *ysStrDup(CONST char *txt);
  41.  * char *ysStrDupWaf(CONST char *txt, ysmaf af);
  42.  *
  43.  * DESCRIPTION
  44.  * ysStrDup() duplicates a text string, allocating memory from the global
  45.  * heap.  ysStrDupWaf() does the same thing but uses the allocator provided
  46.  * to obtain the memory for the string.  If a null pointer is passed for
  47.  * txt, a null pointer is returned.
  48.  */
  49. #define ysStrDup(txt)  ysStrDupWaf((txt), (ysmaf) 0)
  50. char *ysStrDupWaf(CONST char *txt, ysmaf af);
  51.  
  52. /*
  53.  * ysStrLen - length of the string
  54.  *
  55.  * SYNOPSIS
  56.  * size_t ysStrLen(ysstr *str);
  57.  *
  58.  * DESCRIPTION
  59.  * ysStrLen() returns the length of a string.
  60.  */
  61. #define ysStrLen(str)  strlen(ysStrToText(str))
  62.  
  63. /*
  64.  * ysStrToText - convert string to text
  65.  *
  66.  * SYNOPSIS
  67.  * char *ysStrToText(ysstr *str);
  68.  *
  69.  * DESCRIPTION
  70.  * ysStrToText() returns the representation of a string.  The representation
  71.  * should not be freed directly.
  72.  */
  73. #define ysStrToText(str)  ((char *) (str))
  74.  
  75. /*
  76.  * ysStrCat, ysStrnCat, ysStrApp - concatenate text & characters
  77.  *
  78.  * DESCRIPTION
  79.  * ysStrCat() concatenates text to the end of a string.  ysStrApp()
  80.  * appends a single character to the end of a string.  Both of these
  81.  * functions return the resulting string, which, much like the semantics
  82.  * of realloc(), may or may not be a different pointer than the one passed
  83.  * in for str.
  84.  *
  85.  * ysStrnCat() is identical to ysStrCat() except that if n is less than
  86.  * the length of txt, only the first n characters of txt are concatenated
  87.  * to str.
  88.  */
  89. ysstr *ysStrCat(ysstr *str, CONST char *txt);
  90. ysstr *ysStrnCat(ysstr *str, CONST char *txt, size_t n);
  91. ysstr *ysStrApp(ysstr *str, char ch);
  92.  
  93. /*
  94.  * ysStrIns - insert text into a string
  95.  *
  96.  * DESCRIPTION
  97.  * ysStrIns() inserts txt starting at the given position in str.
  98.  */
  99. ysstr *ysStrIns(ysstr *str, size_t pos, CONST char *txt);
  100.  
  101. /*
  102.  * ysStrDel - delete text from a string
  103.  *
  104.  * DESCRIPTION
  105.  * ysStrDel() deletes cnt characters from str starting at the given
  106.  * position.
  107.  */
  108. ysstr *ysStrDel(ysstr *str, size_t pos, sword cnt);
  109.  
  110. /*
  111.  * ysStrCaseCmp, ysStrnCaseCmp - case-insensitive string comparison
  112.  *
  113.  * DESCRIPTION
  114.  * ysStrCaseCmp() compares two strings and returns a value greater than,
  115.  * equal to, or less than zero, according as s1 is lexicographically
  116.  * greater than, equal to, or less than s2, ignoring the differences
  117.  * in case.  This routine assumes the C character set when equating
  118.  * upper and lower case.  ysStrnCaseCmp() performs the same comparison
  119.  * as ysStrCaseCmp() but compares at most 'max' bytes.  Bytes beyond
  120.  * a NUL byte are not compared.
  121.  */
  122. sword ysStrCaseCmp(CONST char *s1, CONST char *s2);
  123. sword ysStrnCaseCmp(CONST char *s1, CONST char *s2, sword max);
  124.  
  125. EXTC_END
  126. #endif /* YSSTR_ORACLE */
  127.