static int doSSdata (struct assocblk *acb, int *invokeID, struct SSAPdata *sx, struct RoSAPindication *roi) { int result; PE pe; if (sx -> sx_type != SX_NORMAL) { ropktlose (acb, roi, ROS_PROTOCOL, NULLCP, "unexpected data indication (0x%x)", sx -> sx_type); goto out; } if (pe = (*acb -> acb_getosdu) (&sx -> sx_qbuf, sx -> sx_cc, &result)) return acb2osdu (acb, invokeID, pe, roi); if (result != PS_ERR_NMEM) return rosapreject (acb, roi, ROS_GP_STRUCT, NULLCP, "%s", ps_error (result)); ropktlose (acb, roi, ROS_CONGEST, NULLCP, "%s", ps_error (result)); out: ; SXFREE (sx); freeacblk (acb); return NOTOK; }
static dased (int vecp, char **vec) { int sd; struct TSAPstart tss; struct TSAPstart *ts = &tss; struct TSAPdisconnect tds; struct TSAPdisconnect *td = &tds; if (TInit (vecp, vec, ts, td) == NOTOK) ts_adios (td, "T-CONNECT.INDICATION failed"); sd = ts -> ts_sd; advise (LLOG_NOTICE, NULLCP, "T-CONNECT.INDICATION: <%d, %s, %s, %d, %d>", ts -> ts_sd, taddr2str (&ts -> ts_calling), taddr2str (&ts -> ts_called), ts -> ts_expedited, ts -> ts_tsdusize); if (TConnResponse (sd, NULLTA, 0, NULLCP, 0, NULLQOS, td) == NOTOK) ts_adios (td, "T-CONNECT.RESPONSE failed"); if ((ps = ps_alloc (dg_open)) == NULLPS) adios (NULLCP, "ps_alloc: out of memory"); if (dg_setup (ps, sd, MAXDGRAM, ts_read, ts_write, NULLIFP) == NOTOK) adios (NULLCP, "dg_setup: %s", ps_error (ps -> ps_errno)); for (;;) { struct type_DASE_Query__REQ *req; PE pe; if ((pe = ps2pe (ps)) == NULLPE) { if (ps -> ps_errno == PS_ERR_NONE) { advise (LLOG_NOTICE, NULLCP, "T-DISCONNECT.INDICATION"); break; } else adios (NULLCP, "ps2pe: %s", ps_error (ps -> ps_errno)); } if (decode_DASE_Query__REQ (pe, 1, NULLIP, NULLVP, &req) == NOTOK) adios (NULLCP, "decode_DASE_Query__REQ: %s", PY_pepy); PLOGP (pgm_log,DASE_Message, pe, "message", 1); dase_aux (req); free_DASE_Query__REQ (req); pe_free (pe); } if (isbound) { if (debug) advise (LLOG_DEBUG, NULLCP, "unbound from directory"); ds_unbind (); isbound = 0; } exit (0); }
int ps_move4(t_psdata *ps, enum e_move move) { if (ps->verb) ps_move4_print(ps, move); if (move == sa || move == ss) ps_move4_swap(ps->st4a); if (move == sb || move == ss) ps_move4_swap(ps->st4b); if (move == pa) ps_move4_push(&ps->st4b, &ps->st4a); if (move == pb) ps_move4_push(&ps->st4a, &ps->st4b); if (move == ra || move == rr) ps->st4a = ps->st4a->p; if (move == rb || move == rr) ps->st4b = ps->st4b->p; if (move == rra || move == rrr) ps->st4a = ps->st4a->n; if (move == rrb || move == rrr) ps->st4b = ps->st4b->n; if (!ps->log4 && !(ps->log4 = ft_strnew(0))) ps_error(ps, 100); ps->nb4++; ps_move4_log(ps, move); return (1); }
int main(int ac, char **av) { int *numbers; if (ac < 2) ps_error(); check_arg(av + 1); numbers = convertav(av + 1, ac - 1); init_piles(ac - 1, numbers); return (0); }
static Node * populate_scene(hash *scene_hash) { Node *root; if(!scene_hash) ps_error("populate_scene", "Empty scene"); if (populate_cameras(FindHashElement(scene_hash, "cameras")) != -1) ps_error("populate_scene", "cameras"); if (populate_avatars(FindHashElement(scene_hash, "avatars")) != -1) ps_error("populate_scene", "avatars"); if (populate_gobjs(FindHashElement(scene_hash, "gObjects")) != -1) ps_error("populate_scene", "gObjects"); if (populate_shaders(FindHashElement(scene_hash, "shaders")) != -1) ps_error("populate_scene", "shaders"); if (populate_lights(FindHashElement(scene_hash, "lights")) != -1) ps_error("populate_scene", "lights"); root = populate_nodes(FindHashElement(scene_hash, "node")); AttachNodeScene(root); // takes ownership return root; }
static void check_arg(char **av) { int i; while (av && *av) { i = 0; if ((*av)[0] == '-') i++; while((*av)[i]) { if((*av)[i] < '0' || (*av)[i] > '9') ps_error(); i++; } av++; } }
static arginit (char **vec) { int argp; char *ap; char **argptr, *args[4]; struct TSAPaddr *ta = NULL; if (pgmname = rindex (*vec, '/')) pgmname++; if (pgmname == NULL || *pgmname == NULL) pgmname = *vec; isodetailor (pgmname, 0); ll_hdinit (pgm_log, pgmname); quipu_syntaxes (); argp = 0; args[argp++] = pgmname; for (argptr = vec, argptr++; ap = *argptr; argptr++) { if (*ap == '-') switch (*++ap) { case 'a': case 'u': case 'p': if ((ap = *++argptr) == NULL || *ap == '-') break; continue; case 'c': if ((ap = *++argptr) == NULL || *ap == '-') break; args[argp++] = "-c"; args[argp++] = ap; break; default: continue; } break; } args[argp] = NULLCP; dsap_init (&argp, (argptr = args, &argptr)); userdn = NULLDN, passwd[0] = NULL; for (vec++; ap = *vec; vec++) { if (*ap == '-') switch (*++ap) { case 'a': if ((ap = *++vec) == NULL || *ap == '-') adios (NULLCP, "usage: %s -a address", pgmname); if ((ta = str2taddr (ap)) == NULLTA) adios (NULLCP, "bad address \"%s\"", ap); continue; case 'b': prebind++; continue; case 'd': debug++; continue; case 'c': if ((ap = *++vec) == NULL || *ap == '-') adios (NULLCP, "usage: %s -c DSA-name-or-address", pgmname); continue; case 'u': if ((ap = *++vec) == NULL || *ap == '-') adios (NULLCP, "usage: %s -u username", pgmname); if ((userdn = str2dn (*ap != '@' ? ap : ap + 1)) == NULLDN) adios (NULLCP, "invalid DN for username: %s", ap); bzero ((char *) ap, strlen (ap)); continue; case 'p': if ((ap = *++vec) == NULL || *ap == '-') adios (NULLCP, "usage: %s -p passwd", pgmname); strcpy (passwd, ap); bzero ((char *) ap, strlen (ap)); continue; default: adios (NULLCP, "unknown switch -%s", ap); } adios (NULLCP, "usage: %s [switches]", pgmname); } if (ta == NULL && (ta = str2taddr (ns_address)) == NULLTA) adios (NULLCP, "bad default address \"%s\"", ns_address); tas = *ta; /* struct copy */ if ((nps = ps_alloc (str_open)) == NULLPS) adios (NULLCP, "ps_alloc: out of memory"); if (str_setup (nps, NULLCP, 0, 0) == NOTOK) adios (NULLCP, "str_setup: %s", ps_error (ps -> ps_errno)); }
static DNS dase_interact (DNS dns, DN dn, char *s) { int i; struct type_DASE_Callback__REQ *req = NULL; struct element_DASE_3 **dp; struct type_DASE_Callback__RSP *rsp = NULL; struct type_DASE_Callback__RSP *rp; DNS ds, *dq; PE pe = NULLPE; if (dns == NULLDNS) return NULL; i = 0; for (ds = dns; ds; ds = ds -> dns_next) i++; if (i > 1) { struct dn_seq **base, **bp, **ep; if (base = (struct dn_seq **) malloc ((unsigned) (i * sizeof *base))) { ep = base; for (ds = dns; ds; ds = ds -> dns_next) *ep++ = ds; qsort ((char *) base, i, sizeof *base, dns_compar); bp = base; ds = dns = *bp++; while (bp < ep) { ds -> dns_next = *bp; ds = *bp++; } ds -> dns_next = NULL; free ((char *) base); } } if ((req = (struct type_DASE_Callback__REQ *) calloc (1, sizeof *req)) == NULL) { no_mem: ; advise (LLOG_EXCEPTIONS, NULLCP, "out of memory"); out: ; if (req) free_DASE_Callback__REQ (req); if (rsp) free_DASE_Callback__RSP (rsp); if (pe) pe_free (pe); dn_seq_free (dns); return NULL; } if ((req -> string = str2qb (s, strlen (s), 1)) == NULL) goto no_mem; dp = &req -> choices; for (; dns; dns = ds) { struct element_DASE_3 *d3; struct type_DASE_Pair *pair; if ((d3 = (struct element_DASE_3 *) calloc (1, sizeof *d3)) == NULL) goto no_mem; *dp = d3, dp = &d3 -> next; if ((pair = (struct type_DASE_Pair *) calloc (1, sizeof *pair)) == NULL) goto no_mem; d3 -> Pair = pair; dn_print (nps, dns -> dns_dn, EDBOUT); ps_print (nps, " "); *--nps -> ps_ptr = NULL, nps -> ps_cnt++; pair -> complete = str2qb (nps -> ps_base, strlen (nps -> ps_base), 1); nps -> ps_ptr = nps -> ps_base, nps -> ps_cnt = nps -> ps_bufsiz; ufn_dn_print_aux (nps, dns -> dns_dn, dn, 0); ps_print (nps, " "); *--nps -> ps_ptr = NULL, nps -> ps_cnt++; pair -> friendly = str2qb (nps -> ps_base, strlen (nps -> ps_base), 1); nps -> ps_ptr = nps -> ps_base, nps -> ps_cnt = nps -> ps_bufsiz; if (pair -> complete == NULL || pair -> friendly == NULL) goto no_mem; ds = dns -> dns_next; dn_free (dns -> dns_dn); free ((char *) dns); } dns = NULL; if (encode_DASE_Callback__REQ (&pe, 1, NULL, NULLCP, req) == NOTOK) { advise (LLOG_EXCEPTIONS, NULLCP, "encode_DASE_Callback__REQ: %s", PY_pepy); goto out; } if (pe2ps (ps, pe) == NOTOK) adios (NULLCP, "pe2ps: %s", ps_error (ps -> ps_errno)); PLOGP (pgm_log,DASE_Message, pe, "message", 0); free_DASE_Callback__REQ (req); req = NULL; pe_free (pe); if ((pe = ps2pe (ps)) == NULLPE) adios (NULLCP, "ps2pe: %s", ps_error (ps -> ps_errno)); if (decode_DASE_Callback__RSP (pe, 1, NULLIP, NULLVP, &rsp) == NOTOK) { advise (LLOG_EXCEPTIONS, NULLCP, "decode_DASE_Callback__RSP: %s", PY_pepy); goto out; } PLOGP (pgm_log,DASE_Message, pe, "message", 1); dq = &dns; for (rp = rsp; rp; rp = rp -> next) { char *cp; if ((ds = (struct dn_seq *) calloc (1, sizeof *ds)) == NULL) goto no_mem; *dq = ds, dq = &ds -> dns_next; if ((cp = qb2str (rp -> IA5String)) == NULL) goto no_mem; ds -> dns_dn = str2dn (cp); free (cp); } free_DASE_Callback__RSP (rsp); pe_free (pe); return dns; }
static dase_aux (struct type_DASE_Query__REQ *req) { int i; int vecp; char **vp; char *context, **vec; struct type_DASE_Query__RSP *rsp; struct element_DASE_0 *d0; struct element_DASE_1 *d1; envlist el; envlist en, *ep; DN *dn; DNS dns; PE pe; if ((rsp = (struct type_DASE_Query__RSP *) calloc (1, sizeof *rsp)) == NULL) { no_mem: ; adios (NULLCP, "out of memory"); } vec = NULL, el = NULL, context = NULL, dns = NULL; i = 1; for (d0 = req -> name; d0; d0 = d0 -> next) i++; if ((vec = (char **) calloc ((unsigned) i, sizeof *vec)) == NULL) goto no_mem; for (vp = vec, d0 = req -> name; d0; vp++, d0 = d0 -> next) if ((*vp = qb2str (d0 -> IA5String)) == NULL) goto no_mem; #ifdef STATS else advise (LLOG_NOTICE, NULLCP, "lookup: %s", *vp); #endif vecp = i - 1; el = NULL, ep = ⪙ for (d1 = req -> envlist; d1; d1 = d1 -> next) { struct type_DASE_Environment *ev = d1 -> Environment; struct element_DASE_2 *d2; struct dn_seq **dp; if ((en = (envlist) calloc (1, sizeof *en)) == NULL) goto no_mem; *ep = en, ep = &en -> Next; en -> Upper = ev -> upper; en -> Lower = ev -> lower; dp = &en -> Dns; for (d2 = ev -> path; d2; d2 = d2 -> next) { char *cp; struct dn_seq *ds; if ((ds = (struct dn_seq *) calloc (1, sizeof *ds)) == NULL) goto no_mem; *dp = ds, dp = &ds -> dns_next; if ((cp = qb2str (d2 -> IA5String)) == NULL) goto no_mem; if (*cp != '-') ds -> dns_dn = str2dn (cp); free (cp); if (*cp != '-' && ds -> dns_dn == NULLDN) { PY_advise (NULLCP, "bad DN in environment (%s)", cp); goto send_rsp; } } } if ((context = qb2str (req -> context)) == NULL) goto no_mem; #ifdef STATS advise (LLOG_NOTICE, NULLCP, "context: %s", context); #endif if (req -> userdn) { int changed = 0; char *cp; DN newdn; if ((cp = qb2str (req -> userdn)) == NULL) goto no_mem; #ifdef STATS advise (LLOG_NOTICE, NULLCP, "userdn: %s", cp); #endif if ((newdn = str2dn (*cp != '@' ? cp : cp + 1)) == NULLDN) { PY_advise (NULLCP, "bad DN for userdn (%s)", cp); free (cp); goto send_rsp; } if (!userdn || dn_cmp (userdn, newdn)) changed++; if (userdn) dn_free (userdn); userdn = newdn; free (cp); if (req -> passwd) { if ((cp = qb2str (req -> passwd)) == NULL) goto no_mem; if (strcmp (passwd, cp)) changed++; strcpy (passwd, cp); free (cp); } else { if (passwd[0]) changed++; passwd[0] = NULL; } if (isbound && changed) { ds_unbind (); isbound = 0; } } if (!isbound && bind_to_dsa () == NOTOK) goto send_rsp; PY_pepy[0] = NULL; pe = NULLPE; if (vecp == 1 && *vec[0] == '@') { static DN dnstat; if ((dnstat = str2dn (vec[0])) == NULLDN) { PY_advise (NULLCP, "invalid name"); goto send_rsp; } rsp -> value = name2psap (*(dn = &dnstat)); goto all_done; } if (!aet_match (vecp, vec, req -> interactive ? dase_interact : just_say_no, &dns, el, context)) { if (PY_pepy[0] == NULL) PY_advise (NULLCP, "unable to resolve name"); goto send_rsp; } if (dns == NULL) { PY_advise (NULLCP, "search failed to find anything"); goto send_rsp; } dn = NULL; if (dns -> dns_next) { if (req -> interactive) dnSelect (vec[0], &dns, dase_interact, el -> Dns); for (; dns; dns = dns -> dns_next) { dn = &dns -> dns_dn; if (rsp -> value = name2psap (*dn)) break; } } else { dn = &dns -> dns_dn; rsp -> value = name2psap (*dn); } all_done: ; if (dn) { encode_IF_DistinguishedName (&rsp -> name, 1, NULL, NULLCP,*dn); #ifdef STATS advise (LLOG_NOTICE, NULLCP, "answer: %s", dn2str (*dn)); #endif ufn_dn_print_aux (nps, *dn, NULLDN, 0); ps_print (nps, " "); *--nps -> ps_ptr = NULL, nps -> ps_cnt++; rsp -> friendly = str2qb (nps -> ps_base, strlen (nps -> ps_base), 1); nps -> ps_ptr = nps -> ps_base, nps -> ps_cnt = nps -> ps_bufsiz; dn_free (*dn); *dn = NULLDN; } send_rsp: ; if (PY_pepy[0]) { advise (LLOG_NOTICE, NULLCP, "diagnostic: %s", PY_pepy); if ((rsp -> diagnostic = str2qb (PY_pepy, strlen (PY_pepy), 1)) == NULL) goto no_mem; } if (encode_DASE_Query__RSP (&pe, 1, NULL, NULLCP, rsp) == NOTOK) adios (NULLCP, "encode_DASE_Query__RSP: %s", PY_pepy); if (pe2ps (ps, pe) == NOTOK) adios (NULLCP, "pe2ps: %s", ps_error (ps -> ps_errno)); PLOGP (pgm_log,DASE_Message, pe, "message", 0); free_DASE_Query__RSP (rsp); pe_free (pe); if (vec) { for (vp = vec; *vp; vp++) free (*vp); free ((char *) vec); } for (; el; el = en) { en = el -> Next; dn_seq_free (el -> Dns); free ((char *) el); } if (context) free (context); if (dns) dn_seq_free (dns); }
int ro2ssready (struct assocblk *acb, int priority, struct RoSAPindication *roi) { int result; PE pe; struct SSAPdata sxs; struct SSAPdata *sx = &sxs; struct SSAPindication sis; struct SSAPindication *si = &sis; struct SSAPabort *sa = &si -> si_abort; if (acb -> acb_apdu || (acb -> acb_flags & ACB_CLOSING)) return rosaplose (roi, ROS_WAITING, NULLCP, NULLCP); if (!(acb -> acb_requirements & SR_HALFDUPLEX) || (acb -> acb_flags & ACB_TURN)) return OK; if (!(acb -> acb_flags & ACB_PLEASE)) { if (SPTokenRequest (acb -> acb_fd, ST_DAT_TOKEN, NULLCP, 0, si) == NOTOK) { ss2roslose (acb, roi, "SPTokenRequest", sa); goto out; } acb -> acb_flags |= ACB_PLEASE; } for (;;) { switch (result = SReadRequest (acb -> acb_fd, sx, NOTOK, si)) { case NOTOK: return doSSabort (acb, &si -> si_abort, roi); case OK: if (sx -> sx_type != SX_NORMAL) { ropktlose (acb, roi, ROS_PROTOCOL, NULLCP, "unexpected data indication (0x%x)", sx -> sx_type); goto bad_sx; } if (pe = qbuf2pe (&sx -> sx_qbuf, sx -> sx_cc, &result)) { acb -> acb_apdu = pe; return rosaplose (roi, ROS_WAITING, NULLCP, NULLCP); } if (result != PS_ERR_NMEM) { rosapreject (acb, roi, ROS_GP_STRUCT, NULLCP, "%s", ps_error (result)); continue; } ropktlose (acb, roi, ROS_PROTOCOL, NULLCP, "%s", ps_error (result)); bad_sx: ; SXFREE (sx); goto out; case DONE: switch (si -> si_type) { case SI_TOKEN: if (doSStokens (acb, &si -> si_token, roi) == NOTOK) return NOTOK; return OK; case SI_SYNC: if (doSSsync (acb, &si -> si_sync, roi) == NOTOK) return NOTOK; continue; case SI_ACTIVITY: if (doSSactivity (acb, &si -> si_activity, roi) == NOTOK) return NOTOK; continue; case SI_REPORT: if (doSSreport (acb, &si -> si_report, roi) == NOTOK) return NOTOK; continue; case SI_FINISH: if (doSSfinish (acb, &si -> si_finish, roi) == NOTOK) return NOTOK; return DONE; default: ropktlose (acb, roi, ROS_PROTOCOL, NULLCP, "unknown indication (0x%x) from session", si -> si_type); break; } break; default: ropktlose (acb, roi, ROS_PROTOCOL, NULLCP, "unexpected return from SReadRequest=%d", result); break; } break; } out: ; freeacblk (acb); return NOTOK; }