Possible compatibility problems with earlier versions marked with '*'.
+New function yaz_strerror which is a portable wrapper for
+strerror/strerror_r/GetLastMessage.
+
ZOOM_record_get supports type "xml" in which case OAI MARC is
returned for MARC. If type is "MarcXML" , MARC XML is returned.
* Copyright (c) 1995-2002, Index Data
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.174 2002-11-08 12:23:38 adam Exp $
+ * $Id: client.c,v 1.175 2002-12-05 12:19:23 adam Exp $
*/
#include <stdio.h>
{
printf ("error = %s\n", cs_strerror(conn));
if (conn->cerrno == CSYSERR)
- perror("system");
+ {
+ char msg[256];
+ yaz_strerror(msg, sizeof(msg));
+ printf ("%s\n", msg);
+ }
cs_close(conn);
conn = 0;
return 0;
/*
- * Copyright (c) 1995-2001, Index Data.
+ * Copyright (c) 1995-2002, Index Data.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation, in whole or in part, for any purpose, is hereby granted,
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Log: nmem.h,v $
- * Revision 1.8 2002-09-25 12:37:07 adam
- * Thread-safe handling of errno variable.
- * For server option -a@ produces APDU prints in YAZ log.
- *
- * Revision 1.7 2002/09/10 18:41:18 adam
- * Added yaz_errno
- *
- * Revision 1.6 2001/06/26 14:11:27 adam
- * Added MUTEX functions for NMEM module (used by OID utility).
- *
- * Revision 1.5 2001/03/25 21:55:12 adam
- * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate.
- *
- * Revision 1.4 2000/05/09 11:48:58 adam
- * Fix (bug introduced by previous commit).
- *
- * Revision 1.3 2000/05/09 10:55:05 adam
- * Public nmem_print_list (for debugging).
- *
- * Revision 1.2 2000/02/28 11:20:06 adam
- * Using autoconf. New definitions: YAZ_BEGIN_CDECL/YAZ_END_CDECL.
- *
- * Revision 1.1 1999/11/30 13:47:11 adam
- * Improved installation. Moved header files to include/yaz.
- *
- * Revision 1.10 1998/10/19 15:24:20 adam
- * New nmem utility, nmem_transfer, that transfer blocks from one
- * NMEM to another.
- *
- * Revision 1.9 1998/10/13 16:00:17 adam
- * Implemented nmem_critical_{enter,leave}.
- *
- * Revision 1.8 1998/07/20 12:35:59 adam
- * Added more memory diagnostics (when NMEM_DEBUG is 1).
- *
- * Revision 1.7 1997/10/31 12:20:08 adam
- * Improved memory debugging for xmalloc/nmem.c. References to NMEM
- * instead of ODR in n ESPEC-1 handling in source d1_espec.c.
- * Bug fix: missing fclose in data1_read_espec1.
- *
+ * $Id: nmem.h,v 1.9 2002-12-05 12:19:23 adam Exp $
*/
#ifndef NMEM_H
YAZ_EXPORT void nmem_exit (void);
YAZ_EXPORT int yaz_errno (void);
YAZ_EXPORT void yaz_set_errno (int v);
+YAZ_EXPORT void yaz_strerror(char *buf, int max);
YAZ_END_CDECL
* Copyright (c) 1995-2002, Index Data
* See the file LICENSE for details.
*
- * $Id: log.c,v 1.31 2002-11-26 16:56:39 adam Exp $
+ * $Id: log.c,v 1.32 2002-12-05 12:19:24 adam Exp $
*/
#if HAVE_CONFIG_H
/* WIN32 */
if (o_level & LOG_ERRNO)
{
-#ifdef WIN32
- DWORD err = GetLastError();
- if (err)
- {
- strcat(buf, " [");
- FormatMessage(
- FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- err,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR) buf + strlen(buf),
- 2048,
- NULL);
- strcat(buf, "]");
- }
-#else
- sprintf(buf + strlen(buf), " [%s]", strerror(yaz_errno()));
-#endif
+ strcat(buf, " [");
+ yaz_strerror(buf+strlen(buf), 2048);
+ strcat(buf, "]");
}
va_end (ap);
if (start_hook_func)
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: nmem.c,v 1.37 2002-09-25 12:37:07 adam Exp $
+ * $Id: nmem.c,v 1.38 2002-12-05 12:19:24 adam Exp $
*/
/*
{
errno = v;
}
+
+void yaz_strerror(char *buf, int max)
+{
+ char *cp;
+#ifdef WIN32
+ DWORD err = GetLastError();
+ if (err)
+ {
+ FormatMessage(
+ FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ err,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) buf,
+ max-1,
+ NULL);
+ }
+ else
+ *buf = '\0';
+#else
+#if YAZ_POSIX_THREADS
+ strerror_r(errno, buf, max);
+#else
+ strcpy(buf, strerror(yaz_errno()));
+#endif
+#endif
+ if ((cp=strrchr(buf, '\n')))
+ *cp = '\0';
+ if ((cp=strrchr(buf, '\r')))
+ *cp = '\0';
+}