%%s 0/0/0 %%d D 1.1 25-Mar-82 12:11:12 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 #-h- crar 623 asc 25-mar-82 08:19:28 v1.1 (sw-tools v1.1) common / crar / arcint, nmods, fstat(MAX_FILES), filptr(MAX_FILES), size(2, MAX_FILES), siz(2), lptr(MAX_FILES), fname(MAX_FILE_SPACE), file(FILENAMESIZE), buf(MAXLINE) filedes arcint # ratfor unit for archive integer nmods # number of modules in archive integer fstat # if module has been processed previously; init = NO integer size # double integer size of module integer siz # scratch double integer array linepointer lptr # linepointers for start of each module in archive character fname # array holding module names character file # scratch file name array character buf # scratch buffer for getlin's #-h- rar.r 4166 asc 25-mar-82 08:19:29 v1.1 (sw-tools v1.1) #-h- defns 100 asc 25-mar-82 08:19:07 v1.1 (sw-tools v1.1) define(MAX_FILES,256) define(MAX_FILE_SPACE,arith(MAX_FILES,*,10)) define(arskip,arcopy($1,ERR,$2)) #-h- main 917 asc 25-mar-82 08:19:08 v1.1 (sw-tools v1.1) DRIVER(rar) character aname(FILENAMESIZE), rbuf(MAXLINE) integer verbos, n, i, compl integer getarg, open, getlin, index include crar string usestr "usage: rar [-cv] archive." call query(usestr) aname(1) = EOS verbos = NO compl = YES for (i=1; getarg(i, rbuf, FILENAMESIZE) != EOF; i=i+1) if (rbuf(1) == '-') { call fold(rbuf) if (index(rbuf, 'v') > 0) verbos = YES if (index(rbuf, 'c') > 0) compl = NO } else call strcpy(rbuf, aname) if (aname(1) == EOS) call error(usestr) arcint = open(aname, READ) if (int == ERR) call cant(aname) call rainit for (n=getlin(rbuf, STDIN); n != EOF; n=getlin(rbuf, STDIN)) { rbuf(n) = EOS call fold(rbuf) call putmod(rbuf, verbos) } if (compl == YES) for (n=1; n <= nmods; n=n+1) if (fstat(n) == NO) { i = filptr(n) call scopy(fname, i, rbuf, 1) call putmod(rbuf, verbos) } DRETURN end #-h- arcopy 383 asc 25-mar-82 08:19:09 v1.1 (sw-tools v1.1) subroutine arcopy(fdi, fdo, size) filedes fdi, fdo integer size(2), hi, lo character c character getch hi = size(1) lo = size(2) if (lo == 0 & hi > 0) { lo = 10000 hi = hi - 1 } while (lo > 0) { if (getch(c, fdi) == EOF) break if (fdo != ERR) call putch(c, fdo) lo = lo - 1 if (lo == 0 & hi > 0) { lo = 10000 hi = hi - 1 } } return end #-h- gethdr 738 asc 25-mar-82 08:19:11 v1.1 (sw-tools v1.1) ## GetHdr - Get header info from archive member `fd'. integer function gethdr(fd, buf, name, size, type) character buf(MAXLINE), c, name(FILENAMESIZE), temp(FILENAMESIZE) integer ctoi, equal, getlin, getwrd, ishdr # function(s) integer fd, i, len, size(2), type, j string asc "asc" string local "local" string bin "bin" if( getlin(buf, fd) == EOF ) { gethdr = EOF return } call fold(buf) if (ishdr(buf, i) == NO) call error("? Archive not in proper format.") gethdr = YES len = getwrd(buf, i, name) call ctodi(buf, i, size) len = getwrd (buf, i, temp) if( len <= 0 | equal(temp,asc) ) type = ASCII else if( equal(temp, local) ) type = LOCAL else if( equal(temp, bin) ) type = BINARY else type = ASCII return end #-h- ishdr 252 asc 25-mar-82 08:19:12 v1.1 (sw-tools v1.1) integer function ishdr(buf, i) character buf(ARB) integer i string hdr "#-h-" ishdr = YES for (i=1; hdr(i) != EOS; i=i+1) if (buf(i) != hdr(i)) { ishdr = NO break } if (ishdr == YES) if (buf(i) != ' ') ishdr = NO return end #-h- putmod 631 asc 25-mar-82 08:19:13 v1.1 (sw-tools v1.1) subroutine putmod(name, verbos) character name(FILENAMESIZE) integer verbos, i, j, junk integer equal, getlin include crar for (i=1; i <= nmods; i=i+1) { j = filptr(i) call scopy(fname, j, file, 1) if (equal(file, name) == YES) { if (fstat(i) == YES) { call putlin(name, ERROUT) call error(" - already output.") } call seek(lptr(i), arcint) junk = getlin(buf, arcint) call putlin(buf, STDOUT) siz(1) = size(1, i) siz(2) = size(2, i) call arcopy(arcint, STDOUT, siz) fstat(i) = YES if (verbos == YES) call remark(name) break } } return end #-h- rainit 634 asc 25-mar-82 08:19:13 v1.1 (sw-tools v1.1) subroutine rainit integer i, type, junk integer gethdr, length, note include crar i = 1 for (nmods = 1; nmods <= MAX_FILES; nmods = nmods + 1) { junk = note(lptr(nmods), arcint) if (gethdr(arcint, buf, file, siz, type) == EOF) break fstat(nmods) = NO size(1, nmods) = siz(1) size(2, nmods) = siz(2) filptr(nmods) = i if ((i + length(file) + 1) > MAX_FILE_SPACE) call error("Out of space for module names.") call stcopy(file, 1, fname, i) i = i + 1 # skip over EOS call arskip(arcint, siz) } if (nmods > MAX_FILES) call error("Too many modules in archive.") else nmods = nmods - 1 return end #-h- rar.fmt 1102 asc 25-mar-82 08:19:30 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Rar (1) 2-May-81 rearrange archive .sy rar [-cv] archive .ds `rar' permits the rearrangement of the modules of an archive, `archive'. `rar' opens `archive' and notes the names and starting address of each module. It then reads the names of modules from standard input and outputs each module so indicated to standard output. Upon detecting an EOF on standard input, any modules not yet output are written out in the order found in the original archive. .sp 1 Switches: .sp 1 .in +5 .ti -3 -c Suppresses the output of modules not specified on the standard input. This permits the selection of only a subset of the original archive's modules. .ti -3 -v Print the name of each module on error output after it has been successfully output to the standard output. .sp 1 .ti -5 Example of use: .sp 1 Suppose that you wish to create a new version (newarch) of an archive (oldarch) with all of the modules sorted by name. The following shell command will suffice: ar t oldarch | sort | rar -v oldarch >newarch .in -5 .fl none .sa ar - archive file maintainer .di .au Joe Sventek .bu %%E 1