ref: 3bc1ca00562af4c7c3d287ae44181f02c361adb3
dir: /src/print.c/
/* This file is part of REWise. * * REWise 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. * * REWise 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 <https://www.gnu.org/licenses/>. */ #include <stdio.h> #include <stdarg.h> #include "print.h" static enum __PrintFlags PrintFlags = (PRINT_INFO | PRINT_WARNING | PRINT_ERROR); void setPrintFlags(enum __PrintFlags flags) { PrintFlags = flags; } void setPrintFlag(enum __PrintFlags flag) { PrintFlags |= flag; } void unsetPrintFlag(enum __PrintFlags flag) { PrintFlags &= ~flag; } void printInfo(const char * fmt, ...) { if (PrintFlags & PRINT_INFO) { va_list args; va_start (args, fmt); fprintf(stdout, "INFO: "); vfprintf(stdout, fmt, args); va_end(args); } } void printWarning(const char * fmt, ...) { if (PrintFlags & PRINT_WARNING) { va_list args; va_start (args, fmt); fprintf(stderr, "WARNING: "); vfprintf(stderr, fmt, args); va_end(args); } } void printError(const char * fmt, ...) { if (PrintFlags & PRINT_ERROR) { va_list args; va_start (args, fmt); fprintf(stderr, "ERROR: "); vfprintf(stderr, fmt, args); va_end(args); } } void printDebug(const char * fmt, ...) { if (PrintFlags & PRINT_DEBUG) { fprintf(stderr, "DEBUG: "); va_list args; va_start (args, fmt); vfprintf(stderr, fmt, args); va_end(args); } }