util.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. #ifndef BASE_UTIL_H
  13. #define BASE_UTIL_H
  14. #ifndef NOINTNSAPI
  15. #define INTNSAPI
  16. #endif /* !NOINTNSAPI */
  17. /*
  18. * util.h: A hodge podge of utility functions and standard functions which
  19. * are unavailable on certain systems
  20. *
  21. * Rob McCool
  22. */
  23. #ifndef PUBLIC_NSAPI_H
  24. #include "public/nsapi.h"
  25. #endif /* !PUBLIC_NSAPI_H */
  26. /* --- Begin common function prototypes --- */
  27. #ifdef INTNSAPI
  28. NSPR_BEGIN_EXTERN_C
  29. NSAPI_PUBLIC char *INTutil_hostname(void);
  30. NSAPI_PUBLIC int INTutil_itoa(int i, char *a);
  31. NSAPI_PUBLIC
  32. int INTutil_vsprintf(char *s, register const char *fmt, va_list args);
  33. NSAPI_PUBLIC int INTutil_sprintf(char *s, const char *fmt, ...)
  34. #ifdef __GNUC__
  35. __attribute__ ((format (printf, 2, 3)));
  36. #else
  37. ;
  38. #endif
  39. NSAPI_PUBLIC int INTutil_vsnprintf(char *s, int n, register const char *fmt,
  40. va_list args);
  41. NSAPI_PUBLIC int INTutil_snprintf(char *s, int n, const char *fmt, ...)
  42. #ifdef __GNUC__
  43. __attribute__ ((format (printf, 3, 4)));
  44. #else
  45. ;
  46. #endif
  47. NSAPI_PUBLIC int INTutil_strftime(char *s, const char *format, const struct tm *t);
  48. NSAPI_PUBLIC struct tm *INTutil_localtime(const time_t *clock, struct tm *res);
  49. #ifdef NEED_STRCASECMP
  50. NSAPI_PUBLIC int INTutil_strcasecmp(CASECMPARG_T char *one, CASECMPARG_T char *two);
  51. #endif /* NEED_STRCASECMP */
  52. #ifdef NEED_STRNCASECMP
  53. NSAPI_PUBLIC int INTutil_strncasecmp(CASECMPARG_T char *one, CASECMPARG_T char *two, int n);
  54. #endif /* NEED_STRNCASECMP */
  55. /* --- End common function prototypes --- */
  56. NSPR_END_EXTERN_C
  57. #define util_hostname INTutil_hostname
  58. #define util_itoa INTutil_itoa
  59. #define util_vsprintf INTutil_vsprintf
  60. #define util_sprintf INTutil_sprintf
  61. #define util_vsnprintf INTutil_vsnprintf
  62. #define util_snprintf INTutil_snprintf
  63. #define util_strftime INTutil_strftime
  64. #define util_strcasecmp INTutil_strcasecmp
  65. #define util_strncasecmp INTutil_strncasecmp
  66. #define util_localtime INTutil_localtime
  67. #ifdef NEED_STRINGS_H /* usually for strcasecmp */
  68. #include <strings.h>
  69. #endif
  70. #endif /* INTNSAPI */
  71. #endif /* !BASE_UTIL_H */