|
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 o
Length: 12289 (0x3001) Types: TextFile Names: »objinst.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦e83f91978⟧ »EurOpenD22/isode/osimis-2.0.tar.Z« └─⟦d846658bd⟧ └─⟦this⟧ »osimis/smap/objinst.c«
/* * Copyright (c) 1988 University College London * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the Department of Computer Science, University College London. * The name of the University may not be used to * endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* Routines for transforming managed object instances */ /* * By George Pavlou, October 1988 */ #include <stdio.h> #include "isode/rosap.h" #include "msap.h" #include "objectS.h" static char *cthlds[] = { "CrFailIn", "CrFailOut", "CrCongst", "CrConfErr", "ProtErr", "CkSumErr", "PDUSent", "PDURecvd", "PDUReSent" }; #define CTHLDNO 9 int objinst2parent (inst) MO_ID *inst; { MO_ID *tinst = inst, *tinst_last; if (tinst->Next == (MO_ID *) NULL) { advise(NULLCP, "objectinst2parent: illegal inst"); return (NOTOK); } while (tinst->Next != (MO_ID *) NULL) { tinst_last = tinst; tinst = tinst->Next; } moid_free(tinst); tinst_last->Next = (MO_ID *) NULL; return (OK); } int objinst2subord (inst, subordrdn) MO_ID *inst, *subordrdn; { MO_ID *tinst = inst; OID oid_copy(); while (tinst->Next != (MO_ID *) NULL) tinst = tinst->Next; if ((tinst->Next = (MO_ID *) calloc(1, sizeof(MO_ID))) == (MO_ID *) NULL) return (NOTOK); tinst = tinst->Next; tinst->rdnlen = subordrdn->rdnlen; bcopy(subordrdn->rdnval, tinst->rdnval, 10); if (oid_copy(&subordrdn->rdntype, &tinst->rdntype) == (OID) NULL) return (NOTOK); return (OK); } int objinst2type (inst) MO_ID *inst; { MO_ID *tinst = inst; int level = 0; if (inst == (MO_ID *) NULL) { advise(NULLCP, "objinst2type: bad inst"); return (NOTOK); } while (tinst->Next != (MO_ID *) NULL) { tinst = tinst->Next; level++; } switch (level) { case 0: /* M_SYSTEM */ if (oid_cmp(&tinst->rdntype, str2oid("2.37.1.1.1")) == 0) return (M_SYSTEM); break; case 1: /* T_SUBSYS or RPCTL */ if (oid_cmp(&tinst->rdntype, str2oid("2.37.1.2.1")) == 0) return (T_SUBSYS); else if (oid_cmp(&tinst->rdntype, str2oid("2.37.3.3.1")) == 0) return (RPCTL); break; case 2: /* T_ENTITY */ if (oid_cmp(&tinst->rdntype, str2oid("2.37.1.3.1")) == 0) return (T_ENTITY); break; case 3: /* T_EINV or RPCTL */ if (oid_cmp(&tinst->rdntype, str2oid("2.37.1.4.1")) == 0) return (T_EINV); else if (oid_cmp(&tinst->rdntype, str2oid("2.37.3.3.1")) == 0) return (RPCTL); break; case 4: /* T_CEPT or C_THLD */ if (oid_cmp(&tinst->rdntype, str2oid("2.37.1.5.1")) == 0) return (T_CEPT); else if (oid_cmp(&tinst->rdntype, str2oid("2.37.3.1.1")) == 0) return (C_THLD); break; case 5: /* C_THLD */ if (oid_cmp(&tinst->rdntype, str2oid("2.37.3.1.1")) == 0) return (C_THLD); break; default: advise(NULLCP, "objinst2type: bad inst - level %d", level); return (NOTOK); } advise(NULLCP, "objinst2type: malformed inst - level %d, type %s", level, sprintoid(&tinst->rdntype)); return (NOTOK); } /* VARARGS3 */ int objinst2id (obj_inst, type, obj_id1, obj_id2, obj_id3, obj_id4) MO_ID *obj_inst; int type, *obj_id1, *obj_id2, *obj_id3, *obj_id4; { MO_ID *tinst; char buf[10]; int i; if ((tinst = obj_inst) == (MO_ID *) NULL) { advise(NULLCP, "objinst2id: bad obj_inst"); return (NOTOK); } switch (type) { case M_SYSTEM: advise(NULLCP, "M_SYSTEM id is always NULL"); if (obj_id1 != NULLIP) *obj_id1 = NULL; break; case T_SUBSYS: advise(NULLCP, "T_SUBSYS id is always NULL"); if (obj_id1 != NULLIP) *obj_id1 = NULL; break; case T_ENTITY: for (i = 0; i < 2; i++) if (tinst->Next != (MO_ID *) NULL) tinst = tinst->Next; else { advise(NULLCP, "objinst2id: bad obj_inst"); return (NOTOK); } if (oid_cmp(&tinst->rdntype, str2oid("2.37.1.3.1")) != 0) { advise(NULLCP, "objinst2id: bad obj_inst"); return (NOTOK); } strncpy(buf, &tinst->rdnval[1], 9); if (strncmp(buf, "isode", 9) != 0) { advise(NULLCP, "objinst2id: bad T-Entity %s", buf); return (NOTOK); } if (obj_id1 != NULLIP) *obj_id1 = ISODE; break; case T_EINV: if (objinst2id(obj_inst, T_ENTITY, obj_id1) == NOTOK) return (NOTOK); for (i = 0; i < 3; i++) if (tinst->Next != (MO_ID *) NULL) tinst = tinst->Next; else { advise(NULLCP, "objinst2id: bad obj_inst"); return (NOTOK); } if (oid_cmp(&tinst->rdntype, str2oid("2.37.1.4.1")) != 0) { advise(NULLCP, "objinst2id: bad obj_inst"); return (NOTOK); } bcopy(&tinst->rdnval[1], obj_id2, sizeof(int)); break; case T_CEPT: if (objinst2id(obj_inst, T_EINV, obj_id1, obj_id2) == NOTOK) return (NOTOK); for (i = 0; i < 4; i++) if (tinst->Next != (MO_ID *) NULL) tinst = tinst->Next; else { advise(NULLCP, "objinst2id: bad obj_inst"); return (NOTOK); } if (oid_cmp(&tinst->rdntype, str2oid("2.37.1.5.1")) != 0) { advise(NULLCP, "objinst2id: bad obj_inst"); return (NOTOK); } bcopy(&tinst->rdnval[1], obj_id3, sizeof(int)); break; case C_THLD: tinst = obj_inst; while (tinst->Next != (MO_ID *) NULL) { tinst = tinst->Next; i++; } { int *cthld_id; if (i == 4) { if (objinst2id(obj_inst, T_EINV, obj_id1, obj_id2) == NOTOK) return (NOTOK); cthld_id = obj_id3; } else if (i == 5) { if (objinst2id(obj_inst, T_CEPT, obj_id1, obj_id2, obj_id3) == NOTOK) return (NOTOK); cthld_id = obj_id4; } else { advise(NULLCP, "objinst2id: bad obj_inst"); return (NOTOK); } if (oid_cmp(&tinst->rdntype, str2oid("2.37.3.1.1")) != 0) { advise(NULLCP, "objinst2id: bad obj_inst"); return (NOTOK); } strncpy(buf, &tinst->rdnval[1], 9); buf[9] = '\0'; for (i = 0; i < CTHLDNO; i++) if (strcmp(buf, cthlds[i]) == 0) break; if (i >= CTHLDNO) { advise(NULLCP, "objinst2id: bad C_THLD %s", buf); return (NOTOK); } *cthld_id = i; } break; case RPCTL: tinst = obj_inst; while (tinst->Next != (MO_ID *) NULL) { tinst = tinst->Next; i++; } { int *rpctl_id; if (i == 1) rpctl_id = obj_id1; else if (i == 3) { if (objinst2id(obj_inst, T_ENTITY, obj_id1) == NOTOK) return (NOTOK); rpctl_id = obj_id2; } else { advise(NULLCP, "objinst2id: bad obj_inst"); return (NOTOK); } if (oid_cmp(&tinst->rdntype, str2oid("2.37.3.3.1")) != 0) { advise(NULLCP, "objinst2id: bad obj_inst"); return (NOTOK); } bcopy(&tinst->rdnval[1], rpctl_id, sizeof(int)); } break; default: advise(NULLCP, "objinst2id: illegal type %d", type); return (NOTOK); } return (OK); } /* VARARGS2 */ MO_ID *objid2inst (type, obj_id1, obj_id2, obj_id3, obj_id4) int type, obj_id1, obj_id2, obj_id3, obj_id4; { MO_ID *inst, *tinst; OID oid_copy(); switch (type) { case M_SYSTEM: if ((inst = (MO_ID *) calloc(1, sizeof(MO_ID))) == (MO_ID *) NULL) return ((MO_ID *) NULL); if (oid_copy(str2oid("2.37.1.1.1"), &inst->rdntype) == (OID) NULL) return ((MO_ID *) NULL); inst->rdnlen = 0; return (inst); case T_SUBSYS: if ((inst = objid2inst(M_SYSTEM, NULL)) == (MO_ID *) NULL) return ((MO_ID *) NULL); tinst = inst; if ((tinst->Next = (MO_ID *) calloc(1,sizeof(MO_ID))) == (MO_ID *) NULL) return ((MO_ID *) NULL); tinst = tinst->Next; if (oid_copy(str2oid("2.37.1.2.1"), &tinst->rdntype) == (OID) NULL) return ((MO_ID *) NULL); tinst->rdnlen = 0; return (inst); case T_ENTITY: if (obj_id1 != ISODE) { advise(NULLCP, "objid2inst: illegal T_ENTITY %d", obj_id1); return ((MO_ID *) NULL); } if ((inst = objid2inst(T_SUBSYS, NULL)) == (MO_ID *) NULL) return ((MO_ID *) NULL); tinst = inst; while (tinst->Next != (MO_ID *) NULL) tinst = tinst->Next; if ((tinst->Next = (MO_ID *) calloc(1,sizeof(MO_ID))) == (MO_ID *) NULL) return ((MO_ID *) NULL); tinst = tinst->Next; if (oid_copy(str2oid("2.37.1.3.1"), &tinst->rdntype) == (OID) NULL) return ((MO_ID *) NULL); tinst->rdnlen = strlen("isode")+1; tinst->rdnval[0] = 1; strncpy(&tinst->rdnval[1], "isode", 9); return (inst); case T_EINV: if (obj_id1 != ISODE) { advise(NULLCP, "objid2inst: illegal T_ENTITY %d", obj_id1); return ((MO_ID *) NULL); } if ((inst = objid2inst(T_ENTITY, obj_id1)) == (MO_ID *) NULL) return ((MO_ID *) NULL); tinst = inst; while (tinst->Next != (MO_ID *) NULL) tinst = tinst->Next; if ((tinst->Next = (MO_ID *) calloc(1,sizeof(MO_ID))) == (MO_ID *) NULL) return ((MO_ID *) NULL); tinst = tinst->Next; if (oid_copy(str2oid("2.37.1.4.1"), &tinst->rdntype) == (OID) NULL) return ((MO_ID *) NULL); tinst->rdnlen = sizeof(int); tinst->rdnval[0] = 0; bcopy(&obj_id2, &tinst->rdnval[1], sizeof(int)); return (inst); case T_CEPT: if (obj_id1 != ISODE) { advise(NULLCP, "objid2inst: illegal T_ENTITY %d", obj_id1); return ((MO_ID *) NULL); } if ((inst = objid2inst(T_EINV, obj_id1, obj_id2)) == (MO_ID *) NULL) return ((MO_ID *) NULL); tinst = inst; while (tinst->Next != (MO_ID *) NULL) tinst = tinst->Next; if ((tinst->Next = (MO_ID *) calloc(1,sizeof(MO_ID))) == (MO_ID *) NULL) return ((MO_ID *) NULL); tinst = tinst->Next; if (oid_copy(str2oid("2.37.1.5.1"), &tinst->rdntype) == (OID) NULL) return ((MO_ID *) NULL); tinst->rdnlen = sizeof(int); tinst->rdnval[0] = 0; bcopy(&obj_id3, &tinst->rdnval[1], sizeof(int)); return (inst); case C_THLD: if (obj_id1 != ISODE) { advise(NULLCP, "objid2inst: illegal T_ENTITY %d", obj_id1); return ((MO_ID *) NULL); } if (obj_id4 == 0) { if ((inst = objid2inst(T_EINV, obj_id1, obj_id2, obj_id3)) == (MO_ID *) NULL) return ((MO_ID *) NULL); } else if ((inst = objid2inst(T_CEPT, obj_id1, obj_id2, obj_id3, obj_id4)) == (MO_ID *) NULL) return ((MO_ID *) NULL); tinst = inst; while (tinst->Next != (MO_ID *) NULL) tinst = tinst->Next; if ((tinst->Next = (MO_ID *) calloc(1, sizeof(MO_ID))) == (MO_ID *) NULL) return ((MO_ID *) NULL); tinst = tinst->Next; { int i = (obj_id4 == 0 ? obj_id3 : obj_id4); if (oid_copy(str2oid("2.37.3.1.1"), &tinst->rdntype) == (OID) NULL) return ((MO_ID *) NULL); tinst->rdnval[0] = 1; tinst->rdnlen = strlen(cthlds[i])+1; strncpy(&tinst->rdnval[1], cthlds[i], 9); } return (inst); case RPCTL: if (obj_id2 == 1) { if ((inst = objid2inst(M_SYSTEM, NULL)) == (MO_ID *) NULL) return ((MO_ID *) NULL); tinst = inst; } else { if (obj_id1 != ISODE) { advise(NULLCP, "objid2inst: illegal T_ENTITY %d", obj_id1); return ((MO_ID *) NULL); } if ((inst = objid2inst(T_ENTITY,obj_id1)) == (MO_ID *) NULL) return ((MO_ID *) NULL); tinst = inst; while (tinst->Next != (MO_ID *) NULL) tinst = tinst->Next; } if ((tinst->Next = (MO_ID *) calloc(1, sizeof(MO_ID))) == (MO_ID *) NULL) return ((MO_ID *) NULL); tinst = tinst->Next; if (oid_copy(str2oid("2.37.3.3.1"), &tinst->rdntype) == (OID) NULL) return ((MO_ID *) NULL); tinst->rdnlen = sizeof(int); tinst->rdnval[0] = 0; bcopy(&obj_id2, &tinst->rdnval[1], sizeof(int)); return (inst); default: advise(NULLCP, "objid2inst: illegal type %d", type); return ((MO_ID *) NULL); } }