]> andersk Git - splint.git/blame - src/Headers/misc.h
Initial revision
[splint.git] / src / Headers / misc.h
CommitLineData
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
19extern void assertSet (/*@special@*/ /*@sef@*/ /*@unused@*/ void *p_x)
20 /*@sets p_x, *p_x@*/ ;
21# define assertSet(x) ;
22
23extern bool isLCLfile (cstring p_s) /*@*/ ;
24extern bool isCext(char *p_ext) /*@*/ ;
25extern char *addExtension(char *p_s, const char *p_suffix);
26
27extern char *removeExtension (char *p_s, const char *p_suffix) /*@*/ ;
28
29# ifndef NOLCL
30extern char *removePath (char *p_s) /*@*/ ;
31# endif
32
33extern char *removePathFree (/*@only@*/ char *p_s) /*@*/ ;
34extern char *removeAnyExtension (char *p_s) /*@*/ ;
35
36extern int getInt (char **p_s) /*@modifies *p_s@*/ ;
37extern char loadChar (char **p_s) /*@modifies *p_s@*/ ;
38extern double getDouble (char **p_s) /*@modifies *p_s@*/ ;
39extern void docheckChar (char ** p_s, char p_c, char *p_file, int p_line)
40 /*@modifies *p_s;@*/;
41
42extern bool optCheckChar (char **p_s, char p_c) /*@modifies *p_s;@*/ ;
43extern void checkChar (char **p_s, char p_c) /*@modifies *p_s;@*/ ;
44# define checkChar(s,c) (docheckChar (s, c, __FILE__, __LINE__))
45extern /*@only@*/ /*@null@*/ char *getWord (char **p_s) /*@modifies *p_s@*/ ;
46extern cstring getStringWord (char **p_s) /*@modifies *p_s@*/ ;
47
48/*@-czechfcns@*/
49extern int size_toInt (size_t p_x) /*@*/ ;
50extern long size_toLong (size_t p_x) /*@*/ ;
51extern size_t size_fromInt (int p_x) /*@*/ ;
52extern int longUnsigned_toInt (long unsigned int p_x) /*@*/ ;
53extern int long_toInt (long p_x) /*@*/ ;
54extern long unsigned longUnsigned_fromInt (int p_x) /*@*/ ;
55/*@=czechfcns@*/
56
57/* string functions */
58
59typedef /*@concrete@*/ char *mstring;
60typedef /*@observer@*/ char *ob_mstring;
61typedef /*@observer@*/ /*@null@*/ char *bn_mstring;
62
63extern /*@unused@*/ /*@notnull@*/ /*@observer@*/ char *
64 mstring_safePrint (/*@returned@*/ /*@null@*/ mstring p_s) /*@*/ ;
65extern char *mstring_spaces (int p_n) /*@*/ ;
66extern char *mstring_concat (const char *p_s1, const char *p_s2) /*@*/ ;
67extern char *mstring_concatFree (/*@only@*/ char *p_s1, /*@only@*/ char *p_s2) /*@modifies *p_s1, *p_s2*/ ;
68extern char *mstring_concatFree1 (/*@only@*/ char *p_s1, const char *p_s2);
69extern char *mstring_append (/*@only@*/ char *p_s1, char p_c);
70extern char *mstring_copy (/*@null@*/ char *p_s1) /*@*/ ;
71extern bool mstring_equalPrefix (const char *p_c1, const char *p_c2) /*@*/ ;
72extern bool mstring_equal (/*@null@*/ const char *p_s1, /*@null@*/ const char *p_s2) /*@*/ ;
73
74extern int mstring_length (/*@sef@*/ /*@null@*/ char *p_s) /*@*/ ;
75# define mstring_length(s) \
76 (((s) != NULL) ? size_toInt (strlen (s)) : 0)
77
78extern /*@falsenull@*/ bool mstring_isDefined (/*@sef@*/ /*@null@*/ char *p_s) /*@*/ ;
79# define mstring_isDefined(s) ((s) != NULL)
80
81extern /*@truenull@*/ bool mstring_isEmpty (/*@sef@*/ /*@null@*/ char *p_s) /*@*/ ;
82# define mstring_isEmpty(s) (mstring_length(s) == 0)
83
84extern void mstring_markFree (/*@owned@*/ char *p_s) /*@modifies *p_s;@*/ ;
85
86extern /*@notnull@*/ /*@only@*/ char *mstring_create (int p_n) /*@*/ ;
87extern /*@notnull@*/ /*@only@*/ char *mstring_createEmpty (void) /*@*/ ;
88
89extern 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
94extern 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
106extern bool isHeaderFile (cstring) /*@*/ ;
107
108extern void fputline (FILE *p_out, char *p_s) /*@modifies p_out@*/;
109
110extern int int_log (int p_x) /*@*/ ;
111
112extern char char_fromInt (int p_x) /*@*/ ;
113
114extern /*@observer@*/ /*@null@*/ char *
115 filenameExtension (/*@returned@*/ char *p_s) /*@*/ ;
116
117extern /*@exposed@*/ char *removePreDirs (char *p_s);
118extern void checkUngetc (int p_c, FILE *p_f) /*@modifies *p_f@*/ ;
119
120/* These are defined by the bison library (?) */
121extern /*@external@*/ int isatty (int);
122extern /*@external@*/ int yywrap (void);
123
124# else
125# error "Multiple include"
126# endif
This page took 0.072719 seconds and 5 git commands to generate.