home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
TELECOM
/
rn_4_3_blars.lzh
/
norm.saver.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-08-26
|
1KB
|
60 lines
/* norm.saver.c created from norm.saver.SH by blarson@usc.edu */
/*
/* Arguments:
/* 1 Full name of article (%A)
/* 2 Public news spool directory (%P)
/* 3 Directory of current newsgroup (%c)
/* 4 Article number (%a)
/* 5 Where in article to start (%B)
/* 6 Newsgroup name (%C)
/* 7 Save destination (%b)
/*
*/
#include <stdio.h>
#include "fileinfo.h"
main(argc, argv)
int argc;
char **argv;
{
register int outfile, infile, count;
char buffer[8192];
if(argc < 8) {
fprintf(stderr, "norm.saver: less than 7 arguments\n");
exit(1);
}
if((infile = open(argv[1], OPEN_READ)) < 0) {
fprintf(stderr, "Can't open %s for reading\n", argv[1]);
exit(1);
}
count = atoi(argv[5]);
if(count > 0) {
if(lseek(infile, count, 0) < 0) {
fprintf(stderr, "Can't position in %s\n", argv[1]);
exit(1);
}
}
if((outfile = open(argv[7], OPEN_READWRITE)) < 0) {
if((outfile = creat(argv[7], CREAT_READWRITE)) < 0) {
fprintf(stderr, "Can't open %s for writing\n", argv[7]);
exit(1);
}
} else {
if(lseek(outfile, 0, 2) < 0) {
fprintf(stderr, "Can't position to end of %s\n", argv[7]);
exit(1);
}
}
if(count==0) {
sprintf(buffer, "Article %s of %s:\n", argv[4], argv[6]);
write(outfile, buffer, strlen(buffer));
}
while((count = read(infile, buffer, sizeof buffer)) > 0) {
write(outfile, buffer, count);
}
write(outfile, "\n\n", 2);
exit(0);
}