home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Tools / probe / p_stdin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  2.9 KB  |  149 lines

  1. /* p_stdin.c: Gets values for the probe via stdin */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Tools/probe/RCS/p_stdin.c,v 6.0 1991/12/18 20:32:41 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Tools/probe/RCS/p_stdin.c,v 6.0 1991/12/18 20:32:41 jpo Rel $
  9.  *
  10.  * $Log: p_stdin.c,v $
  11.  * Revision 6.0  1991/12/18  20:32:41  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include "util.h"
  19. #include "q.h"
  20. #include "tb_q.h"
  21. #include <isode/cmd_srch.h>
  22.  
  23.  
  24. #define  GetStr(buf)            (gets (buf) != NULL && isstr(buf))
  25.  
  26.  
  27. /* --- externals --- */
  28. extern CMD_TABLE            qtbl_que[];
  29. extern Q_struct                *QuePtr;
  30. extern ADDR                *make_adr_new();
  31.  
  32.  
  33. /* --- static routines  --- */
  34. static void                 prompt_encoded();
  35.  
  36.  
  37.  
  38.  
  39. /* ---------------------  Begin  Routines  -------------------------------- */
  40.  
  41.  
  42.  
  43.  
  44. void prompt_probe_stdin()
  45. {
  46.     char    buf[BUFSIZ];
  47.     int    found;
  48.     ADDR    *ap;
  49.  
  50.     /* --- Print a message --- */
  51.     printf ("\n\n");
  52.     printf (
  53. "******************************************************************************");
  54.     printf ("\n\n");
  55.     printf ("This is a probe generation utility. Please note that the Recipient address \n"); 
  56.     printf ("field is recursive, and that each address should be input, a line at a time\n\n"); 
  57.     printf (
  58. "******************************************************************************");
  59.     printf ("\n\n");
  60.  
  61.  
  62.     /* --- Originator --- */
  63.     printf ("From:   ");
  64.     printf ("%s\n", QuePtr -> Oaddress  -> ad_value);
  65.  
  66.  
  67.     /* --- Recipients --- */
  68.     printf ("To:     ");
  69.     for (found = FALSE; GetStr(buf);) {
  70.         ap = make_adr_new (buf, AD_RECIPIENT);
  71.         adr_add (&QuePtr -> Raddress, ap);
  72.         printf ("        ");
  73.         found = TRUE;
  74.     }
  75.     if (found == FALSE) {
  76.         printf ("*** Error: No Recipients specified ***\n"); 
  77.         exit (1);
  78.     }
  79.  
  80.  
  81.     /* --- Content Length --- */
  82.     printf ("%s:  ", rcmd_srch(Q_MSGSIZE, qtbl_que));
  83.     GetStr(buf);
  84.     QuePtr -> msgsize = atoi(buf);
  85.  
  86.  
  87.     /* --- EncodedInformationTypes --- */
  88.     (void) prompt_encoded();
  89.  
  90.  
  91.     /* --- UA id --- */
  92.     printf ("%s:  ", rcmd_srch(Q_UA_ID, qtbl_que));
  93.     GetStr(buf);
  94.     if (isstr(buf))
  95.         QuePtr -> ua_id = strdup (buf); 
  96.  
  97.  
  98.     /* --- Per Message Flag --- */
  99.     QuePtr -> implicit_conversion_prohibited = 
  100.         prompt_yn (rcmd_srch (Q_IMPLICIT_CONVERSION, qtbl_que));
  101.  
  102.     QuePtr -> alternate_recip_allowed = 
  103.         prompt_yn (rcmd_srch (Q_ALTERNATE_RECIP_ALLOWED, qtbl_que));
  104.  
  105.     printf ("\n");
  106. }
  107.  
  108.  
  109.  
  110. /* ---------------------  Static Routines  -------------------------------- */
  111.  
  112.  
  113.  
  114. static int prompt_yn (name)
  115. char    *name; 
  116.     char    buf[BUFSIZ];
  117.     int    retval;
  118.     
  119.     if (name == NULLCP) { 
  120.          printf ("*** Error: Internal error no key specified ***\n");
  121.                 exit (1);
  122.         }
  123.     
  124.     printf ("%s (y/n):  ", name);
  125.     if (gets(buf) == NULL)
  126.         exit (1);
  127.     retval = set_yn(buf);
  128.     return retval;
  129. }
  130.  
  131.  
  132.  
  133. static void prompt_encoded()
  134. {
  135.     char    buf[BUFSIZ];
  136.     int    retval;        
  137.  
  138.  
  139.     for (;;) {
  140.         printf ("%s:  ", rcmd_srch(Q_ENCODED_INFO, qtbl_que));
  141.         if (gets(buf) == NULL)    exit (1);
  142.         retval = set_encoded (buf);
  143.         if (retval == NOTOK)
  144.             continue;
  145.         return;
  146.     }
  147. }
  148.