net-snmp  5.4.1
system.h
00001 #ifndef SNMP_SYSTEM_H
00002 #define SNMP_SYSTEM_H
00003 
00004 #ifndef NET_SNMP_CONFIG_H
00005 #error "Please include <net-snmp/net-snmp-config.h> before this file"
00006 #endif
00007 
00008 #ifdef __cplusplus
00009 extern          "C" {
00010 #endif
00011 
00012 /* Portions of this file are subject to the following copyrights.  See
00013  * the Net-SNMP's COPYING file for more details and other copyrights
00014  * that may apply:
00015  */
00016 /***********************************************************
00017         Copyright 1993 by Carnegie Mellon University
00018 
00019                       All Rights Reserved
00020 
00021 Permission to use, copy, modify, and distribute this software and its
00022 documentation for any purpose and without fee is hereby granted,
00023 provided that the above copyright notice appear in all copies and that
00024 both that copyright notice and this permission notice appear in
00025 supporting documentation, and that the name of CMU not be
00026 used in advertising or publicity pertaining to distribution of the
00027 software without specific, written prior permission.
00028 
00029 CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
00030 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
00031 CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
00032 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
00033 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
00034 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00035 SOFTWARE.
00036 ******************************************************************/
00037 /*
00038  * portions Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
00039  * Use is subject to license terms specified in the COPYING file
00040  * distributed with the Net-SNMP package.
00041  */
00042 
00043 
00044     /*
00045      * function to create a daemon. Will fork and call setsid().
00046      *
00047      * Returns: -1 : fork failed
00048      *           0 : No errors
00049      */
00050     int netsnmp_daemonize(int quit_immediately, int stderr_log);
00051 
00052     /*
00053      * Definitions for the system dependent library file
00054      */
00055 #ifndef MSVC_PERL
00056 #ifdef WIN32
00057 
00058 #ifndef HAVE_DIRENT_H /* MingGW has dirent.h but also defines WIN32 */
00059     /*
00060      * structure of a directory entry 
00061      */
00062     typedef struct direct {
00063         long            d_ino;  /* inode number (not used by MS-DOS) */
00064         int             d_namlen;       /* Name length */
00065         char            d_name[257];    /* file name */
00066     } _DIRECT;
00067 
00068     /*
00069      * structure for dir operations 
00070      */
00071     typedef struct _dir_struc {
00072         char           *start;  /* Starting position */
00073         char           *curr;   /* Current position */
00074         long            size;   /* Size of string table */
00075         long            nfiles; /* number if filenames in table */
00076         struct direct   dirstr; /* Directory structure to return */
00077     } DIR;
00078 
00079     DIR            *opendir(const char *filename);
00080     struct direct  *readdir(DIR * dirp);
00081     int             closedir(DIR * dirp);
00082 #endif /* HAVE_DIRENT_H */
00083 
00084 #ifndef HAVE_GETTIMEOFDAY
00085     int             gettimeofday(struct timeval *, struct timezone *tz);
00086 #endif
00087 #ifndef HAVE_STRCASECMP
00088     int             strcasecmp(const char *s1, const char *s2);
00089 #endif
00090 #ifndef HAVE_STRNCASECMP
00091     int             strncasecmp(const char *s1, const char *s2, size_t n);
00092 #endif
00093 
00094     char           *winsock_startup(void);
00095     void            winsock_cleanup(void);
00096 
00097 #define SOCK_STARTUP winsock_startup()
00098 #define SOCK_CLEANUP winsock_cleanup()
00099 
00100 #else                           /* !WIN32 */
00101 
00102 #define SOCK_STARTUP
00103 #define SOCK_CLEANUP
00104 
00105 #endif                          /* WIN32 */
00106 #endif                          /* MSVC_PERL */
00107 
00108 #include <net-snmp/types.h>     /* For definition of in_addr_t */
00109 
00110     in_addr_t       get_myaddr(void);
00111     long            get_uptime(void);
00112 
00113 #ifndef HAVE_STRDUP
00114     char           *strdup(const char *);
00115 #endif
00116 #ifndef HAVE_SETENV
00117     int             setenv(const char *, const char *, int);
00118 #endif
00119 
00120     int             calculate_time_diff(struct timeval *,
00121                                         struct timeval *);
00122     u_int           calculate_sectime_diff(struct timeval *now,
00123                                            struct timeval *then);
00124 
00125 #ifndef HAVE_STRCASESTR
00126     char           *strcasestr(const char *, const char *);
00127 #endif
00128 #ifndef HAVE_STRTOL
00129     long            strtol(const char *, char **, int);
00130 #endif
00131 #ifndef HAVE_STRTOUL
00132     unsigned long   strtoul(const char *, char **, int);
00133 #endif
00134 #ifndef HAVE_STRTOK_R
00135     char           *strtok_r(char *, const char *, char **);
00136 #endif
00137 #ifndef HAVE_SNPRINTF
00138     int             snprintf(char *, size_t, const char *, ...);
00139 #endif
00140 
00141     int             mkdirhier(const char *pathname, mode_t mode,
00142                               int skiplast);
00143     const char     *netsnmp_mktemp(void);
00144 #ifndef HAVE_STRLCPY
00145     size_t            strlcpy(char *, const char *, size_t);
00146 #endif
00147 
00148     int             netsnmp_os_prematch(const char *ospmname,
00149                                         const char *ospmrelprefix);
00150     int             netsnmp_os_kernel_width(void);
00151 
00152 #ifdef __cplusplus
00153 }
00154 #endif
00155 #endif                          /* SNMP_SYSTEM_H */