|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T t
Length: 3463 (0xd87) Types: TextFile Names: »tasn.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z« └─⟦e5a54fb17⟧ └─⟦this⟧ »pp-5.0/Chans/x40088/tasn.c«
/* tasn.c : test the incremental asn1 reading */ # ifndef lint static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Chans/x40088/RCS/tasn.c,v 5.0 90/09/20 15:58:23 pp Exp Locker: pp $"; # endif /* * $Header: /cs/research/pp/hubris/pp-beta/Chans/x40088/RCS/tasn.c,v 5.0 90/09/20 15:58:23 pp Exp Locker: pp $ * * $Log: tasn.c,v $ * Revision 5.0 90/09/20 15:58:23 pp * rcsforce : 5.0 public release * */ #include "util.h" #include "q.h" #include <isode/psap.h> char *myname; void adios (), advise (); int numbytes = 40; extern IFP asn_procfnx; main (argc, argv) int argc; char **argv; { extern char *optarg; extern int optind; int opt; myname = argv[0]; while((opt = getopt(argc, argv, "n:")) != EOF) switch (opt) { case 'n': numbytes = atoi (optarg); break; default: fprintf (stderr, "Usage: %s\n", myname); break; } argc -= optind; argv += optind; if (argc > 0) { while (argc -- > 0) { FILE *fp; if ((fp = fopen (*argv, "r")) == NULL) adios (*argv, "Can't open file"); process (fp); (void) fclose (fp); argv ++; } } else process (stdin); exit (0); } static int hdrprint (pe, type) PE pe; int type; { switch (type) { case MT_UMPDU: advise (NULLCP, "Message"); if (print_MTA_MessageTransferEnvelope (pe, 1, NULLINTP, NULLVP, NULL) == NOTOK) { advise (NULLCP, "print MessageTransferEnvelope failed: [%s]", PY_pepy); vunknown (pe); } break; case MT_PMPDU: advise (NULLCP, "Probe"); if (print_MTA_ProbeTransferEnvelope (pe, 1, NULLINTP, NULLVP, NULL) == NOTOK) { advise (NULLCP, "print MessageTransferEnvelope failed: [%s]", PY_pepy); vunknown (pe); } break; case MT_DMPDU: advise (NULLCP, "Delivery Report"); if (print_Transfer_ReportAPDU (pe, 1, NULLINTP, NULLVP, NULL) == NOTOK) { advise (NULLCP, "print Transfer_ReportAPDU failed: [%s]", PY_pepy); vunknown (pe); } break; } return OK; } static int total_count; copycount (str, len) char *str; int len; { total_count += len; return OK; } process (fp) FILE *fp; { char buf[BUFSIZ]; int n; struct qbuf *qb; int result = NOTOK; total_count = 0; asn_init (hdrprint, copycount); while ((n = fread (buf, 1, numbytes, fp)) > 0) { qb = str2qb (buf, n, 1); result = (*asn_procfnx) (qb); qb_free (qb); switch (result) { default: case NOTOK: adios (NULLCP, "Error"); break; case OK: case DONE: break; } } if (result != DONE) adios (NULLCP, "Read message - not parsed"); else advise (NULLCP, "Message received, %d bytes of content", total_count); } #include <varargs.h> #ifndef lint void _advise (); void adios (va_alist) va_dcl { va_list ap; va_start (ap); _advise (ap); va_end (ap); _exit (1); } #else /* VARARGS */ void adios (what, fmt) char *what, *fmt; { adios (what, fmt); } #endif #ifndef lint void advise (va_alist) va_dcl { va_list ap; va_start (ap); _advise (ap); va_end (ap); } void _advise (ap) va_list ap; { char buffer[BUFSIZ]; asprintf (buffer, ap); (void) fflush (stdout); fprintf (stderr, "%s: ", myname); (void) fputs (buffer, stderr); (void) fputc ('\n', stderr); (void) fflush (stderr); } #else /* VARARGS */ void advise (what, fmt) char *what, *fmt; { advise (what, fmt); } #endif