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

Diff of /trunk/util.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 99 by siliconforks, Wed May 14 00:01:21 2008 UTC revision 370 by siliconforks, Mon Oct 27 20:34:27 2008 UTC
# Line 20  Line 20 
20  #ifndef UTIL_H_  #ifndef UTIL_H_
21  #define UTIL_H_  #define UTIL_H_
22    
 #include <config.h>  
   
23  #ifndef HAVE_VASPRINTF  #ifndef HAVE_VASPRINTF
24  #include <stdarg.h>  #include <stdarg.h>
25  #endif  #endif
26    #include <stdbool.h>
27  #include <stdio.h>  #include <stdio.h>
28  #include <stdlib.h>  #include <stdlib.h>
29    
# Line 36  Line 35 
35    __attribute__((__noreturn__))    __attribute__((__noreturn__))
36    __attribute__((__format__(printf, 1, 2)));    __attribute__((__format__(printf, 1, 2)));
37    
38    void fatal_command_line(const char * format, ...)
39      __attribute__((__noreturn__))
40      __attribute__((__format__(printf, 1, 2)));
41    
42    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    void version(void)
47      __attribute__((__noreturn__));
48    
49    size_t addst(size_t x, size_t y);
50    
51    size_t mulst(size_t x, size_t y);
52    
53  void * xmalloc(size_t size);  void * xmalloc(size_t size);
54    
55    #define xnew(type, count) ((type *) xmalloc(mulst((count), sizeof(type))))
56    
57  void * xrealloc(void * p, size_t size);  void * xrealloc(void * p, size_t size);
58    
59  char * xstrdup(const char * s);  char * xstrdup(const char * s);
60    
61    char * xstrndup(const char * s, size_t size);
62    
63    int xasprintf(char ** s, const char * template, ...) __attribute__((__format__(printf, 2, 3)));
64    
65  char * xgetcwd(void);  char * xgetcwd(void);
66    
67  FILE * xfopen(const char * file, const char * mode);  FILE * xfopen(const char * file, const char * mode);
# Line 56  Line 76 
76    
77  void mkdirs(const char * path);  void mkdirs(const char * path);
78    
79    bool str_starts_with(const char * string, const char * prefix);
80    
81    bool str_ends_with(const char * string, const char * suffix);
82    
83  char * make_path(const char * parent, const char * relative_path);  char * make_path(const char * parent, const char * relative_path);
84    
85  char * make_canonical_path(const char * relative_path);  char * make_canonical_path(const char * relative_path);
# Line 72  Line 96 
96    
97  void copy_file(const char * source_file, const char * destination_file);  void copy_file(const char * source_file, const char * destination_file);
98    
99  int directory_is_empty(const char * directory);  bool directory_is_empty(const char * directory);
100    
101  struct DirListEntry {  struct DirListEntry {
102    char * name;    char * name;
# Line 83  Line 107 
107    
108  void free_dir_list(struct DirListEntry * list);  void free_dir_list(struct DirListEntry * list);
109    
110    #ifndef HAVE_STRNDUP
111    char * strndup(const char * s, size_t size);
112    #endif
113    
114  #ifndef HAVE_VASPRINTF  #ifndef HAVE_VASPRINTF
115  int vasprintf(char ** s, const char * template, va_list a);  int vasprintf(char ** s, const char * template, va_list a);
116  #endif  #endif
117    
118  #ifndef HAVE_ASPRINTF  #ifndef HAVE_ASPRINTF
119  int asprintf(char ** s, const char * template, ...)  int asprintf(char ** s, const char * template, ...) __attribute__((__format__(printf, 2, 3)));
   __attribute__((__format__(printf, 2, 3)));  
120  #endif  #endif
121    
122  #endif  #endif

Legend:
Removed from v.99  
changed lines
  Added in v.370

  ViewVC Help
Powered by ViewVC 1.1.24