home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / communic / pcmail / main / errdisp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-05  |  8.2 KB  |  318 lines

  1. /*++
  2. /* NAME
  3. /*      errdisp 3
  4. /* SUMMARY
  5. /*      produce an error message display
  6. /* PROJECT
  7. /*      pc-mail
  8. /* PACKAGE
  9. /*      mail
  10. /* SYNOPSIS
  11. /*      int errdisp(errcode);
  12. /*      int errcode;
  13. /* DESCRIPTION
  14. /*      errdisp() produces an error display in the middle screen
  15. /*      window. The error code must be one defined in status.h.
  16. /*    Otherwise, an "unknown error" message is displayed.
  17. /*    errdisp() gives the user a chance to read it, before resuming
  18. /*      the program. errdisp() returns its argument, or the
  19. /*    value E_UNKNOWN if an unknown error code was specified.
  20. /* FUNCTIONS AND MACROS
  21. /*      kbdinp(), open_pager(), app_pager(), ds_pager(), close_pager()
  22. /* BUGS
  23. /*      Cannot force the user to really stop. It just recommends
  24. /*      to do so.
  25. /* AUTHOR(S)
  26. /*      W.Z. Venema
  27. /*      Eindhoven University of Technology
  28. /*      Department of Mathematics and Computer Science
  29. /*      Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  30. /* CREATION DATE
  31. /*      Thu Apr  9 21:19:05 GMT+1:00 1987
  32. /* LAST MODIFICATION
  33. /*    90/01/22 13:01:36
  34. /* VERSION/RELEASE
  35. /*    2.1
  36. /*--*/
  37.  
  38. #include "defs.h"
  39. #include "screen.h"
  40. #include "pager.h"
  41. #include "status.h"
  42. #include "window.h"
  43.  
  44. /* forward declarations */
  45.  
  46. hidden int ds_error();
  47.  
  48. /* A list of error mesages */
  49.  
  50. /* when the spool directory is not found */
  51.  
  52. hidden char *e_nospool[] = {
  53.     "",
  54.     "The mail program cannot access essential data files.",
  55.     "",
  56.     "Please check whether the spool directory is present",
  57.     "and whether the environment variable MAILDIR has been",
  58.     "set correctly.",
  59.     0,
  60. };
  61.  
  62. /* when we cannot open as many files as we need */
  63.  
  64. hidden char *e_fileno[] = {
  65.     "",
  66. #ifdef  MSDOS
  67.     "Check your CONFIG.SYS file. It should have a line",
  68.     "stating (for example)",
  69.     "    FILES = 20 .",
  70.     "While you're at it, also make sure that file also",
  71.     "has a line (for example)",
  72.     "    DEVICE = ANSI.SYS .",
  73.     "If your system does not have such a file create",
  74.     "one with an editor and place the file in the root",
  75.     "directory.",
  76.     "Reboot after making the changes and try again.",
  77. #endif
  78. #ifdef  unix
  79.     "Your UNIX is crippled (not enough file descriptors",
  80.     "per process). Rebuild the system or buy a better one.",
  81. #endif
  82.     0,
  83. };
  84.  
  85. /* when a program is not found */
  86.  
  87. hidden char *e_noprog[] = {
  88.     "",
  89.     "The mail program cannot execute an essential program file.",
  90.     "",
  91.     "Please make sure that the environment variable PATH has",
  92.     "been set to include the directories with the SMAIL, NMAIL,",
  93. #ifdef    DAEMON
  94.     "and EDITOR programs.",
  95. #else
  96.     "CICO and EDITOR programs.",
  97. #endif
  98.     "Also, make sure that the environment variable EDITOR has",
  99.     "been set to the editor of your preference, and that the",
  100.     "machine has enough free memory",
  101.     0,
  102. };
  103.  
  104. /* when a read error ocurred, or a file could not be opened */
  105.  
  106. hidden char *e_readerr[] = {
  107.     "",
  108.     "The mail program cannot read a data file.",
  109.     "",
  110.     "Please check your disk. This may be a serious problem.",
  111.     0,
  112. };
  113.  
  114. /* when a write error occurred */
  115.  
  116. hidden char *e_writerr[] = {
  117.     "",
  118.     "The mail program cannot write a data file.",
  119.     "",
  120.     "Please make sure that the disk is not write protected",
  121.     "and that there is sufficient free space.",
  122.     0,
  123. };
  124.  
  125. /* when the program is confused */
  126.  
  127. hidden char *e_confused[] = {
  128.     "",
  129.     "The mail program has detected a serious internal problem.",
  130.     "",
  131.     "You are requested to leave the mail system as it is and",
  132.     "call an expert.",
  133.     0,
  134. };
  135.  
  136. /* an unknown error (perhaps the editor returned a nonzero status) */
  137.  
  138. hidden char *e_unknown[] = {
  139.     "",
  140.     "The mail program has detected a unknown error. This may",
  141.     "not be a serious problem.",
  142.     0,
  143. };
  144.  
  145. /* when the UNIX host does not ask for login/password */
  146.  
  147. hidden char *e_noline[] = {
  148.     "",
  149.     "The mail program is not able to exchange mail with the",
  150.     "network.",
  151.     "",
  152.     "Please check the password, or try again later.",
  153.     0,
  154. };
  155.  
  156. /* when the UNIX host does not send initial protocol messages */
  157.  
  158. hidden char *e_noresp[] = {
  159.     "",
  160.     "The mail program is not able to exchange mail with the",
  161.     "network. Probably the password was incorrect.",
  162.     0,
  163. };
  164.  
  165. /* when the UNIX host does not want to talk to us */
  166.  
  167. hidden char *e_reject[] = {
  168.     "",
  169.     "The mail program is not able to exchange mail with the",
  170.     "network. Please contact the system administrator who is",
  171.     "responsible for the nearest UNIX system.",
  172.     0,
  173. };
  174.  
  175. /* when the link is lost (timeout,...) */
  176.  
  177. hidden char *e_lost[] = {
  178.     "",
  179.     "The mail program has lost contact with the network.",
  180.     "",
  181.     "We suggest that you try again at a later time.",
  182.     0,
  183. };
  184.  
  185. /* the resources are exhausted */
  186.  
  187. hidden char *e_sysfail[] = {
  188.     "",
  189.     "The mail program cannot proceed due to the fact",
  190.     "that the computer system is overloaded.",
  191.     "",
  192.     "Consult your local systems manager.",
  193.     0,
  194. };
  195.  
  196. /* bad setup parameter */
  197.  
  198. hidden char *e_badsetup[] = {
  199.     "",
  200.     "The mail program cannot communicate with the network",
  201.     "due to missing or invalid data in the setup.",
  202.     "",
  203.     "Check the Setup command in the main menu.",
  204.     0,
  205. };
  206.  
  207. /* when a file could not be removed */
  208.  
  209. hidden char *e_unlink[] = {
  210.     "",
  211.     "The mail program cannot remove a data file.",
  212.     "",
  213.     "Please make sure that your disk is not write protected",
  214.     0,
  215. };
  216.  
  217. /* when a file could not be printed */
  218.  
  219. hidden char *e_printerr[] = {
  220.     "",
  221.     "The mail programm cannot write to the printer",
  222.     "",
  223.     "Please check your default printer device",
  224.     0,
  225. };
  226.  
  227. hidden char *e_nouser[] = {
  228.     "",
  229.     "An unknown local user name was specified",
  230.     "",
  231.     "Please check the list of user names",
  232.     0,
  233. };
  234.  
  235. hidden char *e_ovalias[] = {
  236.     "",
  237.     "There probably is an error in your alias data base,",
  238.     "such that an alias is defined in terms of itself.",
  239.     "",
  240.     "Please check your alias data base, and then try to",
  241.     "send this message again.",
  242.     0,
  243. };
  244.  
  245. hidden char *e_toolong[] = {
  246.     "",
  247.     "The list of recipients is too long.",
  248.     "",
  249.     "There is no easy solution to this problem; you might",
  250.     "ask your UNIX system administrator to set up a mailing",
  251.     "list, and use the name of that mailing list instead.",
  252.     0,
  253. };
  254.  
  255. /* The folowing data structure links an error code to an error message */
  256.  
  257. typedef struct {
  258.     short code;                /* error return value */
  259.     char **msg;                /* associated message */
  260. } msgmap;
  261.  
  262. hidden msgmap errmap[] = {        /* lookup table for error codes */
  263.     E_UNKNOWN,    e_unknown,        /* don't remove this one! */
  264.     E_SYSFAIL,    e_sysfail,
  265.     E_NOPROG,    e_noprog,        /* and error messages */
  266.     E_NOSPOOL,    e_nospool,
  267.     E_READERR,    e_readerr,
  268.     E_WRITERR,    e_writerr,
  269.     E_CONFUSED,    e_confused,
  270.     E_FILENO,    e_fileno,
  271.     E_NOLINE,    e_noline,
  272.     E_NORESP,    e_noresp,
  273.     E_REJECT,    e_reject,
  274.     E_LOST,    e_lost,
  275.     E_BADSETUP,    e_badsetup,
  276.     E_UNLINK,    e_unlink,
  277.     E_PRINTERR,    e_printerr,
  278.     E_NOUSER,    e_nouser,
  279.     E_OVALIAS,    e_ovalias,
  280.     E_TOOLONG,    e_toolong,
  281.     0,        0,            /* terminator */
  282. };
  283.  
  284. /* errdisp - set up error pager file, return error code */
  285.  
  286. public int errdisp(code)
  287. int code;
  288. {
  289.     static Screen screen[] = {
  290.     ENTER,    "Enter",        0,      "Resume the mail program",
  291.     0,    0,              ds_error,"Press ENTER to continue",
  292.     };
  293.     register msgmap *mp;
  294.  
  295.     /* linear table search; this code is not used heavily */
  296.  
  297.     for (mp = errmap; mp->code && mp->code != code; mp++)
  298.     /* void */ ;                /* look it up in table */
  299.     if (mp->code == 0) {
  300.     return(errdisp(E_UNKNOWN));        /* unknown error code */
  301.     } else {
  302.     File *pp = open_pager();        /* open pager file */
  303.     mesg_pager(pp,mp->msg);            /* copy to pager file */
  304.     beep();                    /* red alert! red alert! */
  305.     kbdinp(screen);                /* give a chance to read it */
  306.     close_pager(pp);            /* forget screen display */
  307.     return(code);                /* return error code */
  308.     }
  309. }
  310.  
  311. /* ds_error - display error window */
  312.  
  313. hidden int ds_error()
  314. {
  315.     ds_pager();                    /* use "current" pager file */
  316.     return(0);                    /* say screen up-to-date */
  317. }
  318.