|
|
1.1 ! root 1: static char ID[] = "@(#) lists.c: 1.3 5/27/83"; ! 2: #include "system.h" ! 3: ! 4: #include "list.h" ! 5: #include "structs.h" ! 6: #include "sgsmacros.h" ! 7: ! 8: #define NULL 0 ! 9: /*eject*/ ! 10: listadd(seqid, ownerp, memp) ! 11: int seqid; /* sequence id */ ! 12: LISTOWN *ownerp; /* ptr to owner structure */ ! 13: char *memp; /* ptr to member structure */ ! 14: { ! 15: ! 16: /* ! 17: * Add a member structure to a linked list. ! 18: * ! 19: * This function is implemented as one function in case a general ! 20: * Storage Management System capability ever becomes available. ! 21: * ! 22: * Currently, the l_AI, l_IF, l_IS, l_OS, and l_INC lists are ! 23: * implemented as queues. The l_REG, l_MEM, and l_ADR lists are ! 24: * ordered lists. ! 25: */ ! 26: ! 27: switch (seqid) { ! 28: ! 29: case l_AI: ! 30: if (ownerp->tail == NULL) ! 31: ownerp->head = memp; ! 32: else ! 33: ((ACTITEM *) ownerp->tail)->ldlbry.ainext = (ACTITEM *) memp; ! 34: ownerp->tail = memp; ! 35: ((ACTITEM *) memp)->ldlbry.ainext = NULL; ! 36: break; ! 37: case l_IF: ! 38: if (ownerp->tail == NULL) ! 39: ownerp->head = memp; ! 40: else ! 41: ((INFILE *) ownerp->tail)->flnext = (INFILE *) memp; ! 42: ownerp->tail = memp; ! 43: ((INFILE *) memp)->flnext = NULL; ! 44: break; ! 45: case l_IS: ! 46: if (((INFILE *) ownerp)->flishead == NULL) ! 47: ((INFILE *) ownerp)->flishead = (INSECT *) memp; ! 48: else ! 49: ((INFILE *) ownerp)->flistail->isnext = (INSECT *) memp; ! 50: ((INFILE *) ownerp)->flistail = (INSECT *) memp; ! 51: ((INSECT *) memp)->isnext = NULL; ! 52: ((INSECT *) memp)->isfilptr = (INFILE *) ownerp; ! 53: break; ! 54: case l_OS: ! 55: if (ownerp->head == NULL) ! 56: ownerp->head = memp; ! 57: else ! 58: ((OUTSECT *) ownerp->tail)->osnext = (OUTSECT *) memp; ! 59: ownerp->tail = memp; ! 60: ((OUTSECT *) memp)->osnext = NULL; ! 61: break; ! 62: case l_INC: ! 63: if (((OUTSECT *) ownerp)->osinclhd == NULL) ! 64: ((OUTSECT *) ownerp)->osinclhd = (INSECT *) memp; ! 65: else ! 66: ((OUTSECT *) ownerp)->osincltl->isincnxt = (INSECT *) memp; ! 67: ((OUTSECT *) ownerp)->osincltl = (INSECT *) memp; ! 68: ((INSECT *) memp)->isincnxt = NULL; ! 69: ((INSECT *) memp)->isoutsec = (OUTSECT *) ownerp; ! 70: break; ! 71: case l_GRP: ! 72: if (((OUTSECT *) ownerp)->osinclhd == NULL) ! 73: ((OUTSECT *) (((OUTSECT *) ownerp)->osinclhd)) = (OUTSECT *) memp; ! 74: else ! 75: ((OUTSECT *) (((OUTSECT *) ownerp)->osincltl))->osnext = (OUTSECT *) memp; ! 76: ((OUTSECT *) ownerp)->osincltl = (INSECT *) memp; ! 77: ((OUTSECT *) memp)->osnext = NULL; ! 78: break; ! 79: case l_REG: ! 80: /* ! 81: * REGIONS list is ordered on address ! 82: */ ! 83: if (ownerp->head == NULL) { ! 84: ownerp->head = memp; ! 85: ownerp->tail = memp; ! 86: } ! 87: else { ! 88: REGION *rp, *prevrp; ! 89: rp = (REGION *) ownerp->head; ! 90: prevrp = NULL; ! 91: while( rp ) { ! 92: if(rp->rgorig > ((REGION *) memp)->rgorig){ ! 93: if (prevrp) ! 94: prevrp->rgnext = (REGION *) memp; ! 95: else ! 96: ownerp->head = memp; ! 97: ((REGION *) memp)->rgnext = rp; ! 98: return; ! 99: } ! 100: prevrp = rp; ! 101: rp = rp->rgnext; ! 102: } ! 103: prevrp->rgnext = (REGION *) memp; ! 104: ownerp->tail = memp; ! 105: } ! 106: break; ! 107: case l_MEM: ! 108: /* ! 109: * MEMORY list is ordered on address ! 110: */ ! 111: if (ownerp->head == NULL) { ! 112: ownerp->head = memp; ! 113: ownerp->tail = memp; ! 114: ((MEMTYPE *) memp)->mtnext = NULL; ! 115: } ! 116: else { ! 117: MEMTYPE *mp, *prevmp; ! 118: mp = (MEMTYPE *) ownerp->head; ! 119: prevmp = NULL; ! 120: while( mp ) { ! 121: if(mp->mtorig > ((MEMTYPE*)memp)->mtorig) { ! 122: if( prevmp ) ! 123: prevmp->mtnext = (MEMTYPE *) memp; ! 124: else ! 125: ownerp->head = memp; ! 126: ((MEMTYPE *) memp)->mtnext = mp; ! 127: return; ! 128: } ! 129: prevmp = mp; ! 130: mp = mp->mtnext; ! 131: } ! 132: prevmp->mtnext = (MEMTYPE *) memp; ! 133: ownerp->tail = memp; ! 134: } ! 135: break; ! 136: case l_ADR: ! 137: /* ! 138: * ADDR NODE list is ordered on address ! 139: */ ! 140: if(ownerp->head == NULL) { ! 141: ownerp->head = ownerp->tail = memp; ! 142: ((ANODE *) memp)->adprev = ((ANODE *) memp)->adnext = NULL; ! 143: } ! 144: else { ! 145: ANODE *p; ! 146: p = (ANODE *) ownerp->head; ! 147: while( p ) { ! 148: if(p->adpaddr >= ((ANODE *) memp)->adpaddr){ ! 149: if( p->adprev ) ! 150: p->adprev->adnext = (ANODE *) memp; ! 151: else ! 152: ownerp->head = memp; ! 153: ((ANODE *) memp)->adprev = p->adprev; ! 154: ((ANODE *) memp)->adnext = p; ! 155: p->adprev = (ANODE *) memp; ! 156: return; ! 157: } ! 158: p = p->adnext; ! 159: } ! 160: p = (ANODE *) ownerp->tail; ! 161: ownerp->tail = memp; ! 162: ((ANODE *) memp)->adnext = NULL; ! 163: ((ANODE *) memp)->adprev = p; ! 164: p->adnext = (ANODE *) memp; ! 165: } ! 166: break; ! 167: case l_DS: ! 168: if (ownerp->tail == NULL) ! 169: ownerp->head = memp; ! 170: else ! 171: ((OUTSECT *) ownerp->tail)->osdsnext = (OUTSECT *) memp; ! 172: ownerp->tail = memp; ! 173: ((OUTSECT *) memp)->osdsnext = NULL; ! 174: break; ! 175: } ! 176: } ! 177: /*eject*/ ! 178: listins(seqid, ownerp, basep, memp) ! 179: int seqid; /* sequence id */ ! 180: LISTOWN *ownerp; /* ptr to owner structure */ ! 181: char *basep; /* ptr to insertion point in sequence */ ! 182: char *memp; /* ptr to member structure */ ! 183: { ! 184: ! 185: /* ! 186: * Insert a member structure into a linked list, after a specified ! 187: * existing list member. ! 188: * ! 189: * If the insertion member pointer (= basep) is NULL, then the list ! 190: * is empty, and the new member will become the first list element ! 191: * ! 192: * This function is implemented as one function in case a general ! 193: * Storage Management System capability ever becomes available. ! 194: * ! 195: * Currently, the l_AI, l_IF, l_IS, l_OS, and l_INC lists are ! 196: * implemented as queues. The l_REG, l_MEM, and l_ADR lists are ! 197: * ordered lists. ! 198: */ ! 199: ! 200: if( basep == NULL ) { ! 201: listadd(seqid, ownerp, memp); ! 202: return; ! 203: } ! 204: ! 205: switch (seqid) { ! 206: ! 207: case l_AI: ! 208: ((ACTITEM *) memp)->ldlbry.ainext = ((ACTITEM *) basep)->ldlbry.ainext; ! 209: ((ACTITEM *) basep)->ldlbry.ainext = (ACTITEM *) memp; ! 210: if( ownerp->tail == basep ) ! 211: ownerp->tail = memp; ! 212: break; ! 213: case l_IF: ! 214: ((INFILE *) memp)->flnext = ((INFILE *) basep)->flnext; ! 215: ((INFILE *) basep)->flnext = (INFILE *) memp; ! 216: if( ownerp->tail == basep ) ! 217: ownerp->tail = memp; ! 218: break; ! 219: case l_IS: ! 220: ((INSECT *) memp)->isnext = ((INSECT *) basep)->isnext; ! 221: ((INSECT *) basep)->isnext = (INSECT *) memp; ! 222: if( ((INFILE *) ownerp)->flistail == ((INSECT *) basep) ) ! 223: ((INFILE *) ownerp)->flistail = (INSECT *) memp; ! 224: break; ! 225: case l_OS: ! 226: ((OUTSECT *) memp)->osnext = ((OUTSECT *) basep)->osnext; ! 227: ((OUTSECT *) basep)->osnext = (OUTSECT *) memp; ! 228: if( ownerp->tail == basep ) ! 229: ownerp->tail = memp; ! 230: break; ! 231: case l_INC: ! 232: ((INSECT *) memp)->isincnxt = ((INSECT *) basep)->isincnxt; ! 233: ((INSECT *) basep)->isincnxt = (INSECT *) memp; ! 234: if( ((OUTSECT *) ownerp)->osincltl == ((INSECT *) basep) ) ! 235: ((OUTSECT *) ownerp)->osincltl = (INSECT *) memp; ! 236: break; ! 237: case l_GRP: ! 238: ((OUTSECT *) memp)->osnext = ((OUTSECT *) basep)->osnext; ! 239: ((OUTSECT *) basep)->osnext = ((OUTSECT *) memp); ! 240: if( ((OUTSECT *) ownerp)->osincltl == ((INSECT *) basep) ) ! 241: ((OUTSECT *) ownerp)->osincltl = ((INSECT *) memp); ! 242: break; ! 243: case l_REG: ! 244: ((REGION *) memp)->rgnext = ((REGION *) basep)->rgnext; ! 245: ((REGION *) basep)->rgnext = ((REGION *) memp); ! 246: if( ownerp->tail == basep ) ! 247: ownerp->tail = memp; ! 248: break; ! 249: case l_MEM: ! 250: ((MEMTYPE *) memp)->mtnext = ((MEMTYPE *) basep)->mtnext; ! 251: ((MEMTYPE *) basep)->mtnext = ((MEMTYPE *) memp); ! 252: if( ownerp->tail == basep ) ! 253: ownerp->tail = memp; ! 254: break; ! 255: case l_ADR: ! 256: ((ANODE *) memp)->adnext = ((ANODE *) basep)->adnext; ! 257: ((ANODE *) basep)->adnext = ((ANODE *) memp); ! 258: ((ANODE *) memp)->adprev = ((ANODE *) basep); ! 259: if (((ANODE *) memp)->adnext) ! 260: ((ANODE *) memp)->adnext->adprev = ((ANODE *) memp); ! 261: if( ownerp->tail == basep ) ! 262: ownerp->tail = memp; ! 263: break; ! 264: case l_DS: ! 265: ((OUTSECT *) memp)->osdsnext = ((OUTSECT *) basep)->osdsnext; ! 266: ((OUTSECT *) basep)->osdsnext = (OUTSECT *) memp; ! 267: if( ownerp->tail == basep ) ! 268: ownerp->tail = memp; ! 269: break; ! 270: } ! 271: } ! 272: /*eject*/ ! 273: listdel(seqid, headp, prevp, memp) ! 274: int seqid; /* sequence id */ ! 275: LISTOWN *headp; /* ptr to head-of-list structure */ ! 276: char *prevp; /* ptr to member preceeding the member to delete +/ ! 277: char *memp; /* ptr to member to delete */ ! 278: { ! 279: ! 280: /* ! 281: * Delete a member structure from a linked list ! 282: * ! 283: * If the member structure is null, this function is a noop ! 284: * ! 285: * This function is implemented as one function in case a general ! 286: * Storage Management System capability ever becomes available. ! 287: * ! 288: * Currently, the l_AI, l_IF, l_IS, l_OS, and l_INC lists are ! 289: * implemented as queues. The l_REG, l_MEM, and l_ADR lists are ! 290: * ordered lists. ! 291: */ ! 292: ! 293: if( memp == NULL ) ! 294: return; ! 295: ! 296: switch( seqid ) { ! 297: ! 298: case l_AI: ! 299: if( prevp ) ! 300: ((ACTITEM *) prevp)->ldlbry.ainext = ((ACTITEM *) memp)->ldlbry.ainext; ! 301: else ! 302: headp->head = (char *) ((ACTITEM *) memp)->ldlbry.ainext; ! 303: if( headp->tail == (char *) memp ) ! 304: headp->tail = prevp; ! 305: break; ! 306: case l_IF: ! 307: if( prevp ) ! 308: ((INFILE *) prevp)->flnext = ((INFILE *) memp)->flnext; ! 309: else ! 310: headp->head = (char *) ((INFILE *) memp)->flnext; ! 311: if( headp->tail == (char *) memp ) ! 312: headp->tail = prevp; ! 313: break; ! 314: case l_IS: ! 315: if( prevp ) ! 316: ((INSECT *) prevp)->isnext = ((INSECT *) memp)->isnext; ! 317: else ! 318: ((INFILE*) headp)->flishead = ((INSECT *) memp)->isnext; ! 319: if( ((INFILE *) headp)->flistail == ((INSECT *) memp) ) ! 320: ((INFILE *) headp)->flistail = (INSECT *) prevp; ! 321: break; ! 322: case l_OS: ! 323: if( prevp ) ! 324: ((OUTSECT *) prevp)->osnext = ((OUTSECT *) memp)->osnext; ! 325: else ! 326: headp->head = (char *) ((OUTSECT *) memp)->osnext; ! 327: if( headp->tail == (char *) memp ) ! 328: headp->tail = prevp; ! 329: break; ! 330: case l_INC: ! 331: if( prevp ) ! 332: ((INSECT *) prevp)->isincnxt = ((INSECT *) memp)->isincnxt; ! 333: else ! 334: ((OUTSECT *) headp)->osinclhd = ((INSECT *) memp)->isincnxt; ! 335: if( ((OUTSECT *) headp)->osincltl == ((INSECT *) memp) ) ! 336: ((OUTSECT *) headp)->osincltl = (INSECT *) prevp; ! 337: break; ! 338: case l_GRP: ! 339: if( prevp ) ! 340: ((OUTSECT *) prevp)->osnext = ((OUTSECT *) memp)->osnext; ! 341: else ! 342: ((OUTSECT *) headp)->osinclhd = ((INSECT *) ((OUTSECT *) memp)->osnext); ! 343: if( ((OUTSECT *) headp)->osincltl == ((INSECT *) memp) ) ! 344: ((OUTSECT *) headp)->osincltl = ((INSECT *) prevp); ! 345: break; ! 346: case l_REG: ! 347: if( prevp ) ! 348: ((REGION *) prevp)->rgnext = ((REGION *) memp)->rgnext; ! 349: else ! 350: headp->head = (char *) ((REGION *) memp)->rgnext; ! 351: if( headp->tail == (char *) memp ) ! 352: headp->tail = prevp; ! 353: break; ! 354: case l_MEM: ! 355: if( prevp ) ! 356: ((MEMTYPE *) prevp)->mtnext = ((MEMTYPE *) memp)->mtnext; ! 357: else ! 358: headp->head = (char *) ((MEMTYPE *) memp)->mtnext; ! 359: if( headp->tail == (char *) memp ) ! 360: headp->tail = prevp; ! 361: break; ! 362: case l_ADR: ! 363: if( prevp ) ! 364: ((ANODE *) prevp)->adnext = ((ANODE *) memp)->adnext; ! 365: else ! 366: headp->head = (char *) ((ANODE *) memp)->adnext; ! 367: if( headp->tail == (char *) memp ) ! 368: headp->tail = prevp; ! 369: else ! 370: ((ANODE *) memp)->adnext->adprev = (ANODE *) prevp; ! 371: break; ! 372: case l_DS: ! 373: if( prevp ) ! 374: ((OUTSECT *) prevp)->osdsnext = ((OUTSECT *) memp)->osdsnext; ! 375: else ! 376: headp->head = (char *) ((OUTSECT *) memp)->osdsnext; ! 377: if( headp->tail == (char *) memp ) ! 378: headp->tail = prevp; ! 379: break; ! 380: } ! 381: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.