libexplain  1.4.D001
libexplain/buffer/errno/tcdrain.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - Explain errno values returned by libc functions
00003  * Copyright (C) 2009, 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
00012  * ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULesser
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/ebadf.h>
00022 #include <libexplain/buffer/enosys.h>
00023 #include <libexplain/buffer/errno/generic.h>
00024 #include <libexplain/buffer/errno/tcdrain.h>
00025 #include <libexplain/buffer/fildes.h>
00026 #include <libexplain/explanation.h>
00027 
00028 
00029 static void
00030 explain_buffer_errno_tcdrain_system_call(explain_string_buffer_t *sb, int
00031     errnum, int fildes)
00032 {
00033     (void)errnum;
00034     explain_string_buffer_puts(sb, "tcdrain(fildes = ");
00035     explain_buffer_fildes(sb, fildes);
00036     explain_string_buffer_putc(sb, ')');
00037 }
00038 
00039 
00040 void
00041 explain_buffer_errno_tcdrain_explanation(explain_string_buffer_t *sb, int
00042     errnum, const char *syscall_name, int fildes)
00043 {
00044     switch (errnum)
00045     {
00046     case EBADF:
00047         explain_buffer_ebadf(sb, fildes, "fildes");
00048         break;
00049 
00050     case ENOTTY:
00051     case ENOSYS:
00052 #if defined(EOPNOTSUPP) && EOPNOTSUPP != ENOSYS
00053     case EOPNOTSUPP:
00054 #endif
00055 #ifdef ENOIOCTLCMD
00056     case ENOIOCTLCMD:
00057 #endif
00058 #ifdef ENOIOCTL
00059     case ENONOIOCTL:
00060 #endif
00061         explain_buffer_enosys_fildes(sb, fildes, "fildes", syscall_name);
00062         break;
00063 
00064     default:
00065         explain_buffer_errno_generic(sb, errnum, syscall_name);
00066         break;
00067     }
00068 }
00069 
00070 
00071 void
00072 explain_buffer_errno_tcdrain(explain_string_buffer_t *sb, int errnum, int
00073     fildes)
00074 {
00075     explain_explanation_t exp;
00076 
00077     explain_explanation_init(&exp, errnum);
00078     explain_buffer_errno_tcdrain_system_call(&exp.system_call_sb, errnum,
00079         fildes);
00080     explain_buffer_errno_tcdrain_explanation(&exp.explanation_sb, errnum,
00081         "tcdrain", fildes);
00082     explain_explanation_assemble(&exp, sb);
00083 }
00084 
00085 
00086 /* vim: set ts=8 sw=4 et : */