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

Last change on this file since 1621 was 1621, checked in by Sam Hocevar, 14 years ago
  • Factor regex stuff into fd.c, so that <regex.h> isn’t needed otherwhere.
  • Property svn:keywords set to Id
File size: 2.1 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 1621 2007-01-07 21:14:26Z 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 <unistd.h>
29#include <stdlib.h>
30#include <string.h>
31#include <fcntl.h>
32
33#include <stdarg.h>
34#include <dlfcn.h>
35
36#include "libzzuf.h"
37#include "debug.h"
38#include "load.h"
39#include "fd.h"
40#include "fuzz.h"
41
42/* Global variables */
43int   _zz_ready    = 0;
44int   _zz_disabled = 0;
45int   _zz_hasdebug = 0;
46int   _zz_signal   = 0;
47int   _zz_network  = 0;
48
49/* Library initialisation shit */
50void _zz_init(void)
51{
52    char *tmp;
53
54    tmp = getenv("ZZUF_DEBUG");
55    if(tmp && *tmp == '1')
56        _zz_hasdebug = 1;
57
58    tmp = getenv("ZZUF_SEED");
59    if(tmp && *tmp)
60        _zz_setseed(atol(tmp));
61
62    tmp = getenv("ZZUF_RATIO");
63    if(tmp && *tmp)
64        _zz_setratio(atof(tmp));
65
66    tmp = getenv("ZZUF_PROTECT");
67    if(tmp && *tmp)
68        _zz_protect(tmp);
69
70    tmp = getenv("ZZUF_REFUSE");
71    if(tmp && *tmp)
72        _zz_refuse(tmp);
73
74    tmp = getenv("ZZUF_INCLUDE");
75    if(tmp && *tmp)
76        _zz_include(tmp);
77
78    tmp = getenv("ZZUF_EXCLUDE");
79    if(tmp && *tmp)
80        _zz_exclude(tmp);
81
82    tmp = getenv("ZZUF_SIGNAL");
83    if(tmp && *tmp == '1')
84        _zz_signal = 1;
85
86    tmp = getenv("ZZUF_NETWORK");
87    if(tmp && *tmp == '1')
88        _zz_network = 1;
89
90    _zz_fd_init();
91
92    tmp = getenv("ZZUF_STDIN");
93    if(tmp && *tmp == '1')
94        _zz_register(0);
95
96    _zz_load_fd();
97    _zz_load_signal();
98    _zz_load_stream();
99
100    _zz_ready = 1;
101
102    debug("libzzuf initialised");
103}
104
105/* Deinitialisation */
106void _zz_fini(void)
107{
108    _zz_fd_fini();
109}
110
Note: See TracBrowser for help on using the repository browser.