libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2008, 2009, 2012, 2013 Peter Miller 00004 * Written by Peter Miller <pmiller@opensource.org.au> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 3 of the License, or (at 00009 * your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #include <libexplain/ac/sys/resource.h> 00021 00022 #include <libexplain/buffer/int.h> 00023 #include <libexplain/buffer/long.h> 00024 #include <libexplain/buffer/long_long.h> 00025 #include <libexplain/buffer/rlimit.h> 00026 #include <libexplain/string_buffer.h> 00027 00028 00029 void 00030 explain_buffer_rlim_t(explain_string_buffer_t *sb, rlim_t rlim) 00031 { 00032 if (rlim == RLIM_INFINITY) 00033 explain_string_buffer_puts(sb, "RLIM_INFINITY"); 00034 else if (sizeof(rlim) <= sizeof(int)) 00035 explain_buffer_int(sb, rlim); 00036 else if (sizeof(rlim) <= sizeof(long)) 00037 explain_buffer_long(sb, rlim); 00038 else 00039 explain_buffer_long_long(sb, rlim); 00040 } 00041 00042 00043 void 00044 explain_buffer_rlimit(explain_string_buffer_t *sb, const struct rlimit *p) 00045 { 00046 explain_string_buffer_puts(sb, "{ rlim_cur = "); 00047 explain_buffer_rlim_t(sb, p->rlim_cur); 00048 if (p->rlim_cur != p->rlim_max) 00049 { 00050 explain_string_buffer_puts(sb, ", rlim_max = "); 00051 explain_buffer_rlim_t(sb, p->rlim_max); 00052 } 00053 explain_string_buffer_puts(sb, " }"); 00054 } 00055 00056 00057 /* vim: set ts=8 sw=4 et : */