]> andersk Git - splint.git/blob - src/Headers/cstring.h
Initial revision
[splint.git] / src / Headers / cstring.h
1 /*
2 ** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2000.
3 ** See ../LICENSE for license information.
4 **
5 */
6 /*
7 ** cstring.h
8 */
9
10 # ifndef CSTRING_H
11 # define CSTRING_H
12
13 /* does this cause problems on Solaris?  linux?  */
14 /* sgi's don't like it */
15 # ifndef IRIX
16 # ifdef NULL   /* hack so <strings.h> works */
17 # undef NULL
18 # endif
19 # endif
20
21 /* typedefs in forwardTypes */
22
23 extern /*@notnull@*/ cstring cstring_create (int p_n) /*@*/ ;
24 extern /*@notnull@*/ cstring cstring_appendChar (/*@only@*/ cstring p_s1, char p_c);
25
26 extern cstring cstring_concatLength (/*@only@*/ cstring p_s1, char *p_s2, int p_len) /*@*/ ;
27
28 extern /*@notnull@*/ cstring cstring_prependChar (char p_c, /*@temp@*/ cstring p_s1);
29 extern /*@notnull@*/ cstring cstring_prependCharO (char p_c, /*@only@*/ cstring p_s1);
30 extern cstring cstring_downcase (cstring p_s) /*@*/ ;
31 extern cstring cstring_copy (cstring p_s) /*@*/ ;
32 extern cstring cstring_copyLength (char *p_s, int p_len) /*@*/ ;
33
34 extern int cstring_toPosInt (cstring p_s) /*@*/ ;
35
36 typedef enum {
37   CGE_SAME,     /* no differences */
38   CGE_DISTINCT, /* significant differences */
39   CGE_CASE,     /* case differences */
40   CGE_LOOKALIKE /* lookalike differences */
41   } cmpcode;
42
43 extern cmpcode cstring_genericEqual (cstring p_s, cstring p_t,
44                                      int p_nchars,
45                                      bool p_caseinsensitive,
46                                      bool p_lookalike) /*@*/ ;
47
48 # ifdef WIN32
49 extern void cstring_replaceAll (cstring p_s, char p_old, char p_snew) /*@modifies p_s@*/ ;
50 # endif
51
52 extern void cstring_replaceLit (/*@unique@*/ cstring p_s, char *p_old, char *p_snew);
53 extern char cstring_firstChar (cstring p_s);
54 extern char cstring_secondChar (cstring p_s);
55 extern char cstring_lastChar (cstring p_s) /*@*/ ;
56 extern char cstring_getChar (cstring p_s, int p_n);
57 extern void cstring_setChar (cstring p_s, int p_n, char p_c);
58
59 # define cstring_secondChar(s) cstring_getChar (s, 2)
60
61 extern /*@exposed@*/ /*@notnull@*/ char *
62   cstring_toCharsSafe (/*@temp@*/ /*@exposed@*/ /*@returned@*/ cstring p_s)
63      /*@*/ ;
64
65 extern int cstring_length (cstring p_s) /*@*/ ;
66 extern bool cstring_contains (/*@unique@*/ cstring p_c, cstring p_sub) /*@*/ ;
67 extern bool cstring_containsChar (cstring p_c, char p_ch) /*@*/ ;
68 extern bool cstring_equal (cstring p_c1, cstring p_c2) /*@*/ ;
69 extern bool cstring_equalCaseInsensitive (cstring p_c1, cstring p_c2) /*@*/ ;
70 extern bool cstring_equalLen (cstring p_c1, cstring p_c2, int p_len) /*@*/ ;
71 extern bool cstring_equalLenCaseInsensitive (cstring p_c1, cstring p_c2, int p_len) /*@*/ ;
72 extern bool cstring_equalPrefix (cstring p_c1, char *p_c2) /*@*/ ;
73 extern bool cstring_equalCanonicalPrefix (cstring p_c1, char *p_c2) /*@*/ ;
74 extern bool cstring_equalLit (cstring p_c1, char *p_c2) /*@*/ ;
75 extern int cstring_compare (cstring p_c1, cstring p_c2) /*@*/ ;
76 extern int cstring_xcompare (cstring *p_c1, cstring *p_c2) /*@*/ ;
77
78 # ifndef NOLCL
79 extern bool cstring_hasNonAlphaNumBar (cstring p_s) /*@*/ ;
80 # endif
81
82 extern cstring cstring_elide (cstring p_s, int p_len) /*@*/ ;
83 extern cstring cstring_clip (/*@returned@*/ cstring p_s, int p_len) 
84    /*@modifies p_s@*/ ;
85 extern void cstring_stripChars (cstring p_s, const char *p_clist) /*@modifies p_s@*/ ;
86
87 extern /*@dependent@*/ cstring 
88   cstring_bsearch (cstring p_key,
89                    char **p_table,
90                    int p_nentries);
91
92 extern bool cstring_lessthan (cstring p_s1, cstring p_s2) /*@*/ ;
93 # define cstring_lessthan(s1, s2) (cstring_compare (s1, s2) < 0)
94
95 # define cstring_equalLit(s, lit) \
96   (mstring_equal (cstring_toCharsSafe (s), lit))
97
98 extern bool cstring_equalFree (/*@only@*/ cstring p_c1, /*@only@*/ cstring p_c2);
99
100 /* really exposed! */
101 extern cstring 
102   cstring_fromChars (/*@returned@*/ /*@null@*/ 
103                      const /*@exposed@*/ /*@temp@*/ char *p_cp) /*@*/ ;
104
105 extern cstring
106   cstring_fromCharsO (/*@null@*/ /*@only@*/ char *p_cp) /*@*/ ;
107 /*@-mustfree@*/
108 # define cstring_fromCharsO(s) cstring_fromChars(s)
109 /*@=mustfree@*/
110
111 extern cstring cstring_fromCharsNew (/*@null@*/ char *p_s) /*@*/ ;
112 # define cstring_fromCharsNew(s) cstring_copy(cstring_fromChars(s))
113
114 # ifndef NOLCL
115 extern /*@exposed@*/ /*@notnull@*/ 
116   char *cstring_toCharsSafeO (/*@only@*/ /*@exposed@*/ /*@returned@*/ cstring p_s);
117 /*@-mustfree@*/
118 # define cstring_toCharsSafeO(s) cstring_toCharsSafe(s)
119 /*@=mustfree@*/
120 # endif
121
122 extern void cstring_free (/*@only@*/ cstring p_s);
123
124 /*@constant null cstring cstring_undefined;@*/
125 # define cstring_undefined     ((cstring)NULL)
126
127 extern /*@falsenull@*/ bool cstring_isDefined (cstring p_s) /*@*/ ;
128 extern /*@truenull@*/ bool cstring_isUndefined (cstring p_s) /*@*/ ;
129
130 extern bool cstring_isEmpty (cstring p_s) /*@*/ ;
131 extern /*@falsenull@*/ bool cstring_isNonEmpty (cstring p_s) /*@*/ ;
132
133 # define cstring_isDefined(s)   ((s) != cstring_undefined)
134 # define cstring_isUndefined(s) (!cstring_isDefined(s))
135
136 # define cstring_isEmpty(s)     (cstring_length(s) == 0)
137 # define cstring_isNonEmpty(s)  (!cstring_isEmpty(s))
138
139 extern cstring cstring_makeLiteral (char *) /*@*/ ;
140 extern /*@observer@*/ /*@dependent@*/ cstring 
141   cstring_makeLiteralTemp (char *) /*@*/ ;
142
143 # define cstring_makeLiteral(s) (cstring_copy (cstring_fromChars (s)))
144 # define cstring_makeLiteralTemp(s) (cstring_fromChars (s))
145
146 extern cstring cstring_capitalize (cstring p_s) /*@*/ ;
147 extern cstring cstring_capitalizeFree (/*@only@*/ cstring p_s) /*@modifies p_s@*/ ;
148 extern cstring cstring_fill (cstring p_s, int p_n) /*@*/ ;
149 extern cstring cstring_prefix (cstring p_s, int p_n) /*@*/ ;
150 extern /*@observer@*/ cstring cstring_suffix (cstring p_s, int p_n) /*@*/ ;
151 extern cstring cstring_concat (cstring p_s, cstring p_t) /*@*/ ;
152
153 extern cstring 
154   cstring_concatFree (/*@only@*/ cstring p_s, /*@only@*/ cstring p_t)
155   /*@modifies p_s, p_t@*/ ;
156
157 extern cstring 
158   cstring_concatFree1 (/*@only@*/ cstring p_s, cstring p_t) 
159   /*@modifies p_s@*/ ;
160
161 # ifndef NOLCL
162 extern cstring 
163   cstring_concatChars (/*@only@*/ cstring p_s, char *p_t)
164   /*@modifies p_s@*/ ;
165
166 extern lsymbol cstring_toSymbol (/*@only@*/ cstring p_s) /*@*/ ;
167 # endif
168
169 extern void cstring_markOwned (/*@owned@*/ cstring p_s) /*@modifies p_s@*/ ;
170
171 extern cstring cstring_beforeChar (cstring p_s, char p_c) /*@*/ ;
172
173 /*@iter cstring_chars (sef cstring s, yield char c);@*/
174 # define cstring_chars(s, m_c) \
175   if (cstring_isDefined (s)) \
176     { char *m_current = (char *) (s); \
177       char m_c; \
178       for (; (m_c = *m_current) != '\0'; m_current++) {
179 # define end_cstring_chars }}
180
181 extern /*@observer@*/ cstring cstring_advanceWhiteSpace (cstring) /*@*/ ;
182
183 extern bool cstring_containsLit (/*@unique@*/ cstring p_c, char *p_sub) /*@*/ ;
184 # define cstring_containsLit(c,sub) \
185   (cstring_contains (c, cstring_fromChars (sub)))
186
187 # else
188 # error "Multiple include"
189 # endif
190
191
192
This page took 0.487412 seconds and 5 git commands to generate.