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

Contents of /trunk/util.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations)
Wed Aug 1 13:51:53 2007 UTC (15 years, 10 months ago) by siliconforks
File MIME type: text/plain
File size: 2167 byte(s)
Initial import.

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

  ViewVC Help
Powered by ViewVC 1.1.24