Changeset 1695 for zzuf


Ignore:
Timestamp:
Jan 18, 2007, 1:21:07 AM (14 years ago)
Author:
Sam Hocevar
Message:
  • Added enough autoconf checks and #ifdefs so that libzzuf builds on Win32. zzuf itself doesn't build yet, though.
Location:
zzuf/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/configure.ac

    r1674 r1695  
    1515AC_PROG_LIBTOOL
    1616
    17 AC_CHECK_HEADERS(inttypes.h stdint.h getopt.h libc.h malloc.h)
    18 AC_CHECK_FUNCS(open64 lseek64 mmap64 fopen64 fseeko _IO_getc getline getdelim __getdelim fgetln __srefill map_fd memalign posix_memalign)
     17AC_CHECK_HEADERS(inttypes.h stdint.h getopt.h libc.h malloc.h dlfcn.h regex.h sys/socket.h sys/uio.h aio.h sys/mman.h sys/wait.h sys/resource.h)
     18AC_CHECK_FUNCS(open64 lseek64 mmap64 fopen64 fseeko _IO_getc getline getdelim __getdelim fgetln __srefill map_fd memalign posix_memalign aio_read accept socket readv pread recv recvfrom recvmsg mmap valloc sigaction)
    1919AC_CHECK_TYPES(sighandler_t, [], [],
    2020  [#define _GNU_SOURCE
     
    2525  [#include <sys/types.h>
    2626   #include <sys/socket.h>])
     27
     28AC_MSG_CHECKING(for read() prototype)
     29AC_TRY_COMPILE([#include <unistd.h>],
     30 [ssize_t read(int fd, void *buf, size_t count);],
     31 [AC_MSG_RESULT(ssize_t read(... size_t);)
     32  AC_DEFINE(READ_USES_SSIZE_T, 1, [Define to 1 if read() uses ssize_t.])],
     33 [AC_MSG_RESULT(int read(... unsigned int);)])
    2734
    2835AC_CHECK_FUNCS(getopt_long,
  • zzuf/trunk/src/fd.c

    r1694 r1695  
    2626#endif
    2727#include <stdlib.h>
    28 #include <regex.h>
     28#if defined HAVE_REGEX_H
     29#   include <regex.h>
     30#endif
    2931#include <string.h>
    3032#include <math.h>
     
    3537
    3638/* Regex stuff */
     39#if defined HAVE_REGEX_H
    3740static regex_t re_include, re_exclude;
    3841static int has_include = 0, has_exclude = 0;
     42#endif
    3943
    4044/* File descriptor stuff. When program is launched, we use the static array of
     
    6771void _zz_include(char const *regex)
    6872{
     73#if defined HAVE_REGEX_H
    6974    if(regcomp(&re_include, regex, REG_EXTENDED) == 0)
    7075        has_include = 1;
     76#else
     77    (void)regex;
     78#endif
    7179}
    7280
    7381void _zz_exclude(char const *regex)
    7482{
     83#if defined HAVE_REGEX_H
    7584    if(regcomp(&re_exclude, regex, REG_EXTENDED) == 0)
    7685        has_exclude = 1;
     86#else
     87    (void)regex;
     88#endif
    7789}
    7890
     
    162174int _zz_mustwatch(char const *file)
    163175{
     176#if defined HAVE_REGEX_H
    164177    if(has_include && regexec(&re_include, file, 0, NULL, 0) == REG_NOMATCH)
    165178        return 0; /* not included: ignore */
     
    167180    if(has_exclude && regexec(&re_exclude, file, 0, NULL, 0) != REG_NOMATCH)
    168181        return 0; /* excluded: ignore */
     182#else
     183    (void)file;
     184#endif
    169185
    170186    return 1; /* default */
     
    230246    files[i].fuzz.ratio = _zz_getratio();
    231247    files[i].fuzz.cur = -1;
    232 #ifdef HAVE_FGETLN
     248#if defined HAVE_FGETLN
    233249    files[i].fuzz.tmp = NULL;
    234250#endif
     
    246262
    247263    files[fds[fd]].managed = 0;
    248 #ifdef HAVE_FGETLN
     264#if defined HAVE_FGETLN
    249265    if(files[fds[fd]].fuzz.tmp)
    250266        free(files[fds[fd]].fuzz.tmp);
  • zzuf/trunk/src/lib-fd.c

    r1694 r1695  
    3434#include <stdlib.h>
    3535#include <string.h>
    36 #include <dlfcn.h>
     36#include <stdio.h>
    3737
    3838#include <sys/types.h>
    39 #include <sys/socket.h>
    40 #include <sys/uio.h>
     39#if defined HAVE_SYS_SOCKET_H
     40#   include <sys/socket.h>
     41#endif
     42#if defined HAVE_SYS_UIO_H
     43#   include <sys/uio.h>
     44#endif
    4145#include <unistd.h>
    4246#include <fcntl.h>
    4347#include <stdarg.h>
    44 #include <aio.h>
     48#if defined HAVE_AIO_H
     49#   include <aio.h>
     50#endif
    4551
    4652#include "libzzuf.h"
     
    5056#include "fd.h"
    5157
    52 #ifdef HAVE_SOCKLEN_T
     58#if defined HAVE_SOCKLEN_T
    5359#   define SOCKLEN_T socklen_t
    5460#else
     
    5763
    5864/* Local prototypes */
     65#if defined HAVE_READV || defined HAVE_RECVMSG
    5966static void fuzz_iovec   (int fd, const struct iovec *iov, ssize_t ret);
     67#endif
    6068static void offset_check (int fd);
    6169
    6270/* Library functions that we divert */
    6371static int     (*open_orig)    (const char *file, int oflag, ...);
    64 #ifdef HAVE_OPEN64
     72#if defined HAVE_OPEN64
    6573static int     (*open64_orig)  (const char *file, int oflag, ...);
    6674#endif
     75#if defined HAVE_ACCEPT
    6776static int     (*accept_orig)  (int sockfd, struct sockaddr *addr,
    6877                                SOCKLEN_T *addrlen);
     78#endif
     79#if defined HAVE_SOCKET
    6980static int     (*socket_orig)  (int domain, int type, int protocol);
     81#endif
     82#if defined HAVE_RECV
    7083static int     (*recv_orig)    (int s, void *buf, size_t len, int flags);
     84#endif
     85#if defined HAVE_RECVFROM
    7186static int     (*recvfrom_orig)(int s, void *buf, size_t len, int flags,
    7287                                struct sockaddr *from, SOCKLEN_T *fromlen);
     88#endif
     89#if defined HAVE_RECVMSG
    7390static int     (*recvmsg_orig) (int s,  struct msghdr *hdr, int flags);
     91#endif
     92#if defined READ_USES_SSIZE_T
    7493static ssize_t (*read_orig)    (int fd, void *buf, size_t count);
     94#else
     95static int     (*read_orig)    (int fd, void *buf, unsigned int count);
     96#endif
     97#if defined HAVE_READV
    7598static ssize_t (*readv_orig)   (int fd, const struct iovec *iov, int count);
     99#endif
     100#if defined HAVE_PREAD
    76101static ssize_t (*pread_orig)   (int fd, void *buf, size_t count, off_t offset);
     102#endif
     103#if defined HAVE_AIO_READ
    77104static int     (*aio_read_orig)   (struct aiocb *aiocbp);
    78105static ssize_t (*aio_return_orig) (struct aiocb *aiocbp);
     106#endif
    79107static off_t   (*lseek_orig)   (int fd, off_t offset, int whence);
    80 #ifdef HAVE_LSEEK64
     108#if defined HAVE_LSEEK64
    81109static off64_t (*lseek64_orig) (int fd, off64_t offset, int whence);
    82110#endif
     
    120148}
    121149
    122 #ifdef HAVE_OPEN64
     150#if defined HAVE_OPEN64
    123151int open64(const char *file, int oflag, ...)
    124152{
     
    127155#endif
    128156
     157#if defined HAVE_ACCEPT
    129158int accept(int sockfd, struct sockaddr *addr, SOCKLEN_T *addrlen)
    130159{
     
    144173    return ret;
    145174}
    146 
     175#endif
     176
     177#if defined HAVE_SOCKET
    147178int socket(int domain, int type, int protocol)
    148179{
     
    162193    return ret;
    163194}
    164 
     195#endif
     196
     197#if defined HAVE_RECV
    165198int recv(int s, void *buf, size_t len, int flags)
    166199{
     
    192225    return ret;
    193226}
    194 
     227#endif
     228
     229#if defined HAVE_RECVFROM
    195230int recvfrom(int s, void *buf, size_t len, int flags,
    196231             struct sockaddr *from, SOCKLEN_T *fromlen)
     
    224259    return ret;
    225260}
    226 
     261#endif
     262
     263#if defined HAVE_RECVMSG
    227264int recvmsg(int s, struct msghdr *hdr, int flags)
    228265{
     
    239276    return ret;
    240277}
    241 
     278#endif
     279
     280#if defined READ_USES_SSIZE_T
    242281ssize_t read(int fd, void *buf, size_t count)
     282#else
     283int read(int fd, void *buf, unsigned int count)
     284#endif
    243285{
    244286    int ret;
     
    270312}
    271313
     314#if defined HAVE_READV
    272315ssize_t readv(int fd, const struct iovec *iov, int count)
    273316{
     
    285328    return ret;
    286329}
    287 
     330#endif
     331
     332#if defined HAVE_PREAD
    288333ssize_t pread(int fd, void *buf, size_t count, off_t offset)
    289334{
     
    318363    return ret;
    319364}
     365#endif
    320366
    321367#define LSEEK(fn, off_t) \
     
    339385}
    340386
    341 #ifdef HAVE_LSEEK64
     387#if defined HAVE_LSEEK64
    342388off64_t lseek64(int fd, off64_t offset, int whence)
    343389{
     
    348394#endif
    349395
     396#if defined HAVE_AIO_READ
    350397int aio_read(struct aiocb *aiocbp)
    351398{
     
    394441    return ret;
    395442}
     443#endif
    396444
    397445int close(int fd)
     
    416464/* XXX: the following functions are local */
    417465
     466#if defined HAVE_READV || defined HAVE_RECVMSG
    418467static void fuzz_iovec(int fd, const struct iovec *iov, ssize_t ret)
    419468{
     
    434483    }
    435484}
     485#endif
    436486
    437487static void offset_check(int fd)
    438488{
    439489    /* Sanity check, can be OK though (for instance with a character device) */
    440 #ifdef HAVE_LSEEK64
     490#if defined HAVE_LSEEK64
    441491    off64_t ret;
    442492    LOADSYM(lseek64);
  • zzuf/trunk/src/lib-load.h

    r1687 r1695  
    3030#define ORIG(x) x##_orig
    3131
    32 #define LOADSYM(x) \
    33     do { \
    34         if(!ORIG(x)) \
    35             ORIG(x) = dlsym(RTLD_NEXT, STR(x)); \
    36         if(!ORIG(x)) \
    37             abort(); \
    38     } while(0)
     32/* TODO: do the Win32 part */
     33#ifdef HAVE_DLFCN_H
     34#   include <dlfcn.h>
     35#   define LOADSYM(x) \
     36        do { \
     37            if(!ORIG(x)) \
     38                ORIG(x) = dlsym(RTLD_NEXT, STR(x)); \
     39            if(!ORIG(x)) \
     40                abort(); \
     41        } while(0)
     42#else
     43#   define LOADSYM(x) \
     44        do { \
     45            if(!ORIG(x)) \
     46                abort(); \
     47        } while(0)
     48#endif
    3949
  • zzuf/trunk/src/lib-mem.c

    r1694 r1695  
    3535#include <stdlib.h>
    3636#include <string.h>
    37 #include <dlfcn.h>
    3837#include <errno.h>
    3938#include <signal.h>
     
    4342#endif
    4443#include <unistd.h>
    45 #include <sys/mman.h>
     44#if defined HAVE_SYS_MMAN_H
     45#   include <sys/mman.h>
     46#endif
    4647#if defined HAVE_LIBC_H
    4748#   include <libc.h>
     
    5455#include "fd.h"
    5556
     57#if !defined SIGKILL
     58#   define SIGKILL 9
     59#endif
     60
    5661/* TODO: mremap, maybe brk/sbrk (haha) */
    5762
     
    6065static void *  (*malloc_orig)   (size_t size);
    6166static void    (*free_orig)     (void *ptr);
     67#if defined HAVE_VALLOC
    6268static void *  (*valloc_orig)   (size_t size);
    63 #ifdef HAVE_MEMALIGN
     69#endif
     70#if defined HAVE_MEMALIGN
    6471static void *  (*memalign_orig) (size_t boundary, size_t size);
    6572#endif
    66 #ifdef HAVE_POSIX_MEMALIGN
     73#if defined HAVE_POSIX_MEMALIGN
    6774static int     (*posix_memalign_orig) (void **memptr, size_t alignment,
    6875                                       size_t size);
     
    7077static void *  (*realloc_orig)  (void *ptr, size_t size);
    7178
     79#if defined HAVE_MMAP
    7280static void *  (*mmap_orig)     (void *start, size_t length, int prot,
    7381                                 int flags, int fd, off_t offset);
    74 #ifdef HAVE_MMAP64
     82#endif
     83#if defined HAVE_MMAP64
    7584static void *  (*mmap64_orig)   (void *start, size_t length, int prot,
    7685                                 int flags, int fd, off64_t offset);
    7786#endif
     87#if defined HAVE_MUNMAP
    7888static int     (*munmap_orig)   (void *start, size_t length);
    79 #ifdef HAVE_MAP_FD
     89#endif
     90#if defined HAVE_MAP_FD
    8091static kern_return_t (*map_fd_orig) (int fd, vm_offset_t offset,
    8192                                     vm_offset_t *addr, boolean_t find_space,
     
    148159}
    149160
     161#if defined HAVE_VALLOC
    150162void *valloc(size_t size)
    151163{
     
    157169    return ret;
    158170}
    159 
    160 #ifdef HAVE_MEMALIGN
     171#endif
     172
     173#if defined HAVE_MEMALIGN
    161174void *memalign(size_t boundary, size_t size)
    162175{
     
    170183#endif
    171184
    172 #ifdef HAVE_POSIX_MEMALIGN
     185#if defined HAVE_POSIX_MEMALIGN
    173186int posix_memalign(void **memptr, size_t alignment, size_t size)
    174187{
     
    227240    } while(0)
    228241
     242#if defined HAVE_MMAP
    229243void *mmap(void *start, size_t length, int prot, int flags,
    230244           int fd, off_t offset)
     
    232246    void *ret; MMAP(mmap, off_t); return ret;
    233247}
    234 
    235 #ifdef HAVE_MMAP64
     248#endif
     249
     250#if defined HAVE_MMAP64
    236251void *mmap64(void *start, size_t length, int prot, int flags,
    237252             int fd, off64_t offset)
     
    241256#endif
    242257
     258#if defined HAVE_MUNMAP
    243259int munmap(void *start, size_t length)
    244260{
     
    261277    return munmap_orig(start, length);
    262278}
    263 
    264 #ifdef HAVE_MAP_FD
     279#endif
     280
     281#if defined HAVE_MAP_FD
    265282kern_return_t map_fd(int fd, vm_offset_t offset, vm_offset_t *addr,
    266283                     boolean_t find_space, vm_size_t numbytes)
  • zzuf/trunk/src/lib-signal.c

    r1687 r1695  
    2828#endif
    2929#include <stdlib.h>
    30 #include <dlfcn.h>
    3130
    3231#include <string.h>
     
    4847/* Library functions that we divert */
    4948static SIG_T (*signal_orig)    (int signum, SIG_T handler);
     49#if defined HAVE_SIGACTION
    5050static int   (*sigaction_orig) (int signum, const struct sigaction *act,
    5151                                struct sigaction *oldact);
     52#endif
    5253/* Local functions */
    5354static int isfatal(int signum);
     
    6061        case SIGFPE:
    6162        case SIGILL:
     63#if defined SIGQUIT
    6264        case SIGQUIT:
     65#endif
    6366        case SIGSEGV:
     67#if defined SIGTRAP
    6468        case SIGTRAP:
    65 #ifdef SIGSYS
     69#endif
     70#if defined SIGSYS
    6671        case SIGSYS:
    6772#endif
    68 #ifdef SIGEMT
     73#if defined SIGEMT
    6974        case SIGEMT:
    7075#endif
    71 #ifdef SIGBUS
     76#if defined SIGBUS
    7277        case SIGBUS:
    7378#endif
    74 #ifdef SIGXCPU
     79#if defined SIGXCPU
    7580        case SIGXCPU:
    7681#endif
    77 #ifdef SIGXFSZ
     82#if defined SIGXFSZ
    7883        case SIGXFSZ:
    7984#endif
     
    100105}
    101106
     107#if defined HAVE_SIGACTION
    102108int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
    103109{
     
    123129    return ret;
    124130}
     131#endif
    125132
  • zzuf/trunk/src/lib-stream.c

    r1694 r1695  
    2727#endif
    2828#include <stdlib.h>
    29 #include <dlfcn.h>
    3029
    3130#include <stdio.h>
    3231#include <sys/types.h>
    33 #ifdef HAVE___SREFILL
     32#if defined HAVE___SREFILL
    3433#   include <unistd.h> /* Needed for __srefill’s lseek() call */
    3534#endif
     
    4140#include "fd.h"
    4241
    43 #ifdef HAVE___SREFILL
     42#if defined HAVE___SREFILL
    4443int __srefill(FILE *fp);
    4544#endif
     
    4746/* Library functions that we divert */
    4847static FILE *  (*fopen_orig)    (const char *path, const char *mode);
    49 #ifdef HAVE_FOPEN64
     48#if defined HAVE_FOPEN64
    5049static FILE *  (*fopen64_orig)  (const char *path, const char *mode);
    5150#endif
     
    5352                                 FILE *stream);
    5453static int     (*fseek_orig)    (FILE *stream, long offset, int whence);
    55 #ifdef HAVE_FSEEKO
     54#if defined HAVE_FSEEKO
    5655static int     (*fseeko_orig)   (FILE *stream, off_t offset, int whence);
    5756#endif
     
    6160static int     (*getc_orig)     (FILE *stream);
    6261static int     (*fgetc_orig)    (FILE *stream);
    63 #ifdef HAVE__IO_GETC
     62#if defined HAVE__IO_GETC
    6463static int     (*_IO_getc_orig) (FILE *stream);
    6564#endif
     
    6968
    7069/* Additional GNUisms */
    71 #ifdef HAVE_GETLINE
     70#if defined HAVE_GETLINE
    7271static ssize_t (*getline_orig)    (char **lineptr, size_t *n, FILE *stream);
    7372#endif
    74 #ifdef HAVE_GETDELIM
     73#if defined HAVE_GETDELIM
    7574static ssize_t (*getdelim_orig)   (char **lineptr, size_t *n, int delim,
    7675                                   FILE *stream);
    7776#endif
    78 #ifdef HAVE___GETDELIM
     77#if defined HAVE___GETDELIM
    7978static ssize_t (*__getdelim_orig) (char **lineptr, size_t *n, int delim,
    8079                                   FILE *stream);
     
    8281
    8382/* Additional BSDisms */
    84 #ifdef HAVE_FGETLN
     83#if defined HAVE_FGETLN
    8584static char *  (*fgetln_orig)    (FILE *stream, size_t *len);
    8685#endif
    87 #ifdef HAVE___SREFILL
     86#if defined HAVE___SREFILL
    8887int            (*__srefill_orig) (FILE *fp);
    8988#endif
     
    112111}
    113112
    114 #ifdef HAVE_FOPEN64
     113#if defined HAVE_FOPEN64
    115114FILE *fopen64(const char *path, const char *mode)
    116115{
     
    192191}
    193192
    194 #ifdef HAVE_FSEEKO
     193#if defined HAVE_FSEEKO
    195194int fseeko(FILE *stream, off_t offset, int whence)
    196195{
     
    302301}
    303302
    304 #ifdef HAVE__IO_GETC
     303#if defined HAVE__IO_GETC
    305304int _IO_getc(FILE *stream)
    306305{
     
    469468    } while(0)
    470469
    471 #ifdef HAVE_GETLINE
     470#if defined HAVE_GETLINE
    472471ssize_t getline(char **lineptr, size_t *n, FILE *stream)
    473472{
     
    476475#endif
    477476
    478 #ifdef HAVE_GETDELIM
     477#if defined HAVE_GETDELIM
    479478ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream)
    480479{
     
    483482#endif
    484483
    485 #ifdef HAVE___GETDELIM
     484#if defined HAVE___GETDELIM
    486485ssize_t __getdelim(char **lineptr, size_t *n, int delim, FILE *stream)
    487486{
     
    490489#endif
    491490
    492 #ifdef HAVE_FGETLN
     491#if defined HAVE_FGETLN
    493492char *fgetln(FILE *stream, size_t *len)
    494493{
     
    545544#endif
    546545
    547 #ifdef HAVE___SREFILL
     546#if defined HAVE___SREFILL
    548547int __srefill(FILE *fp)
    549548{
  • zzuf/trunk/src/libzzuf.c

    r1694 r1695  
    3333
    3434#include <stdarg.h>
    35 #include <dlfcn.h>
    3635
    3736#include "libzzuf.h"
  • zzuf/trunk/src/zzuf.c

    r1692 r1695  
    2424#   include <inttypes.h>
    2525#endif
    26 #if defined(HAVE_GETOPT_H)
     26#if defined HAVE_GETOPT_H
    2727#   include <getopt.h>
    2828#endif
     
    3030#include <stdlib.h>
    3131#include <unistd.h>
    32 #include <regex.h>
     32#if defined HAVE_REGEX_H
     33#   include <regex.h>
     34#endif
    3335#include <string.h>
    3436#include <errno.h>
    3537#include <signal.h>
    36 #include <sys/wait.h>
     38#if defined HAVE_SYS_WAIT_H
     39#   include <sys/wait.h>
     40#endif
    3741#include <sys/time.h>
    38 #include <sys/resource.h>
     42#if defined HAVE_SYS_RESOURCE_H
     43#   include <sys/resource.h>
     44#endif
    3945
    4046#include "libzzuf.h"
     
    4652#include "timer.h"
    4753
     54#if !defined SIGKILL
     55#   define SIGKILL 9
     56#endif
     57
    4858static void loop_stdin(struct opts *opts);
    4959
     
    5363
    5464static char const *sig2str(int);
     65#if defined HAVE_REGEX_H
    5566static char *merge_regex(char *, char *);
    5667static char *merge_file(char *, char *);
     68#endif
    5769static void set_environment(char const *);
    5870static void version(void);
    59 #if defined(HAVE_GETOPT_H)
     71#if defined HAVE_GETOPT_H
    6072static void usage(void);
    6173#endif
     
    7587{
    7688    struct opts _opts, *opts = &_opts;
    77     char *tmp, *include, *exclude;
    78     int i, cmdline = 0;
    79 
    80     include = exclude = NULL;
     89    char *tmp;
     90#if defined HAVE_REGEX_H
     91    char *include = NULL, *exclude = NULL;
     92    int cmdline = 0;
     93#endif
     94    int i;
    8195
    8296    _zz_opts_init(opts);
    8397
    84 #if defined(HAVE_GETOPT_H)
     98#if defined HAVE_GETOPT_H
    8599    for(;;)
    86100    {
    87 #   define OPTSTR "AB:cC:dD:E:F:iI:mM:nP:qr:R:s:ST:vxhV"
    88 #   ifdef HAVE_GETOPT_LONG
     101#   if defined HAVE_REGEX_H
     102#       define OPTSTR "AB:cC:dD:E:F:iI:mM:nP:qr:R:s:ST:vxhV"
     103#   else
     104#       define OPTSTR "AB:C:dD:F:imM:nP:qr:R:s:ST:vxhV"
     105#   endif
     106#   if defined HAVE_GETOPT_LONG
    89107#       define MOREINFO "Try `%s --help' for more information.\n"
    90108        int option_index = 0;
     
    94112            { "autoinc",     0, NULL, 'A' },
    95113            { "max-bytes",   1, NULL, 'B' },
     114#if defined HAVE_REGEX_H
    96115            { "cmdline",     0, NULL, 'c' },
     116#endif
    97117            { "max-crashes", 1, NULL, 'C' },
    98118            { "debug",       0, NULL, 'd' },
    99119            { "delay",       1, NULL, 'D' },
     120#if defined HAVE_REGEX_H
    100121            { "exclude",     1, NULL, 'E' },
     122#endif
    101123            { "max-forks",   1, NULL, 'F' },
    102124            { "stdin",       0, NULL, 'i' },
     125#if defined HAVE_REGEX_H
    103126            { "include",     1, NULL, 'I' },
     127#endif
    104128            { "md5",         0, NULL, 'm' },
    105129            { "max-memory",  1, NULL, 'M' },
     
    134158            opts->maxbytes = atoi(optarg);
    135159            break;
     160#if defined HAVE_REGEX_H
    136161        case 'c': /* --cmdline */
    137162            cmdline = 1;
    138163            break;
     164#endif
    139165        case 'C': /* --max-crashes */
    140166            opts->maxcrashes = atoi(optarg);
     
    148174            opts->delay = (int64_t)(atof(optarg) * 1000000.0);
    149175            break;
     176#if defined HAVE_REGEX_H
    150177        case 'E': /* --exclude */
    151178            exclude = merge_regex(exclude, optarg);
     
    157184            }
    158185            break;
     186#endif
    159187        case 'F': /* --max-forks */
    160188            opts->maxchild = atoi(optarg) > 1 ? atoi(optarg) : 1;
     
    163191            setenv("ZZUF_STDIN", "1", 1);
    164192            break;
     193#if defined HAVE_REGEX_H
    165194        case 'I': /* --include */
    166195            include = merge_regex(include, optarg);
     
    172201            }
    173202            break;
     203#endif
    174204        case 'm': /* --md5 */
    175205            opts->md5 = 1;
     
    255285
    256286    /* If asked to launch programs */
     287#if defined HAVE_REGEX_H
    257288    if(cmdline)
    258289    {
     
    274305    if(exclude)
    275306        setenv("ZZUF_EXCLUDE", exclude, 1);
     307#endif
     308
    276309    if(opts->protect)
    277310        setenv("ZZUF_PROTECT", opts->protect, 1);
     
    371404}
    372405
     406#if defined HAVE_REGEX_H
    373407static char *merge_file(char *regex, char *file)
    374408{
     
    418452    return regex;
    419453}
     454#endif
    420455
    421456static void spawn_children(struct opts *opts)
     
    770805}
    771806
    772 #if defined(HAVE_GETOPT_H)
     807#if defined HAVE_GETOPT_H
    773808static void usage(void)
    774809{
     810#if defined HAVE_REGEX_H
    775811    printf("Usage: zzuf [-AcdimnqSvx] [-r ratio] [-s seed | -s start:stop]\n");
    776812    printf("                          [-D delay] [-F forks] [-C crashes] [-B bytes]\n");
    777813    printf("                          [-T seconds] [-M bytes] [-P protect] [-R refuse]\n");
    778814    printf("                          [-I include] [-E exclude] [PROGRAM [--] [ARGS]...]\n");
    779 #   ifdef HAVE_GETOPT_LONG
     815#else
     816    printf("Usage: zzuf [-AdimnqSvx] [-r ratio] [-s seed | -s start:stop]\n");
     817    printf("                         [-D delay] [-F forks] [-C crashes] [-B bytes]\n");
     818    printf("                         [-T seconds] [-M bytes] [-P protect] [-R refuse]\n");
     819    printf("                         [PROGRAM [--] [ARGS]...]\n");
     820#endif
     821#   if defined HAVE_GETOPT_LONG
    780822    printf("       zzuf -h | --help\n");
    781823    printf("       zzuf -V | --version\n");
     
    787829    printf("\n");
    788830    printf("Mandatory arguments to long options are mandatory for short options too.\n");
    789 #   ifdef HAVE_GETOPT_LONG
     831#   if defined HAVE_GETOPT_LONG
    790832    printf("  -A, --autoinc             increment seed each time a new file is opened\n");
    791833    printf("  -B, --max-bytes <n>       kill children that output more than <n> bytes\n");
     834#if defined HAVE_REGEX_H
    792835    printf("  -c, --cmdline             only fuzz files specified in the command line\n");
     836#endif
    793837    printf("  -C, --max-crashes <n>     stop after <n> children have crashed (default 1)\n");
    794838    printf("  -d, --debug               print debug messages\n");
    795839    printf("  -D, --delay               delay between forks\n");
     840#if defined HAVE_REGEX_H
    796841    printf("  -E, --exclude <regex>     do not fuzz files matching <regex>\n");
     842#endif
    797843    printf("  -F, --max-forks <n>       number of concurrent children (default 1)\n");
    798844    printf("  -i, --stdin               fuzz standard input\n");
     845#if defined HAVE_REGEX_H
    799846    printf("  -I, --include <regex>     only fuzz files matching <regex>\n");
     847#endif
    800848    printf("  -m, --md5                 compute the output's MD5 hash\n");
    801849    printf("  -M, --max-memory <n>      maximum child virtual memory size in MB\n");
     
    817865    printf("  -A               increment seed each time a new file is opened\n");
    818866    printf("  -B <n>           kill children that output more than <n> bytes\n");
     867#if defined HAVE_REGEX_H
    819868    printf("  -c               only fuzz files specified in the command line\n");
     869#endif
    820870    printf("  -C <n>           stop after <n> children have crashed (default 1)\n");
    821871    printf("  -d               print debug messages\n");
    822872    printf("  -D               delay between forks\n");
     873#if defined HAVE_REGEX_H
    823874    printf("  -E <regex>       do not fuzz files matching <regex>\n");
     875#endif
    824876    printf("  -F <n>           number of concurrent forks (default 1)\n");
    825877    printf("  -i               fuzz standard input\n");
     878#if defined HAVE_REGEX_H
    826879    printf("  -I <regex>       only fuzz files matching <regex>\n");
     880#endif
    827881    printf("  -m               compute the output's MD5 hash\n");
    828882    printf("  -M               maximum child virtual memory size in MB\n");
Note: See TracChangeset for help on using the changeset viewer.