home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / ip / manage / snmp / mit / asntest / asntest.c next >
Encoding:
C/C++ Source or Header  |  1991-05-17  |  1.3 KB  |  81 lines

  1.  
  2.  
  3. /*
  4.  *    $Header: asntest.c,v 3.0 91/05/17 16:15:13 jrd Rel $
  5.  *    Author: J. Davin
  6.  *    Copyright 1988, 1989, Massachusetts Institute of Technology
  7.  *    See permission and disclaimer notice in file "notice.h"
  8.  */
  9.  
  10. #include    <notice.h>
  11.  
  12. #include    <ctypes.h>
  13. #include    <rdx.h>
  14. #include    <debug.h>
  15. #include    <asn.h>
  16.  
  17. int    main (argc, argv)
  18.  
  19. int    argc;
  20. char    *argv [];
  21.  
  22. {
  23.     AsnIdType        asn;
  24.     AsnStatusType        status;
  25.     CByteType        buf [ 512 ];
  26.     CBytePtrType        cp;
  27.     CIntfType        i;
  28.     AsnLengthType        l;
  29.     CUnslType        number;
  30.  
  31.     cp = buf;
  32.     for (i = 1; i < (CIntfType) argc; i++) {
  33.         (void) rdxDecodeAny (& number, argv [ i ]);
  34.         *cp++ = (CByteType) number;
  35.     }
  36.  
  37.     asn = asnNew ((AsnLanguageType) 0);
  38.  
  39.     status = asnStatusOk;
  40.     cp = buf;
  41.     for (i = 1; ((status == asnStatusOk) && (i < (CIntfType) argc)); i++) {
  42.         status = asnDecode (asn, *cp);
  43.         DEBUG2 ("%02.02X %d\n", (unsigned) *cp, status);
  44.         cp++;
  45.     }
  46.  
  47.     switch (status) {
  48.  
  49.     case asnStatusOk:
  50.         DEBUG0 ("++OK\n");
  51.         break;
  52.  
  53.     case asnStatusAccept:
  54.         DEBUG0 ("++ACCEPT\n");
  55.         break;
  56.  
  57.     case asnStatusReject:
  58.         DEBUG0 ("++REJECT\n");
  59.         break;
  60.  
  61.     case asnStatusBad:
  62.         DEBUG0 ("++BAD\n");
  63.         break;
  64.  
  65.     default:
  66.         DEBUG0 ("++Panic\n");
  67.         break;
  68.     }
  69.  
  70.     l = asnEncode (asn, buf, (AsnLengthType) 512);
  71.     cp = buf;
  72.     for (i = (CIntfType) l; i > 0; i--) {
  73. /*        DEBUG1 ("%02.02X ", *cp++);        */
  74.         DEBUG1 ("%d ", *cp++);
  75.     }
  76.     DEBUG0 ("\n");
  77.  
  78.     asn = asnFree (asn);
  79.     exit (0);
  80. }
  81.