Merged changes from 3.14 branch up to revno 12516

This commit is contained in:
Andrew Johnson
2015-02-27 17:47:55 -06:00
5 changed files with 96 additions and 92 deletions

View File

@@ -1,11 +1,9 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
@@ -20,28 +18,36 @@
#include "epicsStdio.h"
/*
* epicsSocketConvertErrnoToString ()
* epicsSocketConvertErrorToString ()
*/
void epicsSocketConvertErrnoToString (
char * pBuf, unsigned bufSize )
void epicsSocketConvertErrorToString (
char * pBuf, unsigned bufSize, int theSockError )
{
if ( bufSize ) {
/*
* this does not work on systems prior to W2K
*/
int theSockError = SOCKERRNO;
DWORD success = FormatMessage (
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_MAX_WIDTH_MASK,
NULL, theSockError,
MAKELANGID ( LANG_NEUTRAL, SUBLANG_DEFAULT ), /* Default language */
pBuf, bufSize, NULL );
if ( ! success ) {
/*
* this does not work on systems prior to W2K
*/
DWORD success = FormatMessage (
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_MAX_WIDTH_MASK,
NULL, theSockError,
MAKELANGID ( LANG_NEUTRAL, SUBLANG_DEFAULT ), /* Default language */
pBuf, bufSize, NULL );
if ( ! success ) {
int status = epicsSnprintf (
pBuf, bufSize, "WINSOCK Error %d", theSockError );
if ( status <= 0 ) {
strncpy ( pBuf, "WINSOCK Error", bufSize );
pBuf [bufSize - 0] = '\0';
}
}
}
}
}
/*
* epicsSocketConvertErrnoToString ()
*/
void epicsSocketConvertErrnoToString (
char * pBuf, unsigned bufSize )
{
epicsSocketConvertErrorToString ( pBuf, bufSize, SOCKERRNO );
}

View File

@@ -1,11 +1,9 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* osdSock.c */
@@ -22,14 +20,22 @@
#include "osiSock.h"
/*
* epicsSocketConvertErrnoToString()
* epicsSocketConvertErrorToString()
*/
void epicsSocketConvertErrnoToString (
char * pBuf, unsigned bufSize )
void epicsSocketConvertErrorToString (
char * pBuf, unsigned bufSize, int theSockError )
{
if ( bufSize ) {
strncpy ( pBuf, strerror ( SOCKERRNO ), bufSize );
strncpy ( pBuf, strerror ( theSockError ), bufSize );
pBuf[bufSize-1] = '\0';
}
}
/*
* epicsSocketConvertErrnoToString()
*/
void epicsSocketConvertErrnoToString (
char * pBuf, unsigned bufSize )
{
epicsSocketConvertErrorToString ( pBuf, bufSize, SOCKERRNO );
}

View File

@@ -140,9 +140,11 @@ epicsShareFunc int epicsShareAPI osiSockAttach (void); /* returns T if success,
epicsShareFunc void epicsShareAPI osiSockRelease (void);
/*
* convert socket error number to a string
* convert socket error numbers to a string
*/
epicsShareFunc void epicsSocketConvertErrnoToString (
epicsShareFunc void epicsSocketConvertErrorToString (
char * pBuf, unsigned bufSize, int error );
epicsShareFunc void epicsSocketConvertErrnoToString (
char * pBuf, unsigned bufSize );
typedef union osiSockAddr {