This is Unofficial EPICS BASE Doxygen Site
epicsSocketConvertErrnoToString.cpp
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Chicago, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * EPICS BASE is distributed subject to a Software License Agreement found
7 * in file LICENSE that is included with this distribution.
8 \*************************************************************************/
9 
10 #include <stdio.h>
11 
12 #include "osiSock.h"
13 #include "epicsStdio.h"
14 
15 /*
16  * epicsSocketConvertErrorToString ()
17  */
19  char * pBuf, unsigned bufSize, int theSockError )
20 {
21  if ( bufSize ) {
22  /*
23  * this does not work on systems prior to W2K
24  */
25  DWORD success = FormatMessage (
26  FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_MAX_WIDTH_MASK,
27  NULL, theSockError,
28  MAKELANGID ( LANG_NEUTRAL, SUBLANG_DEFAULT ), /* Default language */
29  pBuf, bufSize, NULL );
30  if ( ! success ) {
31  int status = epicsSnprintf (
32  pBuf, bufSize, "WINSOCK Error %d", theSockError );
33  if ( status <= 0 ) {
34  strncpy ( pBuf, "WINSOCK Error", bufSize );
35  pBuf [bufSize - 0] = '\0';
36  }
37  }
38  }
39 }
40 
41 /*
42  * epicsSocketConvertErrnoToString ()
43  */
45  char * pBuf, unsigned bufSize )
46 {
47  epicsSocketConvertErrorToString ( pBuf, bufSize, SOCKERRNO );
48 }
pvd::Status status
#define NULL
Definition: catime.c:38
void epicsSocketConvertErrnoToString(char *pBuf, unsigned bufSize)
#define SOCKERRNO
Definition: osdSock.h:33
void epicsSocketConvertErrorToString(char *pBuf, unsigned bufSize, int theSockError)
LIBCOM_API int epicsStdCall epicsSnprintf(char *str, size_t size, const char *format,...) EPICS_PRINTF_STYLE(3