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

  1. /*++
  2. /* NAME
  3. /*    alias
  4. /* SUMMARY
  5. /*    manipulate alias data base
  6. /* PROJECT
  7. /*    pc-mail
  8. /* PACKAGE
  9. /*    mail
  10. /* SYNOPSIS
  11. /*    #include "mail.h"
  12. /*
  13. /*    int alias()
  14. /* DESCRIPTION
  15. /*    The alias data base is a text file. Each line is of the form
  16. /*
  17. /*        word    one or more words
  18. /*
  19. /*    The first word is the alias; words are separated by blanks
  20. /*    or commas. Upon alias expansion, the alias will be replaced
  21. /*    by the words on the remainder of the line of its definition.
  22. /*    An alias may be defined in terms of other aliases, but in terms
  23. /*    of itself.  Aliases may defined in any order. If an alias is defined
  24. /*    more than once, only the last definition will be effective.
  25. /*
  26. /*    alias() is invoked from the main menu and displays the contents
  27. /*    of the alias data base. An editor is invoked if the user wants
  28. /*    to make changes.
  29. /* COMMANDS
  30. /*    the program specified in the EDITOR environment variable,
  31. /*    or a system-dependent default.
  32. /* FILES
  33. /*      temporary edit file in current directory
  34. /*    $MAILDIR/a00000, alias data base
  35. /* SEE ALSO
  36. /*      pager(3), pager(5), kbdinp(3)
  37. /* AUTHOR(S)
  38. /*      W.Z. Venema
  39. /*      Eindhoven University of Technology
  40. /*      Department of Mathematics and Computer Science
  41. /*      Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  42. /* CREATION DATE
  43. /*    Wed Apr  6 20:21:35 MET 1988
  44. /* LAST MODIFICATION
  45. /*    90/01/22 13:01:13
  46. /* VERSION/RELEASE
  47. /*    2.1
  48. /*--*/
  49.  
  50. #include <errno.h>
  51. #include "defs.h"
  52. #include "path.h"
  53. #include "pager.h"
  54. #include "mail.h"
  55. #include "screen.h"
  56. #include "status.h"
  57.  
  58. /* forward declarations */
  59.  
  60. hidden int edit_alias();
  61. hidden void junk_alias();
  62. hidden int show_alias();
  63.  
  64. hidden File *afile = 0;            /* pager file */
  65.  
  66. /* alias - display alias data base */
  67.  
  68. public int alias()
  69. {
  70.     static Screen screen[] = {
  71.     'C',    "Close",    0,    prevscreen,
  72.     'E',    "Edit",        edit_alias,"Edit alias data base",
  73.     'P',    "Print",    print,    "Print alias data base",
  74.     PGUP,    PgUp,        pu_pager,pageup,
  75.     PGDN,    PgDn,        pd_pager,pagedn,
  76.     UP,    "Up",           up_pager,csrup,
  77.     DOWN,    "Down",         dn_pager,csrdn,
  78.     0,    0,              show_alias,
  79.     "(Reading alias database)",
  80.     };
  81.  
  82.     kbdinp(screen);                /* ask disposition */
  83.     junk_alias();                /* forget alias display */
  84.     return(S_REDRAW);                /* say screen was changed */
  85. }
  86.  
  87. /* show_alias - show alias data base or default message in middle window */
  88.  
  89. hidden int show_alias()
  90. {
  91.     static char *noalias[] = {            /* Ha ha ha ho ho hum */
  92.     "",
  93.     "The alias data base is empty. Normally it holds lines of the form",
  94.     "",
  95.     "    alias-name   one-or-more-mail-addresses",
  96.     "",
  97.     "You can create or change the alias data base with the E command.",
  98.     0,
  99.     };
  100.     if (afile) {                /* check pager file exists */
  101.     set_pager(afile);            /* select existing display */
  102.     } else if (rd_pager(afile = open_pager(),aliases())) {
  103.     mesg_pager(afile,noalias);        /* no alias database */
  104.     }
  105.     ds_pager();                    /* (re)draw display */
  106.     return(0);                    /* screen is up-to-date */
  107. }
  108.  
  109. /* junk_alias - destroy alias data base display */
  110.  
  111. hidden void junk_alias()
  112. {
  113.     if (afile) {                /* no-op if no display */
  114.     close_pager(afile);            /* release memory */
  115.     afile = 0;                /* say it is gone */
  116.     }
  117. }
  118.  
  119. /* edit_alias - edit or create alias data base */
  120.  
  121. hidden int edit_alias()
  122. {
  123.     register int stat;
  124.  
  125.     if (stat = edit(aliases(),TMPALIAS))
  126.     errdisp(stat);                /* edit() had a problem */
  127.     junk_alias();                /* force new display */
  128.     return(S_REDRAW);                /* say screen has changed */
  129. }
  130.