]>
Commit | Line | Data |
---|---|---|
885824d3 | 1 | /* |
2 | ** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2000. | |
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 | ||
23 | extern bool isLCLfile (cstring p_s) /*@*/ ; | |
24 | extern bool isCext(char *p_ext) /*@*/ ; | |
25 | extern char *addExtension(char *p_s, const char *p_suffix); | |
26 | ||
27 | extern char *removeExtension (char *p_s, const char *p_suffix) /*@*/ ; | |
28 | ||
29 | # ifndef NOLCL | |
30 | extern char *removePath (char *p_s) /*@*/ ; | |
31 | # endif | |
32 | ||
33 | extern char *removePathFree (/*@only@*/ char *p_s) /*@*/ ; | |
34 | extern char *removeAnyExtension (char *p_s) /*@*/ ; | |
35 | ||
36 | extern int getInt (char **p_s) /*@modifies *p_s@*/ ; | |
37 | extern char loadChar (char **p_s) /*@modifies *p_s@*/ ; | |
38 | extern double getDouble (char **p_s) /*@modifies *p_s@*/ ; | |
39 | extern void docheckChar (char ** p_s, char p_c, char *p_file, int p_line) | |
40 | /*@modifies *p_s;@*/; | |
41 | ||
42 | extern bool optCheckChar (char **p_s, char p_c) /*@modifies *p_s;@*/ ; | |
43 | extern void checkChar (char **p_s, char p_c) /*@modifies *p_s;@*/ ; | |
44 | # define checkChar(s,c) (docheckChar (s, c, __FILE__, __LINE__)) | |
45 | extern /*@only@*/ /*@null@*/ char *getWord (char **p_s) /*@modifies *p_s@*/ ; | |
46 | extern cstring getStringWord (char **p_s) /*@modifies *p_s@*/ ; | |
47 | ||
48 | /*@-czechfcns@*/ | |
49 | extern int size_toInt (size_t p_x) /*@*/ ; | |
50 | extern long size_toLong (size_t p_x) /*@*/ ; | |
51 | extern size_t size_fromInt (int p_x) /*@*/ ; | |
52 | extern int longUnsigned_toInt (long unsigned int p_x) /*@*/ ; | |
53 | extern int long_toInt (long p_x) /*@*/ ; | |
54 | extern long unsigned longUnsigned_fromInt (int p_x) /*@*/ ; | |
55 | /*@=czechfcns@*/ | |
56 | ||
57 | /* string functions */ | |
58 | ||
59 | typedef /*@concrete@*/ char *mstring; | |
60 | typedef /*@observer@*/ char *ob_mstring; | |
61 | typedef /*@observer@*/ /*@null@*/ char *bn_mstring; | |
62 | ||
63 | extern /*@unused@*/ /*@notnull@*/ /*@observer@*/ char * | |
64 | mstring_safePrint (/*@returned@*/ /*@null@*/ mstring p_s) /*@*/ ; | |
65 | extern char *mstring_spaces (int p_n) /*@*/ ; | |
66 | extern char *mstring_concat (const char *p_s1, const char *p_s2) /*@*/ ; | |
67 | extern char *mstring_concatFree (/*@only@*/ char *p_s1, /*@only@*/ char *p_s2) /*@modifies *p_s1, *p_s2*/ ; | |
68 | extern char *mstring_concatFree1 (/*@only@*/ char *p_s1, const char *p_s2); | |
69 | extern char *mstring_append (/*@only@*/ char *p_s1, char p_c); | |
70 | extern char *mstring_copy (/*@null@*/ char *p_s1) /*@*/ ; | |
71 | extern bool mstring_equalPrefix (const char *p_c1, const char *p_c2) /*@*/ ; | |
72 | extern bool mstring_equal (/*@null@*/ const char *p_s1, /*@null@*/ const char *p_s2) /*@*/ ; | |
73 | ||
74 | extern int mstring_length (/*@sef@*/ /*@null@*/ char *p_s) /*@*/ ; | |
75 | # define mstring_length(s) \ | |
76 | (((s) != NULL) ? size_toInt (strlen (s)) : 0) | |
77 | ||
78 | extern /*@falsenull@*/ bool mstring_isDefined (/*@sef@*/ /*@null@*/ char *p_s) /*@*/ ; | |
79 | # define mstring_isDefined(s) ((s) != NULL) | |
80 | ||
81 | extern /*@truenull@*/ bool mstring_isEmpty (/*@sef@*/ /*@null@*/ char *p_s) /*@*/ ; | |
82 | # define mstring_isEmpty(s) (mstring_length(s) == 0) | |
83 | ||
84 | extern void mstring_markFree (/*@owned@*/ char *p_s) /*@modifies *p_s;@*/ ; | |
85 | ||
86 | extern /*@notnull@*/ /*@only@*/ char *mstring_create (int p_n) /*@*/ ; | |
87 | extern /*@notnull@*/ /*@only@*/ char *mstring_createEmpty (void) /*@*/ ; | |
88 | ||
89 | extern void mstring_free (/*@out@*/ /*@only@*/ /*@null@*/ char *p_s); | |
90 | # define mstring_free(s) sfree(s) | |
91 | ||
92 | # define mstring_createEmpty() mstring_create(0) | |
93 | ||
94 | extern int int_compare (/*@sef@*/ int p_x, /*@sef@*/ int p_y) /*@*/ ; | |
95 | # define int_compare(x,y) (((x) > (y)) ? 1 : (((x) < (y)) ? -1 : 0)) | |
96 | ||
97 | /*@-macroparams@*/ | |
98 | /*@-macrofcndecl@*/ /* works for lots of types */ | |
99 | # define generic_compare(x,y) (((x) > (y)) ? 1 : (((x) < (y)) ? -1 : 0)) | |
100 | /*@=macrofcndecl@*/ | |
101 | /*@=macroparams@*/ | |
102 | ||
103 | /*@notfunction@*/ | |
104 | # define GET(s) ((s *)smalloc(sizeof(s))) | |
105 | ||
106 | extern bool isHeaderFile (cstring) /*@*/ ; | |
107 | ||
108 | extern void fputline (FILE *p_out, char *p_s) /*@modifies p_out@*/; | |
109 | ||
110 | extern int int_log (int p_x) /*@*/ ; | |
111 | ||
112 | extern char char_fromInt (int p_x) /*@*/ ; | |
113 | ||
114 | extern /*@observer@*/ /*@null@*/ char * | |
115 | filenameExtension (/*@returned@*/ char *p_s) /*@*/ ; | |
116 | ||
117 | extern /*@exposed@*/ char *removePreDirs (char *p_s); | |
118 | extern void checkUngetc (int p_c, FILE *p_f) /*@modifies *p_f@*/ ; | |
119 | ||
120 | /* These are defined by the bison library (?) */ | |
121 | extern /*@external@*/ int isatty (int); | |
122 | extern /*@external@*/ int yywrap (void); | |
123 | ||
124 | # else | |
125 | # error "Multiple include" | |
126 | # endif |