libexplain  1.4.D001
libexplain/buffer/einval.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - Explain errno values returned by libc functions
00003  * Copyright (C) 2008, 2009, 2011, 2013 Peter Miller
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU Lesser General Public License as
00007  * published by the Free Software Foundation; either version 3 of the
00008  * License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser 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/einval.h>
00020 
00021 
00022 void
00023 explain_buffer_einval_bits(explain_string_buffer_t *sb,
00024     const char *caption)
00025 {
00026     explain_string_buffer_printf_gettext
00027     (
00028         sb,
00029         /*
00030          * xgettext: This message is used when explaining an EINVAL
00031          * error returned by a system call that is complaining about
00032          * undefined bits in a bitfield argument, e.g. access(2).
00033          *
00034          * %1$s => the name of the offending system call argument
00035          */
00036         i18n("the %s argument was incorrectly specified, it contained "
00037             "undefined bits"),
00038         caption
00039     );
00040 }
00041 
00042 
00043 void
00044 explain_buffer_einval_too_small(explain_string_buffer_t *sb,
00045     const char *caption, long value)
00046 {
00047     if (value < 0)
00048     {
00049         explain_string_buffer_printf_gettext
00050         (
00051             sb,
00052             /*
00053              * xgettext: This message is used when explaining an EINVAL
00054              * error returned by a system call that is complaining about a
00055              * size being too small or negative (e.g. bind's sock_addr_size
00056              * field).
00057              *
00058              * %1$s => the name of the offending system call argument
00059              */
00060             i18n("the %s argument was incorrectly specified, it was negative"),
00061             caption
00062         );
00063     }
00064     else
00065     {
00066         explain_string_buffer_printf_gettext
00067         (
00068             sb,
00069             /*
00070              * xgettext: This message is used when explaining an EINVAL
00071              * error returned by a system call that is complaining about a
00072              * size being too small or negative (e.g. bind's sock_addr_size
00073              * field).
00074              *
00075              * %1$s => the name of the offending system call argument
00076              */
00077             i18n("the %s argument was incorrectly specified, it was too small"),
00078             caption
00079         );
00080     }
00081 }
00082 
00083 
00084 void
00085 explain_buffer_einval_vague(explain_string_buffer_t *sb,
00086     const char *caption)
00087 {
00088     explain_string_buffer_printf_gettext
00089     (
00090         sb,
00091         /*
00092          * xgettext: This message is used when an argument of a
00093          * system call results in an EINVAL error being reported.
00094          *
00095          * %1$s => the name of the offending system call argument.
00096          */
00097         i18n("the %s argument was incorrectly specified"),
00098         caption
00099     );
00100 }
00101 
00102 
00103 void
00104 explain_buffer_einval_value(explain_string_buffer_t *sb,
00105     const char *caption, long value)
00106 {
00107     explain_buffer_einval_vague(sb, caption);
00108     explain_string_buffer_printf(sb, " (%ld)", value);
00109 }
00110 
00111 
00112 void
00113 explain_buffer_einval_not_a_number(explain_string_buffer_t *sb,
00114     const char *caption)
00115 {
00116     explain_string_buffer_printf_gettext
00117     (
00118         sb,
00119         /*
00120          * xgettext: This error message is issued when a call to
00121          * strtol is given a string containing no digits.
00122          * Similarly for related functions.
00123          *
00124          * %1$s => the name of the offending system call argument
00125          */
00126         i18n("the %s argument does not appear to be a number"),
00127         caption
00128     );
00129 }
00130 
00131 
00132 /* vim: set ts=8 sw=4 et : */