2013-11-04 17:43:22 +01:00
|
|
|
/*
|
|
|
|
|
This file is part of Pretty Curved Privacy (pcp1).
|
|
|
|
|
|
|
|
|
|
Copyright (C) 2013 T.Linden.
|
|
|
|
|
|
|
|
|
|
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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
You can contact me by mail: <tlinden AT cpan DOT org>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2013-10-28 22:50:05 +01:00
|
|
|
#include "defines.h"
|
2013-11-17 16:53:20 +01:00
|
|
|
#include "platform.h"
|
2013-10-28 22:50:05 +01:00
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2013-12-01 16:15:41 +01:00
|
|
|
char *PCP_ERR;
|
|
|
|
|
byte PCP_ERRSET;
|
|
|
|
|
int PCP_EXIT;
|
|
|
|
|
|
2013-10-28 22:50:05 +01:00
|
|
|
void fatal(const char * fmt, ...) {
|
|
|
|
|
va_list ap;
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
|
|
|
|
|
|
vasprintf(&PCP_ERR, fmt, ap);
|
|
|
|
|
|
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
|
|
PCP_ERRSET = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-02 11:02:36 +01:00
|
|
|
void fatals_reset() {
|
|
|
|
|
PCP_ERRSET = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-28 22:50:05 +01:00
|
|
|
void fatals_ifany() {
|
|
|
|
|
if(PCP_ERRSET == 1) {
|
|
|
|
|
fprintf(stderr, PCP_ERR);
|
|
|
|
|
if(errno) {
|
|
|
|
|
fprintf(stderr, "Error: %s\n", strerror(errno));
|
|
|
|
|
}
|
|
|
|
|
PCP_EXIT = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-13 20:19:32 +01:00
|
|
|
|
|
|
|
|
void fatals_done() {
|
|
|
|
|
free(PCP_ERR);
|
|
|
|
|
}
|