]>
Commit | Line | Data |
---|---|---|
885824d3 | 1 | /* |
28bf4b0b | 2 | ** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2001. |
885824d3 | 3 | ** See ../LICENSE for license information. |
4 | ** | |
5 | */ | |
6 | /* | |
7 | ** misc.h | |
8 | ** | |
9 | ** (general.c) | |
10 | */ | |
11 | ||
12 | # ifndef MISC_H | |
13 | # define MISC_H | |
14 | ||
15 | # ifndef NOLCL | |
16 | # include "lclMisc.h" | |
17 | # endif | |
18 | ||
19 | extern void assertSet (/*@special@*/ /*@sef@*/ /*@unused@*/ void *p_x) | |
20 | /*@sets p_x, *p_x@*/ ; | |
21 | # define assertSet(x) ; | |
22 | ||
cd7d9b17 | 23 | extern void assertDefined (/*@sef@*/ /*@unused@*/ void *p_x) ; |
24 | # define assertDefined(x) ; | |
25 | ||
26 | ||
885824d3 | 27 | /*@-czechfcns@*/ |
86d93ed3 | 28 | extern int size_toInt (size_t p_x) /*@*/ /*@ensures result==p_x@*/; |
29 | extern long size_toLong (size_t p_x) /*@*/ /*@ensures result==p_x@*/ ; | |
30 | extern size_t size_fromInt (int p_x) /*@*/ /*@ensures result==p_x@*/ ; | |
31 | extern int longUnsigned_toInt (long unsigned int p_x) /*@*/ /*@ensures result==p_x@*/ ; | |
32 | extern int long_toInt (long p_x) /*@*/ /*@ensures result==p_x@*/; | |
33 | extern long unsigned longUnsigned_fromInt (int p_x) /*@*/ /*@ensures result==p_x@*/ ; | |
885824d3 | 34 | /*@=czechfcns@*/ |
35 | ||
36 | /* string functions */ | |
37 | ||
38 | typedef /*@concrete@*/ char *mstring; | |
39 | typedef /*@observer@*/ char *ob_mstring; | |
40 | typedef /*@observer@*/ /*@null@*/ char *bn_mstring; | |
41 | ||
42 | extern /*@unused@*/ /*@notnull@*/ /*@observer@*/ char * | |
43 | mstring_safePrint (/*@returned@*/ /*@null@*/ mstring p_s) /*@*/ ; | |
44 | extern char *mstring_spaces (int p_n) /*@*/ ; | |
45 | extern char *mstring_concat (const char *p_s1, const char *p_s2) /*@*/ ; | |
46 | extern char *mstring_concatFree (/*@only@*/ char *p_s1, /*@only@*/ char *p_s2) /*@modifies *p_s1, *p_s2*/ ; | |
47 | extern char *mstring_concatFree1 (/*@only@*/ char *p_s1, const char *p_s2); | |
48 | extern char *mstring_append (/*@only@*/ char *p_s1, char p_c); | |
86d93ed3 | 49 | extern char *mstring_copy (/*@null@*/ char *p_s1) /*@*/ /*@ensures maxRead(result) == maxRead(p_s1) /\ maxSet(result) == maxSet(p_s1) @*/ ; |
885824d3 | 50 | extern bool mstring_equalPrefix (const char *p_c1, const char *p_c2) /*@*/ ; |
51 | extern bool mstring_equal (/*@null@*/ const char *p_s1, /*@null@*/ const char *p_s2) /*@*/ ; | |
68de3f33 | 52 | extern bool mstring_containsChar (/*@unique@*/ const char *p_s, char p_c) /*@*/ ; |
53 | extern bool mstring_containsString (/*@unique@*/ const char *p_s, /*@unique@*/ const char *p_c) /*@*/ ; | |
885824d3 | 54 | |
55 | extern int mstring_length (/*@sef@*/ /*@null@*/ char *p_s) /*@*/ ; | |
56 | # define mstring_length(s) \ | |
57 | (((s) != NULL) ? size_toInt (strlen (s)) : 0) | |
58 | ||
0e41eb0e | 59 | extern /*@falsewhennull@*/ bool mstring_isDefined (/*@sef@*/ /*@null@*/ char *p_s) /*@*/ ; |
885824d3 | 60 | # define mstring_isDefined(s) ((s) != NULL) |
61 | ||
0e41eb0e | 62 | extern /*@nullwhentrue@*/ bool mstring_isEmpty (/*@sef@*/ /*@null@*/ char *p_s) /*@*/ ; |
885824d3 | 63 | # define mstring_isEmpty(s) (mstring_length(s) == 0) |
64 | ||
65 | extern void mstring_markFree (/*@owned@*/ char *p_s) /*@modifies *p_s;@*/ ; | |
66 | ||
86d93ed3 | 67 | extern /*@notnull@*/ /*@only@*/ char *mstring_create (int p_n) /*@*/ /*@ensures maxSet(result) == p_n /\ maxRead(result) == 0 @*/ ; |
885824d3 | 68 | extern /*@notnull@*/ /*@only@*/ char *mstring_createEmpty (void) /*@*/ ; |
69 | ||
70 | extern void mstring_free (/*@out@*/ /*@only@*/ /*@null@*/ char *p_s); | |
71 | # define mstring_free(s) sfree(s) | |
72 | ||
73 | # define mstring_createEmpty() mstring_create(0) | |
74 | ||
75 | extern int int_compare (/*@sef@*/ int p_x, /*@sef@*/ int p_y) /*@*/ ; | |
76 | # define int_compare(x,y) (((x) > (y)) ? 1 : (((x) < (y)) ? -1 : 0)) | |
77 | ||
78 | /*@-macroparams@*/ | |
79 | /*@-macrofcndecl@*/ /* works for lots of types */ | |
80 | # define generic_compare(x,y) (((x) > (y)) ? 1 : (((x) < (y)) ? -1 : 0)) | |
81 | /*@=macrofcndecl@*/ | |
82 | /*@=macroparams@*/ | |
83 | ||
84 | /*@notfunction@*/ | |
85 | # define GET(s) ((s *)smalloc(sizeof(s))) | |
86 | ||
28bf4b0b | 87 | /*@-czechfcns@*/ |
885824d3 | 88 | extern bool isHeaderFile (cstring) /*@*/ ; |
89 | ||
90 | extern void fputline (FILE *p_out, char *p_s) /*@modifies p_out@*/; | |
91 | ||
92 | extern int int_log (int p_x) /*@*/ ; | |
93 | ||
94 | extern char char_fromInt (int p_x) /*@*/ ; | |
95 | ||
28bf4b0b | 96 | extern /*@exposed@*/ cstring removePreDirs (cstring p_s); |
885824d3 | 97 | |
98 | /* These are defined by the bison library (?) */ | |
99 | extern /*@external@*/ int isatty (int); | |
100 | extern /*@external@*/ int yywrap (void); | |
28bf4b0b | 101 | /*@=czechfcns@*/ |
885824d3 | 102 | |
103 | # else | |
104 | # error "Multiple include" | |
105 | # endif | |
28bf4b0b | 106 | |
107 | ||
108 | ||
109 | ||
110 |