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 00021 #include <libexplain/buffer/address_family.h> 00022 #include <libexplain/buffer/efault.h> 00023 #include <libexplain/buffer/errno/socket.h> 00024 #include <libexplain/buffer/errno/socketpair.h> 00025 #include <libexplain/buffer/pointer.h> 00026 #include <libexplain/buffer/socket_protocol.h> 00027 #include <libexplain/buffer/socket_type.h> 00028 #include <libexplain/explanation.h> 00029 00030 00031 static void 00032 explain_buffer_errno_socketpair_system_call(explain_string_buffer_t *sb, int 00033 errnum, int domain, int type, int protocol, int *sv) 00034 { 00035 (void)errnum; 00036 explain_string_buffer_puts(sb, "socketpair(domain = "); 00037 explain_buffer_address_family(sb, domain); 00038 explain_string_buffer_puts(sb, ", type = "); 00039 explain_buffer_socket_type(sb, type); 00040 explain_string_buffer_puts(sb, ", protocol = "); 00041 explain_buffer_socket_protocol(sb, protocol); 00042 explain_string_buffer_puts(sb, ", sv = "); 00043 explain_buffer_pointer(sb, sv); 00044 explain_string_buffer_putc(sb, ')'); 00045 } 00046 00047 00048 void 00049 explain_buffer_errno_socketpair_explanation(explain_string_buffer_t *sb, 00050 int errnum, const char *syscall_name, int domain, int type, int protocol, 00051 int *sv) 00052 { 00053 /* 00054 * http://www.opengroup.org/onlinepubs/009695399/functions/socketpair.html 00055 */ 00056 (void)sv; 00057 switch (errnum) 00058 { 00059 case EFAULT: 00060 explain_buffer_efault(sb, "sv"); 00061 break; 00062 00063 default: 00064 explain_buffer_errno_socket_explanation 00065 ( 00066 sb, 00067 errnum, 00068 syscall_name, 00069 domain, 00070 type, 00071 protocol 00072 ); 00073 break; 00074 } 00075 } 00076 00077 00078 void 00079 explain_buffer_errno_socketpair(explain_string_buffer_t *sb, int errnum, int 00080 domain, int type, int protocol, int *sv) 00081 { 00082 explain_explanation_t exp; 00083 00084 explain_explanation_init(&exp, errnum); 00085 explain_buffer_errno_socketpair_system_call 00086 ( 00087 &exp.system_call_sb, 00088 errnum, 00089 domain, 00090 type, 00091 protocol, 00092 sv 00093 ); 00094 explain_buffer_errno_socketpair_explanation 00095 ( 00096 &exp.explanation_sb, 00097 errnum, 00098 "socketpair", 00099 domain, 00100 type, 00101 protocol, 00102 sv 00103 ); 00104 explain_explanation_assemble(&exp, sb); 00105 } 00106 00107 00108 /* vim: set ts=8 sw=4 et : */