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/ac/errno.h> 00020 #include <libexplain/ac/stdio.h> 00021 00022 #include <libexplain/buffer/errno/printf.h> 00023 #include <libexplain/common_message_buffer.h> 00024 #include <libexplain/printf.h> 00025 00026 00027 const char * 00028 explain_printf(const char *format, ...) 00029 { 00030 int errnum; 00031 va_list ap; 00032 explain_string_buffer_t sb; 00033 00034 va_start(ap, format); 00035 errnum = errno; 00036 explain_string_buffer_init 00037 ( 00038 &sb, 00039 explain_common_message_buffer, 00040 explain_common_message_buffer_size 00041 ); 00042 explain_buffer_errno_printf(&sb, errnum, format, ap); 00043 va_end(ap); 00044 return explain_common_message_buffer; 00045 } 00046 00047 00048 const char * 00049 explain_errno_printf(int errnum, const char *format, ...) 00050 { 00051 va_list ap; 00052 explain_string_buffer_t sb; 00053 00054 va_start(ap, format); 00055 explain_string_buffer_init 00056 ( 00057 &sb, 00058 explain_common_message_buffer, 00059 explain_common_message_buffer_size 00060 ); 00061 explain_buffer_errno_printf(&sb, errnum, format, ap); 00062 va_end(ap); 00063 return explain_common_message_buffer; 00064 } 00065 00066 00067 void 00068 explain_message_printf(char *message, int message_size, const char *format, ...) 00069 { 00070 int errnum; 00071 va_list ap; 00072 explain_string_buffer_t sb; 00073 00074 va_start(ap, format); 00075 errnum = errno; 00076 explain_string_buffer_init(&sb, message, message_size); 00077 explain_buffer_errno_printf(&sb, errnum, format, ap); 00078 va_end(ap); 00079 } 00080 00081 00082 void 00083 explain_message_errno_printf(char *message, int message_size, int errnum, 00084 const char *format, ...) 00085 { 00086 va_list ap; 00087 explain_string_buffer_t sb; 00088 00089 va_start(ap, format); 00090 explain_string_buffer_init(&sb, message, message_size); 00091 explain_buffer_errno_printf(&sb, errnum, format, ap); 00092 va_end(ap); 00093 } 00094 00095 00096 /* vim: set ts=8 sw=4 et : */