libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2010-2013 Peter Miller 00004 * Written by Peter Miller <pmiller@opensource.org.au> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as 00008 * published by the Free Software Foundation; either version 3 of the 00009 * License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef LIBEXPLAIN_OUTPUT_H 00021 #define LIBEXPLAIN_OUTPUT_H 00022 00023 #include <libexplain/gcc_attributes.h> 00024 00025 #ifdef __cplusplus 00026 extern "C" { 00027 #endif 00028 00090 typedef struct explain_output_t explain_output_t; 00091 00098 struct explain_output_t 00099 { 00104 const struct explain_output_vtable_t *vtable; 00105 00114 int exit_has_been_used; 00115 }; 00116 00121 typedef struct explain_output_vtable_t explain_output_vtable_t; 00122 00127 struct explain_output_vtable_t 00128 { 00136 void (*destructor)(explain_output_t *op); 00137 00148 void (*message)(explain_output_t *op, const char *text); 00149 00165 void (*exit)(explain_output_t *op, int status); 00166 00172 unsigned int size; 00173 }; 00174 00186 explain_output_t *explain_output_new(const explain_output_vtable_t *vtable); 00187 00215 explain_output_t *explain_output_stderr_new(void); 00216 00232 explain_output_t *explain_output_syslog_new(void); 00233 00250 explain_output_t *explain_output_syslog_new1(int level); 00251 00269 explain_output_t *explain_output_syslog_new3(int option, int facility, 00270 int level); 00271 00286 explain_output_t *explain_output_file_new(const char *filename, int append); 00287 00307 explain_output_t *explain_output_tee_new(explain_output_t *first, 00308 explain_output_t *second); 00309 00319 void explain_output_message(const char *text); 00320 00346 void explain_output_error(const char *fmt, ...) 00347 LIBEXPLAIN_FORMAT_PRINTF(1, 2); 00348 00358 void explain_output_error_and_die(const char *fmt, ...) 00359 LIBEXPLAIN_FORMAT_PRINTF(1, 2) 00360 LIBEXPLAIN_NORETURN; 00361 00386 void explain_output_warning(const char *fmt, ...) 00387 LIBEXPLAIN_FORMAT_PRINTF(1, 2); 00388 00399 void explain_output_method_message(explain_output_t *op, const char *text); 00400 00409 void explain_output_exit(int status) LIBEXPLAIN_NORETURN; 00410 00416 void explain_output_exit_failure(void) LIBEXPLAIN_NORETURN; 00417 00427 void explain_output_method_exit(explain_output_t *op, int status) 00428 LIBEXPLAIN_NORETURN; 00429 00448 void explain_output_register(explain_output_t *op); 00449 00462 void explain_output_method_destructor(explain_output_t *op); 00463 00475 void explain_program_name_assemble(int yesno); 00476 00496 void explain_option_hanging_indent_set(int columns); 00497 00498 #ifdef __cplusplus 00499 } 00500 #endif 00501 00502 #endif /* LIBEXPLAIN_OUTPUT_H */ 00503 /* vim: set ts=8 sw=4 et : */