libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2010, 2013 Peter Miller 00004 * 00005 * This program is free software; you can redistribute it and/or modify it 00006 * under the terms of the GNU Lesser General Public License as published by 00007 * the Free Software Foundation; either version 3 of the License, or (at 00008 * your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, but 00011 * WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 00013 * General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #include <libexplain/buffer/errno/vfprintf.h> 00020 #include <libexplain/buffer/errno/vprintf.h> 00021 #include <libexplain/buffer/pathname.h> 00022 #include <libexplain/buffer/va_list.h> 00023 #include <libexplain/explanation.h> 00024 00025 00026 static void 00027 explain_buffer_errno_vprintf_system_call(explain_string_buffer_t *sb, 00028 int errnum, const char *format, va_list ap) 00029 { 00030 (void)errnum; 00031 explain_string_buffer_puts(sb, "vprintf(format = "); 00032 explain_buffer_pathname(sb, format); 00033 explain_string_buffer_puts(sb, ", ap = "); 00034 explain_buffer_va_list(sb, ap); 00035 explain_string_buffer_putc(sb, ')'); 00036 } 00037 00038 00039 void 00040 explain_buffer_errno_vprintf_explanation(explain_string_buffer_t *sb, 00041 int errnum, const char *syscall_name, const char *format, va_list ap) 00042 { 00043 /* 00044 * http://www.opengroup.org/onlinepubs/009695399/functions/vprintf.html 00045 */ 00046 explain_buffer_errno_vfprintf_explanation 00047 ( 00048 sb, 00049 errnum, 00050 syscall_name, 00051 stdout, 00052 format, 00053 ap 00054 ); 00055 } 00056 00057 00058 void 00059 explain_buffer_errno_vprintf(explain_string_buffer_t *sb, int errnum, const char 00060 *format, va_list ap) 00061 { 00062 explain_explanation_t exp; 00063 00064 explain_explanation_init(&exp, errnum); 00065 explain_buffer_errno_vprintf_system_call(&exp.system_call_sb, errnum, 00066 format, ap); 00067 explain_buffer_errno_vprintf_explanation(&exp.explanation_sb, errnum, 00068 "vprintf", format, ap); 00069 explain_explanation_assemble(&exp, sb); 00070 } 00071 00072 00073 /* vim: set ts=8 sw=4 et : */