aboutsummaryrefslogtreecommitdiff
path: root/main.h
blob: 6436216168cd5e5a12de43d94b93e9090a8646f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 * Copyright 2005-2010 Gentoo Foundation
 * Distributed under the terms of the GNU General Public License v2
 * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.h,v 1.15 2011/12/19 20:27:36 vapier Exp $
 *
 * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
 * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
 */

#ifndef _q_static
# define _q_static static
#endif

/* make sure our buffers are as big as they can be */
#if PATH_MAX > _POSIX_PATH_MAX  /* _Q_PATH_MAX */
# define _Q_PATH_MAX PATH_MAX
#else
# define _Q_PATH_MAX _POSIX_PATH_MAX
#endif

/* http://tinderbox.dev.gentoo.org/default-linux/arm */
/* http://tinderbox.dev.gentoo.org/default-linux/hppa */

#ifdef __linux__
#undef  URL
#define URL "http://tinderbox.dev.gentoo.org"
# ifdef __i386__
#  ifdef __UCLIBC__
#   define DEFAULT_PORTAGE_BINHOST URL "/uclibc/i386"
#  else
#   ifdef __SSP__
#    define DEFAULT_PORTAGE_BINHOST URL "/hardened/x86"
#   else
#    define DEFAULT_PORTAGE_BINHOST URL "/default-linux/x86/All"
#   endif
#  endif
#  if defined(__powerpc__) && defined(__SSP__)
#   if !defined(__UCLIBC__)
#    define DEFAULT_PORTAGE_BINHOST URL "/hardened/ppc"
#   else
#    define DEFAULT_PORTAGE_BINHOST URL "/uclibc/ppc"
#   endif
#  endif
# endif
#endif

#ifndef DEFAULT_PORTAGE_BINHOST
# define DEFAULT_PORTAGE_BINHOST ""
#endif

#define qfprintf(stream, fmt, args...) do { if (!quiet) fprintf(stream, _( fmt ), ## args); } while (0)
#define qprintf(fmt, args...) qfprintf(stdout, _( fmt ), ## args)

#define _q_unused_ __attribute__((__unused__))

#ifndef BUFSIZE
# define BUFSIZE 8192
#endif

#ifdef EBUG
# define DBG(fmt, args...) warnf(fmt , ## args)
# define IF_DEBUG(x) x
#else
# define DBG(fmt, args...)
# define IF_DEBUG(x)
#endif

#define GETOPT_LONG(A, a, ex) \
	getopt_long(argc, argv, ex A ## _FLAGS, a ## _long_opts, NULL)

#ifndef MIN
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif
#ifndef MAX
#define MAX(x, y) ((x) < (y) ? (y) : (x))
#endif

#define a_argument required_argument

/* Easy enough to glue to older versions */
#ifndef O_CLOEXEC
# define O_CLOEXEC 0
#endif

#ifndef CONFIG_EPREFIX
#define CONFIG_EPREFIX "/"
#endif