| 1 | /* |
| 2 | * Copyright 2015 Red Hat Inc., Durham, North Carolina. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public |
| 16 | * License along with this library; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | * |
| 19 | * Authors: |
| 20 | * Jan Černý <[email protected]> |
| 21 | */ |
| 22 | |
| 23 | #ifndef OSCAP_DEBUG_H_ |
| 24 | #define OSCAP_DEBUG_H_ |
| 25 | |
| 26 | #include "oscap_export.h" |
| 27 | |
| 28 | typedef enum { |
| 29 | DBG_E = 1, |
| 30 | DBG_W, |
| 31 | DBG_I, |
| 32 | DBG_D, |
| 33 | DBG_UNKNOWN = -1 |
| 34 | } oscap_verbosity_levels; |
| 35 | |
| 36 | /** |
| 37 | * Version of the oscap_dprintf function with support for debug level. |
| 38 | * Uses logic similar to the debug() macro described above. |
| 39 | * @param level debug level |
| 40 | * @param file name of the source file |
| 41 | * @param fn name of the function |
| 42 | * @param line current line |
| 43 | * @param delta_indent changes indentation |
| 44 | * @param fmt printf-line format string |
| 45 | * @param ... __oscap_dlprintf parameters |
| 46 | */ |
| 47 | OSCAP_API void __oscap_dlprintf(int level, const char *file, const char *fn, size_t line, int delta_indent, const char *fmt, ...); |
| 48 | |
| 49 | /** |
| 50 | * Turn on debugging information |
| 51 | * @param verbosity_level Verbosity level |
| 52 | * @param filename Name of file used as output file for store debugging |
| 53 | * and other additional information. |
| 54 | * @return When an error occurred, returns false, otherwise true. |
| 55 | */ |
| 56 | OSCAP_API bool oscap_set_verbose(const char *verbosity_level, const char *filename); |
| 57 | |
| 58 | /** |
| 59 | * Parse verbosity level from a string. |
| 60 | * @param level_name Verbosity level as a C string. |
| 61 | * @return Verbosity level number (or -1 on error). |
| 62 | */ |
| 63 | OSCAP_API oscap_verbosity_levels oscap_verbosity_level_from_cstr(const char *level_name); |
| 64 | |
| 65 | /** |
| 66 | * Print an informational message (verbose level INFO) listing the values |
| 67 | * of all environment variables known by oscap. |
| 68 | * See the "List of accepted environment variables" section of the OpenSCAP User Manual. |
| 69 | */ |
| 70 | OSCAP_API void oscap_print_env_vars(void); |
| 71 | |
| 72 | #if defined(_WIN32) |
| 73 | int setenv(const char *name, const char *value, int overwrite); |
| 74 | #endif |
| 75 | |
| 76 | #endif |