|
|
1.1 ! root 1: /* extent.c 1.7 83/05/13 */ ! 2: ! 3: #include <stdio.h> ! 4: #include "cpmio.h" ! 5: #include "cpmfio.h" ! 6: ! 7: /* ! 8: * Allocate a new extent to the file pointed to by curext, ! 9: * or, if curext < 0, return the index of the first free ! 10: * directory slot. ! 11: * Return a negative pointer if no directory space, otherwise ! 12: * the index to the new extent. ! 13: */ ! 14: ! 15: creext(curext) ! 16: int curext; ! 17: { ! 18: ! 19: int i, j; ! 20: ! 21: for (i=0; i < maxdir; i++) ! 22: if ((dirbuf + i)->status == (char) 0xe5) ! 23: break; ! 24: if (i == maxdir) ! 25: return (EOF); ! 26: if (curext >= 0) ! 27: *(dirbuf+i) = *(dirbuf+curext); ! 28: ! 29: /* clear all file pointers */ ! 30: for (j=0; j<16; j++) ! 31: (dirbuf+i)->pointers[j] = '\0'; ! 32: ! 33: #ifdef DEBUG ! 34: printf("extent allocated: %d (old: %d)\n", i, curext); ! 35: printf("extent data: 0x%x, name: %s\n", (dirbuf+i)->status, ! 36: (dirbuf+i)->name); ! 37: #endif ! 38: return(i); ! 39: } ! 40: ! 41: ! 42: /* ! 43: * Find next extent of the file pointed to by file pointer 'current', ! 44: * return the new extent's index if found, otherwise NULL. ! 45: */ ! 46: ! 47: getnext(cur) ! 48: C_FILE *cur; ! 49: { ! 50: ! 51: int ind; ! 52: ! 53: cur->c_extno++; ! 54: for (ind = 0; ind < maxdir; ind++) ! 55: if ((strncmp(cur->c_dirp->name,(dirbuf+ind)->name,8)==0) && ! 56: (strncmp((dirbuf+ind)->ext, cur->c_dirp->ext,3)==0) && ! 57: ((dirbuf+ind)->extno == cur->c_extno)) { ! 58: cur->c_ext=ind; ! 59: cur->c_seccnt = 0xff & (int)(dirbuf+ind)->blkcnt; ! 60: cur->c_dirp = dirbuf + ind; ! 61: cur->c_blk = 0; ! 62: #ifdef DEBUG ! 63: printf("getnext: dir. index: %d\n",ind); ! 64: #endif ! 65: return (ind); ! 66: } ! 67: return (NULL); ! 68: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.