home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: alt.sources
- Path: sparky!uunet!mcsun!fuug!news.funet.fi!ousrvr.oulu.fi!phoenix!yaz
- From: yaz@phoenix.oulu.fi
- Subject: NewsAgent: uutimet (preliminary)
- Message-ID: <1992Dec21.233325.17428@ousrvr.oulu.fi>
- Followup-To: alt.sources.d
- Lines: 362
- Sender: news@ousrvr.oulu.fi
- Organization: University of Oulu, Finland
- X-Newsagent: :: uutimet -- news-agent by yaz@phoenix.oulu.fi ::
- Date: Mon, 21 Dec 1992 23:33:25 GMT
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of shell archive."
- # Contents: readme.yaz uutimet telagent.c nagent.c
- # Wrapped by yaz@phoenix on Tue Dec 22 01:31:28 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f readme.yaz -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"readme.yaz\"
- else
- echo shar: Extracting \"readme.yaz\" \(1645 characters\)
- sed "s/^X//" >readme.yaz <<'END_OF_readme.yaz'
- XThis is a readme-file for the first published packaged NewsAgent by yaz.
- XCompile the following c-programs with your favorite ccompiler and
- Xmv them to your bin-directory. Place the sh-script into any directory
- Xwhere you want it, I use src/sh but it might not be proper on your
- Xaccount.
- X
- XWhy: I wrote this bunch of programs because GNUS was too slow on
- X the computer I used, and I did not want to stick with telnet
- X any more.
- X
- XWhat: uutimet does not save read article numbers, neither it reads them.
- X It is fast, useful, and pretty. (Hah, listen to the man boast).
- X It uses less , or user defined pager, to page the output.
- X It does ugly quotes in follow-up, and does not believe in
- X Follow-Up-To or whatever.
- X
- XWho: Tuomas "yaz" Kaikkonen wrote this in his freetime.
- X (yaz@phoenix.oulu.fi)
- X
- XContents :
- X
- Xnagent.c : this is the newsreader
- Xtelagent.c : and this is the general purpose telnet substitute
- Xuutimet : the sh-script to rule them all
- X
- XUsage:
- X
- Xuutimet
- X
- XThe first two programs are used by the third one. If you want to use them
- Xalone:
- X
- X
- Xnagent <newsgroup> [article]
- X
- XWhere <newsgroup> is any newsgroup name known to your $NNTPSERVER and
- Xif you want to read spesific article, then give that as the third
- Xargument [article]. If you omit the article number, then the newsreader
- Xnagent shows the current high- and low-article counts for that group.
- X
- Xwhatever | telagent host port
- X
- X
- XWhere whatever is any command which output is used as the input to
- Xthe telnet substitute program.
- X
- X
- XMore help can be found from the sh-file when you run it.
- X
- X
- XMerry Xmas & a happy new year!
- X
- X--Tuomas
- END_OF_readme.yaz
- if test 1645 -ne `wc -c <readme.yaz`; then
- echo shar: \"readme.yaz\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f uutimet -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"uutimet\"
- else
- echo shar: Extracting \"uutimet\" \(3644 characters\)
- sed "s/^X//" >uutimet <<'END_OF_uutimet'
- X#!/bin/sh
- X#
- X# Simple sh-script for news reading+posting <yaz@phoenix.oulu.fi> 92/12/09
- X
- Xeditori="memacs"
- Xlessi="less"
- Xvali="help"
- Xgroup="oy.test"
- Xnumber="1"
- Xwhile true
- Xdo
- X case $vali in
- X help) echo "help - this help";
- X echo "conn [NNTPserver name] - connect a NNTPserver";
- X echo "list - list of newsgroups with $lessi";
- X echo "join [group name] - join a newsgroup";
- X echo "next - read next article with $lessi";
- X echo "Next - read next article without $lessi";
- X echo "prev - read prev article with $lessi";
- X echo "Prev - read prev article without $lessi";
- X echo "goto [article number] - goto article";
- X echo "read - read current article with $lessi";
- X echo "Read - read current article without $lessi";
- X echo "post - post an article edited with $editori";
- X echo "foll - post a follow-up to current article edited with $editori";
- X echo "show - show current variables";
- X echo "quit - quit this program";;
- X conn) NNTPSERVER="$toka";
- X export NNTPSERVER;
- X echo "quit" | telagent $NNTPSERVER 119 | head -1 | cut -d" " -f2-;;
- X list) bartfile="`whoami`$$";
- X echo list > $bartfile;
- X echo quit >> $bartfile;
- X cat $bartfile | telagent $NNTPSERVER 119 | $lessi;
- X rm $bartfile;;
- X join) echo "joining newsgroup $toka";
- X group=$toka;
- X nagent $group;
- X number=`nagent $group | cut -d"-" -f1`;;
- X next) number=`expr $number + 1`;
- X nagent $group $number | $lessi;;
- X Next) number=`expr $number + 1`;
- X nagent $group $number;;
- X prev) number=`expr $number - 1`;
- X nagent $group $number | $lessi;;
- X Prev) number=`expr $number - 1`;
- X nagent $group $number;;
- X goto) echo "going to article number $toka in group $group";
- X number=$toka;;
- X read) nagent $group $number | $lessi;;
- X Read) nagent $group $number;;
- X post) artfile="`whoami`$$";
- X echo "Path: `who am i | cut -d\! -f1`!`whoami`" > $artfile;
- X echo "Newsgroups: $group" >> $artfile;
- X echo "From: `whoami`@`hostname`.oulu.fi" >> $artfile;
- X echo "Subject ?";
- X read artsubj;
- X echo "Subject: $artsubj" >> $artfile;
- X echo "Lines: " >> $artfile;
- X echo "Followup-To: " >> $artfile;
- X echo "Organization: " >> $artfile;
- X echo "X-NewsAgent: :: uutimet -- news-agent by yaz@phoenix.oulu.fi ::" >> $artfile;
- X echo "" >> $artfile;
- X $editori $artfile;
- X nlines=`cat $artfile | wc -l`;
- X nlines=`expr $nlines - 8`;
- X echo "" >> $artfile;
- X echo "." >> $artfile;
- X echo "quit" >> $artfile;
- X echo post | cat - $artfile | sed 6s/"Lines: "/"Lines: $nlines"/ | telagent $NNTPSERVER 119;
- X rm $artfile;;
- X foll) artfile="`whoami`$$";
- X echo "Path: `who am i | cut -d\! -f1`!`whoami`" > $artfile;
- X echo "Newsgroups: $group" >> $artfile;
- X echo "From: `whoami`@`hostname`.oulu.fi" >> $artfile;
- X nagent $group $number | grep "^Subject:" | tr -d '\015' | sed s/"Re: "//g | sed s/"^Subject: "/"Subject: Re: "/g >> $artfile;
- X echo "Lines: " >> $artfile;
- X echo "Followup-To: " >> $artfile;
- X echo "Organization: " >> $artfile;
- X echo "X-NewsAgent: :: uutimet -- news-agent by yaz@phoenix.oulu.fi ::" >> $artfile;
- X echo "" >> $artfile;
- X nagent $group $number | sed s/"^"/"> "/g | tr -d '\015' >> $artfile;
- X $editori $artfile;
- X nlines=`cat $artfile | wc -l`;
- X nlines=`expr $nlines - 8`;
- X echo "" >> $artfile;
- X echo "." >> $artfile;
- X echo "quit" >> $artfile;
- X echo post | cat - $artfile | sed 6s/"Lines: "/"Lines: $nlines"/ | telagent $NNTPSERVER 119;
- X rm $artfile;;
- X show) echo "NNTPserver: $NNTPSERVER";
- X nagent $group;
- X echo "current article number:$number";;
- X quit) exit ;;
- X *) echo "read the help with command help";;
- X esac
- X echo ":: uutimet -- news-agent by yaz@phoenix.oulu.fi ::"
- X read vali toka
- Xdone
- END_OF_uutimet
- if test 3644 -ne `wc -c <uutimet`; then
- echo shar: \"uutimet\" unpacked with wrong size!
- fi
- chmod +x uutimet
- # end of overwriting check
- fi
- if test -f telagent.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"telagent.c\"
- else
- echo shar: Extracting \"telagent.c\" \(1126 characters\)
- sed "s/^X//" >telagent.c <<'END_OF_telagent.c'
- X#include <sys/types.h>
- X#include <sys/socket.h>
- X#include <netinet/in.h>
- X#include <netdb.h>
- X#include <stdio.h>
- X#include <signal.h>
- X
- Xmain(argc,argv) /* telagent main */
- Xint argc;
- Xchar *argv[];
- X{
- X int i,j,sd,port=23;
- X struct sockaddr_in server;
- X struct hostent *hp, *gethostbyname();
- X char text[512];
- X char string[512];
- X FILE *out_file,*in_file;
- X
- X if (argc<2) {
- X fprintf(stderr, "Usage: %s <host> [port]\n", argv[0]);
- X exit(1);
- X }
- X if (argc == 3) port=atoi(argv[2]);
- X sd=socket(AF_INET,SOCK_STREAM,0);
- X if(sd<0) { perror("socket"); exit(1); }
- X server.sin_family = AF_INET;
- X hp=gethostbyname(argv[1]);
- X if(hp==0) {
- X fprintf(stderr, "%s: Unknown host\n",argv[1]);
- X exit(2);
- X }
- X bcopy(hp->h_addr, &server.sin_addr, hp->h_length);
- X server.sin_port=htons(port);
- X
- X if(connect(sd,&server,sizeof(server))<0) {
- X perror("connecting stream socket");
- X exit(1);
- X }
- X in_file=fdopen(sd,"r+");
- X out_file=fdopen(sd,"r+");
- X while(fgets(string, 512, stdin)!=NULL) fputs(string, out_file);
- X fflush(out_file);
- X for(string[0]=0;fgets(string, 512, in_file)!=NULL;) printf("%s",string);
- X close(out_file);
- X close(in_file);
- X close(sd);
- X return 0;
- X}
- X
- END_OF_telagent.c
- if test 1126 -ne `wc -c <telagent.c`; then
- echo shar: \"telagent.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f nagent.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"nagent.c\"
- else
- echo shar: Extracting \"nagent.c\" \(2375 characters\)
- sed "s/^X//" >nagent.c <<'END_OF_nagent.c'
- X#include <sys/types.h>
- X#include <sys/socket.h>
- X#include <netinet/in.h>
- X#include <netdb.h>
- X#include <stdio.h>
- X#include <signal.h>
- X
- Xint getword(s,t,p) /* return one word from input string, s, position p */
- Xint p; /* to output string t; getword returns new position */
- Xchar s[],t[];
- X{
- X int i;
- X
- X while(s[p]==' ' || s[p]==':' &&
- X (s[p]!='\n' && s[p]!=0)) p++;
- X
- X for (i=0,t[0]=0;s[p+i]!=' ' && s[p+i]!=':' && s[p+i]!='\n';
- X t[i]=s[p+(i++)]);
- X t[i]=0;
- X return(p+i);
- X}
- X
- Xmain(argc,argv) /* nagent main */
- Xint argc;
- Xchar *argv[];
- X{
- X int i,j,sd;
- X struct sockaddr_in server;
- X struct hostent *hp, *gethostbyname();
- X char text[512];
- X char string[512];
- X FILE *out_file,*in_file;
- X
- X if (argc<2) {
- X fprintf(stderr, "Usage: %s <group> [article_number]\n", argv[0]);
- X exit(1);
- X }
- X
- X sd=socket(AF_INET,SOCK_STREAM,0);
- X if(sd<0) { perror("socket"); exit(1); }
- X server.sin_family = AF_INET;
- X hp=gethostbyname(getenv("NNTPSERVER"));
- X if(hp==0) {
- X fprintf(stderr, "%s: Unkown host\n",getenv("NNTPSERVER"));
- X exit(2);
- X }
- X bcopy(hp->h_addr, &server.sin_addr, hp->h_length);
- X server.sin_port=htons(119);
- X
- X if(connect(sd,&server,sizeof(server))<0) {
- X perror("connecting stream socket");
- X exit(1);
- X }
- X in_file=fdopen(sd,"r+");
- X out_file=fdopen(sd,"r+");
- X fgets(string, 512, in_file);
- X fprintf(out_file, "group %s\n", argv[1]);
- X fflush(out_file);
- X fgets(string, 512, in_file);
- X if (string[0] != '2' || string[1] != '1' || string[2] != '1') {
- X printf("%s",string);
- X fprintf(out_file, "quit\n");
- X fflush(out_file);
- X argc = 0;
- X } else {
- X if (argc == 2) {
- X i=getword(string,text,0);
- X i=getword(string,text,i);
- X i=getword(string,text,i);
- X printf("%s-", text);
- X i=getword(string,text,i);
- X printf("%s ", text);
- X i=getword(string,text,i);
- X printf("%s\n", text);
- X fprintf(out_file, "quit\n");
- X fflush(out_file);
- X }
- X }
- X if (argc == 3) {
- X fprintf(out_file, "article %s\n", argv[2]);
- X fflush(out_file);
- X fgets(string, 512, in_file);
- X if (string[0] != '2' || string[1] != '2' || string[2] != '0') {
- X printf("%s",string);
- X } else {
- X fgets(string, 512, in_file);
- X fprintf(out_file, "quit\n");
- X fflush(out_file);
- X for(string[0]=0;fgets(string, 512, in_file)!=NULL;)
- X {
- X printf("%s",string);
- X if (string[0] == '.' && string[1] == '\r') {
- X fgets(string, 512, in_file);
- X }
- X }
- X }
- X }
- X close(out_file);
- X close(in_file);
- X close(sd);
- X return 0;
- X}
- X
- END_OF_nagent.c
- if test 2375 -ne `wc -c <nagent.c`; then
- echo shar: \"nagent.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- echo shar: End of shell archive.
- exit 0
-
-