home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume16 / pcomm2 / part03 / d_manual.c < prev    next >
C/C++ Source or Header  |  1988-09-14  |  2KB  |  88 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 "config.h"
  10. #include "misc.h"
  11. #include "dial_dir.h"
  12.  
  13. int
  14. manual()
  15. {
  16.     extern int xmc;
  17.     extern char *null_ptr;
  18.     WINDOW *m_win, *newwin();
  19.     char *number, *strdup(), *get_str(), ld_code, *strchr();
  20.     void fix_xmc(), free_ptr();
  21.  
  22.     m_win = newwin(5, 50, 0, 20);
  23.  
  24.     box(m_win, VERT, HORZ);
  25.     mvwaddstr(m_win, 2, 3, "Phone Number: ");
  26.     wrefresh(m_win);
  27.                     /* get a phone number */
  28.     if ((number = get_str(m_win, 30, "", "")) == NULL) {
  29.         werase(m_win);
  30.         wrefresh(m_win);
  31.         delwin(m_win);
  32.         if (xmc > 0)
  33.             fix_xmc();
  34.         return(0);
  35.     }
  36.                     /* is first char an LD code? */
  37.     ld_code = NULL;
  38.     if (strchr("+-@#", *number)) {
  39.         ld_code = *number;
  40.         number++;
  41.     }
  42.                     /* put it in the queue */
  43.     dir->q_ld[0] = ld_code;
  44.     dir->q_num[0] = 0;
  45.                     /* end of queue marker */
  46.     dir->q_num[1] = -1;
  47.     dir->d_cur = 0;
  48.                     /* build the entry zero */
  49.     free_ptr(dir->name[0]);
  50.     free_ptr(dir->number[0]);
  51.     dir->name[0] = strdup(number);
  52.                     /* if space, change to null */
  53.     if (!strcmp(number, " "))
  54.         dir->number[0] = null_ptr;
  55.     else
  56.         dir->number[0] = strdup(number);
  57.                     /* it overlaps dm_win, so erase it */
  58.     werase(m_win);
  59.     wrefresh(m_win);
  60.     delwin(m_win);
  61.     if (xmc > 0)
  62.         fix_xmc();
  63.     return(1);
  64. }
  65.  
  66. /*
  67.  * Clear the end of the physical screen where the magic cookie got shifted
  68.  * Geez, I hate magic cookie terminals...  Wyse, are you listening?
  69.  */
  70.  
  71. static void
  72. fix_xmc()
  73. {
  74.     WINDOW *cl_win, *newwin();
  75.  
  76.     /*
  77.      * Since the cookie got shifted off the window, we have to
  78.      * create a new window to cover where the cookie ended up.
  79.      */
  80.     cl_win = newwin(1, 2, 4, 78);
  81.                     /* have to touch, otherwise nothing! */
  82.     touchwin(cl_win);
  83.     wrefresh(cl_win);
  84.     delwin(cl_win);
  85.  
  86.     return;
  87. }
  88.