|
|
1.1 ! root 1: ! 2: ! 3: /* ! 4: sioarg( ioflg,ioptr,scptr ) scans any arguments after the ! 5: filename and sets appropriate values in the passed ioblk. ! 6: ! 7: ioflg 0 - input / 3 - output association ! 8: ioptr -> ioblk ! 9: ! 10: */ ! 11: ! 12: #include "spitblks.h" ! 13: #include "spitio.h" ! 14: ! 15: int sioarg( ioflg,ioptr,scptr ) ! 16: ! 17: int ioflg; ! 18: struct ioblk *ioptr; ! 19: struct scblk *scptr; ! 20: ! 21: { ! 22: int cnt, lastdash = 0, strlen, v; ! 23: int lenfnm(), scnint(); ! 24: char chr, *cp, tab = 011; ! 25: ! 26: cp = scptr -> str; ! 27: ! 28: ioptr -> typ = 0; ! 29: ioptr -> len = RECSIZ; ! 30: ioptr -> pid = BUFSIZ; ! 31: ioptr -> fdn = 0; ! 32: ioptr -> flg = ioflg ? IO_OUP : IO_INP; ! 33: ! 34: if ( (cnt = lenfnm( scptr )) < 0 ) ! 35: return -1; ! 36: ! 37: strlen = scptr -> len; ! 38: ! 39: while ( cnt < strlen ) { ! 40: ! 41: chr = *(cp + cnt++); ! 42: ! 43: if ( (chr == ' ') || (chr == tab) ) { ! 44: lastdash = 0; ! 45: continue; ! 46: } ! 47: ! 48: if ( chr == '-' ) { ! 49: if ( lastdash != 0 ) { ! 50: return ( -1 ); ! 51: } else { ! 52: lastdash = 1; ! 53: continue; ! 54: } ! 55: } ! 56: ! 57: switch ( chr ) { ! 58: ! 59: ! 60: case 'a': ! 61: case 'A': ! 62: ioptr -> flg |= IO_APP; ! 63: break; ! 64: ! 65: case 'b': ! 66: case 'B': ! 67: v = scnint( cp + cnt,strlen - cnt,&cnt ); ! 68: if ( v > 0 ) { ! 69: ioptr -> pid = v; ! 70: } else { ! 71: return -1; ! 72: } ! 73: break; ! 74: ! 75: case 'c': ! 76: case 'C': ! 77: ioptr -> len = -1; ! 78: break; ! 79: ! 80: case 'f': ! 81: case 'F': ! 82: v = scnint( cp + cnt,strlen - cnt,&cnt ); ! 83: ioptr -> fdn = v; ! 84: ioptr -> flg |= ( IO_OPN | IO_SYS ); ! 85: if ( testty( v ) == 0 ) ! 86: ioptr -> flg |= IO_WRC; ! 87: break; ! 88: ! 89: case 'l': ! 90: case 'L': ! 91: v = scnint( cp + cnt,strlen - cnt,&cnt ); ! 92: if ( v > 0 ) { ! 93: ioptr -> len = v; ! 94: } else { ! 95: return -1; ! 96: } ! 97: break; ! 98: ! 99: case 'r': ! 100: case 'R': ! 101: v = scnint( cp + cnt,strlen - cnt,&cnt ); ! 102: if ( v > 0 ) { ! 103: ioptr -> len = -v; ! 104: } else { ! 105: return -1; ! 106: } ! 107: break; ! 108: ! 109: case 'w': ! 110: case 'W': ! 111: ioptr -> flg |= IO_WRC; ! 112: break; ! 113: ! 114: default: ! 115: return -1; ! 116: } ! 117: ioptr -> typ = 1; ! 118: lastdash = 0; ! 119: } ! 120: return 0; ! 121: } ! 122: ! 123: /* ! 124: scnint( str,len ) scans an integer starting at the front of ! 125: str. in no case can the scan go more than len digits. ! 126: */ ! 127: ! 128: int scnint( str,len,intptr ) ! 129: ! 130: char *str; ! 131: int len; ! 132: int *intptr; ! 133: ! 134: { ! 135: int i = 0, n = 0; ! 136: char chr; ! 137: ! 138: while ( i < len ) { ! 139: chr = *(str + i++); ! 140: if ( (chr >= '0') && (chr <= '9')) { ! 141: n = 10 * n + chr - '0'; ! 142: } else { ! 143: --i; ! 144: break; ! 145: } ! 146: } ! 147: *intptr += i; ! 148: return n; ! 149: } ! 150: ! 151:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.