home *** CD-ROM | disk | FTP | other *** search
/ kermit.columbia.edu / kermit.columbia.edu.tar / kermit.columbia.edu / bin / p205.zip / exesrc / error.c < prev    next >
C/C++ Source or Header  |  1994-12-18  |  2KB  |  85 lines

  1. /*****************************************************************************/
  2. /*           Copyright (c) 1994 by Jyrki Salmi <jytasa@jyu.fi>             */
  3. /*        You may modify, recompile and distribute this file freely.         */
  4. /*****************************************************************************/
  5.  
  6. /*
  7.    Error routines used to report errors occurred in the P.DLL as well as
  8.    in the P.EXE.
  9. */
  10.  
  11. #include <stdio.h>
  12. #define INCL_DOSMISC
  13. #include <os2.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include "typedefs.h"
  17. #include "errmsgs.h"
  18. #include "tcpipapi.h"
  19.  
  20. /* Report an error occurred in the OS/2 API */
  21.  
  22. void os2_error(U32 num,
  23.            U32 ret_code,
  24.            U32 module,
  25.            U32 line_num,
  26.            U8 *opt_arg) {
  27.  
  28.   UCHAR buf[4096];
  29.   ULONG msg_len;
  30.   APIRET rc;
  31.  
  32.   fprintf(stderr, "\rOS/2 Error %lu:%lu@%lu:%lu: ",
  33.       num, ret_code,        /* First %lu:%lu */
  34.       module, line_num);        /* Second %lu:%lu */
  35.   /* Show the verbal description */
  36.   fprintf(stderr, os2_error_msg[num - 1], opt_arg);
  37.   if (ret_code != 0) {
  38.     fprintf(stderr, ", OS/2 reports:\n\n");
  39.     rc = DosGetMessage(NULL,
  40.                0,
  41.                buf,
  42.                4096,
  43.                ret_code,
  44.                "OSO001.MSG",
  45.                &msg_len);
  46.     if (rc) {
  47.       fprintf(stderr,
  48. "Couldn't read error message from file OSO001.MSG which is a part of OS/2\n"
  49. "and usually located in \\OS2\\SYSTEM directory.\n");
  50.  
  51.     } else {
  52.       fprintf(stderr, "%s\n", buf);
  53.  
  54.       if (strncmp(buf, "SYS", 3) == 0)
  55.     fprintf(stderr,
  56. "Enter \"HELP %.7s\" at OS/2 prompt to get more information.\n", buf);
  57.     }
  58.   } else
  59.     fprintf(stderr, "\n");
  60.  
  61.   exit(1);
  62. }
  63.  
  64. /* Report an error occurred in the TCP/IP API */
  65.  
  66. void tcpip_error(U32 num,
  67.          U32 ret_code,
  68.          U32 module,
  69.          U32 line_num,
  70.          U8 *opt_arg) {
  71.  
  72.   fprintf(stderr, "\rTCP/IP Error %lu:%lu@%lu:%lu: ",
  73.       num, ret_code,        /* First %lu:%lu */
  74.       module, line_num);        /* Second %lu:%lu */
  75.   /* Show the verbal description */
  76.   fprintf(stderr, tcpip_error_msg[num - 0x30], opt_arg);
  77.   if (ret_code != 0) {
  78.     fprintf(stderr, ", API reports:\n\n");
  79.     psock_errno(NULL);
  80.   } else
  81.     fprintf(stderr, "\n");
  82.  
  83.   exit(1);
  84. }
  85.