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

  1. /* t-chkpe.c: Checks the pe2or and or2pe routines using an RFC address */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Tools/misc/RCS/t-chkpe.c,v 6.0 1991/12/18 20:30:40 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Tools/misc/RCS/t-chkpe.c,v 6.0 1991/12/18 20:30:40 jpo Rel $
  9.  *
  10.  * $Log: t-chkpe.c,v $
  11.  * Revision 6.0  1991/12/18  20:30:40  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include "head.h"
  19. #include "or.h"
  20.  
  21. extern char             or_error[];
  22.  
  23.  
  24.  
  25.  
  26. /* ---------------------  Begin  Routines  -------------------------------- */
  27.  
  28.  
  29.  
  30. main (argc, argv)
  31. int     argc;
  32. char    *argv[];
  33. {
  34.     char    buf[BUFSIZ];
  35.     int     i = 1;
  36.  
  37.     sys_init (argv[0]);
  38.  
  39.     if (or_init() == NOTOK ) {
  40.         printf ("or_init() failed\n");
  41.         exit (1);
  42.     }
  43.  
  44.     if (argc == 1)
  45.         while (gets (buf) != NULL)
  46.             parse_address (buf);
  47.     else
  48.         while (i < argc)
  49.             parse_address (argv[i++]);
  50. }
  51.  
  52.  
  53. /* ---------------------  Static  Routines  ------------------------------- */
  54.  
  55.  
  56.  
  57. static int parse_address (str)
  58. char    *str;
  59. {
  60.     char            rfcbuf [BUFSIZ];
  61.     char            x400buf_orig [BUFSIZ];
  62.     char            x400buf_after [BUFSIZ];
  63.     OR_ptr          or = NULLOR;
  64.     PE              pe = NULLPE;
  65.  
  66.     x400buf_orig[0] = x400buf_after[0] = rfcbuf[0] = '\0';
  67.  
  68.     /* --- Perform the x400 addressing --- */
  69.     if ((or_rfc2or (str, &or) != OK) || (or == NULLOR))
  70.         goto error;
  71.     or_or2std (or, x400buf_orig, FALSE);
  72.  
  73.  
  74.     /* --- Do the pe routines -- */
  75.     pe = ora2pe (or);
  76.     if (pe == NULLPE)
  77.         goto error;
  78.  
  79.     or_free (or);
  80.     or = pe2ora (pe);
  81.     pe_free (pe);
  82.  
  83.     if (or == NULLOR)
  84.         goto error;
  85.  
  86.     /* --- Perform the rfc822 address parsing --- */
  87.     or_or2std (or, x400buf_after, FALSE);
  88.     if (or_or2rfc (or, rfcbuf) == NOTOK)
  89.         goto error;
  90.  
  91.     printf ("PE check Succeded\n");
  92.     printf ("%s -> (x400 orig)  %s\n%-*s -> (x400 after) %s\n%-*s -> (rfc822)     %s\n",
  93.         str, x400buf_orig, strlen(str), "", x400buf_after,
  94.         strlen(str), "", rfcbuf);
  95.  
  96.     goto finish;
  97.  
  98.  
  99. error:  ;
  100.     printf ("PE check Failed \nReason : %s\n", or_error);
  101.     if (x400buf_orig[0] != '\0')
  102.         printf ("%s -> (x400 orig) %s\n", str, x400buf_orig);
  103.     if (x400buf_after[0] != '\0')
  104.         printf ("%s -> (x400 after) %s\n", str, x400buf_after);
  105.     if (rfcbuf[0] != '\0')
  106.         printf ("%s -> (rfc822) %s\n", str, rfcbuf);
  107.  
  108.  
  109. finish: ;
  110.     fflush (stdout);
  111.     if (or)         or_free (or);
  112.     if (pe)         pe_free (pe);
  113.     return;
  114. }
  115.  
  116.  
  117. int advise ()
  118. {
  119.     return;
  120. }
  121.