#-h- asplit.r 1772 asc 08-apr-81 08:06:12 [002,101] #-h- main 880 asc 08-apr-81 08:05:53 [002,101] DRIVER(asplit) character header(5), tag(FILENAMESIZE), buf(MAXLINE), clower, file(FILENAMESIZE) integer getlin, i, getarg, nmatch, out, open, verbos, scline data header/SHARP, MINUS, LETH, MINUS, EOS/ data tag(1)/EOS/ call query("usage: asplit [-tstring] [-v].") verbos = NO for (i=1; getarg(i, buf, MAXLINE) != EOF; i=i+1) if (buf(1) == MINUS & clower(buf(2)) == LETT) call scopy(buf, 3, tag, 1) else if (buf(1) == MINUS & clower(buf(2)) == LETV) verbos = YES else { call putlin(buf, ERROUT) call remark(": invalid argument.") } out = STDOUT while (getlin(buf, STDIN) != EOF) if (nmatch(buf, 1, header) > 0) { call close(out) if (scline(buf, tag, file) == ERR) call cant(buf) out = open(file, WRITE) if (out == ERR) call cant(file) if (verbos == YES) call remark(file) } else call putlin(buf, out) DRETURN end #-h- nmatch 247 asc 08-apr-81 08:05:54 [002,101] integer function nmatch(lin, from, pat) character lin(MAXLINE), pat(ARB) integer from, i, j i = from for (j=1; pat(j) != EOS; j = j + 1) { if (lin(i) != pat(j)) { nmatch = 0 return } i = i + 1 } nmatch = i return end #-h- scline 459 asc 08-apr-81 08:05:55 [002,101] integer function scline(buf, tag, file) character buf(ARB), tag(ARB), file(ARB), type, c integer i, j for (i=1; buf(i) != BLANK; i=i+1) ; # skip over header call skipbl(buf, i) # skip over blanks c = type(buf(i)) for (j=1; c == LETTER | c == DIGIT | c == PERIOD; j=j+1) { file(j) = buf(i) i = i + 1 c = type(buf(i)) } if (j == 1) scline = ERR else { call scopy(tag, 1, file, j) scline = OK } return end #-h- asplit.rof 1768 asc 02-may-81 21:25:19 [002,100] .in 5 .rm 75 .pl 60 .he 'ASPLIT'8/25/80'ASPLIT' .fo //-#-/ .bp 1 NAME .in +3 asplit - salvage garbaged archive files .ti -3 SYNOPSIS asplit