Move common definitions to a single header file
This commit is contained in:
parent
dbc9a6a781
commit
a5e45a445f
|
@ -18,15 +18,11 @@
|
|||
#include <stdlib.h>
|
||||
#include <libintl.h>
|
||||
#include <Desktop.h>
|
||||
#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);
|
||||
}
|
||||
|
||||
|
||||
|
|
26
src/common.h
Normal file
26
src/common.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2020 Pierre Pronchery <khorben@defora.org> */
|
||||
/* 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 <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
|
||||
#ifndef PDFVIEWER_COMMON_H
|
||||
# define PDFVIEWER_COMMON_H
|
||||
|
||||
|
||||
/* constants */
|
||||
# ifndef PROGNAME_PDFVIEWER
|
||||
# define PROGNAME_PDFVIEWER "pdfviewer"
|
||||
#endif
|
||||
|
||||
#endif /* !PDFVIEWER_COMMON_H */
|
|
@ -17,14 +17,12 @@
|
|||
#include <stdio.h>
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
#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;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,16 +28,12 @@ static char const _license[] =
|
|||
#include <System.h>
|
||||
#include <Desktop.h>
|
||||
#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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user