1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
|
/*
* LsofTest.h -- header file for lsof tests
*/
/*
* Copyright 2002 Purdue Research Foundation, West Lafayette, Indiana
* 47907. All rights reserved.
*
* Written by Victor A. Abell
*
* This software is not subject to any license of the American Telephone
* and Telegraph Company or the Regents of the University of California.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it freely, subject
* to the following restrictions:
*
* 1. Neither the authors nor Purdue University are responsible for any
* consequences of the use of this software.
*
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission. Credit to the authors and Purdue
* University must appear in documentation and sources.
*
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 4. This notice may not be removed or altered.
*/
/*
* $Id: LsofTest.h,v 1.12 2008/07/05 16:21:07 abe Exp $
*/
#if !defined(LSOF_TEST_H)
#define LSOF_TEST_H 1
/*
* The _PROTOTYPE macro provides strict ANSI C prototypes if __STDC__
* is defined, and old-style K&R prototypes otherwise.
*
* (With thanks to Andy Tanenbaum)
*/
# if defined(__STDC__)
#define _PROTOTYPE(function, params) function params
# else /* !defined(__STDC__) */
#define _PROTOTYPE(function, params) function()
# endif /* defined(__STDC__) */
/*
* The following define keeps gcc>=2.7 from complaining about the failure
* of the Exit() function to return.
*
* Paul Eggert <eggert@twinsun.com> supplied it.
*/
# if defined(__GNUC__) && !(__GNUC__<2 || (__GNUC__==2 && __GNUC_MINOR__<7))
#define exiting __attribute__((__noreturn__))
# else /* !gcc || gcc<2.7 */
#define exiting
# endif /* gcc && gcc>=2.7 */
/*
* Necessary header files.
*/
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
/*
* Definitions that may be revoked by a particular dialect.
*/
#define USE_GETCWD /* use the POSIX getcwd() function in
* place of getwd() */
#define USE_LSOF_C_OPT /* use lsof's -C option */
#undef USE_LSOF_X_OPT /* don't use lsof's -X option */
# if defined(LT_DIAL_aix)
/*
* AIX-specific items
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/access.h>
#undef USE_LSOF_C_OPT
#define USE_LSOF_X_OPT
# endif /* defined(LT_DIAL_aix) */
# if defined(LT_DIAL_bsdi)
/*
* OpenBSD-specific items
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
# endif /* defined(LT_DIAL_bsdi) */
# if defined(LT_DIAL_darwin)
/*
* Darwin-specific items
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#undef USE_LSOF_C_OPT
# endif /* defined(LT_DIAL_darwin) */
# if defined(LT_DIAL_du)
/*
* DEC_OSF/1|Digital_UNIX|Tru64_UNIX-specific items
*/
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
# if LT_VERS<50000
#define snprintf snpf /* use lsof's snpf() */
# endif /* LT_VERS<50000 */
# endif /* defined(LT_DIAL_du) */
# if defined(LT_DIAL_freebsd)
/*
* FreeBSD-specific items
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
# endif /* defined(LT_DIAL_freebsd) */
# if defined(LT_DIAL_linux)
/*
* Linux-specific items
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#undef USE_LSOF_C_OPT
# endif /* defined(LT_DIAL_linux) */
# if defined(LT_DIAL_hpux)
/*
* HP-UX-specific items
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
# endif /* defined(LT_DIAL_hpux) */
# if defined(LT_DIAL_netbsd)
/*
* NetBSD-specific items
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
# endif /* defined(LT_DIAL_netbsd) */
# if defined(LT_DIAL_openbsd)
/*
* OpenBSD-specific items
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
# endif /* defined(LT_DIAL_openbsd) */
# if defined(LT_DIAL_ou)
/*
* OpenUNIX-specific items
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
# endif /* defined(LT_DIAL_ou) */
# if defined(LT_DIAL_osr)
/*
* OSR-specific items
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
# endif /* defined(LT_DIAL_osr) */
# if defined(LT_DIAL_ns)
/*
* NEXTSTEP-specific items
*/
#include <stdlib.h>
#include <string.h>
#include <sys/file.h>
#include <sys/wait.h>
typedef int pid_t;
#define snprintf snpf
#undef USE_GETCWD
# endif /* defined(LT_DIAL_ns) */
# if defined(LT_DIAL_solaris)
/*
* Solaris-specific items
*/
#include <fcntl.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include <sys/wait.h>
# if defined(LT_VPATH)
#undef USE_LSOF_C_OPT
#endif /* defined(LT_VPATH) */
# endif /* defined(LT_DIAL_solaris) */
# if defined(LT_DIAL_uw)
/*
* UnixWare-specific items
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
# endif /* defined(LT_DIAL_uw) */
/*
* Local definitions, including ones may have been left undefined by
* dialect-specific header files
*/
#define LT_DONT_DO_TEST "this test does not run on this dialect."
#define LT_DEF_LSOF_PATH "../lsof"
# if !defined(MAXPATHLEN)
#define MAXPATHLEN 1024
# endif /* !defined(MAXPATHLEN) */
/*
* Local structure definitions
*/
typedef struct LTdev { /* local device parameters */
unsigned int maj; /* major device number */
unsigned int min; /* minor device number */
unsigned int unit; /* unit number (where applicable) */
} LTdev_t;
typedef struct LTfldo { /* lsof field output information */
char ft; /* field identifier (see the LSOF_FID_*
* definitions in ../lsof_fields.h) */
char *v; /* field value character string */
} LTfldo_t;
#define LT_FLDO_ALLOC 16 /* LTfldo_t allocation increment */
/*
* Lsof test library global variable external declarations:
*
* these global variables may be found in LTlib.c.
*/
extern int LsofFd; /* lsof pipe FD */
extern FILE *LsofFs; /* stream for lsof pipe FD */
extern char *LsofPath; /* path to lsof executable */
extern pid_t LsofPid; /* PID of lsof child process */
extern int LTopt_h; /* "-h" option's switch value */
extern char *LTopt_p; /* "-p path" option's path value */
extern int MsgStat; /* message status */
/*
* External declarations
*/
extern int errno; /* error number */
/*
* Lsof test library function prototypes:
*
* these functions may be found in LTlib.c.
*/
_PROTOTYPE(extern char *CanRdKmem,(void));
_PROTOTYPE(extern char *ConvStatDev,(dev_t *dev, LTdev_t *ldev));
_PROTOTYPE(extern char *ConvLsofDev,(char *dev, LTdev_t *ldev));
_PROTOTYPE(extern char *ExecLsof,(char **opt));
_PROTOTYPE(extern char *IsLsofExec,(void));
_PROTOTYPE(extern void LTlibClean,(void));
_PROTOTYPE(extern char *MkStrCpy,(char *src, int *len));
_PROTOTYPE(extern LTfldo_t *RdFrLsof,(int *nf, char **em));
_PROTOTYPE(extern void PrtMsg,(char *mp, char *pn));
_PROTOTYPE(extern void PrtMsgX,(char *mp, char *pn, void (*f)(), int xv));
_PROTOTYPE(extern int ScanArg,(int ac, char *av[], char *opt, char *pn));
_PROTOTYPE(extern void StopLsof,(void));
#endif /* LSOF_TEST_H */
|