00001 #pragma ident "@(#)92/msgnew/catgetmsg.c 92.2 06/03/99 09:59:18" 00002 00003 /* 00004 00005 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00006 00007 This program is free software; you can redistribute it and/or modify it 00008 under the terms of version 2 of the GNU General Public License as 00009 published by the Free Software Foundation. 00010 00011 This program is distributed in the hope that it would be useful, but 00012 WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00014 00015 Further, this software is distributed without any warranty that it is 00016 free of the rightful claim of any third person regarding infringement 00017 or the like. Any license provided herein, whether implied or 00018 otherwise, applies only to this software file. Patent licenses, if 00019 any, provided herein do not apply to combinations of this program with 00020 other software, or any other product whatsoever. 00021 00022 You should have received a copy of the GNU General Public License along 00023 with this program; if not, write the Free Software Foundation, Inc., 59 00024 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00025 00026 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00027 Mountain View, CA 94043, or: 00028 00029 http://www.sgi.com 00030 00031 For further information regarding this notice, see: 00032 00033 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00034 00035 */ 00036 00037 00038 #ident "$Header: /proj/osprey/CVS/open64/osprey1.0/libcsup/msgnew/catgetmsg.c,v 1.1.1.1 2005/10/21 19:00:00 marcel Exp $" 00039 00040 #if ! defined(BUILD_OS_DARWIN) 00041 /* Mach-O doesn't implement aliases; Linux version ignores these anyway 00042 * because there's no C declaration of the alias id */ 00043 #if defined(__STDC__) && defined(_LITTLE_ENDIAN) 00044 #pragma weak _catgetmsg = catgetmsg 00045 #else /* else STDC and _LITTLE_ENDIAN */ 00046 #if defined(__STDC__) && !defined(_LIBU) 00047 #pragma weak catgetmsg = _catgetmsg 00048 #pragma weak __catgetmsg_error_code = ___catgetmsg_error_code 00049 #endif 00050 #endif 00051 #endif /* end STDC and _LITTLE_ENDIAN */ 00052 00053 /* 00054 * IMPORTANT: 00055 * This section is needed since this file also resides in the compilers' 00056 * libcsup/msg (v7.2 and higher). Once the compilers drop support for 00057 * pre-IRIX 6.5 releases this can be removed. Please build a libu before 00058 * checking in any changes to this file. 00059 * 00060 */ 00061 00062 #ifdef _LITTLE_ENDIAN 00063 #include <nl_types.h> 00064 #include <cray/nlcatmsg.h> 00065 #include <string.h> 00066 #else /* Else _LITTLE_ENDIAN */ 00067 #ifndef _LIBU 00068 #include "synonyms.h" 00069 #endif 00070 00071 #define __NLS_INTERNALS 1 00072 #include <nl_types.h> 00073 #undef __NLS_INTERNALS 00074 #include <string.h> 00075 #endif /* End _LITTLE_ENDIAN */ 00076 00077 /* 00078 * catgetmsg -- retrieves a message to a user supplied buffer from a catalog 00079 * 00080 */ 00081 char * 00082 catgetmsg( 00083 nl_catd catd, 00084 int set_num, 00085 int msg_num, 00086 char *buf, 00087 int buflen 00088 ) 00089 { 00090 size_t len; 00091 char *str; 00092 00093 if ((str = catgets(catd, set_num, msg_num, NULL)) != NULL) { 00094 00095 /* find the proper string length to copy */ 00096 len = strlen(str); 00097 if (len >= buflen) 00098 len = buflen - 1; 00099 00100 (void) strncpy(buf, str, len); 00101 buf[len] = '\0'; 00102 00103 return buf; 00104 } else { 00105 return "\0"; 00106 } 00107 } 00108 00109 00110 #ifndef _LITTLE_ENDIAN 00111 /* 00112 * __catgetmsg_error_code - returns the error status from the last 00113 * failed catgetmsg() call. 00114 * 00115 * returns < 0 Internal error code 00116 * > 0 System error code 00117 */ 00118 int 00119 __catgetmsg_error_code(void) 00120 { 00121 return(__catgets_error_code()); 00122 } 00123 #endif /* End NOT _LITTLE_ENDIAN */
1.5.6