Commit f53fe3d4 authored by Steven Murray's avatar Steven Murray Committed by Steven Murray
Browse files

Added the strerror_r_wrapper()

The  strerror_r_wrapper() function wraps the XSI compliant version of
strerror_r().

This wrapper facilitates the task of having the XSI compliant verson
of strerror_r() as opposed to the GNU version.  In order to the XSI
compliant version, the implemenation file common/strerror_r_wrapper.cpp
undefines _GNU_SOURCE and defines _XOPEN_SOURCE to be 600.

Please note that the strerror_r_wrapper() is not yet called by any
other code in CASTOR.  The purpose of this commit is to see how the
wrapper function compiles on SLC5, SLC6 and MAC.
parent 7cf9cc39
/******************************************************************************
* common/strerror_r_wrapper.cpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Steven.Murray@cern.ch
*****************************************************************************/
#include "h/strerror_r_wrapper.hpp"
#if defined(linux)
#undef _GNU_SOURCE
#define _XOPEN_SOURCE 600
#endif
#include <string.h>
/*******************************************************************************
* strerror_r_wrapper
******************************************************************************/
int strerror_r_wrapper(int errnum, char *buf, unsigned int buflen) {
return strerror_r(errnum, buf, buflen);
}
/******************************************************************************
* h/strerror_r_wrapper.h
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Steven.Murray@cern.ch
*****************************************************************************/
#ifndef H_STRERROR_R_WRAPPER_H
#define H_STRERROR_R_WRAPPER_H 1
#include <stddef.h>
/* The following EXTERN_C marco has been intentionally copied from */
/* h/osdep.h instead of just including h/osdep.h. The reason for this is */
/* this header file must include the minimum number of header files because */
/* the implementation file common/strerror_r_wrapper.cpp will undefine */
/* _GNU_SOURCE and define _XOPEN_SOURCE as being 600. */
/* */
/* Macros for externalization (UNIX) (J.-D.Durand) */
#ifdef EXTERN_C
#undef EXTERN_C
#endif
#if defined(__cplusplus)
#define EXTERN_C extern "C"
#else
#define EXTERN_C extern
#endif
/**
* This function wraps the XSI compliant version of strerror_r() and therefore
* writes the string representation of the specified error number to the
* specified buffer.
*
* @param errnum The error number.
* @param buf The buffer.
* @param buflen The length of the buffer.
*/
EXTERN_C int strerror_r_wrapper(int errnum, char *buf, size_t buflen);
#endif /* H_STRERROR_R_WRAPPER_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment