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 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/ac/limits.h> /* for PATH_MAX on Solaris */ 00020 #include <libexplain/ac/sys/param.h> /* for PATH_MAX except Solaris */ 00021 #include <libexplain/ac/stdio.h> 00022 00023 #include <libexplain/buffer/eexist.h> 00024 #include <libexplain/dirname.h> 00025 #include <libexplain/option.h> 00026 00027 00028 void 00029 explain_buffer_eexist_tempname(explain_string_buffer_t *sb, 00030 const char *directory) 00031 { 00032 char qdir[PATH_MAX + 3]; 00033 explain_string_buffer_t qdir_sb; 00034 00035 explain_string_buffer_init(&qdir_sb, qdir, sizeof(qdir)); 00036 explain_string_buffer_puts_quoted(&qdir_sb, directory); 00037 00038 if (explain_option_dialect_specific()) 00039 { 00040 explain_string_buffer_printf_gettext 00041 ( 00042 sb, 00043 /* 00044 * xgettext: This error message is issued when we 00045 * are unable to locate a unique temporary file. 00046 * 00047 * %1$s => The directory used to hold temporary files. 00048 * %2$d => the number of attempts (TMP_MAX) 00049 */ 00050 i18n("the system was unable to find a unique unused temporary file " 00051 "name in the %s directory, after %d attempts"), 00052 qdir, 00053 (int)(TMP_MAX) 00054 ); 00055 } 00056 else 00057 { 00058 explain_string_buffer_printf_gettext 00059 ( 00060 sb, 00061 /* 00062 * xgettext: This error message is issued when we 00063 * are unable to locate a unique temporary file. 00064 * 00065 * %1$s => The directory used to hold temporary files. 00066 */ 00067 i18n("the system was unable to find a unique unused temporary file " 00068 "name in the %s directory"), 00069 qdir 00070 ); 00071 } 00072 } 00073 00074 00075 void 00076 explain_buffer_eexist_tempname_dirname(explain_string_buffer_t *sb, 00077 const char *child) 00078 { 00079 char parent[PATH_MAX + 1]; 00080 00081 explain_dirname(parent, child, sizeof(parent)); 00082 explain_buffer_eexist_tempname(sb, parent); 00083 } 00084 00085 00086 /* vim: set ts=8 sw=4 et : */