/contrib/groff/src/include/lib.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 170 lines · 99 code · 36 blank · 35 comment · 6 complexity · d7292de621aa42f1ac9f1611d98574d1 MD5 · raw file

  1. // -*- C++ -*-
  2. /* Copyright (C) 1989-2000, 2001, 2002, 2003, 2005
  3. Free Software Foundation, Inc.
  4. Written by James Clark (jjc@jclark.com)
  5. This file is part of groff.
  6. groff is free software; you can redistribute it and/or modify it under
  7. the terms of the GNU General Public License as published by the Free
  8. Software Foundation; either version 2, or (at your option) any later
  9. version.
  10. groff is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. for more details.
  14. You should have received a copy of the GNU General Public License along
  15. with groff; see the file COPYING. If not, write to the Free Software
  16. Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
  17. #ifdef HAVE_CONFIG_H
  18. #include <config.h>
  19. #endif
  20. extern "C" {
  21. #ifndef HAVE_STRERROR
  22. char *strerror(int);
  23. #endif
  24. const char *i_to_a(int);
  25. const char *ui_to_a(unsigned int);
  26. const char *if_to_a(int, int);
  27. }
  28. #define __GETOPT_PREFIX groff_
  29. #include <getopt.h>
  30. #ifdef HAVE_SETLOCALE
  31. #include <locale.h>
  32. #else
  33. #define setlocale(category, locale) do {} while(0)
  34. #endif
  35. char *strsave(const char *s);
  36. int is_prime(unsigned);
  37. double groff_hypot(double, double);
  38. #include <stdio.h>
  39. #include <string.h>
  40. #ifdef HAVE_STRINGS_H
  41. #include <strings.h>
  42. #endif
  43. #include <stdarg.h>
  44. /* HP-UX 10.20 and LynxOS 4.0.0 don't declare snprintf() */
  45. #if !defined(HAVE_SNPRINTF) || defined(NEED_DECLARATION_SNPRINTF)
  46. extern "C" { int snprintf(char *, size_t, const char *, /*args*/ ...); }
  47. #endif
  48. /* LynxOS 4.0.0 has snprintf() but no vsnprintf() */
  49. #if !defined(HAVE_VSNPRINTF) || defined(NEED_DECLARATION_VSNPRINTF)
  50. extern "C" { int vsnprintf(char *, size_t, const char *, va_list); }
  51. #endif
  52. /* LynxOS 4.0.0 doesn't declare vfprintf() */
  53. #ifdef NEED_DECLARATION_VFPRINTF
  54. extern "C" { int vfprintf(FILE *, const char *, va_list); }
  55. #endif
  56. #ifndef HAVE_MKSTEMP
  57. /* since mkstemp() is defined as a real C++ function if taken from
  58. groff's mkstemp.cpp we need a declaration */
  59. int mkstemp(char *tmpl);
  60. #endif /* HAVE_MKSTEMP */
  61. int mksdir(char *tmpl);
  62. FILE *xtmpfile(char **namep = 0,
  63. const char *postfix_long = 0, const char *postfix_short = 0,
  64. int do_unlink = 1);
  65. char *xtmptemplate(const char *postfix_long, const char *postfix_short);
  66. #ifdef NEED_DECLARATION_POPEN
  67. extern "C" { FILE *popen(const char *, const char *); }
  68. #endif /* NEED_DECLARATION_POPEN */
  69. #ifdef NEED_DECLARATION_PCLOSE
  70. extern "C" { int pclose (FILE *); }
  71. #endif /* NEED_DECLARATION_PCLOSE */
  72. size_t file_name_max(const char *fname);
  73. size_t path_name_max();
  74. int interpret_lf_args(const char *p);
  75. extern char invalid_char_table[];
  76. inline int invalid_input_char(int c)
  77. {
  78. return c >= 0 && invalid_char_table[c];
  79. }
  80. #ifdef HAVE_STRCASECMP
  81. #ifdef NEED_DECLARATION_STRCASECMP
  82. // Ultrix4.3's string.h fails to declare this.
  83. extern "C" { int strcasecmp(const char *, const char *); }
  84. #endif /* NEED_DECLARATION_STRCASECMP */
  85. #else /* not HAVE_STRCASECMP */
  86. extern "C" { int strcasecmp(const char *, const char *); }
  87. #endif /* HAVE_STRCASECMP */
  88. #if !defined(_AIX) && !defined(sinix) && !defined(__sinix__)
  89. #ifdef HAVE_STRNCASECMP
  90. #ifdef NEED_DECLARATION_STRNCASECMP
  91. // SunOS's string.h fails to declare this.
  92. extern "C" { int strncasecmp(const char *, const char *, int); }
  93. #endif /* NEED_DECLARATION_STRNCASECMP */
  94. #else /* not HAVE_STRNCASECMP */
  95. extern "C" { int strncasecmp(const char *, const char *, size_t); }
  96. #endif /* HAVE_STRNCASECMP */
  97. #endif /* !_AIX && !sinix && !__sinix__ */
  98. #ifdef HAVE_CC_LIMITS_H
  99. #include <limits.h>
  100. #else /* not HAVE_CC_LIMITS_H */
  101. #define INT_MAX 2147483647
  102. #endif /* not HAVE_CC_LIMITS_H */
  103. /* It's not safe to rely on people getting INT_MIN right (ie signed). */
  104. #ifdef INT_MIN
  105. #undef INT_MIN
  106. #endif
  107. #ifdef CFRONT_ANSI_BUG
  108. /* This works around a bug in cfront 2.0 used with ANSI C compilers. */
  109. #define INT_MIN ((long)(-INT_MAX-1))
  110. #else /* not CFRONT_ANSI_BUG */
  111. #define INT_MIN (-INT_MAX-1)
  112. #endif /* not CFRONT_ANSI_BUG */
  113. /* Maximum number of digits in the decimal representation of an int
  114. (not including the -). */
  115. #define INT_DIGITS 10
  116. #ifdef PI
  117. #undef PI
  118. #endif
  119. const double PI = 3.14159265358979323846;
  120. /* ad_delete deletes an array of objects with destructors;
  121. a_delete deletes an array of objects without destructors */
  122. #ifdef ARRAY_DELETE_NEEDS_SIZE
  123. /* for 2.0 systems */
  124. #define ad_delete(size) delete [size]
  125. #define a_delete delete
  126. #else /* not ARRAY_DELETE_NEEDS_SIZE */
  127. /* for ARM systems */
  128. #define ad_delete(size) delete []
  129. #define a_delete delete []
  130. #endif /* not ARRAY_DELETE_NEEDS_SIZE */