|
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 m
Length: 4382 (0x111e) Types: TextFile Names: »moid.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦e83f91978⟧ »EurOpenD22/isode/osimis-2.0.tar.Z« └─⟦d846658bd⟧ └─⟦this⟧ »osimis/msap/moid.c«
#include <stdio.h> #include <isode/quipu/name.h> #include <isode/rosap.h> #include "msap.h" /* Routines that maintain compatibility with the old naming scheme */ /* * By George Pavlou, April 1990 */ /* LINTLIBRARY */ RDN moid2rdn (moid) MO_ID * moid; { AttributeType rdntype; AttributeValue rdnval; char buf[sizeof(int)+1]; if (moid == (MO_ID *) NULL) return NULLRDN; rdntype = str2AttrT(sprintoid(&moid -> rdntype)); if (moid -> rdnlen == 0) rdnval = str2AttrV("<NULL>", str2syntax("IA5String")); else switch ((int) moid -> rdnval[0]) { case 0: (void) sprintf(buf, "%d", *(int*) &moid -> rdnval[1]); rdnval = str2AttrV(buf, str2syntax("Integer")); break; case 1: rdnval = str2AttrV(&moid -> rdnval[1], str2syntax("IA5String")); break; default: (void) fprintf(stderr, "moid2rdn: unknown value %d\n", (int) moid -> rdnval[0] ); return NULLRDN; } return rdn_comp_new(rdntype, rdnval); } MO_ID * rdn2moid (rdn) RDN rdn; { MO_ID * moid; PS ps; char * buf; OID oid_copy(); if (rdn == NULLRDN) return (MO_ID *) NULL; if ( (moid = (MO_ID *) calloc(1, sizeof(MO_ID))) == NULL || (ps = ps_alloc(str_open)) == NULLPS || str_setup(ps, NULLCP, BUFSIZ, 0) == NOTOK ) return (MO_ID *) NULL; if (rdn -> rdn_at.at_oid != NULLOID) { if (oid_copy(rdn -> rdn_at.at_oid, &moid -> rdntype) == NULLOID) return (MO_ID *) NULL; } else if (rdn -> rdn_at.at_table -> oa_ot.ot_oid != NULLOID) { if (oid_copy(rdn -> rdn_at.at_table -> oa_ot.ot_oid, &moid -> rdntype) == NULLOID) return (MO_ID *) NULL; } else { (void) fprintf(stderr, "rdn2moid: rdn has no OID!\n"); return (MO_ID *) NULL; } AttrV_print(ps, &rdn -> rdn_av, EDBOUT); *ps->ps_ptr = NULL; if ((buf = strdup(ps->ps_base)) == NULLCP) { ps_free (ps); return (MO_ID *) NULL; } ps_free (ps); if (rdn -> rdn_av.av_syntax == str2syntax("Integer")) { int val = atoi(buf); moid -> rdnlen = sizeof(int) + 1; moid -> rdnval[0] = (char) 0; bcopy((char *) &val, &moid -> rdnval[1], sizeof(int)); } else if (rdn -> rdn_av.av_syntax == str2syntax("IA5String")) { if (strcmp(buf, "<NULL>") == 0) moid -> rdnlen = 0; else { moid -> rdnval[0] = (char) 1; moid -> rdnlen = strlen(buf) + 1; (void) strncpy(&moid -> rdnval[1], buf, 9); } } else { (void) fprintf(stderr, "rdn2moid: unknown value type %d\n", rdn -> rdn_av.av_syntax); return (MO_ID *) NULL; } free(buf); return moid; } DN moid2dn (moid) MO_ID * moid; { DN dn = NULLDN, this; RDN rdn; int first = 1; for (; moid; moid = moid -> Next) { if ((rdn = moid2rdn(moid)) == NULLRDN) return NULLDN; if (first) dn = this = dn_comp_new(rdn), first = 0; else this = this -> dn_parent = dn_comp_new(rdn); } return dn; } MO_ID * dn2moid (dn) DN dn; { MO_ID * moid = (MO_ID *) NULL, * this; int first = 1; for (; dn; dn = dn -> dn_parent) if (first) { if ((moid = this = rdn2moid(dn -> dn_rdn)) == NULL) return (MO_ID *) NULL; first = 0; } else if ((this = this -> Next = rdn2moid(dn -> dn_rdn)) == NULL) return (MO_ID *) NULL; return moid; } char * dn2str (dn) DN dn; { PS ps; char * buf; if (((ps = ps_alloc(str_open)) == NULLPS) || (str_setup(ps, NULLCP, BUFSIZ, 0) == NOTOK)) return NULLCP; dn_print(ps, dn, EDBOUT); *ps->ps_ptr = NULL; if ((buf = strdup(ps->ps_base)) == NULLCP) { ps_free(ps); return NULLCP; } ps_free(ps); return buf; } void moid_free (moid) MO_ID * moid; { register MO_ID * this; for (; moid;) { moid = (this = moid) -> Next; free((char *) this -> rdntype.oid_elements); free((char *) this); } } void moid_print (moid) MO_ID * moid; { for (; moid; moid = moid -> Next) { (void) fprintf(stdout, "%s=", sprintoid(&moid -> rdntype)); if ( moid -> rdnlen == 0) (void) fprintf(stdout, "<NULL>"); else switch (moid -> rdnval[0]) { case 0: (void) fprintf(stdout, "%d", *(int*) &moid -> rdnval[1]); break; case 1: (void) fprintf(stdout, "\"%.9s\"", &moid -> rdnval[1]); break; default: (void) fprintf(stdout, "UNKNOWN"); break; } if (moid -> Next) (void) fprintf(stdout, "@"); } (void) fprintf(stdout, "\n"); }