2 * Main functions of the program.
4 * Copyright (C) 2007 David Härdeman <david@hardeman.nu>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation version 2 of the License.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 /* Adjusts the verbosity level for msg() */
29 void adjust_verbosity(int adj
);
31 /* Verbosity levels using stdout */
35 /* Verbosity levels using stderr */
37 #define MSG_CRITICAL -3
39 /* Prints messages to console according to the current verbosity */
40 int msg(int level
, const char *fmt
, ...);
42 /* Malloc which either succeeds or exits */
43 void *xmalloc(size_t size
);
45 /* Ditto for strdup */
46 char *xstrdup(const char *s
);
48 /* Human-readable printout of binary data */
49 void binary_print(const char *s
, ssize_t len
);
51 /* Writes data to a file or exits on failure */
52 void xfwrite(const void *ptr
, size_t size
, FILE *stream
);
54 /* Writes an int to a file, using len bytes, in bigendian order */
55 void write_int(uint64_t value
, size_t len
, FILE *to
);
57 /* Writes a binary string to a file */
58 void write_binary_string(const char *string
, size_t len
, FILE *to
);
60 /* Writes a normal C string to a file */
61 void write_string(const char *string
, FILE *to
);
63 /* Reads an int from a file, using len bytes, in bigendian order */
64 uint64_t read_int(char **from
, size_t len
, const char *max
);
66 /* Reads a binary string from a file */
67 char *read_binary_string(char **from
, size_t len
, const char *max
);
69 /* Reads a normal C string from a file */
70 char *read_string(char **from
, const char *max
);