fatal.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*****************************************************************************
  2. *
  3. * NCSA DTM version 2.3
  4. * May 1, 1992
  5. *
  6. * NCSA DTM Version 2.3 source code and documentation are in the public
  7. * domain. Specifically, we give to the public domain all rights for future
  8. * licensing of the source code, all resale rights, and all publishing rights.
  9. *
  10. * We ask, but do not require, that the following message be included in all
  11. * derived works:
  12. *
  13. * Portions developed at the National Center for Supercomputing Applications at
  14. * the University of Illinois at Urbana-Champaign.
  15. *
  16. * THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
  17. * SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
  18. * WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
  19. *
  20. *****************************************************************************/
  21. /*********************************************************************
  22. **
  23. ** $Header: /X11/mosaic/cvsroot/xmosaic3/libdtm/fatal.c,v 1.2 1995/10/13 06:33:14 spowers Exp $
  24. **
  25. **********************************************************************/
  26. /*
  27. #ifdef RCSLOG
  28. $Log: fatal.c,v $
  29. Revision 1.2 1995/10/13 06:33:14 spowers
  30. Solaris support added.
  31. Revision 1.1.1.1 1995/01/11 00:03:00 alanb
  32. New CVS source tree, Mosaic 2.5 beta 4
  33. * Revision 2.5 1994/12/29 23:39:56 alanb
  34. * I'm committing with a new symbolic revision number.
  35. *
  36. * Revision 1.1.1.1 1994/12/28 21:37:32 alanb
  37. *
  38. * Revision 1.1.1.1 1993/07/04 00:03:12 marca
  39. * Mosaic for X version 2 distribution
  40. *
  41. * Revision 1.1 1993/01/18 21:50:25 marca
  42. * I think I got it now.
  43. *
  44. * Revision 1.8 92/04/30 20:25:27 jplevyak
  45. * Changed Version to 2.3.
  46. *
  47. * Revision 1.7 1992/03/10 22:07:10 jplevyak
  48. * Added changed for PC/MAC from Quincey Koziol (koziol@ncsa.uiuc.edu)
  49. * with modification.
  50. *
  51. * Revision 1.6 1991/10/16 23:25:00 jplevyak
  52. * Added new error message.
  53. *
  54. * Revision 1.5 1991/10/10 14:31:48 jplevyak
  55. * Added new error messages for "bad ack to internal flow control" and
  56. * "Bad address". These may not end up as user error messages.
  57. *
  58. * Revision 1.4 91/09/26 20:19:14 jplevyak
  59. * Added several new errors, changed the DTMerrmsg function to detect
  60. * and return 'unknown error:' errors. Generally encorporated the
  61. * good features of sherr (from the libtest directory).
  62. *
  63. * Revision 1.3 91/06/25 20:13:28 creiman
  64. * Removed varargs and dtm_fatal.
  65. *
  66. * Revision 1.2 1991/06/11 15:19:57 sreedhar
  67. * disclaimer added
  68. *
  69. * Revision 1.1 1990/11/08 16:33:22 jefft
  70. * Initial revision
  71. *
  72. #endif
  73. */
  74. #include <stdio.h>
  75. #include <sys/types.h>
  76. #ifdef _ARCH_MSDOS
  77. #include <nmpcip.h>
  78. #else
  79. #include <netinet/in.h>
  80. #endif
  81. #include "dtmint.h"
  82. static char *err_msg[] = {
  83. "No error",
  84. "Out of memory - can not create port",
  85. "Invalid port name - should be 'hostname:tcp port'",
  86. "Out of DTM ports - 256 ports max",
  87. "Couldn't initialize port",
  88. "DTM routines called in wrong order",
  89. "Encounted EOF",
  90. "Error creating socket",
  91. "Bad hostname",
  92. "Timeout waiting for connection",
  93. "Couldn't connect",
  94. "DTM read error",
  95. "DTM write error",
  96. "DTM header to long for buffer",
  97. "SDS error",
  98. "Select call error",
  99. "Environment not setup",
  100. "User buffer overflow",
  101. "Port table corrupted",
  102. "Bad port supplied to library",
  103. "Bad ack to internal flow control",
  104. "Bad address",
  105. "Problem communicating with server"
  106. };
  107. #ifdef DTM_PROTOTYPES
  108. void dtm_version(void )
  109. #else
  110. void dtm_version()
  111. #endif
  112. {
  113. fprintf(stderr, "\nDTMlib version %s.\n", DTM_VERSION);
  114. }
  115. #ifdef DTM_PROTOTYPES
  116. char *DTMerrmsg(int quiet)
  117. #else
  118. char *DTMerrmsg(quiet)
  119. int quiet;
  120. #endif
  121. {
  122. char * strUnknown = "unknown error: %d";
  123. char strOut[60];
  124. char * strErr;
  125. if ( DTMerrno < (sizeof(err_msg)/sizeof(char *)))
  126. strErr = err_msg[(int)DTMerrno];
  127. else {
  128. sprintf( strOut, strUnknown, DTMerrno);
  129. strErr = strOut;
  130. }
  131. if (!quiet)
  132. fprintf(stderr, "\nDTMerrno = %d: %s\n", DTMerrno,
  133. strErr);
  134. return strErr;
  135. }