|
|
1.1 ! root 1: /* ! 2: * Routines for handling file linking. ! 3: */ ! 4: ! 5: #include "itran.h" ! 6: #include "lfile.h" ! 7: ! 8: struct lfile *lfiles; ! 9: ! 10: /* ! 11: * alclfile allocates an lfile structure for the named file, fills ! 12: * in the name and returns a pointer to it. ! 13: */ ! 14: struct lfile *alclfile(name) ! 15: char *name; ! 16: { ! 17: struct lfile *p; ! 18: char *np; ! 19: int l; ! 20: extern char *allocate(); ! 21: ! 22: p = (struct lfile *)allocate(1,sizeof(struct lfile)); ! 23: if (!p) ! 24: syserr("not enough memory for file list"); ! 25: p->lf_link = NULL; ! 26: l = strlen(name); ! 27: np = allocate(1,(l+1+sizeof(int *)) & ~(sizeof(int *)-1)); ! 28: if (!np) ! 29: syserr("not enough memory for file list"); ! 30: strncpy(np,name,l); ! 31: p->lf_name = np; ! 32: return p; ! 33: } ! 34: /* ! 35: * dumplfiles - print the list of files to link. Debugging only. ! 36: */ ! 37: dumplfiles() ! 38: { ! 39: struct lfile *p,*lfls; ! 40: ! 41: printf("lfiles:\n"); ! 42: lfls = lfiles; ! 43: while (p = getlfile(&lfls)) ! 44: printf("'%s'\n",p->lf_name); ! 45: } ! 46: /* ! 47: * addlfile creates an lfile structure for the named file and add it to the ! 48: * end of the list of files (lfiles) to generate link instructions for. ! 49: */ ! 50: addlfile(name) ! 51: char *name; ! 52: { ! 53: struct lfile *nlf, *p; ! 54: ! 55: nlf = alclfile(name); ! 56: if (lfiles == NULL) { ! 57: lfiles = nlf; ! 58: } ! 59: else { ! 60: p = lfiles; ! 61: while (p->lf_link != NULL) { ! 62: p = p->lf_link; ! 63: } ! 64: p->lf_link = nlf; ! 65: } ! 66: } ! 67: /* ! 68: * getlfile returns a pointer (p) to the lfile structure pointed at by lptr ! 69: * and moves lptr to the lfile structure that p points at. In other words, ! 70: * getlfile returns a pointer to the current (wrt. lptr) lfile and advances ! 71: * lptr. ! 72: */ ! 73: struct lfile * ! 74: getlfile(lptr) ! 75: struct lfile **lptr; ! 76: { ! 77: struct lfile *p; ! 78: ! 79: if (*lptr == NULL) ! 80: return NULL; ! 81: else { ! 82: p = *lptr; ! 83: *lptr = p->lf_link; ! 84: return p; ! 85: } ! 86: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.