Subversion Repositories freemyipod

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
445 theseven 1
/* macros for conversion between host and (internet) network byte order */
2
#ifndef WIN32
3
# include <netinet/in.h> /* Consts and structs defined by the internet system */
4
# define BINARY_FILE_OPTS
5
#else
6
# include <winsock2.h>
7
# define BINARY_FILE_OPTS "b"
8
#endif
9
 
10
#ifndef __WIN32
11
# include <sys/wait.h>
12
#endif
13
#ifndef WIFSIGNALED
14
# define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f)
15
#endif
16
#ifndef WTERMSIG
17
# define WTERMSIG(S) ((S) & 0x7f)
18
#endif
19
#ifndef WIFEXITED
20
# define WIFEXITED(S) (((S) & 0xff) == 0)
21
#endif
22
#ifndef WEXITSTATUS
23
# define WEXITSTATUS(S) (((S) & 0xff00) >> 8)
24
#endif
25
#ifndef WCOREDUMP
26
# define WCOREDUMP(S) ((S) & WCOREFLG)
27
#endif
28
#ifndef WCOREFLG
29
# define WCOREFLG 0200
30
#endif
31
#ifndef HAVE_STRSIGNAL
32
# define strsignal(sig) "SIG???"
33
#endif
34
 
35
#define streq(str1, str2) (strcmp(str1, str2) == 0)
36
#define streqn(str1, str2) (strncmp(str1, str2, strlen(str2)) == 0)
37
 
38
#ifndef DEBUG
39
# define DEBUG -1
40
#endif
41
#define _debug(lvl, fmt, args...) \
42
	do { \
43
		if (lvl <= DEBUG) { \
44
			fprintf(stderr, "%s:%i: " fmt, __func__, __LINE__ , ## args); \
45
			fflush(stderr); \
46
		} \
47
	} while (0)
48
#define debug2(...) _debug(2, __VA_ARGS__)
49
#define debug1(...) _debug(1, __VA_ARGS__)
50
#define debug0(...) _debug(0, __VA_ARGS__)
51
#define debug(...)  debug0(__VA_ARGS__)
52
 
53
#ifndef HAVE_GETLINE
54
ssize_t getline(char **line, size_t *alloc, FILE *in);
55
#endif
56
 
57
extern const char *elf2flt_progname;
58
 
59
void fatal(const char *, ...);
60
void fatal_perror(const char *, ...);
61
 
62
FILE *xfopen(const char *path, const char *mode);
63
 
64
/* Structure to hold a list of options */
65
typedef struct
66
{
67
  const char **options;
68
  size_t num;
69
  size_t alloc;
70
} options_t;
71
/* Initialize an options structure */
72
#define init_options(DST) ((DST)->options = NULL, (DST)->num = (DST)->alloc = 0)
73
void append_options(options_t *dst, const options_t *src);
74
void append_option(options_t *dst, const char *src);
75
void append_option_str(options_t *dst, const char *src, const char *delim);