From a221d981b4349b07d8b3869cb8ad2bb06d353a7a Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Mon, 18 Mar 2019 14:11:41 +0100 Subject: 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 --- main.h | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'main.h') diff --git a/main.h b/main.h index c409057..2508c86 100644 --- a/main.h +++ b/main.h @@ -7,17 +7,23 @@ * Copyright 2019- Fabian Groffen - */ -/* 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 -- cgit v1.2.3-65-gdbad