00001 // Copyright (C) 2001, Compaq Computer Corporation 00002 00003 // This file is part of Vesta. 00004 00005 // Vesta is free software; you can redistribute it and/or modify it 00006 // under the terms of the GNU Lesser General Public License as 00007 // published by the Free Software Foundation; either version 2.1 of 00008 // the License, or (at your option) any later version. 00009 00010 // Vesta 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 00013 // Lesser General Public License for more details. 00014 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with Vesta; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00018 // USA 00019 00020 // Last modified on Sat May 28 16:29:06 EDT 2005 by ken@xorian.net 00021 // modified on Thu Apr 4 17:42:10 PST 1996 by heydon 00022 00023 #include "Basics.H" 00024 00025 #include <string.h> 00026 #include <errno.h> 00027 00028 const char* const BoolName[] = { "false", "true" }; 00029 00030 Text Basics::errno_Text(int err) 00031 { 00032 char msg_buf[512]; 00033 const char *message; 00034 #if defined(__osf__) || defined(__FreeBSD__) 00035 int convert_err = strerror_r(err, msg_buf, sizeof(msg_buf)); 00036 assert(convert_err == 0); 00037 message = msg_buf; 00038 #elif defined(__GLIBC__) 00039 // glibc uses a non-standard prototype for strerror_r. The man page 00040 // says it "must be regarded as obsolete", and yet strerror_r 00041 // behaves differently than SUSv3 says. *sigh* 00042 message = strerror_r(err, msg_buf, sizeof(msg_buf)); 00043 #elif defined(__sun__) 00044 // Solaris has no strerror_r, and it looks like strerror returns 00045 // pointers into a table of string constants. 00046 message = strerror(err); 00047 #else 00048 #error Insert strerror_r here 00049 #endif 00050 00051 assert(message != 0); 00052 return Text(message); 00053 }