|
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 r
Length: 7288 (0x1c78) Types: TextFile Names: »ryinitiator.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z« └─⟦e5a54fb17⟧ └─⟦this⟧ »pp-5.0/Chans/qmgr-load/ryinitiator.c«
/* ryinitiator.c - generic interactive initiator */ # ifndef lint static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Chans/qmgr-load/RCS/ryinitiator.c,v 5.0 90/09/20 15:53:14 pp Exp Locker: pp $"; # endif /* * $Header: /cs/research/pp/hubris/pp-beta/Chans/qmgr-load/RCS/ryinitiator.c,v 5.0 90/09/20 15:53:14 pp Exp Locker: pp $ * * $Log: ryinitiator.c,v $ * Revision 5.0 90/09/20 15:53:14 pp * rcsforce : 5.0 public release * */ /* * NOTICE * * Acquisition, use, and distribution of this module and related * materials are subject to the restrictions of a license agreement. * Consult the Preface in the User's Manual for the full terms of * this agreement. * */ #include <stdio.h> #include <varargs.h> #include "ryinitiator.h" /* \f DATA */ static char *myname = "ryinitiator"; static int invoke(); extern char *isodeversion; /* \f INITIATOR */ /* ARGSUSED */ ryinitiator (myname, host, argc, argv, myservice, mycontext, mypci, ops, dispatches, quit) char *myname, *host; int argc; char **argv, *myservice, *mycontext, *mypci; struct RyOperation ops[]; struct client_dispatch *dispatches; IFP quit; { int sd; register struct client_dispatch *ds; struct SSAPref sfs; register struct SSAPref *sf; register struct PSAPaddr *pa; struct AcSAPconnect accs; register struct AcSAPconnect *acc = &accs; struct AcSAPindication acis; register struct AcSAPindication *aci = &acis; register struct AcSAPabort *aca = &aci -> aci_abort; AEI aei; OID ctx, pci; struct PSAPctxlist pcs; register struct PSAPctxlist *pc = &pcs; struct RoSAPindication rois; register struct RoSAPindication *roi = &rois; register struct RoSAPpreject *rop = &roi -> roi_preject; if ((aei = str2aei (host, myservice)) == NULLAEI) adios (NULLCP, "%s-%s: unknown application-entity", host, myservice); if ((pa = aei2addr (aei)) == NULLPA) adios (NULLCP, "address translation failed"); if ((ctx = ode2oid (mycontext)) == NULLOID) adios (NULLCP, "%s: unknown ISO object descriptor", mycontext); if ((ctx = oid_cpy (ctx)) == NULLOID) adios (NULLCP, "out of memory"); if ((pci = ode2oid (mypci)) == NULLOID) adios (NULLCP, "%s: unknown ISO object descriptor", mypci); if ((pci = oid_cpy (pci)) == NULLOID) adios (NULLCP, "out of memory"); pc -> pc_nctx = 1; pc -> pc_ctx[0].pc_id = 1; pc -> pc_ctx[0].pc_asn = pci; pc -> pc_ctx[0].pc_atn = NULLOID; if ((sf = addr2ref (host)) == NULL) { sf = &sfs; (void) bzero ((char *) sf, sizeof *sf); } for (ds = dispatches; ds -> ds_name; ds++) if (strcmp (ds -> ds_name, "newmessage") == 0) break; if (ds -> ds_name == NULL) adios (NULLCP, "unknown operation \"%s\"", "newmessage"); if (AcAssocRequest (ctx, NULLAEI, aei, NULLPA, pa, pc, NULLOID, 0, ROS_MYREQUIRE, SERIAL_NONE, 0, sf, NULLPEP, 0, NULLQOS, acc, aci) == NOTOK) acs_adios (aca, "A-ASSOCIATE.REQUEST"); if (acc -> acc_result != ACS_ACCEPT) { adios (NULLCP, "Association rejected: [%s]", AcErrString (acc -> acc_result)); } sd = acc -> acc_sd; ACCFREE (acc); if (RoSetService (sd, RoPService, roi) == NOTOK) ros_adios (rop, "set RO/PS fails"); invoke (sd, ops, ds, argv); (*quit) (sd, (struct client_dispatch *) NULL, (char **) NULL, (caddr_t *) NULL); } /* \f */ static int invoke (sd, ops, ds, args) int sd; struct RyOperation ops[]; register struct client_dispatch *ds; char **args; { int result; caddr_t in; struct RoSAPindication rois; register struct RoSAPindication *roi = &rois; register struct RoSAPpreject *rop = &roi -> roi_preject; /* multiple arguments */ while (*args != NULLCP) { in = NULL; if (ds -> ds_argument && (*ds -> ds_argument) (sd, ds, args, &in) != OK) { printf("Failed in attempting %s\n",*args); args++; continue; } printf("Doing %s\n",*args); switch (result = RyStub (sd, ops, ds -> ds_operation, RyGenID (sd), NULLIP, in, ds -> ds_result, ds -> ds_error, ROS_SYNC, roi)) { case NOTOK: /* failure */ if (ROS_FATAL (rop -> rop_reason)) ros_adios (rop, "STUB"); ros_advise (rop, "STUB"); break; case OK: /* got a result/error response */ break; case DONE: /* got RO-END? */ adios (NULLCP, "got RO-END.INDICATION"); /* NOTREACHED */ default: adios (NULLCP, "unknown return from RyStub=%d", result); /* NOTREACHED */ } if (ds -> ds_free && in) (void) (*ds -> ds_free) (in); args++; } } /* \f */ static int getline (buffer) char *buffer; { register int i; register char *cp, *ep; static int sticky = 0; if (sticky) { sticky = 0; return NOTOK; } printf ("%s> ", myname); (void) fflush (stdout); for (ep = (cp = buffer) + BUFSIZ - 1; (i = getchar ()) != '\n';) { if (i == EOF) { printf ("\n"); clearerr (stdin); if (cp != buffer) { sticky++; break; } return NOTOK; } if (cp < ep) *cp++ = i; } *cp = NULL; return OK; } /* \f */ void ros_adios (rop, event) register struct RoSAPpreject *rop; char *event; { ros_advise (rop, event); _exit (1); } void ros_advise (rop, event) register struct RoSAPpreject *rop; char *event; { char buffer[BUFSIZ]; if (rop -> rop_cc > 0) (void) sprintf (buffer, "[%s] %*.*s", RoErrString (rop -> rop_reason), rop -> rop_cc, rop -> rop_cc, rop -> rop_data); else (void) sprintf (buffer, "[%s]", RoErrString (rop -> rop_reason)); advise (NULLCP, "%s: %s", event, buffer); } /* \f */ void acs_adios (aca, event) register struct AcSAPabort *aca; char *event; { acs_advise (aca, event); _exit (1); } void acs_advise (aca, event) register struct AcSAPabort *aca; char *event; { char buffer[BUFSIZ]; if (aca -> aca_cc > 0) (void) sprintf (buffer, "[%s] %*.*s", AcErrString (aca -> aca_reason), aca -> aca_cc, aca -> aca_cc, aca -> aca_data); else (void) sprintf (buffer, "[%s]", AcErrString (aca -> aca_reason)); advise (NULLCP, "%s: %s (source %d)", event, buffer, aca -> aca_source); } /* \f */ #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 #ifndef lint void ryr_advise (va_alist) va_dcl { char *what; va_list ap; va_start (ap); _advise (ap); va_end (ap); } #else /* VARARGS */ void ryr_advise (what, fmt) char *what, *fmt; { ryr_advise (what, fmt); } #endif