diff options
author | 2019-03-18 14:11:41 +0100 | |
---|---|---|
committer | 2019-03-18 14:13:19 +0100 | |
commit | a221d981b4349b07d8b3869cb8ad2bb06d353a7a (patch) | |
tree | 1b3d480c25302c9d49d85884e292c10434421a99 /main.h | |
parent | q.c: move run_applet_l to its only consumer qmerge.c (diff) | |
download | portage-utils-a221d981b4349b07d8b3869cb8ad2bb06d353a7a.tar.gz portage-utils-a221d981b4349b07d8b3869cb8ad2bb06d353a7a.tar.bz2 portage-utils-a221d981b4349b07d8b3869cb8ad2bb06d353a7a.zip |
libq: standardise build
Compile each C-file by itself, producing an object which is linked into
a convenience archive. The q program then links against that archive.
Switch to autotools-based build for everyone.
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Diffstat (limited to 'main.h')
-rw-r--r-- | main.h | 49 |
1 files changed, 43 insertions, 6 deletions
@@ -7,17 +7,23 @@ * Copyright 2019- Fabian Groffen - <grobian@gentoo.org> */ -/* 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 +#ifndef _MAIN_H +#define _MAIN_H 1 + +#include "porting.h" +#include "i18n.h" +#include "colors.h" + +extern const char *argv0; #ifndef DEFAULT_PORTAGE_BINHOST # define DEFAULT_PORTAGE_BINHOST "" #endif +#ifndef CONFIG_EPREFIX +# define CONFIG_EPREFIX "/" +#endif + #define qfprintf(stream, fmt, args...) do { if (!quiet) fprintf(stream, _( fmt ), ## args); } while (0) #define qprintf(fmt, args...) qfprintf(stdout, _( fmt ), ## args) @@ -49,3 +55,34 @@ #define a_argument required_argument #define opt_argument optional_argument + +/* we need the space before the last comma or we trigger a bug in gcc-2 :( */ +FILE *warnout; +#if defined OPTIMIZE_FOR_SIZE && (OPTIMIZE_FOR_SIZE > 1) +#define warn(fmt, args...) +#else +#define warn(fmt, args...) \ + fprintf(warnout, _("%s%s%s: " fmt "\n"), RED, argv0, NORM , ## args) +#endif +#define warnf(fmt, args...) warn("%s%s()%s: " fmt, YELLOW, __func__, NORM , ## args) +#define warnl(fmt, args...) warn("%s%i()%s: " fmt, YELLOW, __LINE__, NORM , ## args) +#define warnp(fmt, args...) warn(fmt ": %s" , ## args , strerror(errno)) +#define warnfp(fmt, args...) warnf(fmt ": %s" , ## args , strerror(errno)) +#define _err(wfunc, fmt, args...) \ + do { \ + if (USE_CLEANUP) { \ + if (warnout != stderr) \ + fclose(warnout); \ + } \ + warnout = stderr; \ + wfunc(fmt , ## args); \ + exit(EXIT_FAILURE); \ + } while (0) +#define err(fmt, args...) _err(warn, fmt , ## args) +#define errf(fmt, args...) _err(warnf, fmt , ## args) +#define errp(fmt, args...) _err(warnp, fmt , ## args) +#define errfp(fmt, args...) _err(warnfp, fmt, ## args) + +int rematch(const char *, const char *, int); + +#endif |