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

Diff of /trunk/util.h

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

revision 2 by siliconforks, Wed Aug 1 13:51:53 2007 UTC revision 106 by siliconforks, Sat May 31 07:37:39 2008 UTC
# Line 1  Line 1 
1  /*  /*
2      util.h - general purpose utility routines      util.h - general purpose utility routines
3      Copyright (C) 2007 siliconforks.com      Copyright (C) 2007, 2008 siliconforks.com
4    
5      This program is free software; you can redistribute it and/or modify      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      it under the terms of the GNU General Public License as published by
# 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    size_t addst(size_t x, size_t y);
39    
40    size_t mulst(size_t x, size_t y);
41    
42  void * xmalloc(size_t size);  void * xmalloc(size_t size);
43    
44    #define xnew(type, count) ((type *) xmalloc(mulst((count), sizeof(type))))
45    
46  void * xrealloc(void * p, size_t size);  void * xrealloc(void * p, size_t size);
47    
48  char * xstrdup(const char * s);  char * xstrdup(const char * s);
49    
50    char * xstrndup(const char * s, size_t size);
51    
52    int xasprintf(char ** s, const char * template, ...) __attribute__((__format__(printf, 2, 3)));
53    
54  char * xgetcwd(void);  char * xgetcwd(void);
55    
56  FILE * xfopen(const char * file, const char * mode);  FILE * xfopen(const char * file, const char * mode);
# Line 51  Line 65 
65    
66  void mkdirs(const char * path);  void mkdirs(const char * path);
67    
68    bool str_starts_with(const char * string, const char * prefix);
69    
70    bool str_ends_with(const char * string, const char * suffix);
71    
72  char * make_path(const char * parent, const char * relative_path);  char * make_path(const char * parent, const char * relative_path);
73    
74  char * make_canonical_path(const char * relative_path);  char * make_canonical_path(const char * relative_path);
# Line 67  Line 85 
85    
86  void copy_file(const char * source_file, const char * destination_file);  void copy_file(const char * source_file, const char * destination_file);
87    
88  int directory_is_empty(const char * directory);  bool directory_is_empty(const char * directory);
89    
90  struct DirListEntry {  struct DirListEntry {
91    char * name;    char * name;
# Line 78  Line 96 
96    
97  void free_dir_list(struct DirListEntry * list);  void free_dir_list(struct DirListEntry * list);
98    
99    #ifndef HAVE_CLOSESOCKET
100    int closesocket(int s);
101    #endif
102    
103    #ifndef HAVE_VASPRINTF
104    int vasprintf(char ** s, const char * template, va_list a);
105    #endif
106    
107    #ifndef HAVE_ASPRINTF
108    int asprintf(char ** s, const char * template, ...) __attribute__((__format__(printf, 2, 3)));
109    #endif
110    
111  #endif  #endif

Legend:
Removed from v.2  
changed lines
  Added in v.106

  ViewVC Help
Powered by ViewVC 1.1.24