/* * 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 2 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 Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "wrapper.h" static int verbose = 0; static int do_syslog = 0; void set_verbose_mode(int enable) { verbose = enable; } int get_verbose_mode() { return verbose; } void set_syslog_mode(int enable) { do_syslog = enable; } int get_syslog_mode() { return do_syslog; } void logmsg(int priority, const char * info, ...) { va_list args; va_start(args, info); if (get_verbose_mode()) { vfprintf(stderr, info, args); fprintf(stderr, "\n"); } if (get_syslog_mode()) vsyslog(priority, info, args); va_end(args); } int saferealloc(void **ptr_result, void *ptr, size_t s) { void *ptr_tmp = NULL; ptr_tmp = (void *)realloc(ptr, s); if (ptr_tmp == NULL) { logmsg(LOG_ERR, "saferealloc() : %s", strerror(errno)); return 0; } *ptr_result = ptr_tmp; return 1; }