2 ** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2003.
3 ** See ../LICENSE for license information.
13 /* does this cause problems on Solaris? linux? */
14 /* sgi's don't like it */
16 # ifdef NULL /* hack so <strings.h> works */
21 /* typedefs in forwardTypes */
23 extern /*@notnull@*/ cstring cstring_create (size_t p_n) /*@*/ /*@ensures maxSet(result) == p_n @*/ ;
24 extern /*@only@*/ /*@notnull@*/ cstring cstring_newEmpty (void) ;
25 extern /*@notnull@*/ cstring cstring_appendChar (/*@only@*/ cstring p_s1, char p_c);
27 extern cstring cstring_concatLength (/*@only@*/ cstring p_s1, char *p_s2, size_t p_len)
29 /*@requires maxSet(p_s2) >= (p_len - 1) @*/ ;
31 extern /*@notnull@*/ cstring cstring_prependChar (char p_c, /*@temp@*/ cstring p_s1);
32 extern /*@notnull@*/ cstring cstring_prependCharO (char p_c, /*@only@*/ cstring p_s1);
33 extern cstring cstring_downcase (cstring p_s) /*@*/ ;
34 extern cstring cstring_copy (cstring p_s) /*@*/ /*@ensures maxSet(result) == maxRead(p_s) /\ maxRead(result) == maxRead(p_s) @*/ ;
35 extern cstring cstring_copyLength (char *p_s, size_t p_len) /*@*/ /*@requires maxSet(p_s) >= (p_len - 1) @*/;
37 extern int cstring_toPosInt (cstring p_s) /*@*/ ;
40 CGE_SAME, /* no differences */
41 CGE_DISTINCT, /* significant differences */
42 CGE_CASE, /* case differences */
43 CGE_LOOKALIKE /* lookalike differences */
46 extern cmpcode cstring_genericEqual (cstring p_s, cstring p_t,
48 bool p_caseinsensitive,
49 bool p_lookalike) /*@*/
50 /*@requires maxRead(p_s) >= p_nchars /\ maxRead(p_t) >= p_nchars @*/ ;
52 /* evans 2001-09-09 - removed conditional compilation on this (for WIN32, OS2) */
53 extern void cstring_replaceAll (cstring p_s, char p_old, char p_snew) /*@modifies p_s@*/ ;
55 extern void cstring_replaceLit (/*@unique@*/ cstring p_s, char *p_old, char *p_snew)
57 /*@requires maxRead(p_snew) >= 0 /\ maxRead(p_old) >= 0 /\ maxRead(p_old) >= maxRead(p_snew) @*/;
59 extern char cstring_firstChar (cstring p_s) /*@*/ ;
60 extern char cstring_secondChar (cstring p_s) /*@*/ ;
61 extern char cstring_lastChar (cstring p_s) /*@*/ ;
62 extern char cstring_getChar (cstring p_s, size_t p_n);
64 extern void cstring_setChar (cstring p_s, size_t p_n, char p_c)
65 /*@requires maxRead(p_s) >= (p_n - 1) /\ maxSet(p_s) >= (p_n - 1) @*/ ;
67 # define cstring_secondChar(s) cstring_getChar (s, 2)
69 extern /*@exposed@*/ /*@notnull@*/ /*@untainted@*/ char *
70 cstring_toCharsSafe (/*@temp@*/ /*@exposed@*/ /*@returned@*/ cstring p_s)
73 extern size_t cstring_length (cstring p_s) /*@*/ /*@ensures result == maxRead(p_s) @*/;
75 extern bool cstring_contains (/*@unique@*/ cstring p_c, cstring p_sub) /*@*/ ;
76 extern bool cstring_containsChar (cstring p_c, char p_ch) /*@*/ ;
77 extern bool cstring_equal (cstring p_c1, cstring p_c2) /*@*/ ;
78 extern bool cstring_equalCaseInsensitive (cstring p_c1, cstring p_c2) /*@*/ ;
79 extern bool cstring_equalLen (cstring p_c1, cstring p_c2, size_t p_len) /*@*/ ;
80 extern bool cstring_equalLenCaseInsensitive (cstring p_c1, cstring p_c2, size_t p_len) /*@*/ ;
81 extern bool cstring_equalPrefix (cstring p_c1, cstring p_c2) /*@*/ ;
82 extern bool cstring_equalPrefixLit (cstring p_c1, /*@observer@*/ const char *p_c2) /*@*/ ;
83 extern bool cstring_equalLit (cstring p_c1, char *p_c2) /*@*/ ;
84 extern int cstring_compare (cstring p_c1, cstring p_c2) /*@*/ ;
85 extern int cstring_xcompare (cstring *p_c1, cstring *p_c2) /*@*/ ;
87 extern bool cstring_hasNonAlphaNumBar (cstring p_s) /*@*/ ;
89 extern cstring cstring_elide (cstring p_s, size_t p_len) /*@*/ ;
91 extern cstring cstring_clip (/*@returned@*/ cstring p_s, size_t p_len)
94 extern void cstring_stripChars (cstring p_s, const char *p_clist) /*@modifies p_s@*/ ;
96 extern /*@dependent@*/ cstring
97 cstring_bsearch (cstring p_key,
101 extern bool cstring_lessthan (cstring p_s1, cstring p_s2) /*@*/ ;
102 # define cstring_lessthan(s1, s2) (cstring_compare (s1, s2) < 0)
104 # define cstring_equalLit(s, lit) \
105 (mstring_equal (cstring_toCharsSafe (s), lit))
107 extern bool cstring_equalFree (/*@only@*/ cstring p_c1, /*@only@*/ cstring p_c2);
109 /* really exposed! */
112 ** Don't allow tainted cstring's
116 cstring_fromChars (/*@returned@*/ /*@null@*/
117 const /*@exposed@*/ /*@temp@*/ char *p_cp) /*@*/ ;
120 cstring_fromCharsO (/*@null@*/ /*@only@*/ char *p_cp) /*@*/ ;
122 # define cstring_fromCharsO(s) cstring_fromChars(s)
125 extern cstring cstring_fromCharsNew (/*@null@*/ char *p_s) /*@*/ ;
126 # define cstring_fromCharsNew(s) cstring_copy(cstring_fromChars(s))
128 extern /*@exposed@*/ /*@notnull@*/ /*@untainted@*/
129 char *cstring_toCharsSafeO (/*@only@*/ /*@exposed@*/ /*@returned@*/ cstring p_s);
131 # define cstring_toCharsSafeO(s) cstring_toCharsSafe(s)
134 extern void cstring_free (/*@only@*/ cstring p_s);
136 /*@constant null cstring cstring_undefined;@*/
137 # define cstring_undefined ((cstring)NULL)
139 extern /*@falsewhennull@*/ bool cstring_isDefined (cstring p_s) /*@*/ ;
140 extern /*@nullwhentrue@*/ bool cstring_isUndefined (cstring p_s) /*@*/ ;
142 extern /*@nullwhentrue@*/ bool cstring_isEmpty (cstring p_s) /*@*/ ;
143 extern /*@falsewhennull@*/ bool cstring_isNonEmpty (cstring p_s) /*@*/ ;
145 # define cstring_isDefined(s) ((s) != cstring_undefined)
146 # define cstring_isUndefined(s) (!cstring_isDefined(s))
148 # define cstring_isEmpty(s) (cstring_length(s) == 0)
149 # define cstring_isNonEmpty(s) (!cstring_isEmpty(s))
151 extern cstring cstring_makeLiteral (char *) /*@*/ ;
152 extern /*@observer@*/ /*@dependent@*/ cstring
153 cstring_makeLiteralTemp (char *) /*@*/ ;
155 # define cstring_makeLiteral(s) (cstring_copy (cstring_fromChars (s)))
156 # define cstring_makeLiteralTemp(s) (cstring_fromChars (s))
158 extern cstring cstring_capitalize (cstring p_s) /*@*/ /*@requires maxSet(p_s) >= 0 @*/ ;
159 extern cstring cstring_capitalizeFree (/*@only@*/ cstring p_s) /*@modifies p_s@*/ /*@requires maxSet(p_s) >= 0 /\ maxRead(p_s) >= 0 @*/ ;
161 extern cstring cstring_fill (cstring p_s, size_t p_n) /*@*/ /*@requires p_n >= 0 @*/;
163 extern cstring cstring_prefix (cstring p_s, size_t p_n)
165 /*@requires maxRead(p_s) >= p_n /\ maxSet(p_s) >= p_n @*/
166 /*@ensures maxRead(result) == p_n /\ maxSet(result) == p_n @*/ ;
168 extern /*@observer@*/ cstring cstring_suffix (cstring p_s, size_t p_n) /*@*/ ;
169 extern cstring cstring_concat (cstring p_s, cstring p_t) /*@*/ /*@requires maxSet(p_s) >= 0 @*/;
172 cstring_concatFree (/*@only@*/ cstring p_s, /*@only@*/ cstring p_t)
173 /*@modifies p_s, p_t@*/ ;
176 cstring_concatFree1 (/*@only@*/ cstring p_s, cstring p_t)
180 cstring_concatChars (/*@only@*/ cstring p_s, char *p_t)
183 extern lsymbol cstring_toSymbol (/*@only@*/ cstring p_s) /*@*/ ;
185 extern void cstring_markOwned (/*@owned@*/ cstring p_s) /*@modifies p_s@*/ ;
187 extern cstring cstring_beforeChar (cstring p_s, char p_c) /*@*/ ;
188 extern /*@exposed@*/ cstring cstring_afterChar (cstring p_s, char p_c) /*@*/ ;
190 /*@iter cstring_chars (sef cstring s, yield char c);@*/
191 # define cstring_chars(s, m_c) \
192 if (cstring_isDefined (s)) \
193 { char *m_current = (char *) (s); \
195 for (; (m_c = *m_current) != '\0'; m_current++) {
196 # define end_cstring_chars }}
198 extern /*@observer@*/ cstring cstring_advanceWhiteSpace (cstring) /*@*/ ;
200 extern /*@only@*/ /*@notnull@*/ cstring
201 cstring_copySegment (cstring p_s, size_t p_findex, size_t p_tindex) /*@*/ ;
203 /*drl added 01/22/2001 Expands the escape squences i.e "\\n\\t\\000"
205 extern /*@notnull@*/ cstring cstring_expandEscapes (cstring p_s);
207 /*drl added 01/23/2001 Gives you the number of characters in an
208 expanded escape squences. This can be different from strlen bc/ of
210 extern size_t cstring_lengthExpandEscapes (cstring p_s);
213 extern bool cstring_containsLit (/*@unique@*/ cstring p_c, char *p_sub) /*@*/ ;
214 # define cstring_containsLit(c,sub) \
215 (cstring_contains (c, cstring_fromChars (sub)))
217 /*drl added July 2, 001 */
218 extern int cstring_compareLit (/*@unique@*/ cstring p_c, char *p_sub) /*@*/ ;
219 # define cstring_compareLit(c,sub) \
220 (cstring_compare (c, cstring_fromChars (sub)))
222 /*drl added 2/4/2002*/
223 /*replaces every instance of the character old with the character new
226 cstring cstring_replaceChar(/*@returned@*/ cstring p_c, char p_oldChar, char p_newChar);
229 # error "Multiple include"