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