home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / pcomm / part02 / d_manual.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-17  |  1.7 KB  |  81 lines

  1. /*
  2.  * The manual dial option of the dialing directory.  A return code of
  3.  * 1 means we're ready to dial.  Dialing directory entry 0 is reserved
  4.  * for the manual dial option.  No sanity checking is done on the input.
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include <curses.h>
  9. #include "dial_dir.h"
  10.  
  11. int
  12. manual()
  13. {
  14.     WINDOW *m_win, *newwin();
  15.     char *number, *strdup(), *get_str(), ld_code, *strchr();
  16.     void fix_xmc(), free_ptr();
  17.     extern int xmc;
  18.     
  19.     m_win = newwin(5, 50, 0, 20);
  20.  
  21.     box(m_win, '|', '-');
  22.     mvwaddstr(m_win, 2, 3, "Phone Number: ");
  23.     wrefresh(m_win);
  24.                     /* get a phone number */
  25.     if ((number = get_str(m_win, 30, NULL, NULL)) == NULL) {
  26.         werase(m_win);
  27.         wrefresh(m_win);
  28.         delwin(m_win);
  29.         if (xmc > 0)
  30.             fix_xmc();
  31.         return(0);
  32.     }
  33.                     /* is first char an LD code ? */
  34.     ld_code = NULL;
  35.     if (strchr("+-@#", *number)) {
  36.         ld_code = *number;
  37.         number++;
  38.     }
  39.                     /* put it in the queue */
  40.     dir->q_ld[0] = ld_code;
  41.     dir->q_num[0] = 0;
  42.                     /* end of queue marker */
  43.     dir->q_num[1] = -1;
  44.     dir->d_cur = 0;
  45.                     /* build the entry zero */
  46.     free_ptr(dir->name[0]);
  47.     free_ptr(dir->number[0]);
  48.     dir->name[0] = strdup(number);
  49.     dir->number[0] = strdup(number);
  50.                     /* it overlaps dm_win, so erase it */
  51.     werase(m_win);
  52.     wrefresh(m_win);
  53.     delwin(m_win);
  54.     if (xmc > 0)
  55.         fix_xmc();
  56.     return(1);
  57. }
  58.  
  59. /*
  60.  * Clear the end of the physical screen where the magic cookie got shifted
  61.  * Geez, I hate magic cookie terminals...  Wyse, are you listening?
  62.  */
  63.  
  64. void
  65. fix_xmc()
  66. {
  67.     WINDOW *cl_win, *newwin();
  68.  
  69.     /*
  70.      * Since the cookie got shifted off the window, we have to
  71.      * create a new window to cover where the cookie ended up.
  72.      */
  73.     cl_win = newwin(1, 2, 4, 78);
  74.                     /* have to touch, otherwise nothing! */
  75.     touchwin(cl_win);
  76.     wrefresh(cl_win);
  77.     delwin(cl_win);
  78.     
  79.     return;
  80. }
  81.