1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// ./lib/current/include/system.h
|
4 |
|
|
//
|
5 |
|
|
//
|
6 |
|
|
//==========================================================================
|
7 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
8 |
|
|
// -------------------------------------------
|
9 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
10 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
11 |
|
|
//
|
12 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
13 |
|
|
// the terms of the GNU General Public License as published by the Free
|
14 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
15 |
|
|
//
|
16 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
17 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
18 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
19 |
|
|
// for more details.
|
20 |
|
|
//
|
21 |
|
|
// You should have received a copy of the GNU General Public License along
|
22 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
23 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
24 |
|
|
//
|
25 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
26 |
|
|
// or inline functions from this file, or you compile this file and link it
|
27 |
|
|
// with other works to produce a work based on this file, this file does not
|
28 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
29 |
|
|
// License. However the source code for this file must still be made available
|
30 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
31 |
|
|
//
|
32 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
33 |
|
|
// this file might be covered by the GNU General Public License.
|
34 |
|
|
//
|
35 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
36 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
37 |
|
|
// -------------------------------------------
|
38 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
39 |
|
|
//####UCDSNMPCOPYRIGHTBEGIN####
|
40 |
|
|
//
|
41 |
|
|
// -------------------------------------------
|
42 |
|
|
//
|
43 |
|
|
// Portions of this software may have been derived from the UCD-SNMP
|
44 |
|
|
// project, <http://ucd-snmp.ucdavis.edu/> from the University of
|
45 |
|
|
// California at Davis, which was originally based on the Carnegie Mellon
|
46 |
|
|
// University SNMP implementation. Portions of this software are therefore
|
47 |
|
|
// covered by the appropriate copyright disclaimers included herein.
|
48 |
|
|
//
|
49 |
|
|
// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
|
50 |
|
|
// -------------------------------------------
|
51 |
|
|
//
|
52 |
|
|
//####UCDSNMPCOPYRIGHTEND####
|
53 |
|
|
//==========================================================================
|
54 |
|
|
//#####DESCRIPTIONBEGIN####
|
55 |
|
|
//
|
56 |
|
|
// Author(s): hmt
|
57 |
|
|
// Contributors: hmt
|
58 |
|
|
// Date: 2000-05-30
|
59 |
|
|
// Purpose: Port of UCD-SNMP distribution to eCos.
|
60 |
|
|
// Description:
|
61 |
|
|
//
|
62 |
|
|
//
|
63 |
|
|
//####DESCRIPTIONEND####
|
64 |
|
|
//
|
65 |
|
|
//==========================================================================
|
66 |
|
|
/********************************************************************
|
67 |
|
|
Copyright 1989, 1991, 1992 by Carnegie Mellon University
|
68 |
|
|
|
69 |
|
|
Derivative Work -
|
70 |
|
|
Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
|
71 |
|
|
|
72 |
|
|
All Rights Reserved
|
73 |
|
|
|
74 |
|
|
Permission to use, copy, modify and distribute this software and its
|
75 |
|
|
documentation for any purpose and without fee is hereby granted,
|
76 |
|
|
provided that the above copyright notice appears in all copies and
|
77 |
|
|
that both that copyright notice and this permission notice appear in
|
78 |
|
|
supporting documentation, and that the name of CMU and The Regents of
|
79 |
|
|
the University of California not be used in advertising or publicity
|
80 |
|
|
pertaining to distribution of the software without specific written
|
81 |
|
|
permission.
|
82 |
|
|
|
83 |
|
|
CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
|
84 |
|
|
WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
|
85 |
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
|
86 |
|
|
THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
|
87 |
|
|
INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
88 |
|
|
FROM THE LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
89 |
|
|
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
90 |
|
|
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
91 |
|
|
*********************************************************************/
|
92 |
|
|
#ifndef SNMP_SYSTEM_H
|
93 |
|
|
#define SNMP_SYSTEM_H
|
94 |
|
|
|
95 |
|
|
#ifdef __cplusplus
|
96 |
|
|
extern "C" {
|
97 |
|
|
#endif
|
98 |
|
|
|
99 |
|
|
/***********************************************************
|
100 |
|
|
Copyright 1993 by Carnegie Mellon University
|
101 |
|
|
|
102 |
|
|
All Rights Reserved
|
103 |
|
|
|
104 |
|
|
Permission to use, copy, modify, and distribute this software and its
|
105 |
|
|
documentation for any purpose and without fee is hereby granted,
|
106 |
|
|
provided that the above copyright notice appear in all copies and that
|
107 |
|
|
both that copyright notice and this permission notice appear in
|
108 |
|
|
supporting documentation, and that the name of CMU not be
|
109 |
|
|
used in advertising or publicity pertaining to distribution of the
|
110 |
|
|
software without specific, written prior permission.
|
111 |
|
|
|
112 |
|
|
CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
113 |
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
114 |
|
|
CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
115 |
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
116 |
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
117 |
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
118 |
|
|
SOFTWARE.
|
119 |
|
|
******************************************************************/
|
120 |
|
|
/*
|
121 |
|
|
* Definitions for the system dependent library file
|
122 |
|
|
*/
|
123 |
|
|
#ifdef WIN32
|
124 |
|
|
#include <sys/timeb.h>
|
125 |
|
|
#include <time.h>
|
126 |
|
|
/* structure of a directory entry */
|
127 |
|
|
typedef struct direct
|
128 |
|
|
{
|
129 |
|
|
long d_ino; /* inode number (not used by MS-DOS) */
|
130 |
|
|
int d_namlen; /* Name length */
|
131 |
|
|
char d_name[257];/* file name */
|
132 |
|
|
} _DIRECT;
|
133 |
|
|
|
134 |
|
|
/* structure for dir operations */
|
135 |
|
|
typedef struct _dir_struc
|
136 |
|
|
{
|
137 |
|
|
char *start; /* Starting position */
|
138 |
|
|
char *curr; /* Current position */
|
139 |
|
|
long size; /* Size of string table */
|
140 |
|
|
long nfiles; /* number if filenames in table */
|
141 |
|
|
struct direct dirstr; /* Directory structure to return */
|
142 |
|
|
} DIR;
|
143 |
|
|
|
144 |
|
|
DIR *opendir (const char *filename);
|
145 |
|
|
struct direct *readdir (DIR *dirp);
|
146 |
|
|
int closedir (DIR *dirp);
|
147 |
|
|
|
148 |
|
|
#ifndef HAVE_GETTIMEOFDAY
|
149 |
|
|
int gettimeofday (struct timeval *, struct timezone *tz);
|
150 |
|
|
#endif
|
151 |
|
|
#ifndef HAVE_STRCASECMP
|
152 |
|
|
int strcasecmp(const char *s1, const char *s2);
|
153 |
|
|
#endif
|
154 |
|
|
#ifndef HAVE_STRNCASECMP
|
155 |
|
|
int strncasecmp(const char *s1, const char *s2, size_t n);
|
156 |
|
|
#endif
|
157 |
|
|
|
158 |
|
|
char * winsock_startup (void);
|
159 |
|
|
void winsock_cleanup (void);
|
160 |
|
|
|
161 |
|
|
#define SOCK_STARTUP winsock_startup()
|
162 |
|
|
#define SOCK_CLEANUP winsock_cleanup()
|
163 |
|
|
#else
|
164 |
|
|
#define SOCK_STARTUP
|
165 |
|
|
#define SOCK_CLEANUP
|
166 |
|
|
#endif
|
167 |
|
|
|
168 |
|
|
in_addr_t get_myaddr (void);
|
169 |
|
|
long get_uptime (void);
|
170 |
|
|
|
171 |
|
|
#if HAVE_STDARG_H
|
172 |
|
|
void DEBUGP (const char *, ...);
|
173 |
|
|
#else
|
174 |
|
|
void DEBUGP (va_alist);
|
175 |
|
|
#endif
|
176 |
|
|
|
177 |
|
|
#ifdef HAVE_CPP_UNDERBAR_FUNCTION_DEFINED
|
178 |
|
|
#define DEBUGPL(x) \
|
179 |
|
|
DEBUGP("%s():%s,%d: ",__FUNCTION__,__FILE__,__LINE__); DEBUGP x ;
|
180 |
|
|
#else
|
181 |
|
|
#define DEBUGPL(x) \
|
182 |
|
|
DEBUGP("():%s,%d: ",__FILE__,__LINE__); DEBUGP x ;
|
183 |
|
|
#endif
|
184 |
|
|
|
185 |
|
|
#ifndef HAVE_STRDUP
|
186 |
|
|
char *strdup (const char *);
|
187 |
|
|
#endif
|
188 |
|
|
#ifndef HAVE_SETENV
|
189 |
|
|
int setenv (const char *, const char *, int);
|
190 |
|
|
#endif
|
191 |
|
|
|
192 |
|
|
#ifdef __ECOS
|
193 |
|
|
#include <pkgconf/system.h>
|
194 |
|
|
#ifdef CYGPKG_NET_FREEBSD_STACK
|
195 |
|
|
#include <sys/param.h>
|
196 |
|
|
#undef printf
|
197 |
|
|
#endif //CYGPKG_NET_FREEBSD_STACK
|
198 |
|
|
#endif // __ECOS
|
199 |
|
|
|
200 |
|
|
#if TIME_WITH_SYS_TIME
|
201 |
|
|
# ifdef WIN32
|
202 |
|
|
# include <sys/timeb.h>
|
203 |
|
|
# else
|
204 |
|
|
# include <sys/time.h>
|
205 |
|
|
# endif
|
206 |
|
|
# include <time.h>
|
207 |
|
|
#else
|
208 |
|
|
# if HAVE_SYS_TIME_H
|
209 |
|
|
# include <sys/time.h>
|
210 |
|
|
# else
|
211 |
|
|
# include <time.h>
|
212 |
|
|
# endif
|
213 |
|
|
#endif
|
214 |
|
|
|
215 |
|
|
int calculate_time_diff(struct timeval *, struct timeval *);
|
216 |
|
|
|
217 |
|
|
#ifndef HAVE_STRCASESTR
|
218 |
|
|
char *strcasestr(const char *, const char *);
|
219 |
|
|
#endif
|
220 |
|
|
|
221 |
|
|
int mkdirhier(const char *pathname, mode_t mode, int skiplast);
|
222 |
|
|
|
223 |
|
|
#ifdef __cplusplus
|
224 |
|
|
}
|
225 |
|
|
#endif
|
226 |
|
|
|
227 |
|
|
#ifndef HAVE_GETTIMEOFDAY
|
228 |
|
|
int gettimeofday (struct timeval *, struct timezone *tz);
|
229 |
|
|
#endif
|
230 |
|
|
#ifndef HAVE_STRCASECMP
|
231 |
|
|
int strcasecmp(const char *s1, const char *s2);
|
232 |
|
|
#endif
|
233 |
|
|
#ifndef HAVE_STRNCASECMP
|
234 |
|
|
int strncasecmp(const char *s1, const char *s2, size_t n);
|
235 |
|
|
#endif
|
236 |
|
|
|
237 |
|
|
#endif /* SNMP_SYSTEM_H */
|