From 9d137b7976caa5176ac270bfee2bb6b57668cd03 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 10 Dec 2015 16:20:04 +0100 Subject: mostly splitting the source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/common.h | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/common.h (limited to 'src/common.h') diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000..93753b6 --- /dev/null +++ b/src/common.h @@ -0,0 +1,76 @@ +/** + * scrotty — Screenshot program for Linux's TTY + * + * Copyright © 2014, 2015 Mattias Andrée (maandree@member.fsf.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, either version 3 of the License, or + * (at your option) any later version. + * + * 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 . + */ +#define _POSIX_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#ifdef USE_GETTEXT +# include +# define _(STR) gettext (STR) +#else +# define _(STR) STR +#endif + + +#ifndef DEVDIR +# define DEVDIR "/dev" +#endif +#ifndef SYSDIR +# define SYSDIR "/sys" +#endif +#ifndef PATH_MAX /* TODO can we avoid this and still have clean code */ +# define PATH_MAX 4096 +#endif + + +/** + * Stores a filename to `failure_file` and goes to the label `fail`. + * + * @param PATH:char * The file that could not be used. + * Must be accessible by `main`. + */ +#define FILE_FAILURE(PATH) \ + do \ + { \ + failure_file = PATH; \ + goto fail; \ + } \ + while (0) + + +/** + * `argv[0]` from `main`. + */ +extern const char *execname; + +/** + * If a function fails when it tries to + * open a file, it will set this variable + * point to the pathname of that file. + */ +extern const char *failure_file; + -- cgit v1.2.3-70-g09d2