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

Annotation of /trunk/util.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 99 - (hide annotations)
Wed May 14 00:01:21 2008 UTC (11 years, 5 months ago) by siliconforks
File MIME type: text/plain
File size: 2462 byte(s)
Add replacement `asprintf' for Windows.

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 #include <config.h>
24    
25     #ifndef HAVE_VASPRINTF
26     #include <stdarg.h>
27     #endif
28 siliconforks 2 #include <stdio.h>
29     #include <stdlib.h>
30    
31     #include <sys/stat.h>
32    
33     extern const char * program;
34    
35     void fatal(const char * format, ...)
36     __attribute__((__noreturn__))
37     __attribute__((__format__(printf, 1, 2)));
38    
39     void * xmalloc(size_t size);
40    
41     void * xrealloc(void * p, size_t size);
42    
43     char * xstrdup(const char * s);
44    
45     char * xgetcwd(void);
46    
47     FILE * xfopen(const char * file, const char * mode);
48    
49     void xstat(const char * file, struct stat * buf);
50    
51     void xlstat(const char * file, struct stat * buf);
52    
53     void xmkdir(const char * directory);
54    
55     void mkdir_if_necessary(const char * directory);
56    
57     void mkdirs(const char * path);
58    
59     char * make_path(const char * parent, const char * relative_path);
60    
61     char * make_canonical_path(const char * relative_path);
62    
63     char * make_basename(const char * path);
64    
65     char * make_dirname(const char * path);
66    
67     int is_same_file(const char * file1, const char * file2);
68    
69     int contains_file(const char * file1, const char * file2);
70    
71     void copy_stream(FILE * source, FILE * destination);
72    
73     void copy_file(const char * source_file, const char * destination_file);
74    
75     int directory_is_empty(const char * directory);
76    
77     struct DirListEntry {
78     char * name;
79     struct DirListEntry * next;
80     };
81    
82     struct DirListEntry * make_recursive_dir_list(const char * directory);
83    
84     void free_dir_list(struct DirListEntry * list);
85    
86 siliconforks 99 #ifndef HAVE_VASPRINTF
87     int vasprintf(char ** s, const char * template, va_list a);
88 siliconforks 2 #endif
89 siliconforks 99
90     #ifndef HAVE_ASPRINTF
91     int asprintf(char ** s, const char * template, ...)
92     __attribute__((__format__(printf, 2, 3)));
93     #endif
94    
95     #endif

  ViewVC Help
Powered by ViewVC 1.1.24