source: zzuf/trunk/src/libzzuf.c @ 1695

Last change on this file since 1695 was 1695, checked in by Sam Hocevar, 14 years ago
  • Added enough autoconf checks and #ifdefs so that libzzuf builds on Win32. zzuf itself doesn't build yet, though.
  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1/*
2 *  zzuf - general purpose fuzzer
3 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: libzzuf.c 1695 2007-01-18 00:21:07Z sam $
7 *
8 *  This program is free software. It comes without any warranty, to
9 *  the extent permitted by applicable law. You can redistribute it
10 *  and/or modify it under the terms of the Do What The Fuck You Want
11 *  To Public License, Version 2, as published by Sam Hocevar. See
12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13 */
14
15/*
16 *  libzzuf.c: preloaded wrapper library
17 */
18
19#include "config.h"
20#define _GNU_SOURCE
21
22#if defined HAVE_STDINT_H
23#   include <stdint.h>
24#elif defined HAVE_INTTYPES_H
25#   include <inttypes.h>
26#endif
27#include <stdio.h>
28#include <sys/types.h>
29#include <unistd.h>
30#include <stdlib.h>
31#include <string.h>
32#include <fcntl.h>
33
34#include <stdarg.h>
35
36#include "libzzuf.h"
37#include "debug.h"
38#include "fd.h"
39#include "fuzz.h"
40
41/* Global variables */
42int   _zz_ready    = 0;
43int   _zz_hasdebug = 0;
44int   _zz_signal   = 0;
45int   _zz_memory   = 0;
46int   _zz_network  = 0;
47
48/* Library initialisation shit */
49void _zz_init(void)
50{
51    char *tmp, *tmp2;
52
53    tmp = getenv("ZZUF_DEBUG");
54    if(tmp && *tmp == '1')
55        _zz_hasdebug = 1;
56
57    tmp = getenv("ZZUF_SEED");
58    if(tmp && *tmp)
59        _zz_setseed(atol(tmp));
60
61    tmp = getenv("ZZUF_MINRATIO");
62    tmp2 = getenv("ZZUF_MAXRATIO");
63    if(tmp && *tmp && tmp2 && *tmp2)
64        _zz_setratio(atof(tmp), atof(tmp2));
65
66    tmp = getenv("ZZUF_AUTOINC");
67    if(tmp && *tmp == '1')
68        _zz_setautoinc();
69
70    tmp = getenv("ZZUF_PROTECT");
71    if(tmp && *tmp)
72        _zz_protect(tmp);
73
74    tmp = getenv("ZZUF_REFUSE");
75    if(tmp && *tmp)
76        _zz_refuse(tmp);
77
78    tmp = getenv("ZZUF_INCLUDE");
79    if(tmp && *tmp)
80        _zz_include(tmp);
81
82    tmp = getenv("ZZUF_EXCLUDE");
83    if(tmp && *tmp)
84        _zz_exclude(tmp);
85
86    tmp = getenv("ZZUF_SIGNAL");
87    if(tmp && *tmp == '1')
88        _zz_signal = 1;
89
90    tmp = getenv("ZZUF_MEMORY");
91    if(tmp && *tmp == '1')
92        _zz_memory = 1;
93
94    tmp = getenv("ZZUF_NETWORK");
95    if(tmp && *tmp == '1')
96        _zz_network = 1;
97
98    _zz_fd_init();
99
100    tmp = getenv("ZZUF_STDIN");
101    if(tmp && *tmp == '1')
102        _zz_register(0);
103
104    _zz_ready = 1;
105
106    debug("libzzuf initialised for PID %li", (long int)getpid());
107}
108
109/* Deinitialisation */
110void _zz_fini(void)
111{
112    _zz_fd_fini();
113}
114
Note: See TracBrowser for help on using the repository browser.