home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) 1995 by Oracle Corporation. All Rights Reserved.
- *
- * ysstr.h - String Manipulation
- *
- * ATTRS: public, external
- */
-
- #ifndef YSSTR_ORACLE
- #define YSSTR_ORACLE
-
- #ifndef SYSX_ORACLE
- #include <sysx.h>
- #endif
- #ifndef YSM_ORACLE
- #include <ysm.h>
- #endif
-
- EXTC_START
-
- /*
- * Types & Constants
- */
- typedef char ysstr;
-
- /*
- * ysStrCreate, ysStrDestroy - create and destroy a string
- *
- * DESCRIPTION
- * ysStrCreate() creates and returns a string, optionally initialized
- * to the given text (if it is not null). ysStrDestroy() destroys a
- * string.
- */
- ysstr *ysStrCreate(CONST char *txt);
- void ysStrDestroy(ysstr *str);
-
- /*
- * ysStrDup, ysStrDupWaf - duplicate a text string
- *
- * SYNOPSIS
- * char *ysStrDup(CONST char *txt);
- * char *ysStrDupWaf(CONST char *txt, ysmaf af);
- *
- * DESCRIPTION
- * ysStrDup() duplicates a text string, allocating memory from the global
- * heap. ysStrDupWaf() does the same thing but uses the allocator provided
- * to obtain the memory for the string. If a null pointer is passed for
- * txt, a null pointer is returned.
- */
- #define ysStrDup(txt) ysStrDupWaf((txt), (ysmaf) 0)
- char *ysStrDupWaf(CONST char *txt, ysmaf af);
-
- /*
- * ysStrLen - length of the string
- *
- * SYNOPSIS
- * size_t ysStrLen(ysstr *str);
- *
- * DESCRIPTION
- * ysStrLen() returns the length of a string.
- */
- #define ysStrLen(str) strlen(ysStrToText(str))
-
- /*
- * ysStrToText - convert string to text
- *
- * SYNOPSIS
- * char *ysStrToText(ysstr *str);
- *
- * DESCRIPTION
- * ysStrToText() returns the representation of a string. The representation
- * should not be freed directly.
- */
- #define ysStrToText(str) ((char *) (str))
-
- /*
- * ysStrCat, ysStrnCat, ysStrApp - concatenate text & characters
- *
- * DESCRIPTION
- * ysStrCat() concatenates text to the end of a string. ysStrApp()
- * appends a single character to the end of a string. Both of these
- * functions return the resulting string, which, much like the semantics
- * of realloc(), may or may not be a different pointer than the one passed
- * in for str.
- *
- * ysStrnCat() is identical to ysStrCat() except that if n is less than
- * the length of txt, only the first n characters of txt are concatenated
- * to str.
- */
- ysstr *ysStrCat(ysstr *str, CONST char *txt);
- ysstr *ysStrnCat(ysstr *str, CONST char *txt, size_t n);
- ysstr *ysStrApp(ysstr *str, char ch);
-
- /*
- * ysStrIns - insert text into a string
- *
- * DESCRIPTION
- * ysStrIns() inserts txt starting at the given position in str.
- */
- ysstr *ysStrIns(ysstr *str, size_t pos, CONST char *txt);
-
- /*
- * ysStrDel - delete text from a string
- *
- * DESCRIPTION
- * ysStrDel() deletes cnt characters from str starting at the given
- * position.
- */
- ysstr *ysStrDel(ysstr *str, size_t pos, sword cnt);
-
- /*
- * ysStrCaseCmp, ysStrnCaseCmp - case-insensitive string comparison
- *
- * DESCRIPTION
- * ysStrCaseCmp() compares two strings and returns a value greater than,
- * equal to, or less than zero, according as s1 is lexicographically
- * greater than, equal to, or less than s2, ignoring the differences
- * in case. This routine assumes the C character set when equating
- * upper and lower case. ysStrnCaseCmp() performs the same comparison
- * as ysStrCaseCmp() but compares at most 'max' bytes. Bytes beyond
- * a NUL byte are not compared.
- */
- sword ysStrCaseCmp(CONST char *s1, CONST char *s2);
- sword ysStrnCaseCmp(CONST char *s1, CONST char *s2, sword max);
-
- EXTC_END
- #endif /* YSSTR_ORACLE */
-