/[jscoverage]/trunk/util.h
ViewVC logotype

Annotation of /trunk/util.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 397 - (hide annotations)
Tue Dec 9 03:23:52 2008 UTC (10 years, 5 months ago) by siliconforks
File MIME type: text/plain
File size: 3463 byte(s)
Add comment.

1 siliconforks 2 /*
2     util.h - general purpose utility routines
3 siliconforks 87 Copyright (C) 2007, 2008 siliconforks.com
4 siliconforks 2
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9    
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13     GNU General Public License for more details.
14    
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18     */
19    
20     #ifndef UTIL_H_
21     #define UTIL_H_
22    
23 siliconforks 99 #ifndef HAVE_VASPRINTF
24     #include <stdarg.h>
25     #endif
26 siliconforks 106 #include <stdbool.h>
27 siliconforks 2 #include <stdio.h>
28     #include <stdlib.h>
29    
30     #include <sys/stat.h>
31    
32     extern const char * program;
33    
34     void fatal(const char * format, ...)
35     __attribute__((__noreturn__))
36     __attribute__((__format__(printf, 1, 2)));
37    
38 siliconforks 191 void fatal_command_line(const char * format, ...)
39     __attribute__((__noreturn__))
40     __attribute__((__format__(printf, 1, 2)));
41    
42 siliconforks 370 void fatal_source(const char * source_file, unsigned int line_number, const char * format, ...)
43     __attribute__((__noreturn__))
44     __attribute__((__format__(printf, 3, 4)));
45    
46 siliconforks 372 void warn_source(const char * source_file, unsigned int line_number, const char * format, ...)
47     __attribute__((__format__(printf, 3, 4)));
48    
49 siliconforks 311 void version(void)
50     __attribute__((__noreturn__));
51    
52 siliconforks 106 size_t addst(size_t x, size_t y);
53    
54     size_t mulst(size_t x, size_t y);
55    
56 siliconforks 2 void * xmalloc(size_t size);
57    
58 siliconforks 106 #define xnew(type, count) ((type *) xmalloc(mulst((count), sizeof(type))))
59    
60 siliconforks 2 void * xrealloc(void * p, size_t size);
61    
62     char * xstrdup(const char * s);
63    
64 siliconforks 106 char * xstrndup(const char * s, size_t size);
65    
66     int xasprintf(char ** s, const char * template, ...) __attribute__((__format__(printf, 2, 3)));
67    
68 siliconforks 2 char * xgetcwd(void);
69    
70     FILE * xfopen(const char * file, const char * mode);
71    
72     void xstat(const char * file, struct stat * buf);
73    
74     void xlstat(const char * file, struct stat * buf);
75    
76     void xmkdir(const char * directory);
77    
78     void mkdir_if_necessary(const char * directory);
79    
80     void mkdirs(const char * path);
81    
82 siliconforks 106 bool str_starts_with(const char * string, const char * prefix);
83    
84     bool str_ends_with(const char * string, const char * suffix);
85    
86 siliconforks 2 char * make_path(const char * parent, const char * relative_path);
87    
88     char * make_canonical_path(const char * relative_path);
89    
90     char * make_basename(const char * path);
91    
92     char * make_dirname(const char * path);
93    
94     int is_same_file(const char * file1, const char * file2);
95    
96     int contains_file(const char * file1, const char * file2);
97    
98     void copy_stream(FILE * source, FILE * destination);
99    
100     void copy_file(const char * source_file, const char * destination_file);
101    
102 siliconforks 106 bool directory_is_empty(const char * directory);
103 siliconforks 2
104     struct DirListEntry {
105     char * name;
106     struct DirListEntry * next;
107     };
108    
109     struct DirListEntry * make_recursive_dir_list(const char * directory);
110    
111     void free_dir_list(struct DirListEntry * list);
112    
113 siliconforks 125 #ifndef HAVE_STRNDUP
114     char * strndup(const char * s, size_t size);
115 siliconforks 106 #endif
116    
117 siliconforks 99 #ifndef HAVE_VASPRINTF
118     int vasprintf(char ** s, const char * template, va_list a);
119 siliconforks 2 #endif
120 siliconforks 99
121     #ifndef HAVE_ASPRINTF
122 siliconforks 106 int asprintf(char ** s, const char * template, ...) __attribute__((__format__(printf, 2, 3)));
123 siliconforks 99 #endif
124    
125 siliconforks 397 #endif /* UTIL_H_ */

  ViewVC Help
Powered by ViewVC 1.1.24