/* WARNING: This file was generated by dkct. Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: dk4socka01.ctr */ /* Copyright (C) 2015-2017, Dirk Krause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above opyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** @file dk4socka01.c The dk4socka01 module. */ #line 10 "dk4socka01.ctr" #include "dk4sock.h" #include "dk4socka.h" #include "dk4mem.h" #include "dk4maodd.h" #include "dk4maodh.h" #if DK4_HAVE_ERRNO_H #ifndef ERRNO_H_INCLUDED #include #define ERRNO_H_INCLUDED 1 #endif #endif #if DK4_HAVE_STRING_H #ifndef STRING_H_INCLUDED #include #define STRING_H_INCLUDED 1 #endif #endif #line 34 "dk4socka01.ctr" /** Constant text keywords, not localized. */ static const dkChar * const dk4socket_app_kwnl[] = { /* 0 */ dkT("dk4sock.str"), /* 1 */ dkT("\n\t"), /* 2 */ dkT(": "), /* 3 */ dkT("WSAStartup"), /* 4 */ dkT("WSACleanup"), /* 5 */ dkT("socket"), /* 6 */ dkT("close"), /* 7 */ dkT("closesocket"), /* 8 */ dkT("bind"), /* 9 */ dkT("listen"), /* 10 */ dkT("accept"), /* 11 */ dkT("connect"), /* 12 */ dkT("setsockopt"), /* 13 */ dkT("ioctlsocket"), /* 14 */ dkT("fcntl"), /* 15 */ dkT("select"), /* 16 */ dkT("getsockopt"), /* 17 */ dkT("getaddrinfo"), /* 18 */ dkT("getnameinfo"), /* 19 */ dkT("gethostbyname"), /* 20 */ dkT("getservbyname"), /* 21 */ dkT("GetAddrInfoW"), /* 22 */ dkT("inet_ntop"), /* 23 */ dkT("shutdown"), /* 24 */ dkT("send/sendto"), /* 25 */ dkT("recv/recvfrom"), /* 26 */ dkT("inet_pton"), NULL #line 126 "dk4socka01.ctr" }; /** Constant text keywords, replaced by localized version if found. */ static const dkChar * const dk4socket_app_kw_def[] = { /* 0 */ dkT("Failed to initialize Winsock subsystem!"), /* 1 */ dkT("Failed to shut down Winsock subsystem!"), /* 2 */ dkT("Failed to create socket!"), /* 3 */ dkT("Failed to close socket!"), /* 4 */ dkT("Failed to bind local address!"), /* 5 */ dkT("Failed to listen for incoming connection requests!"), /* 6 */ dkT("Failed to accept incoming connection request!"), /* 7 */ dkT("Failed to connect to remote address!"), /* 8 */ dkT("Failed to modify ``reusable'' option for socket!"), /* 9 */ dkT("Failed to modify ``non-blocking'' option for socket!"), /* 10 */ dkT("Failed to retrieve remote address(es)!"), /* 11 */ dkT("Failed to retrieve local address(es)!"), /* 12 */ dkT("Failed to retrieve remote host address!"), /* 13 */ dkT("Failed to retrieve port number for remote service!"), /* 14 */ dkT("Failed to retrieve port number for local service!"), /* 15 */ dkT("Failed to convert text to ASCII!"), /* 16 */ dkT("\""), /* 17 */ dkT("\"!"), /* 18 */ dkT("Failed to obtain local address(es)!"), /* 19 */ dkT("Port/service: "), /* 20 */ dkT("Failed to obtain remote address(es)!"), /* 21 */ dkT("Host: "), /* 22 */ dkT("Port/service: "), /* 23 */ dkT("Service/port not found: \""), /* 24 */ dkT("\"!"), /* 25 */ dkT("Failed to convert service/port to ASCII: \""), /* 26 */ dkT("\"!"), /* 27 */ dkT("No matching pair of local/remote addresses found!"), /* 28 */ dkT("Illegal local port number!"), /* 29 */ dkT("Illegal remote port number!"), /* 30 */ dkT("Connection established."), /* 31 */ dkT("Illegal address length in gethostbyname() result!"), /* 32 */ dkT("Illegal address family in gethostbyname() result!"), /* 33 */ dkT("Remote host not found: \""), /* 34 */ dkT("\"!"), /* 35 */ dkT("Non-ASCII characters in host name: \n\t\""), /* 36 */ dkT("\"!"), /* 37 */ dkT("errno="), /* 38 */ dkT(" (0x"), /* 39 */ dkT(")"), /* 40 */ dkT("WSAGetLastError()="), /* 41 */ dkT("Failed to create TCP connection!"), /* 42 */ dkT("Local: "), /* 43 */ dkT("Remote: "), /* 44 */ dkT("Timeout while attempting to connect."), /* 45 */ dkT("Invalid arguments passed to function, probably a bug."), /* 46 */ dkT("No matching local/remote address pair available!"), /* 47 */ dkT("Network subsystem not yet ready."), /* 48 */ dkT("Winsock version not supported!"), /* 49 */ dkT("Blocking Winsock operation in progress!"), /* 50 */ dkT("Process limit for Winsock reached!"), /* 51 */ dkT("Invalid parameters passed to function!"), /* 52 */ dkT("Winsock not initialized!"), /* 53 */ dkT("Network subsystem has failed!"), /* 54 */ dkT("Address family not supported!"), /* 55 */ dkT("No more socket/file descriptors available"), /* 56 */ dkT("No buffer space available!"), /* 57 */ dkT("Protocol not supported!"), /* 58 */ dkT("Wrong protocol type for socket!"), /* 59 */ dkT("Service provider failed to initialize!"), /* 60 */ dkT("Socket type not supported by address family!"), /* 61 */ dkT("Unusable service provider version!"), /* 62 */ dkT("Invalid/incomplete procedure table from service provider!"), /* 63 */ dkT("Insufficient permissions!"), /* 64 */ dkT("Address already in use!"), /* 65 */ dkT("Address not available!"), /* 66 */ dkT("File descriptor is not a socket!"), /* 67 */ dkT("Host has no addresses in specified address family!"), /* 68 */ dkT("Temporary problem on name server, try again later!"), /* 69 */ dkT("Illegal flag combination!"), /* 70 */ dkT("Name server failure!"), /* 71 */ dkT("Address family not supported!"), /* 72 */ dkT("Out of memory!"), /* 73 */ dkT("No network address found for host!"), /* 74 */ dkT("No such name or number!"), /* 75 */ dkT("Service not available through specified socket type!"), /* 76 */ dkT("Unsupported socket type or inconsistent arguments!"), /* 77 */ dkT("System error, check errno!"), /* 78 */ dkT("Argument buffer overflow!"), /* 79 */ dkT("Resource temporarily locked, try again later!"), /* 80 */ dkT("Attempt already in progress!"), /* 81 */ dkT("Not a file descriptor!"), /* 82 */ dkT("No-one listening on remote address!"), /* 83 */ dkT("Connection reset by peer!"), /* 84 */ dkT("Operation would result in deadlock!"), /* 85 */ dkT("Destination address required!"), /* 86 */ dkT("Timeout values too large!"), /* 87 */ dkT("Operation is in progress."), /* 88 */ dkT("Operation interrupted by signal!"), /* 89 */ dkT("Socket is already connected!"), /* 90 */ dkT("I/O error occured!"), /* 91 */ dkT("Symbolic link loop detected!"), /* 92 */ dkT("No more file descriptors available for process!"), /* 93 */ dkT("Address or path name too long!"), /* 94 */ dkT("Network unreachable!"), /* 95 */ dkT("No more file descriptors available on system!"), /* 96 */ dkT("File or path component does not exist or is empty!"), /* 97 */ dkT("Failed to set a lock!"), /* 98 */ dkT("Attempt to retrieve or modify unsupported option!"), /* 99 */ dkT("Path component is not a directory!"), /* 100 */ dkT("Provided buffer size is too small!"), /* 101 */ dkT("Operation not supported by socket type or protocol!"), /* 102 */ dkT("File system is mounted read-only!"), /* 103 */ dkT("Timed out!"), /* 104 */ dkT("Numeric overflow in file size/position calculation!"), /* 105 */ dkT("Connection closed due to timeout or other failure!"), /* 106 */ dkT("Host unreachable!"), /* 107 */ dkT("Blocking Winsock operation interrupted by WSACancelBlockingCall()!"), /* 108 */ dkT("Socket is in listening state!"), /* 109 */ dkT("No local address bound yet!"), /* 110 */ dkT("Socket is not in listening state!"), /* 111 */ dkT("Invalid shutdown parameter"), /* 112 */ dkT("Message size too large!"), /* 113 */ dkT("Connection closed, failures in keep-alive tests!"), /* 114 */ dkT("Not connected!"), /* 115 */ dkT("Failed to initialize socket provider!"), /* 116 */ dkT("Socket already shut down!"), /* 117 */ dkT("Operation would block!"), /* 118 */ dkT("Host not found (authorative answer)!"), /* 119 */ dkT("Service provider returned invalid/incomplete procedure table!"), /* 120 */ dkT("Invalid service provider version!"), /* 121 */ dkT("Protocol error!"), /* 122 */ dkT("Insufficient stream resources!"), /* 123 */ dkT("Protocol family not supported!"), /* 124 */ dkT("Connection to remote machine no longer active!"), /* 125 */ dkT("Server exited before completing connection!"), /* 126 */ dkT("Protocol family and type not found in network configuration!"), /* 127 */ dkT("Stale NFS file handle!"), /* 128 */ dkT("Failed to shut down socket!"), /* 129 */ dkT("Failed to bind local address\n\t\""), /* 130 */ dkT("\"!"), /* 131 */ dkT("Failed to connect to remote address\n\t\""), /* 132 */ dkT("\"!"), /* 133 */ dkT("Send operation completed partially, only "), /* 134 */ dkT(" of "), /* 135 */ dkT(" bytes!"), /* 136 */ dkT("Send operation completed partially!"), /* 137 */ dkT("Send operation failed!"), /* 138 */ dkT("Failed to receive data!"), /* 139 */ dkT("Failed to create listener sockets!"), /* 140 */ dkT("Listening: "), /* 141 */ dkT("Failed to obtain allowed peer from string:\n\t\""), /* 142 */ dkT("\"!"), NULL #line 641 "dk4socka01.ctr" }; /** Number of elements in the dk4socket_app_kw_def array. */ static const size_t dk4socket_sz_kw_def = sizeof(dk4socket_app_kw_def)/sizeof(DK4_PCDKCHAR); size_t dk4socket_log_num_texts(void) { return (dk4socket_sz_kw_def); } const dkChar * const * dk4socket_log_texts(dk4_app_t *app) { const dkChar * const *back = dk4socket_app_kw_def; if (NULL != app) { back = dk4app_string_table(app,dk4socket_app_kwnl[0],dk4socket_app_kw_def); } return back; } void dk4socket_log_fctname_msg( const dkChar **fctname, const dkChar **msgtext, dk4_app_t *app, dk4_er_t *erp ) { const dkChar * const *msgtexts = dk4socket_app_kw_def; const dkChar *mytext = NULL; if ((NULL != app) && (NULL != erp)) { msgtexts = dk4app_string_table(app, dk4socket_app_kwnl[0], dk4socket_app_kw_def); if (NULL != fctname) { switch (erp->ec) { case DK4_E_SOCKET_GETADDRINFO : { #if DK4_CHAR_SIZE > 1 *fctname = dk4socket_app_kwnl[21]; #else *fctname = dk4socket_app_kwnl[17]; #endif } break; case DK4_E_SOCKET_GETADDRLOC : { #if DK4_CHAR_SIZE > 1 *fctname = dk4socket_app_kwnl[21]; #else *fctname = dk4socket_app_kwnl[17]; #endif } break; case DK4_E_SOCKET_UP : { *fctname = dk4socket_app_kwnl[3]; } break; case DK4_E_SOCKET_DOWN : { *fctname = dk4socket_app_kwnl[4]; } break; case DK4_E_SOCKET_SOCKET : { *fctname = dk4socket_app_kwnl[5]; } break; case DK4_E_SOCKET_CLOSE : { #if DK4_ON_WINDOWS *fctname = dk4socket_app_kwnl[7]; #else *fctname = dk4socket_app_kwnl[6]; #endif } break; case DK4_E_SOCKET_BIND : { *fctname = dk4socket_app_kwnl[8]; } break; case DK4_E_SOCKET_CONNECT : { *fctname = dk4socket_app_kwnl[11]; } break; case DK4_E_SOCKET_LISTEN : { *fctname = dk4socket_app_kwnl[9]; } break; case DK4_E_SOCKET_ACCEPT : { *fctname = dk4socket_app_kwnl[10]; } break; case DK4_E_SOCKET_SHUTDOWN : { *fctname = dk4socket_app_kwnl[23]; } break; case DK4_E_SOCKET_SEND : { *fctname = dk4socket_app_kwnl[24]; } break; case DK4_E_SOCKET_RECV : { *fctname = dk4socket_app_kwnl[25]; } break; case DK4_E_SOCKET_SELECT : { *fctname = dk4socket_app_kwnl[15]; } break; case DK4_E_SOCKET_SETSOCKOPT : { *fctname = dk4socket_app_kwnl[12]; } break; case DK4_E_SOCKET_GETSOCKOPT : { *fctname = dk4socket_app_kwnl[16]; } break; case DK4_E_SOCKET_IOCTLSOCKET : { *fctname = dk4socket_app_kwnl[13]; } break; case DK4_E_SOCKET_FCNTL : { *fctname = dk4socket_app_kwnl[14]; } break; case DK4_E_SOCKET_GETSERVBYNAME : { *fctname = dk4socket_app_kwnl[20]; } break; case DK4_E_SOCKET_GETHOSTBYNAME : { *fctname = dk4socket_app_kwnl[19]; } break; case DK4_E_SOCKET_INET_NTOP : { *fctname = dk4socket_app_kwnl[22]; } break; case DK4_E_SOCKET_INET_PTON : { *fctname = dk4socket_app_kwnl[26]; } break; default : { *fctname = NULL; } break; } } if (NULL != msgtext) { #if (DK4_CHAR_SIZE == 1) && (!DK4_ON_WINDOWS) switch (erp->ec) { case DK4_E_SOCKET_GETADDRINFO : case DK4_E_SOCKET_GETADDRLOC : { #if DK4_HAVE_GETADDRINFO mytext = gai_strerror((erp->dt).iDetails1); #endif } break; case DK4_E_SOCKET_UP : case DK4_E_SOCKET_DOWN : case DK4_E_SOCKET_SOCKET : case DK4_E_SOCKET_CLOSE : case DK4_E_SOCKET_BIND : case DK4_E_SOCKET_CONNECT : case DK4_E_SOCKET_LISTEN : case DK4_E_SOCKET_ACCEPT : case DK4_E_SOCKET_SHUTDOWN : case DK4_E_SOCKET_SEND : case DK4_E_SOCKET_RECV : case DK4_E_SOCKET_SELECT : case DK4_E_SOCKET_SETSOCKOPT : case DK4_E_SOCKET_GETSOCKOPT : case DK4_E_SOCKET_IOCTLSOCKET : case DK4_E_SOCKET_FCNTL : case DK4_E_SOCKET_INET_NTOP : case DK4_E_SOCKET_INET_PTON : { mytext = strerror((erp->dt).iDetails1); } break; } #endif if (NULL == mytext) { #line 805 "dk4socka01.ctr" switch (erp->ec) { #if DK4_ON_WINDOWS /* +++++ Windows +++++ */ case DK4_E_SOCKET_GETADDRINFO : case DK4_E_SOCKET_GETADDRLOC : { switch (erp->dt.iDetails1) { case EAI_AGAIN : { /* Temporary problem in name resolution */ mytext = msgtexts[68]; } break; case EAI_BADFLAGS : { /* Incorrect flag combination */ mytext = msgtexts[69]; } break; case EAI_FAIL : { /* Nonrecoverable failure in name resolution */ mytext = msgtexts[70]; } break; case EAI_FAMILY : { /* Unsupported address family */ mytext = msgtexts[71]; } break; case EAI_MEMORY: { /* Not enough memory available */ mytext = msgtexts[72]; } break; case EAI_NONAME : { /* No address found for host */ mytext = msgtexts[74]; } break; case EAI_SERVICE : { /* Service type not supported for specified socket type */ mytext = msgtexts[75]; } break; case EAI_SOCKTYPE : { /* Socket type not supported */ mytext = msgtexts[76]; } break; } } break; case DK4_E_SOCKET_UP : case DK4_E_SOCKET_DOWN : case DK4_E_SOCKET_SOCKET : case DK4_E_SOCKET_CLOSE : case DK4_E_SOCKET_BIND : case DK4_E_SOCKET_CONNECT : case DK4_E_SOCKET_LISTEN : case DK4_E_SOCKET_ACCEPT : case DK4_E_SOCKET_SHUTDOWN : case DK4_E_SOCKET_SEND : case DK4_E_SOCKET_RECV : case DK4_E_SOCKET_SELECT : case DK4_E_SOCKET_SETSOCKOPT : case DK4_E_SOCKET_GETSOCKOPT : case DK4_E_SOCKET_IOCTLSOCKET : case DK4_E_SOCKET_FCNTL : case DK4_E_SOCKET_GETSERVBYNAME : case DK4_E_SOCKET_GETHOSTBYNAME : case DK4_E_SOCKET_INET_NTOP : case DK4_E_SOCKET_INET_PTON : { switch (erp->dt.iDetails1) { case ERROR_INVALID_PARAMETER : { /* inet_ntop: Buffer not present or too small */ mytext = msgtexts[100]; } break; case WSAEACCES : { /* bind: Insufficient permissions */ /* connect, send, sendto */ mytext = msgtexts[63]; } break; case WSAEADDRINUSE : { /* bind: Address is already in use */ /* connect, listen */ mytext = msgtexts[64]; } break; case WSAEADDRNOTAVAIL : { /* bind: Address is not valid in context, not a local address*/ /* connect: Invalid remote address */ /* sendto */ mytext = msgtexts[65]; } break; case WSAEAFNOSUPPORT : { /* socket: Addres family is not supported */ /* connect, sendto, inet_ntop, inet_pton */ mytext = msgtexts[54]; } break; case WSAEALREADY : { /* connect: Non-blocking connect already running for socket */ mytext = msgtexts[80]; } break; case WSAECONNABORTED : { /* send: Timeout or other failure, close the socket */ /* sendto, recv, shutdown */ mytext = msgtexts[105]; } break; case WSAECONNREFUSED : { /* connect: Connect attempt forcefully rejected */ mytext = msgtexts[82]; } break; case WSAECONNRESET : { /* accept: Connection request followed by termination request */ /* send, sendto, recv, recvfrom, shutdown */ mytext = msgtexts[83]; } break; case WSAEDESTADDRREQ : { /* sendto: Destination address required */ mytext = msgtexts[85]; } break; case WSAEFAULT : { /* WSAStartup: Invalid data pointer */ /* bind, connect, accept, select, ioctlsocket, gethostbyname */ /* send, sendto, recv, recvfrom, inet_pton */ mytext = msgtexts[51]; } break; case WSAEHOSTUNREACH : { /* connect: Host unreachable */ /* send, sendto */ mytext = msgtexts[106]; } break; case WSAEINPROGRESS : { /* WSAStartup: Blocking Winsock 1.1 operation in progress */ /* WSACleanup, socket, bind, connect, listen, select */ /* ioctlsocket, closesocket, gethostbyname, getservbyname */ /* send, sendto, recv, recvfrom, shutdown */ mytext = msgtexts[49]; } break; case WSAEINTR : { /* connect: Blocking call cancelled by WSACancelBlockingCall */ /* accept, select, closesocket, gethostbyname, getservbyname */ /* send, sendto, recv, recvfrom */ mytext = msgtexts[107]; } break; case WSAEINVAL : { /* socket: Invalid argument supplied */ /* bind, select, send, sendto, recv, recvfrom */ /* connect: The socket is in listening state */ /* listen: Socket not yet bound */ /* accept: Not listening */ /* shutdown: Invalid shutdown parameter */ switch (erp->ec) { case DK4_E_SOCKET_CONNECT : { mytext = msgtexts[108]; } break; case DK4_E_SOCKET_LISTEN : { mytext = msgtexts[109]; } break; case DK4_E_SOCKET_ACCEPT : { mytext = msgtexts[110]; } break; case DK4_E_SOCKET_SHUTDOWN : { mytext = msgtexts[111]; } break; default : { mytext = msgtexts[51]; } break; } } break; case WSAEINVALIDPROCTABLE : { /* socket: Service provider returned invalid procedure table */ mytext = msgtexts[119]; } break; case WSAEINVALIDPROVIDER : { /* socket: Invalid provider version */ mytext = msgtexts[120]; } break; case WSAEISCONN : { /* connect: Socket already connected */ /* listen */ /* recvfrom */ mytext = msgtexts[89]; } break; case WSAEMFILE : { /* socket: No more file descriptors available */ /* listen, accept */ mytext = msgtexts[92]; } break; case WSAEMSGSIZE : { /* send: Message size too large */ /* sendto, recv, recvfrom */ mytext = msgtexts[112]; } break; case WSAENETDOWN : { /* WSACleanup: Network subsystem has failed */ /* socket, bind, connect, listen, accept, select, ioctlsocket */ /* closesocket, gethostbyname, getservbyname, send, sendto */ /* recv, recvfrom, shutdown */ mytext = msgtexts[53]; } break; case WSAENETRESET : { /* send: Connection closed while keep-alive tests */ /* sendto, recv, recvfrom */ mytext = msgtexts[113]; } break; case WSAENETUNREACH : { /* connect: Network unreachable */ /* sendto */ mytext = msgtexts[94]; } break; case WSAENOBUFS : { /* socket: No buffer space available */ /* bind, connect, listen, accept, send, sendto */ mytext = msgtexts[56]; } break; case WSAENOTCONN : { /* send: Not connected */ /* recv, shutdown */ mytext = msgtexts[114]; } break; case WSAENOTSOCK : { /* bind: file descriptor is not a socket */ /* connect, listen, connect, select, ioctlsocket */ /* closesocket, send, sendto, recv, recvfrom, shutdown */ mytext = msgtexts[66]; } break; case WSAEOPNOTSUPP : { /* listen: Not supported by socket type */ /* accept, send, sendto, recv, recvfrom */ mytext = msgtexts[101]; } break; case WSAEPROCLIM : { /* WSAStartup: Limit of processes using Winsock is reached */ mytext = msgtexts[50]; } break; case WSAEPROTONOSUPPORT : { /* socket: Unsupported protocol */ mytext = msgtexts[57]; } break; case WSAEPROTOTYPE : { /* socket: Specified protocol invalid for socket */ mytext = msgtexts[58]; } break; case WSAEPROVIDERFAILEDINIT : { /* socket: Failed to initialize socket provider */ mytext = msgtexts[115]; } break; case WSAESHUTDOWN : { /* send: Socket was shut down */ /* sendto, recv, recvfrom */ mytext = msgtexts[116]; } break; case WSAESOCKTNOSUPPORT : { /* socket: Socket type not supported by address family */ mytext = msgtexts[60]; } break; case WSAETIMEDOUT : { /* connect: Timeout */ /* send, sendto, recv, recvfrom */ mytext = msgtexts[103]; } break; case WSAEWOULDBLOCK : { /* connect: Connection not finished on non-blocking socket */ /* accept: Non-blocking, not connection attempts are present */ /* closesocket, send, sendto, recv, recvfrom */ mytext = msgtexts[117]; } break; case WSAHOST_NOT_FOUND : { /* gethostbyname: Host not found (authorative answer) */ /* getservbyname */ mytext = msgtexts[118]; } break; case WSANO_DATA : { /* gethostbyname: Host name is valid, but no data found */ /* getservbyname */ mytext = msgtexts[73]; } break; case WSANO_RECOVERY : { /* gethostbyname: Unrecoverable error */ /* getservbyname */ mytext = msgtexts[70]; } break; case WSANOTINITIALISED : { /* WSACleanup: Winsock not initialized */ /* socket, bind, connect, listen, accept, select, ioctlsocket */ /* closesocket, gethostbyname, getservbyname, send, sendto */ /* recv, recvfrom, shutdown */ mytext = msgtexts[52]; } break; case WSASYSNOTREADY : { /* WSAStartup: Underlying subsystem not yet read */ mytext = msgtexts[47]; } break; case WSATRY_AGAIN : { /* gethostbyname: Host not found (non-authorative, or server failure */ /* getservbyname */ mytext = msgtexts[68]; } break; case WSAVERNOTSUPPORTED : { /* WSAStartup: The requested version is not supported */ mytext = msgtexts[48]; } break; } } break; /* ----- Windows ----- */ #else /* +++++ non-Windows +++++ */ case DK4_E_SOCKET_GETADDRINFO : case DK4_E_SOCKET_GETADDRLOC : { switch (erp->dt.iDetails1) { #ifdef EAI_ADDRFAMILY case EAI_ADDRFAMILY : { mytext = msgtexts[67]; } break; #endif #ifdef EAI_AGAIN case EAI_AGAIN : { mytext = msgtexts[68]; } break; #endif #ifdef EAI_BADFLAGS case EAI_BADFLAGS : { mytext = msgtexts[69]; } break; #endif #ifdef EAI_FAIL case EAI_FAIL : { mytext = msgtexts[70]; } break; #endif #ifdef EAI_FAMILY case EAI_FAMILY : { mytext = msgtexts[71]; } break; #endif #ifdef EAI_MEMORY case EAI_MEMORY : { mytext = msgtexts[72]; } break; #endif #ifdef EAI_NODATA case EAI_NODATA : { mytext = msgtexts[73]; } break; #endif #ifdef EAI_NONAME case EAI_NONAME : { mytext = msgtexts[74]; } break; #endif #ifdef EAI_OVERFLOW case EAI_OVERFLOW : { mytext = msgtexts[78]; } break; #endif #ifdef EAI_SERVICE case EAI_SERVICE : { mytext = msgtexts[75]; } break; #endif #ifdef EAI_SOCKTYPE case EAI_SOCKTYPE : { mytext = msgtexts[76]; } break; #endif #ifdef EAI_SYSTEM case EAI_SYSTEM : { mytext = msgtexts[77]; } break; #endif } } break; case DK4_E_SOCKET_GETHOSTBYNAME : { switch (erp->dt.iDetails1) { #ifdef HOST_NOT_FOUND case HOST_NOT_FOUND : { mytext = msgtexts[73]; } break; #endif #ifdef NO_ADDRESS case NO_ADDRESS : { mytext = msgtexts[73]; } break; #endif #if defined(NO_DATA) && ((!defined(NO_ADDRESS)) || (NO_DATA != NO_ADDRESS)) case NO_DATA : { mytext = msgtexts[73]; } break; #endif #ifdef NO_RECOVERY case NO_RECOVERY : { mytext = msgtexts[70]; } break; #endif #ifdef TRY_AGAIN case TRY_AGAIN : { mytext = msgtexts[68]; } break; #endif } } break; case DK4_E_SOCKET_UP : case DK4_E_SOCKET_DOWN : case DK4_E_SOCKET_SOCKET : case DK4_E_SOCKET_CLOSE : case DK4_E_SOCKET_BIND : case DK4_E_SOCKET_CONNECT : case DK4_E_SOCKET_LISTEN : case DK4_E_SOCKET_ACCEPT : case DK4_E_SOCKET_SELECT : case DK4_E_SOCKET_SETSOCKOPT : case DK4_E_SOCKET_GETSOCKOPT : case DK4_E_SOCKET_IOCTLSOCKET : case DK4_E_SOCKET_FCNTL : case DK4_E_SOCKET_INET_NTOP : case DK4_E_SOCKET_INET_PTON : { switch (erp->dt.iDetails1) { #ifdef EACCES case EACCES : { /* socket: Insufficient permissions */ /* bind, connect, listen, send */ mytext = msgtexts[63]; } break; #endif #ifdef EADDRINUSE case EADDRINUSE : { /* bind: Address already in used */ /* connect */ /* listen */ mytext = msgtexts[64]; } break; #endif #ifdef EADDRNOTAVAIL case EADDRNOTAVAIL : { /* bind: nonexistent interface or address is not local */ /* connect */ mytext = msgtexts[65]; } break; #endif #ifdef EAFNOSUPPORT case EAFNOSUPPORT : { /* socket: Address family not supported */ /* bind: Mismatch address and address family */ /* connect, sendto, inet_pton */ mytext = msgtexts[54]; } break; #endif #ifdef EAGAIN case EAGAIN : { /* accept: Socket non-blocking, no incoming requests */ /* send, recv */ mytext = msgtexts[79]; } break; #endif #ifdef EALREADY case EALREADY : { /* connect: Already connected */ mytext = msgtexts[80]; } break; #endif #ifdef EBADF case EBADF : { /* close: Not a file descriptr */ /* shutdown, bind, connect */ /* listen, accept, send, recv */ mytext = msgtexts[81]; } break; #endif #ifdef ECONNABORTED case ECONNABORTED : { /* accept: Connection attempt aborted */ mytext = msgtexts[105]; } break; #endif #ifdef ECONNREFUSED case ECONNREFUSED : { /* connect: No-one listening on remote address */ /* recv */ mytext = msgtexts[82]; } break; #endif #ifdef ECONNRESET case ECONNRESET : { /* connect: Remote host denied connection */ /* send, recv */ mytext = msgtexts[83]; } break; #endif #ifdef EDEADLK case EDEADLK : { mytext = msgtexts[84]; } break; #endif #ifdef EDESTADDRREQ case EDESTADDRREQ : { /* bind: Address is a NULL pointer */ /* listen: Socket not yet bound */ /* send */ mytext = msgtexts[85]; } break; #endif #ifdef EDOM case EDOM : { mytext = msgtexts[86]; } break; #endif #ifdef EFAULT case EFAULT : { /* bind: Pointer to outside usable address space */ /* connect, accept, send, recv */ mytext = msgtexts[51]; } break; #endif #ifdef EHOSTUNREACH case EHOSTUNREACH : { /* connect: Remote host unreachable */ /* send */ mytext = msgtexts[106]; } break; #endif #ifdef EINPROGRESS case EINPROGRESS : { /* connect: Socket is non-blocking, operation would block */ mytext = msgtexts[87]; } break; #endif #ifdef EINTR case EINTR : { /* close: Interrupted by signal */ /* connect, accept, send, recv */ mytext = msgtexts[88]; } break; #endif #ifdef EINVAL case EINVAL : { /* socket: unknown protocol, illegal protocol family or flags */ /* shutdown: Invalid argument */ /* bind: Socket already bound */ /* bind: wrong address length */ /* bind: Socket already shut down */ /* connect: Wrong address length or address family */ /* listen: Socket already connected */ /* listen: Socket already shut down */ /* accept: Socket not listening, or illegal socket value */ /* accept: Invalid flags */ /* send: Invalid arguments , recv */ mytext = msgtexts[51]; } break; #endif #ifdef EISCONN case EISCONN : { /* bind: Socket already connected */ /* connect, send */ mytext = msgtexts[89]; } break; #endif #ifdef EISDIR case EISDIR : { /* bind: Address is a NULL pointer */ mytext = msgtexts[85]; } break; #endif #ifdef EIO case EIO : { /* close: I/O error */ /* connect, send */ mytext = msgtexts[90]; } break; #endif #ifdef ELOOP case ELOOP : { /* bind: Too many symbolic links or symlink loop */ /* connect, send */ mytext = msgtexts[91]; } break; #endif #ifdef EMFILE case EMFILE : { /* socket: Process file table overflow */ /* accept */ mytext = msgtexts[92]; } break; #endif #ifdef EMSGSIZE case EMSGSIZE : { /* send: Message size too large */ mytext = msgtexts[112]; } break; #endif #ifdef ENAMETOOLONG case ENAMETOOLONG : { /* bind: Address is too long */ /* connect, send */ mytext = msgtexts[93]; } break; #endif #ifdef ENETDOWN case ENETDOWN : { /* connect: Local network interface is down */ /* send */ mytext = msgtexts[53]; } break; #endif #ifdef ENETUNREACH case ENETUNREACH : { /* connect: Network is unreachable */ /* send */ mytext = msgtexts[94]; } break; #endif #ifdef ENFILE case ENFILE : { /* socket: System file table overflow */ /* accept */ mytext = msgtexts[95]; } break; #endif #ifdef ENOBUFS case ENOBUFS : { /* socket: No memory for buffers */ /* shutdown: Insufficient resources */ /* connect, listen, accept, send */ mytext = msgtexts[56]; } break; #endif #ifdef ENODEV case ENODEV : { /* accept: Protocol family and type not in network config */ mytext = msgtexts[126]; } break; #endif #ifdef ENOENT case ENOENT : { /* bind: File does not exist */ /* connect, send */ mytext = msgtexts[96]; } break; #endif #ifdef ENOLCK case ENOLCK : { mytext = msgtexts[97]; } break; #endif #ifdef ENOLINK case ENOLINK : { /* close: Connection to remote machine no longer active */ mytext = msgtexts[124]; } break; #endif #ifdef ENOMEM case ENOMEM : { /* socket: Not enough memory available */ /* bind, accept, send, recv */ mytext = msgtexts[72]; } break; #endif #ifdef ENOPROTOOPT case ENOPROTOOPT : { mytext = msgtexts[98]; } break; #endif #ifdef ENOSR case ENOSR : { /* socket: Insufficient stream resources */ /* bind, connect, accept, send, recv, shutdown */ mytext = msgtexts[122]; } break; #endif #ifdef ENOTCONN case ENOTCONN : { /* shutdown: Not connected */ /* send, recv */ mytext = msgtexts[114]; } break; #endif #ifdef ENOTDIR case ENOTDIR : { /* bind: Component or path prefix is not a directory */ /* connect, send */ mytext = msgtexts[99]; } break; #endif #ifdef ENOTSOCK case ENOTSOCK : { /* shutdown: Not a socket */ /* bind, connect, listen, accept, send, recv */ mytext = msgtexts[66]; } break; #endif #ifdef ENOSPC case ENOSPC : { /* inet_pton: Insufficient buffer size */ /* close: Not enough space on device */ mytext = msgtexts[100]; } break; #endif #ifdef ENXIO case ENXIO : { /* connect: Server exited before completing connection */ mytext = msgtexts[125]; } break; #endif #ifdef EOPNOTSUPP case EOPNOTSUPP : { /* bind: Operation not supported by socket type */ /* connect: Socket is listening */ /* listen: Socket can not listen */ /* accept: Not a stream socket */ /* send: Illegal flags, recv */ mytext = msgtexts[101]; } break; #endif #ifdef EPERM case EPERM : { /* connect: Insufficient permissions */ /* accept: Firewall rules forbid connection */ mytext = msgtexts[63]; } break; #endif #ifdef EPFNOSUPPORT case EPFNOSUPPORT : { /* socket: Protocol family not supported */ mytext = msgtexts[123]; } break; #endif #ifdef EPIPE case EPIPE : { mytext = msgtexts[116]; } break; #endif #ifdef EPROTONOSUPPORT case EPROTONOSUPPORT : { /* socket: Protocol type not supported in this domain */ mytext = msgtexts[57]; } break; #endif #ifdef EPROTO case EPROTO : { /* accept: Protocol error */ mytext = msgtexts[121]; } break; #endif #ifdef EPROTOTYPE case EPROTOTYPE : { /* socket: Socket type not supported by protocol */ /* connect: Remote type is different address family as local */ mytext = msgtexts[58]; } break; #endif #ifdef EROFS case EROFS : { /* bind: File system is mounted read-only */ mytext = msgtexts[102]; } break; #endif #ifdef ESTALE case ESTALE : { /* recv: Stale NFS file handle */ mytext = msgtexts[127]; } break; #endif #ifdef ETIMEDOUT case ETIMEDOUT : { /* connect: Timed out */ /* recv */ mytext = msgtexts[103]; } break; #endif #ifdef EOVERFLOW case EOVERFLOW : { mytext = msgtexts[104]; } break; #endif #if defined(EWOULDBLOCK) && ((!defined(EAGAIN)) || (EWOULDBLOCK != EAGAIN)) case EWOULDBLOCK : { /* accept: Socket non-blocking, no incoming requests */ /* send, recv */ mytext = msgtexts[79]; } break; #endif } } break; /* ----- non-Windows ----- */ #endif } } *msgtext = mytext; } } } void dk4socket_log_simple_1( dk4_app_t *app, int ll, size_t imain, dk4_er_t *erp ) { dkChar b1[16*sizeof(dk4_um_t)]; /* decimal */ dkChar b2[16*sizeof(dk4_um_t)]; /* hexadecimal */ const dkChar *fctn = NULL; /* Function name */ const dkChar *errt = NULL; /* Error text */ const dkChar *msgt[16]; /* Message components */ const dkChar * const *msga; /* Localized texts array */ size_t used = 0; /* Number of used components */ int res = 0; /* Conversion result */ if (0 != dk4app_log_do(app, ll)) { msga = dk4app_string_table(app,dk4socket_app_kwnl[0],dk4socket_app_kw_def); if (dk4socket_sz_kw_def > imain) { msgt[used++] = msga[imain]; dk4socket_log_fctname_msg(&fctn, &errt, app, erp); if (NULL != fctn) { if (NULL != errt) { msgt[used++] = dk4socket_app_kwnl[1]; msgt[used++] = fctn; msgt[used++] = dk4socket_app_kwnl[2]; msgt[used++] = errt; } else { res = dk4ma_write_decimal_signed( b1, DK4_SIZEOF(b1,dkChar), (dk4_um_t)(erp->dt.iDetails1), 0, NULL ); if (0 != res) { res = dk4ma_write_hex_signed( b2, DK4_SIZEOF(b2,dkChar), (dk4_im_t)(erp->dt.iDetails1), 8, NULL ); if (0 != res) { msgt[used++] = dk4socket_app_kwnl[1]; msgt[used++] = fctn; msgt[used++] = dk4socket_app_kwnl[2]; #if DK4_ON_WINDOWS msgt[used++] = msga[40]; #else msgt[used++] = msga[37]; #endif msgt[used++] = b1; msgt[used++] = msga[38]; msgt[used++] = b2; msgt[used++] = msga[39]; } } } } else { if (NULL != errt) { msgt[used++] = dk4socket_app_kwnl[1]; msgt[used++] = errt; } else { } } dk4app_log_msg(app, ll, msgt, used); } } } void dk4socket_log_simple_3( dk4_app_t *app, int ll, size_t i1, size_t i2, const dkChar *ctext, dk4_er_t *erp ) { dkChar b1[16*sizeof(dk4_um_t)]; /* decimal */ dkChar b2[16*sizeof(dk4_um_t)]; /* hexadecimal */ const dkChar *fctn = NULL; /* Function name */ const dkChar *errt = NULL; /* Error text */ const dkChar *msgt[16]; /* Message components */ const dkChar * const *msga; /* Localized texts array */ size_t used = 0; /* Number of used components */ int res = 0; /* Conversion result */ if (0 != dk4app_log_do(app, ll)) { msga = dk4app_string_table(app,dk4socket_app_kwnl[0],dk4socket_app_kw_def); if ((dk4socket_sz_kw_def > i1) && (dk4socket_sz_kw_def > i2)) { msgt[used++] = msga[i1]; if (NULL != ctext) { msgt[used++] = ctext; } msgt[used++] = msga[i2]; dk4socket_log_fctname_msg(&fctn, &errt, app, erp); if (NULL != fctn) { if (NULL != errt) { msgt[used++] = dk4socket_app_kwnl[1]; msgt[used++] = fctn; msgt[used++] = dk4socket_app_kwnl[2]; msgt[used++] = errt; } else { res = dk4ma_write_decimal_signed( b1, DK4_SIZEOF(b1,dkChar), (dk4_um_t)(erp->dt.iDetails1), 0, NULL ); if (0 != res) { res = dk4ma_write_hex_signed( b2, DK4_SIZEOF(b2,dkChar), (dk4_im_t)(erp->dt.iDetails1), 8, NULL ); if (0 != res) { msgt[used++] = dk4socket_app_kwnl[1]; msgt[used++] = fctn; msgt[used++] = dk4socket_app_kwnl[2]; #if DK4_ON_WINDOWS msgt[used++] = msga[40]; #else msgt[used++] = msga[37]; #endif msgt[used++] = b1; msgt[used++] = msga[38]; msgt[used++] = b2; msgt[used++] = msga[39]; } } } } else { if (NULL != errt) { msgt[used++] = dk4socket_app_kwnl[1]; msgt[used++] = errt; } else { } } dk4app_log_msg(app, ll, msgt, used); } } } void dk4socket_log_simple_5( dk4_app_t *app, int ll, size_t i1, size_t i2, size_t i3, const dkChar *ct1, const dkChar *ct2, dk4_er_t *erp ) { dkChar b1[16*sizeof(dk4_um_t)]; /* decimal */ dkChar b2[16*sizeof(dk4_um_t)]; /* hexadecimal */ const dkChar *fctn = NULL; /* Function name */ const dkChar *errt = NULL; /* Error text */ const dkChar *msgt[16]; /* Message components */ const dkChar * const *msga; /* Localized texts array */ size_t used = 0; /* Number of used components */ int res = 0; /* Conversion result */ if (0 != dk4app_log_do(app, ll)) { msga = dk4app_string_table(app,dk4socket_app_kwnl[0],dk4socket_app_kw_def); if ((dk4socket_sz_kw_def > i1) && (dk4socket_sz_kw_def > i2)) { msgt[used++] = msga[i1]; if (NULL != ct1) { msgt[used++] = ct1; } msgt[used++] = msga[i2]; if (NULL != ct2) { msgt[used++] = ct2; } msgt[used++] = msga[i3]; dk4socket_log_fctname_msg(&fctn, &errt, app, erp); if (NULL != fctn) { if (NULL != errt) { msgt[used++] = dk4socket_app_kwnl[1]; msgt[used++] = fctn; msgt[used++] = dk4socket_app_kwnl[2]; msgt[used++] = errt; } else { res = dk4ma_write_decimal_signed( b1, DK4_SIZEOF(b1,dkChar), (dk4_um_t)(erp->dt.iDetails1), 0, NULL ); if (0 != res) { res = dk4ma_write_hex_signed( b2, DK4_SIZEOF(b2,dkChar), (dk4_im_t)(erp->dt.iDetails1), 8, NULL ); if (0 != res) { msgt[used++] = dk4socket_app_kwnl[1]; msgt[used++] = fctn; msgt[used++] = dk4socket_app_kwnl[2]; #if DK4_ON_WINDOWS msgt[used++] = msga[40]; #else msgt[used++] = msga[37]; #endif msgt[used++] = b1; msgt[used++] = msga[38]; msgt[used++] = b2; msgt[used++] = msga[39]; } } } } else { if (NULL != errt) { msgt[used++] = dk4socket_app_kwnl[1]; msgt[used++] = errt; } else { } } dk4app_log_msg(app, ll, msgt, used); } } }