home *** CD-ROM | disk | FTP | other *** search
/ BUG 14 / BUGCD1998_05.ISO / internet / tcp4u / tcp4u330.exe / tcp4u.330 / src / tcp4_err.c < prev    next >
C/C++ Source or Header  |  1998-03-05  |  6KB  |  143 lines

  1. /*
  2.  * Tcp4u v 3.30        Last Revision 06/06/1997  3.1
  3.  *
  4.  *===========================================================================
  5.  *
  6.  * Project: Tcp4u,      Library for tcp protocol
  7.  * File:    tcp4u_err.c
  8.  * Purpose: version and error management 
  9.  *
  10.  *===========================================================================
  11.  *
  12.  * This software is Copyright (c) 1996-1998 by Philippe Jounin
  13.  *
  14.  * This library is free software; you can redistribute it and/or
  15.  * modify it under the terms of the GNU Library General Public
  16.  * License as published by the Free Software Foundation; either
  17.  * version 2 of the License, or (at your option) any later version.
  18.  * 
  19.  * This library is distributed in the hope that it will be useful,
  20.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  22.  * Library General Public License for more details.
  23.  * 
  24.  * You should have received a copy of the GNU Library General Public
  25.  * License along with this library; if not, write to the
  26.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  27.  * Boston, MA  02111-1307, USA.
  28.  *
  29.  *
  30.  *  If you make modifications to this software that you feel
  31.  *  increases it usefulness for the rest of the community, please
  32.  *  email the changes, enhancements, bug fixes as well as any and
  33.  *  all ideas to me. This software is going to be maintained and
  34.  *  enhanced as deemed necessary by the community.
  35.  *
  36.  *
  37.  *             Philippe Jounin (ph.jounin@computer.org)
  38.  */
  39.  
  40.  
  41.  
  42. #include "build.h"
  43.  
  44.  
  45. /* ------------------------------------------------------------------ */
  46. /* Compataibilite avec les anciennes fonctions                        */
  47. /* ------------------------------------------------------------------ */
  48. #ifdef _WINDOWS
  49.   int API4U Tcp4wVer (LPSTR sz, UINT uSize)   { return Tcp4uVer(sz,uSize);   }
  50.   LPSTR API4U Tcp4wErrorString (int Rc)       { return Tcp4uErrorString(Rc); }
  51. #endif
  52. #ifdef UNIX 
  53.   int API4U Tcp4uxVer(LPSTR sz, UINT uSize)   { return Tcp4uVer(sz,uSize);   }
  54.   LPSTR API4U Tcp4uxErrorString (int Rc)      { return Tcp4uErrorString(Rc); }
  55. #endif
  56.  
  57.  
  58.  
  59. /* ------------------------------------------------------------------ */
  60. /* Informations sur la version                                        */
  61. /* ------------------------------------------------------------------ */
  62. static LPCSTR szTcp4uVersion = 
  63.  
  64. #ifdef _WINDOWS
  65. #  ifdef _WIN32
  66. #     ifdef  TCP4W_DLL
  67.                   "@(#)DLL Tcp4u Win32 by Ph.Jounin Version 3.30";
  68. #     else
  69.                   "@(#)Lib Tcp4u Win32 by Ph.Jounin Version 3.30";
  70. #     endif /* DLL ? */
  71. #  else
  72. #     ifdef  TCP4W_DLL
  73.                   "@(#)DLL Tcp4u Win16 by Ph.Jounin Version 3.30";
  74. #     else
  75.                   "@(#)Lib Tcp4u Win16 by Ph.Jounin Version 3.30";
  76. #     endif /* DLL ? */                  
  77. #  endif /* WIN32 */
  78. #endif /* _WINDOWS */
  79. #ifdef UNIX
  80.                   "@(#)Tcp4u Unix by Ph.jounin Version 3.30";
  81. #endif /* UNIX */
  82.  
  83. int   nTcp4uVersion  = 0x0330;
  84.  
  85.  
  86. /* ------------------------------------------------------------------ */
  87. /* La fonction les retournant                                         */
  88. /* ------------------------------------------------------------------ */
  89.  
  90. int API4U Tcp4uVer (LPSTR szInfo, UINT uBufSize)
  91. {
  92.   if (szInfo!=NULL) Strcpyn(szInfo, szTcp4uVersion + 4, uBufSize);
  93. return nTcp4uVersion;
  94. } /* Tcp4uVer */
  95.  
  96.  
  97.  
  98. /* ------------------------------------------------------ */
  99. /* Fonction:                                              */
  100. /* Retourne un message texte donnant la cause de l'erreur */
  101. /* Note: Certains messages sont specifiques a la version  */
  102. /*       Windows... Peu importe                           */
  103. /* ------------------------------------------------------ */
  104.  
  105. struct S_Tcp4Err
  106. {
  107.    int   Tcp4ErrCode;
  108.    LPSTR Tcp4ErrString;
  109. }; /* struct S_Tcp4Err */
  110.  
  111. static struct S_Tcp4Err sTcp4Err [] =
  112. {
  113.   { TCP4U_SUCCESS,         (LPSTR) "Successful call"                         },
  114.   { TCP4U_ERROR,           (LPSTR) "Network error"                           },
  115.   { TCP4U_TIMEOUT,         (LPSTR) "Timeout in recv or accept"               },
  116.   { TCP4U_HOSTUNKNOWN,     (LPSTR) "Reference to Unknown host"               },
  117.   { TCP4U_NOMORESOCKET,    (LPSTR) "All sockets has been used up"            }, 
  118.   { TCP4U_NOMORERESOURCE,  (LPSTR) "No more free resource"                   },
  119.   { TCP4U_CONNECTFAILED,   (LPSTR) "Connect function has failed"             },
  120.   { TCP4U_UNMATCHEDLENGTH, (LPSTR) "TcpPPRecv : Error in length"             },
  121.   { TCP4U_BINDERROR,       (LPSTR) "Bind failed (Task already started or attempt to open privileged socket )"     },
  122.   { TCP4U_OVERFLOW,        (LPSTR) "Overflow during TcpPPRecv/TcpRecvUntilStr"},
  123.   { TCP4U_EMPTYBUFFER,     (LPSTR) "TcpPPRecv receives 0 byte"               },
  124.   { TCP4U_CANCELLED,       (LPSTR) "Call cancelled by signal or TcpAbort"    }, 
  125.   { TCP4U_INSMEMORY,       (LPSTR) "Not enough memory to perform function"   },
  126.   { TCP4U_BADPORT,         (LPSTR) "Bad port number or alias"                },
  127.   { TCP4U_SOCKETCLOSED,    (LPSTR) "Host has closed connection"              },
  128.   { TCP4U_FILE_ERROR,      (LPSTR) "A file operation has failed"             },
  129. }; /* sTcp4Err */
  130.  
  131. LPSTR API4U Tcp4uErrorString (int Rc)
  132. {
  133. int Idx;
  134.    Tcp4uLog (LOG4U_PROC, "Tcp4uErrorString");
  135.  
  136.    for ( Idx=0 ;  
  137.          Idx<SizeOfTab(sTcp4Err) && sTcp4Err[Idx].Tcp4ErrCode!=Rc;  
  138.          Idx++ );
  139.    Tcp4uLog (LOG4U_EXIT, "Tcp4uErrorString");
  140. return Idx>= SizeOfTab(sTcp4Err) ?   (LPSTR) "Not an Tcp4 return code" :
  141.                                       sTcp4Err[Idx].Tcp4ErrString;
  142. } /* Tcp4(w/ux)ErrorString */
  143.