mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 12:00:56 +01:00
64 lines
1.4 KiB
C
64 lines
1.4 KiB
C
/*
|
|
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>.
|
|
*/
|
|
|
|
|
|
#include "defines.h"
|
|
#include "platform.h"
|
|
|
|
#include <errno.h>
|
|
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
char *PCP_ERR;
|
|
byte PCP_ERRSET;
|
|
int PCP_EXIT;
|
|
|
|
void fatal(const char * fmt, ...) {
|
|
va_list ap;
|
|
va_start(ap, fmt);
|
|
|
|
vasprintf(&PCP_ERR, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
PCP_ERRSET = 1;
|
|
}
|
|
|
|
void fatals_reset() {
|
|
PCP_ERRSET = 0;
|
|
}
|
|
|
|
void fatals_ifany() {
|
|
if(PCP_ERRSET == 1) {
|
|
fprintf(stderr, PCP_ERR);
|
|
if(errno) {
|
|
fprintf(stderr, "Error: %s\n", strerror(errno));
|
|
}
|
|
PCP_EXIT = 1;
|
|
}
|
|
}
|
|
|
|
void fatals_done() {
|
|
free(PCP_ERR);
|
|
}
|