system.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. #ifndef SNMP_SYSTEM_H
  2. #define SNMP_SYSTEM_H
  3. #ifndef NET_SNMP_CONFIG_H
  4. #error "Please include <net-snmp/net-snmp-config.h> before this file"
  5. #endif
  6. #include <stdarg.h> /* va_list */
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /* Portions of this file are subject to the following copyrights. See
  11. * the Net-SNMP's COPYING file for more details and other copyrights
  12. * that may apply:
  13. */
  14. /***********************************************************
  15. Copyright 1993 by Carnegie Mellon University
  16. All Rights Reserved
  17. Permission to use, copy, modify, and distribute this software and its
  18. documentation for any purpose and without fee is hereby granted,
  19. provided that the above copyright notice appear in all copies and that
  20. both that copyright notice and this permission notice appear in
  21. supporting documentation, and that the name of CMU not be
  22. used in advertising or publicity pertaining to distribution of the
  23. software without specific, written prior permission.
  24. CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  25. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  26. CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  27. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  28. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  29. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  30. SOFTWARE.
  31. ******************************************************************/
  32. /*
  33. * portions Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
  34. * Use is subject to license terms specified in the COPYING file
  35. * distributed with the Net-SNMP package.
  36. */
  37. struct timeval;
  38. /*
  39. * function to create a daemon. Will fork and call setsid().
  40. *
  41. * Returns: -1 : fork failed
  42. * 0 : No errors
  43. */
  44. NETSNMP_IMPORT
  45. int netsnmp_daemonize(int quit_immediately, int stderr_log);
  46. /*
  47. * Definitions for the system dependent library file
  48. *
  49. * Do not define 'struct direct' when MSVC_PERL is defined because a
  50. * structure with that name is also defined in the Perl header
  51. * lib\CORE\dirent.h. Do not declare gettimeofday() either.
  52. */
  53. #ifndef MSVC_PERL
  54. #ifndef HAVE_READDIR
  55. /*
  56. * structure of a directory entry
  57. */
  58. typedef struct direct {
  59. long d_ino; /* inode number (not used by MS-DOS) */
  60. int d_namlen; /* Name length */
  61. char d_name[257]; /* file name */
  62. } _DIRECT;
  63. /*
  64. * structure for dir operations
  65. */
  66. typedef struct _dir_struc {
  67. char *start; /* Starting position */
  68. char *curr; /* Current position */
  69. long size; /* Size of string table */
  70. long nfiles; /* number if filenames in table */
  71. struct direct dirstr; /* Directory structure to return */
  72. } DIR;
  73. NETSNMP_IMPORT
  74. DIR *opendir(const char *filename);
  75. NETSNMP_IMPORT
  76. struct direct *readdir(DIR * dirp);
  77. NETSNMP_IMPORT
  78. int closedir(DIR * dirp);
  79. #endif /* HAVE_READDIR */
  80. #ifndef HAVE_GETTIMEOFDAY
  81. NETSNMP_IMPORT
  82. int gettimeofday(struct timeval *, struct timezone *tz);
  83. #endif
  84. #endif /* MSVC_PERL */
  85. #if !defined(HAVE_STRNCASECMP) && !defined(strncasecmp)
  86. NETSNMP_IMPORT
  87. int strcasecmp(const char *s1, const char *s2);
  88. NETSNMP_IMPORT
  89. int strncasecmp(const char *s1, const char *s2, size_t n);
  90. #endif
  91. #ifdef WIN32
  92. NETSNMP_IMPORT
  93. char *winsock_startup(void);
  94. NETSNMP_IMPORT
  95. void winsock_cleanup(void);
  96. #define SOCK_STARTUP winsock_startup()
  97. #define SOCK_CLEANUP winsock_cleanup()
  98. #else /* !WIN32 */
  99. #define SOCK_STARTUP
  100. #define SOCK_CLEANUP
  101. #endif /* WIN32 */
  102. #include <net-snmp/types.h> /* For definition of in_addr_t */
  103. #ifdef HAVE_NETINET_IN_H
  104. #include <netinet/in.h>
  105. #endif
  106. /* Simply resolve a hostname and return first IPv4 address.
  107. * Returns -1 on error */
  108. NETSNMP_IMPORT
  109. int netsnmp_gethostbyname_v4(const char* name,
  110. in_addr_t *addr_out);
  111. /** netsnmp versions of dns resoloution.. may include DNSSEC validation. */
  112. struct addrinfo; /* forward declare */
  113. NETSNMP_IMPORT
  114. struct hostent *netsnmp_gethostbyname(const char *name);
  115. NETSNMP_IMPORT
  116. struct hostent *netsnmp_gethostbyaddr(const void *addr, socklen_t len,
  117. int type);
  118. NETSNMP_IMPORT
  119. int netsnmp_getaddrinfo(const char *name, const char *service,
  120. const struct addrinfo *hints,
  121. struct addrinfo **res);
  122. NETSNMP_IMPORT
  123. in_addr_t get_myaddr(void);
  124. NETSNMP_IMPORT
  125. long get_uptime(void);
  126. #ifndef HAVE_STRDUP
  127. char *strdup(const char *);
  128. #endif
  129. #ifndef HAVE_SETENV
  130. NETSNMP_IMPORT
  131. int setenv(const char *, const char *, int);
  132. #endif
  133. NETSNMP_IMPORT
  134. int calculate_time_diff(const struct timeval *,
  135. const struct timeval *);
  136. NETSNMP_IMPORT
  137. u_int calculate_sectime_diff(const struct timeval *now,
  138. const struct timeval *then);
  139. #ifndef HAVE_STRCASESTR
  140. char *strcasestr(const char *, const char *);
  141. #endif
  142. #ifndef HAVE_STRTOL
  143. long strtol(const char *, char **, int);
  144. #endif
  145. #ifndef HAVE_STRTOUL
  146. unsigned long strtoul(const char *, char **, int);
  147. #endif
  148. #ifndef HAVE_STRTOULL
  149. NETSNMP_IMPORT uint64_t strtoull(const char *, char **, int);
  150. #endif
  151. #ifndef HAVE_STRTOK_R
  152. NETSNMP_IMPORT
  153. char *strtok_r(char *, const char *, char **);
  154. #endif
  155. #ifndef HAVE_SNPRINTF
  156. int snprintf(char *, size_t, const char *, ...);
  157. #endif
  158. #ifndef HAVE_ASPRINTF
  159. NETSNMP_IMPORT
  160. int vasprintf(char **strp, const char *fmt, va_list ap);
  161. NETSNMP_IMPORT
  162. int asprintf(char **strp, const char *fmt, ...);
  163. #endif
  164. NETSNMP_IMPORT
  165. int mkdirhier(const char *pathname, mode_t mode,
  166. int skiplast);
  167. NETSNMP_IMPORT
  168. const char *netsnmp_mktemp(void);
  169. #ifndef HAVE_STRLCPY
  170. NETSNMP_IMPORT
  171. size_t strlcpy(char *, const char *, size_t);
  172. #endif
  173. #ifndef HAVE_STRLCAT
  174. NETSNMP_IMPORT
  175. size_t strlcat(char *, const char *, size_t);
  176. #endif
  177. int netsnmp_os_prematch(const char *ospmname,
  178. const char *ospmrelprefix);
  179. int netsnmp_os_kernel_width(void);
  180. NETSNMP_IMPORT
  181. int netsnmp_str_to_uid(const char *useroruid);
  182. NETSNMP_IMPORT
  183. int netsnmp_str_to_gid(const char *grouporgid);
  184. #ifdef __cplusplus
  185. }
  186. #endif
  187. #endif /* SNMP_SYSTEM_H */