PageRenderTime 24ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/util.h

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
C++ Header | 133 lines | 71 code | 44 blank | 18 comment | 0 complexity | 9f472afbceaf4da928185db77a52ed5a MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. /*
  2. util.h - general purpose utility routines
  3. Copyright (C) 2007, 2008 siliconforks.com
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #ifndef UTIL_H_
  17. #define UTIL_H_
  18. #ifndef HAVE_VASPRINTF
  19. #include <stdarg.h>
  20. #endif
  21. #include <stdbool.h>
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <sys/stat.h>
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. extern const char * program;
  29. void fatal(const char * format, ...)
  30. __attribute__((__noreturn__))
  31. __attribute__((__format__(printf, 1, 2)));
  32. void fatal_command_line(const char * format, ...)
  33. __attribute__((__noreturn__))
  34. __attribute__((__format__(printf, 1, 2)));
  35. void fatal_source(const char * source_file, unsigned int line_number, const char * format, ...)
  36. __attribute__((__noreturn__))
  37. __attribute__((__format__(printf, 3, 4)));
  38. void warn_source(const char * source_file, unsigned int line_number, const char * format, ...)
  39. __attribute__((__format__(printf, 3, 4)));
  40. void version(void)
  41. __attribute__((__noreturn__));
  42. size_t addst(size_t x, size_t y);
  43. size_t mulst(size_t x, size_t y);
  44. void * xmalloc(size_t size);
  45. #define xnew(type, count) ((type *) xmalloc(mulst((count), sizeof(type))))
  46. void * xrealloc(void * p, size_t size);
  47. char * xstrdup(const char * s);
  48. char * xstrndup(const char * s, size_t size);
  49. int xasprintf(char ** s, const char * format, ...) __attribute__((__format__(printf, 2, 3)));
  50. char * xgetcwd(void);
  51. FILE * xfopen(const char * file, const char * mode);
  52. void xstat(const char * file, struct stat * buf);
  53. void xlstat(const char * file, struct stat * buf);
  54. void xmkdir(const char * directory);
  55. void mkdir_if_necessary(const char * directory);
  56. void mkdirs(const char * path);
  57. bool str_starts_with(const char * string, const char * prefix);
  58. bool str_ends_with(const char * string, const char * suffix);
  59. char * make_path(const char * parent, const char * relative_path);
  60. char * make_canonical_path(const char * relative_path);
  61. char * make_basename(const char * path);
  62. char * make_dirname(const char * path);
  63. int is_same_file(const char * file1, const char * file2);
  64. int contains_file(const char * file1, const char * file2);
  65. void copy_stream(FILE * source, FILE * destination);
  66. void copy_file(const char * source_file, const char * destination_file);
  67. bool directory_is_empty(const char * directory);
  68. struct DirListEntry {
  69. char * name;
  70. struct DirListEntry * next;
  71. };
  72. struct DirListEntry * make_recursive_dir_list(const char * directory);
  73. void free_dir_list(struct DirListEntry * list);
  74. #ifndef HAVE_STRNDUP
  75. char * strndup(const char * s, size_t size);
  76. #endif
  77. #ifndef HAVE_VASPRINTF
  78. int vasprintf(char ** s, const char * format, va_list a);
  79. #endif
  80. #ifndef HAVE_ASPRINTF
  81. int asprintf(char ** s, const char * format, ...) __attribute__((__format__(printf, 2, 3)));
  82. #endif
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif /* UTIL_H_ */