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

Diff of /trunk/util.h

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

revision 87 by siliconforks, Mon May 5 20:05:27 2008 UTC revision 372 by siliconforks, Mon Oct 27 20:36:23 2008 UTC
# Line 20  Line 20 
20  #ifndef UTIL_H_  #ifndef UTIL_H_
21  #define UTIL_H_  #define UTIL_H_
22    
23    #ifndef HAVE_VASPRINTF
24    #include <stdarg.h>
25    #endif
26    #include <stdbool.h>
27  #include <stdio.h>  #include <stdio.h>
28  #include <stdlib.h>  #include <stdlib.h>
29    
# Line 31  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 warn_source(const char * source_file, unsigned int line_number, const char * format, ...)
47      __attribute__((__format__(printf, 3, 4)));
48    
49    void version(void)
50      __attribute__((__noreturn__));
51    
52    size_t addst(size_t x, size_t y);
53    
54    size_t mulst(size_t x, size_t y);
55    
56  void * xmalloc(size_t size);  void * xmalloc(size_t size);
57    
58    #define xnew(type, count) ((type *) xmalloc(mulst((count), sizeof(type))))
59    
60  void * xrealloc(void * p, size_t size);  void * xrealloc(void * p, size_t size);
61    
62  char * xstrdup(const char * s);  char * xstrdup(const char * s);
63    
64    char * xstrndup(const char * s, size_t size);
65    
66    int xasprintf(char ** s, const char * template, ...) __attribute__((__format__(printf, 2, 3)));
67    
68  char * xgetcwd(void);  char * xgetcwd(void);
69    
70  FILE * xfopen(const char * file, const char * mode);  FILE * xfopen(const char * file, const char * mode);
# Line 51  Line 79 
79    
80  void mkdirs(const char * path);  void mkdirs(const char * path);
81    
82    bool str_starts_with(const char * string, const char * prefix);
83    
84    bool str_ends_with(const char * string, const char * suffix);
85    
86  char * make_path(const char * parent, const char * relative_path);  char * make_path(const char * parent, const char * relative_path);
87    
88  char * make_canonical_path(const char * relative_path);  char * make_canonical_path(const char * relative_path);
# Line 67  Line 99 
99    
100  void copy_file(const char * source_file, const char * destination_file);  void copy_file(const char * source_file, const char * destination_file);
101    
102  int directory_is_empty(const char * directory);  bool directory_is_empty(const char * directory);
103    
104  struct DirListEntry {  struct DirListEntry {
105    char * name;    char * name;
# Line 78  Line 110 
110    
111  void free_dir_list(struct DirListEntry * list);  void free_dir_list(struct DirListEntry * list);
112    
113    #ifndef HAVE_STRNDUP
114    char * strndup(const char * s, size_t size);
115    #endif
116    
117    #ifndef HAVE_VASPRINTF
118    int vasprintf(char ** s, const char * template, va_list a);
119    #endif
120    
121    #ifndef HAVE_ASPRINTF
122    int asprintf(char ** s, const char * template, ...) __attribute__((__format__(printf, 2, 3)));
123    #endif
124    
125  #endif  #endif

Legend:
Removed from v.87  
changed lines
  Added in v.372

  ViewVC Help
Powered by ViewVC 1.1.24