diff --git a/src/callbacks.c b/src/callbacks.c index 333f1ee..3feed12 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -18,15 +18,11 @@ #include #include #include +#include "common.h" #include "pdfviewer.h" #include "callbacks.h" #include "../config.h" -/* constants */ -#ifndef PROGNAME -# define PROGNAME "pdfviewer" -#endif - /* public */ /* functions */ @@ -43,7 +39,7 @@ gboolean on_closex(gpointer data) /* on_contents */ void on_contents(gpointer data) { - desktop_help_contents(PACKAGE, PROGNAME); + desktop_help_contents(PACKAGE, PROGNAME_PDFVIEWER); } diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000..33eefd8 --- /dev/null +++ b/src/common.h @@ -0,0 +1,26 @@ +/* $Id$ */ +/* Copyright (c) 2020 Pierre Pronchery */ +/* This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +#ifndef PDFVIEWER_COMMON_H +# define PDFVIEWER_COMMON_H + + +/* constants */ +# ifndef PROGNAME_PDFVIEWER +# define PROGNAME_PDFVIEWER "pdfviewer" +#endif + +#endif /* !PDFVIEWER_COMMON_H */ diff --git a/src/main.c b/src/main.c index 281a7d9..49e3054 100644 --- a/src/main.c +++ b/src/main.c @@ -17,14 +17,12 @@ #include #include #include +#include "common.h" #include "pdfviewer.h" #include "../config.h" #define _(string) gettext(string) /* constants */ -#ifndef PROGNAME -# define PROGNAME "pdfviewer" -#endif #ifndef PREFIX # define PREFIX "/usr/local" #endif @@ -46,7 +44,7 @@ static int _usage(void); /* error */ static int _error(char const * message, int ret) { - fputs(PROGNAME ": ", stderr); + fputs(PROGNAME_PDFVIEWER ": ", stderr); perror(message); return ret; } @@ -55,7 +53,7 @@ static int _error(char const * message, int ret) /* usage */ static int _usage(void) { - fprintf(stderr, _("Usage: %s [file]\n"), PROGNAME); + fprintf(stderr, _("Usage: %s [file]\n"), PROGNAME_PDFVIEWER); return 1; } diff --git a/src/pdfviewer.c b/src/pdfviewer.c index daf6205..a32f80f 100644 --- a/src/pdfviewer.c +++ b/src/pdfviewer.c @@ -28,16 +28,12 @@ static char const _license[] = #include #include #include "callbacks.h" +#include "common.h" #include "pdfviewer.h" #include "../config.h" #define _(string) gettext(string) #define N_(string) (string) -/* constants */ -#ifndef PROGNAME -# define PROGNAME "pdfviewer" -#endif - /* PDFviewer */ /* private */ @@ -562,8 +558,8 @@ int pdf_open(PDFviewer * pdfviewer, const char * filename) { if(error != NULL) { - fprintf(stderr, PROGNAME ": %s: %s\n", filename, - error->message); + fprintf(stderr, PROGNAME_PDFVIEWER ": %s: %s\n", + filename, error->message); g_error_free(error); } g_free(pdf); diff --git a/src/project.conf b/src/project.conf index 79a71a2..6011a67 100644 --- a/src/project.conf +++ b/src/project.conf @@ -4,15 +4,20 @@ cflags_force=`pkg-config --cflags libDesktop poppler-glib` cflags=-W -Wall -g -O2 -pedantic -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector ldflags_force=`pkg-config --libs libDesktop poppler-glib` -lm ldflags=-pie -Wl,-z,relro -Wl,-z,now -dist=Makefile,callbacks.h,pdfviewer.h +dist=Makefile,callbacks.h,common.h,pdfviewer.h +#targets [pdfviewer] type=binary sources=callbacks.c,pdfviewer.c,main.c install=$(BINDIR) +#sources [callbacks.c] -depends=callbacks.h +depends=callbacks.h,common.h + +[main.c] +depends=common.h,pdfviewer.h [pdfviewer.c] -depends=callbacks.h,pdfviewer.h,../config.h +depends=callbacks.h,common.h,pdfviewer.h,../config.h