diff -Nrc oneko/COPYRIGHTS oneko-2.0b-pop/COPYRIGHTS *** oneko/COPYRIGHTS Thu Jan 1 09:00:00 1970 --- oneko-2.0b-pop/COPYRIGHTS Sat Aug 9 16:55:33 1997 *************** *** 0 **** --- 1,88 ---- + COPYRIGTHS of oneko-2.0 + oneko-2.0 $@$N(J $@HG8"$K$D$$$F(J + Aug 9,1997 + Nobuyuki Sasaki + + + $@$3$N%Q%C%A$r8x3+$9$k$K$"$?$C$F!"(J + oneko-2.0 $@$NHG8"$K$D$$$F3NG'$7$F$*$-$^$9!#(J + + + $@!cG-$KNr;K$"$j!d(J + + oneko-2.0 $@$O!"(J + Tatsuya Kato , 1990,1991. + $@$5$s$K$h$C$F:n$i$l$^$7$?!#(J + $@$3$l$O!"(Jxneko $@$r%Y!<%9$K:n@.$5$l$^$7$?!#(J + xneko $@%*%j%8%J%k$N%3!<%I$r4^$s$G$$$^$;$s$,!"(J + $@G-$N3($N%S%C%H%^%C%W$O!"(Jxneko $@$N$b$N$r$[$\$=$N$^$^;HMQ$7$F$$$^$9!#(J + + xneko $@$O(J + $@8E>l(J $@@59T$5$s(J + Masayuki Koba , 1990. + $@$K$h$C$F:n$i$l$^$7$?!#(J + $@$3$N;~$K;HMQ$5$l$?G-$N3($O!"(J + $@%^%C%-%s%H%C%7%e$GF0:n$9$k(J neko DA $@$H$$$&%=%U%H%&%(%"$N$b$N$G$9!#(J + + neko DA $@$O!"(J + $@8eF#(J $@l(J $@@59T$5$s$+$i$O!"(J + $@!VG-$N3($r%S%C%H%^%C%W2=$7$?$3$H(J + $@!?G-$N3($N%"%K%a!<%7%g%s$N@Z$jBX$(%?%$%_%s%0$r%W%m%0%i%`2=$7$?$3$H(J + $@$KBP$9$k8E>l$N8"Mx$O!"J|4~$9$k!W(J + $@$3$H$N3NG'$rD:$-$^$7$?!#(J(Aug 7, 1997) + + oneko $@$N:n/$J$/$H$b!";d$NCx:nJ*!J%W%m%0%i%`!"%I%-%e%a%s%H!K$K$D$$$F$O!"(J + $@Cx:n?M3J8"$r9T;H$$$?$7$^$;$s!#(J + $@!J$D$^$j!";HMQ!"2~B$!":FG[I[Ey$K$D$$$F%U%j!<$G$9!K!W(J + $@$3$H$N3NG'$rD:$-$^$7$?!#(J(Aug 6, 1997) + + POP $@%Q%C%A$N:n$l$N@=:n$K4X$o$C$?!"$5$^$6$^$J?M$,$$$k$3$H$bK:$l$J$$$G$/$@$5$$!#(J + + $@$=$7$F!"$b$7(J oneko $@$K2~B$Ey$r2C$($F:FG[I[$9$k>l9g!"(J + oneko $@$NNr;K$K?($l$FM_$7$$$N$G$9!#(J + + $@$3$l$^$G$NG-$NNr;K$K7I0U$rI=$7!"$5$5$d$+$J$*4j$$$G$9!#(J + + + $@$5$5$-$N$V$f$-(J + diff -Nrc oneko/Imakefile oneko-2.0b-pop/Imakefile *** oneko/Imakefile Tue Mar 17 23:08:48 1992 --- oneko-2.0b-pop/Imakefile Wed Aug 6 18:01:01 1997 *************** *** 15,24 **** SYS_LIBRARIES = -lm DEPLIBS = $(DEPXLIB) CDEBUGFLAGS = -g ! DEFINES = -DSHAPE -DONEKODIR=\"$(ONEKOLIBDIR)\" -DLIBDIR=\"$(LIBDIR)\" # DEFINES = -DONEKODIR=\"$(ONEKOLIBDIR)\" -DLIBDIR=\"$(LIBDIR)\" ! SRCS = oneko.c event.c init.c mail.c resource.c state.c ! OBJS = oneko.o event.o init.o mail.o resource.o state.o ComplexProgramTarget(oneko) --- 15,24 ---- SYS_LIBRARIES = -lm DEPLIBS = $(DEPXLIB) CDEBUGFLAGS = -g ! DEFINES = -DPOP -DMAILACTION -DSHAPE -DONEKODIR=\"$(ONEKOLIBDIR)\" -DLIBDIR=\"$(LIBDIR)\" # DEFINES = -DONEKODIR=\"$(ONEKOLIBDIR)\" -DLIBDIR=\"$(LIBDIR)\" ! SRCS = oneko.c event.c init.c mail.c resource.c state.c action.c ! OBJS = oneko.o event.o init.o mail.o resource.o state.o action.o ComplexProgramTarget(oneko) diff -Nrc oneko/README.pop oneko-2.0b-pop/README.pop *** oneko/README.pop Thu Jan 1 09:00:00 1970 --- oneko-2.0b-pop/README.pop Fri Aug 15 01:59:09 1997 *************** *** 0 **** --- 1,211 ---- + oneko - Neko runs over the windows. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Version 2.0 beta + March 3rd 1992 + + Aug 9th 1997 (pop-1.1.1) + POP by Nobuyuki Sasaki (sasaki@thinkfree.co.jp) + + + $@$3$l$O(J oneko 2.0 $@$K$"$k(J biff $@5!G=$r(J POP $@BP1~$K$7$?$b$N$G$9!#(J + $@$^$?!"F1;~$K%a!<%kE~Ce;~$K%3%^%s%I$r5/F0$9$k5!G=$rIU$12C$($F$"$j$^$9!#(J + + $@%*%j%8%J%k$N%=!<%9%Q%C%1!<%8$O!"(J + Niftyserve UNIX$@%U%)!<%i%`(J LIB 9 (X Window Contrib) #96 + $@$KEPO?$5$l$F$$$^$9!#(J + $@$^$?!";d$N(J WEB$@%Z!<%8(J + http://www02.so-net.or.jp/~nsasaki/oneko/ + $@$K$bCV$$$F$*$-$^$9!#(J + + $@;d$,DI2C$7$?5!G=(J (POP $@BP1~!"%3%^%s%IH$7$F$/$@$5$$!#(J + + + $@!c$J$K$,?7$7$$$N$+!)!d(J + + Aug 9th 1997 (pop-1.1.1) + $@!&%*%j%8%J%k$NHG8"$K$D$$$F3NG'$7!"(JCOPYRIGHTS $@$r=q$-B-$7$^$7$?(J + ($@$D$^$k$H$3$m%I%-%e%a%s%H$N2~HG$@$1$J$s$G$9!D(J) + + Aug 5th 1997 (pop-1.1) + $@!&%a!<%k%A%'%C%/;~$N%?%$%^F0:n$r8+D>$7!"%"%\!<%H$7$J$/$J$j$^$7$?!#(J + $@!&%a!<%k%A%'%C%/$N4V3V$reLdBj$J$$$@$1D9$/@_Dj$G$-$k$h$&$K$J$j$^$7$?!#(J + $@!&:FG[I[$K$D$$$F=q$-B-$7$^$7$?(J + + May 30th 1997 (pop-1.0) + $@!&$"$NL>:n(J oneko $@$,!"(Jpop $@$J(J oneko $@$K$J$j$^$7$?!#(J + $@1s$$$H$3$m$N%a!<%k$bD4$Y$F$-$^$9!#(J + $@LD$$$FCN$i$;$k$3$H$b$G$-$^$9!#(J + + + $@!c(Jpatch $@$NJ}K!!d(J + + 0. $@$3$N%U%!%$%k$K$U$/$^$l$F$$$k$b$N$r3NG'$7$F$/$@$5$$(J + README.pop ($@$3$N%U%!%$%k(J) + oneko-2.0b-pop1.1.patch ($@%Q%C%A%U%!%$%k(J) + oneko2.au ($@1w5H$NLD$-@<(J sun 8bit-law) + + 1. oneko $@$N%*%j%8%J%k%=!<%9$rE,Ev$J%G%#%l%/%H%j$KE83+$7$F$/$@$5$$!#(J + + 2. oneko $@$N8+$($k%G%#%l%/%H%j$G!"%Q%C%A$r$"$F$F$/$@$5$$!#(J + patch -p < oneko-2.0b-pop1.1.patch + + + + $@!c(Jmake $@$NJ}K!!d(J + + make $@$NJ}K!$O4pK\E*$K%*%j%8%J%k$HF1MM$G$9!#(J + $@%*%j%8%J%k$O(J SunOS4.x, FreeBSD $@Ey$GF0:n$9$k$h$&$K$J$C$F$^$9!#(J + + Imakefile $@$N(J DEFINES $@$K!"$r;XDj$7$^$9!#(J + $@$3$l$r;XDj$9$k$H!"(JPOP $@7PM3$G$N$_!"%a!<%k%A%'%C%/$r9T$$$^$9!#(J + $@;XDj$7$J$1$l$P!"%*%j%8%J%kF1MM%a!<%k%\%C%/%9%G%#%l%/%H%j$r%A%'%C%/$7$^$9!#(J + + Mailaction $@$K$O!"%a!<%kE~Ce;~$K5/F0$7$?$$%3%^%s%I$r;XDj$7$^$9!#(J + $@0z?t$,$"$k>l9g$G$b!"%j%F%i%k$G0O$`I,MW$O$"$j$^$;$s!#(J + # $@$H$f!<$+!"=q$/$HF0$-$^$;$s!#(J + + $@$3$l$i$O%G%U%)%k%H$N(J Oneko.ad $@$K$O4^$a$F$"$j$^$;$s!#(J + $@3F<+$N(J .Xdefaults $@Fb$G;XDj$9$k$+!"(J + $@%G%U%)%k%H$N%j%=!<%9%U%!%$%k$K=q$-B-$7$F$/$@$5$$!#(J + + $@;d$,(J Solaris2.4 $@>e$G;XDj$7$F$$$k$b$N$rNc$H$7$F5-=R$7$F$*$-$^$9!#(J + + Oneko*Popserver: pop.thinkfree.co.jp + Oneko*Mailaction: /usr/bin/audioplay -v30 /usr/local/lib/oneko/oneko2.au + + + $@%a!<%k%A%'%C%/$N4V3V$O%*%j%8%J%kF1MM(J Update $@%j%=!<%9$K@_Dj$7$^$9!#(J + POP $@7PM3$N>l9g!"%a!<%k%A%'%C%/$N$?$S$KG'>Z$r9T$&$?$a!"(J + $@%5!<%P!<$KIi2Y$,$+$+$j$d$9$/$J$j$^$9!#(J + + Oneko.Update: 180 + + $@$/$i$$$r;XDj$7$F$*$/$[$&$,NI$$$+$b$7$l$^$;$s!#(J + ($@!cG'<1$7$F$$$kLdBj!d$b;2>H$7$F$/$@$5$$(J) + + + POP $@%5!<%P!<$KBP$9$kG'>Z%f!<%6!<>pJs$O!"(J + $HOME/.netrc + $@$K5-=R$7$^$9!#(J + ftp $@Ey$G$b;HMQ$9$k%U%!%$%k$G$9!#(J + machine popserver login myname password mypassword + $@$N$h$&$K5-=R$7$^$9!#(J + account $@$H(J macdef $@%?%0$OL5;k$9$k$h$&$K$7$?$D$b$j$G$9$,!"3NG'$7$F$$$^$;$s!#(J + + $@$3$N%U%!%$%k$N%Q!<%_%C%7%g%s$O(J 0600 $@$G$J$1$l$P$J$j$^$;$s!#(J + + $@>\:Y$O(J man netrc $@$7$F$/$@$5$$!#(J + + + + POP $@%5!<%P!<$N%5!<%S%9%]!<%H$H$7$F!"(J"pop3" $@$^$?$O(J "pop" $@$rC5$7$^$9!#(J + $@L>A0$+$i%]!<%H$,0z$1$J$$>l9g!"%o!<%K%s%0$r=P$7%a!<%k%A%'%C%/$r$7$^$;$s!#(J + + + + $@!cG'<1$7$F$$$kLdBj!d(J + + Oneko.Update $@$NCM$O!"%*%j%8%J%k$G$O!"(J + 1800 $@$H$+$NCM$K$9$k$HFbIt$G$N7W;;;~$KJQ?t$N3JGo$KF0:n$9$k$h$&$K$7$^$7$?!#(J + 86400 $@IC(J (24$@;~4V(J) $@0J>e$K@_Dj$G$-$^$9$N$G!"eLdBj$J$$$O$:$G$9!#(J + $@$7$+$7!"%*%j%8%J%k$N%3!<%I$KBP$7$$$$2C8:$J$D$8$D$^9g$o$;$r$7$F$$$k$?$a!"(J + Oneko.Intervaltime + $@$NCM$r(J 1000$@%^%$%/%mIC0J2<$K$G$-$^$;$s!#(J + Oneko.Intervaltime > 1000 + $@$H$$$&@)8B$,?7$?$K2C$o$C$F$7$^$$$^$7$?!#(J + ($@e$NLdBj$K$O$J$i$J$$$H;W$C$F$^$9$,(J) + + $@%a!<%k%A%'%C%/;~!"%$%s%?!<%P%k%?%$%^$r;_$a$F$$$k$?$a!"(J + oneko $@$O$A$g$C$H$@$1;_$^$k$+$b$7$l$^$;$s!#(J + + .netrc $@$K$h$kG'>ZJ}K!$O!"9%$^$7$$$b$N$G$O$"$j$^$;$s!#(J + APOP $@$H$+$rA0$N8=:_(J 7$@:P$NG-$N@<$G$9!#(J + $@BgJQ$JFbJ[7DG-$J$N$G!"@<$@$1$G$b$$$m$$$m$J$H$3$m$rN99T$7$F$[$7$$$N$G$9!D(J + + $@$3$s$J%Q%C%A$G3Z$7$s$GD:$1$l$PK\K>$G$9!#(J + + + $@!c $@$K$O!"(J + $@G-$N3($N;HMQ$K$D$$$F=u8@$rD:$-$^$7$?!#(J + + xneko $@86:n$N8E>l$5$s(J $@$K$O!"(J + $@G-$NNr;K$K$D$$$F=u8@$rD:$-$^$7$?!#(J + + oneko $@86:n$N2CF#$5$s(J $@$O!"(J + oneko-2.0 $@%*%j%8%J%k$N:FG[I[$r2wBz$7$F$/$@$5$$$^$7$?!#(J + + $@;3ED(J $@BY;J$5$s(J $@$K$O!"(J + pop $@F0:n;~$N%5!<%P!<$X$N@\B3IT6q9g!"99?7%?%$%^IT6q9g$K$D$$$F=u8@$rD:$-!"(J + $@;n83$K6(NO$7$FD:$-$^$7$?!#(J + $@$"$j$,$H$&$4$6$$$^$7$?!#(J + + + $@!c:n$C$?$R$H!d(J + + $@:4!9LZ?-9,(J($@$5$5$-$N$V$f$-(J) + saaski@thinkfree.co.jp + nsasaki@da2.so-net.or.jp + HAG05226@niftyserve.or.jp + diff -Nrc oneko/action.c oneko-2.0b-pop/action.c *** oneko/action.c Thu Jan 1 09:00:00 1970 --- oneko-2.0b-pop/action.c Sun Jun 1 00:45:32 1997 *************** *** 0 **** --- 1,61 ---- + /* + * execute command when mail arrived + * + */ + #ifdef MAILACTION + #include + #include + #include + #include + #include + + + char *MailActionCmd = NULL; + + void sigchld_handler() + { + int stat; + + wait(&stat); + signal(SIGCHLD, sigchld_handler); + return; + } + + + void MailAction(void) + { + int pid; + char *argv[20]; + int argc = 0; + char buf[256]; + char *p; + + if ( MailActionCmd==NULL ) return; + + signal(SIGCHLD, sigchld_handler); + + if ( (pid=fork())<0 ) return; + else if ( pid>0 ) return; + + + strcpy(buf, MailActionCmd); + + argc = 0; + + for(p=strtok(buf, " \t"); p; p=strtok(NULL, " \t") ){ + argv[argc++] = p; + } + + if ( argc>0 ){ + argv[argc++] = NULL; + pid = execv(argv[0], argv); + if ( pid<0 ){ + fprintf(stderr,"%s: cannot exec\n", argv[0]); + } + } + + + exit(0); + } + + #endif diff -Nrc oneko/mail.c oneko-2.0b-pop/mail.c *** oneko/mail.c Wed Jun 9 18:24:14 1993 --- oneko-2.0b-pop/mail.c Wed Aug 6 18:01:01 1997 *************** *** 15,20 **** --- 15,30 ---- #include #include + #ifdef POP + #include + #include + #include + #include + #include + #include + #include + #endif + #include "oneko.h" #ifndef MAILBOX_DIRECTORY *************** *** 33,42 **** --- 43,67 ---- #endif /* i386 */ #endif /* MAILBOX_DIRECTORY */ + #ifdef POP + static int popClose(int); + static int popOpen(char *hostname); + static int popAuth(int s, char *user, char *pass); + static int popStat(int s); + static int popQuit(int s); + static int popNetrc(char *hostname, char *user, char *pass); + static int fgetw(char *buf, FILE *fp); + static int getServer(int fd, char *buf, int n); + static int putServer(int fd, char *buf); + #endif + long MailCount; long UpdateTime; Bool MailArrive = False; char *MailFile; + #ifdef POP + char *PopServer = NULL; + #endif void *************** *** 62,77 **** MailCheck() { struct stat file_stat; if (--MailCount > 0) { return; } ! MailCount = (int) ((UpdateTime * 1000000) / IntervalTime); ! if ((stat(MailFile, &file_stat) == 0) ! && (file_stat.st_size != 0)) { if (MailArrive == False) { ToyAppear(&Post, Post.x, Post.y); } MailArrive = True; --- 87,139 ---- MailCheck() { struct stat file_stat; + struct itimerval value; + if (--MailCount > 0) { return; } ! MailCount = (int) ( (UpdateTime*1000) / (IntervalTime/1000) ); ! ! /* clear interval timer */ ! timerclear(&value.it_interval); ! timerclear(&value.it_value); ! (void) setitimer(ITIMER_REAL, &value, (struct itimerval *) 0); ! #ifdef POP ! if ( (!PopServer) ! && (stat(MailFile, &file_stat) == 0) ! && (file_stat.st_size != 0) ){ ! if (MailArrive == False) { ! #ifdef MAILACTION ! MailAction(); ! #endif ! ToyAppear(&Post, Post.x, Post.y); ! } ! MailArrive = True; ! } ! else if ( PopServer && popMailCheck()>0 ){ ! if (MailArrive == False) { ! #ifdef MAILACTION ! MailAction(); ! #endif ! ToyAppear(&Post, Post.x, Post.y); ! } ! MailArrive = True; ! } ! else { ! if (MailArrive == True) { ! ToyDisappear(&Post); ! } ! MailArrive = False; ! } ! #else /* POP */ ! if ((stat(MailFile, &file_stat) == 0) && (file_stat.st_size != 0)) { if (MailArrive == False) { + #ifdef MAILACTION + MailAction(); + #endif ToyAppear(&Post, Post.x, Post.y); } MailArrive = True; *************** *** 82,85 **** --- 144,568 ---- } MailArrive = False; } + #endif /* POP */ + + + /* reset interval timer */ + value.it_interval.tv_usec = IntervalTime; + value.it_value.tv_usec = IntervalTime; + (void) setitimer(ITIMER_REAL, &value, (struct itimerval *) 0); + + } + + + #ifdef POP + int popMailCheck() + { + int s; + char user[64]; + char pass[64]; + int nmail = 0; + + if ( popNetrc(PopServer, user, pass)<0 ){ + return(0); + } + + if ( (s=popOpen(PopServer))<0 ){ + return(0); + } + + if ( popAuth(s, user, pass)<0 ){ + popQuit(s); + popClose(s); + return(0); + } + + nmail=popStat(s); + + popQuit(s); + popClose(s); + + return(nmail); + } + + static int popClose(s) + int s; + { + if ( s>=0 ){ + #ifdef POPDEBUG + fprintf(stderr, "popClose: closed(%d)\n", s); + fflush(stderr); + #endif + close(s); + } + return(0); + } + + static int popOpen(hostname) + char *hostname; + { + struct sockaddr_in addr; + struct servent *servent; + struct hostent *hostent; + long inaddr; + int s; + + if ( !hostname || !*hostname ){ + fprintf(stderr, "oneko: no POP server name\n"); + return(-1); + } + + /* POPサーバーのIPアドレスを得る */ + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + if ( isdigit(*hostname) ){ + if ( (inaddr=inet_addr(hostname))==(-1) ){ + fprintf(stderr, "oneko: %s: illegal address\n", + hostname); + return(-1); + } + memcpy(&addr.sin_addr, &inaddr, sizeof(inaddr)); + } + else { + extern int h_errno; + if ( !(hostent=gethostbyname(hostname)) ){ + fprintf(stderr, "oneko: %s: unknown host: err(%d)\n", + hostname, h_errno); + return(-1); + } + memcpy(&addr.sin_addr, hostent->h_addr, hostent->h_length); + addr.sin_family = hostent->h_addrtype; + } + + /* popのサービスポートはどこ? */ + if ( (servent=getservbyname("pop3", "tcp"))==NULL ){ + if ( (servent=getservbyname("pop", "tcp"))==NULL ){ + fprintf(stderr, "oneko: pop: unknown service.\n"); + return(-1); + } + } + addr.sin_port = servent->s_port; + + /* あける */ + if ( (s=socket(AF_INET, SOCK_STREAM, 0))<0 ){ + perror("socket"); + return(-1); + } + + /* つなぐ */ + if ( connect(s, (struct sockaddr *)&addr, sizeof(addr))<0 ){ + perror("connect"); + close(s); + return(-1); + } + + #ifdef POPDEBUG + fprintf(stderr, "popOpen: connected %s(%d)\n", hostname, s); + fflush(stdout); + #endif + return(s); + } + + static int popAuth(s, user, pass) + int s; + char *user, *pass; + { + char buf[256]; + + if ( getServer(s, buf, sizeof(buf))<0 ){ + return(-1); + } + #ifdef POPDEBUG + fprintf(stderr, "%s\n", buf); + fflush(stderr); + #endif + + sprintf(buf, "USER %s", user); + if ( putServer(s, buf)<0 ){ + return(-1); + } + if ( getServer(s, buf, sizeof(buf))<0 ){ + return(-1); + } + if ( strncmp(buf, "-ER", 3)==0 ){ + fprintf(stderr, "%s: unknown user\n", user); + return(-1); + } + + sprintf(buf, "PASS %s", pass); + if ( putServer(s, buf)<0 ){ + return(-1); + } + if ( getServer(s, buf, sizeof(buf))<0 ){ + return(-1); + } + if ( strncmp(buf, "-ER", 3)==0 ){ + fprintf(stderr, "%s: auth failed\n", user); + return(-1); + } + + return(0); + } + + static int popStat(s) + int s; + { + char buf[128]; + char *p; + + sprintf(buf, "STAT"); + if ( putServer(s, buf)<0 ){ + return(-1); + } + if ( getServer(s, buf, sizeof(buf))<0 ){ + return(-1); + } + if ( strncmp(buf, "-ER", 3)==0 ){ + return(-1); + } + + if ( (p=strtok(buf," \t\r\n"))==NULL ){ + return(-2); + } + if ( (p=strtok(NULL," \t\r\n"))==NULL ){ + return(-2); + } + + #ifdef POPDEBUG + fprintf(stderr, "popStat: %d mails\n", atoi(p)); + fflush(stderr); + #endif + + return(atoi(p)); + } + + static int popQuit(s) + int s; + { + char buf[128]; + char *p; + + sprintf(buf, "QUIT"); + if ( putServer(s, buf)<0 ){ + return(-1); + } + if ( getServer(s, buf, sizeof(buf))<0 ){ + return(-1); + } + if ( strncmp(buf, "-ER", 3)==0 ){ + return(-1); + } + + return(0); + } + + + static int popNetrc(hostname, user, pass) + char *hostname, *user, *pass; + { + struct stat file_stat; + FILE *fp; + char path[128]; + char mach[128]; + char defmach[128], defu[64], defp[64]; + char c; + char *env; + + if ( !hostname || !*hostname ){ + fprintf(stderr, "oneko: no POP server name\n"); + return(-1); + } + if ( (env = getenv("HOME"))==NULL ){ + fprintf(stderr, "oneko: cannot find HOME directory\n"); + return(-1); + } + + sprintf(path, "%s/.netrc", env); + if ( stat(path, &file_stat)<0 ){ + return(-1); + } + #ifdef POPDEBUG + fprintf(stderr, "popNetrc: %s: status(%08x)\n", + path, file_stat.st_mode); + #endif + if ( file_stat.st_mode & (S_IRWXG|S_IRWXO) ){ + fprintf(stderr, "oneko: authinfo: dangerous permission.\n"); + return(-1); + } + + if ( !(fp=fopen(path,"r")) ){ + perror(path); + return(-1); + } + + *user = *pass = *mach = '\0'; + *defu = *defp = '\0'; + + while( fgetw(path, fp) ){ + if ( strcmp("default", path)==0 ){ + *user = *pass = *mach = '\0'; + strcpy(mach, "_default"); + } + else if ( strcmp("machine", path)==0 ){ + *user = *pass = *mach = '\0'; + if ( !fgetw(path, fp) ){ + break; + } + if ( strcmp(hostname, path)==0 ){ + strcpy(mach, path); + } + } + else if ( strcmp("login", path)==0 ){ + if ( !fgetw(user, fp) ){ + break; + } + } + else if ( strcmp("password", path)==0 ){ + if ( !fgetw(pass, fp) ){ + break; + } + } + else if ( strcmp("account", path)==0 + ||strcmp("macdef", path)==0 ){ + if ( !fgetw(path, fp) ){ + break; + } + } + + if ( *user && *pass && *mach ){ + if ( strcmp(mach, "_default")==0 ){ + strcpy(defu, user); + strcpy(defp, pass); + *user = *pass = *mach = '\0'; + continue; + } + break; + } + } + fclose(fp); + + #ifdef POPDEBUG + fprintf(stderr, "popNetrc: mach[%s] u[%s] p[%s] du[%s] dp[%s]s\n", + mach, user, pass, defu, defp); + #endif + if ( *mach && *user && *pass ){ + return(0); + } + else if ( *defu && *defp ){ + strcpy(user, defu); + strcpy(pass, defp); + return(0); + } + + *user = *pass = *mach = '\0'; + + fprintf(stderr, "oneko: %s: cannot get authinfo\n", hostname); + return(-1); + } + + static int fgetw(buf, fp) + char *buf; + FILE *fp; + { + char c; + int inword = 0; + + while( (c=fgetc(fp))!=EOF ){ + if ( isspace(c) ){ + if ( inword ){ + break; + } + continue; + } + *buf = c; + buf++; + inword++; + } + *buf = '\0'; + return(inword); + } + + + static int getServer (fd, buf, n) + int fd; + char *buf; + int n; + { + char *p; + int len; + char c; + + p = buf; + while (1){ + len = read(fd, &c, 1); + if ( len<0 ){ + if ( errno==EINTR ) { + continue; + } + else { + perror("getServer"); + return(-1); + } + } + else if ( len==0 ){ + fprintf(stderr, "connection closed by foreign host\n"); + return(-1); + } + *p = c; + p++; + if ( c=='\n' ){ + break; + } + } + + *p = '\0'; + len = strlen(buf); + + if (*--p == '\n'){ + *p = '\0'; + } + if (*--p == '\r'){ + *p = '\0'; + } + + #ifdef POPDEBUG + fprintf(stderr, "getServer(%d): [%s]\n", len, buf); + fflush(stdout); + #endif + + return(len); + } + + + static int putServer (fd, buf) + int fd; + char *buf; + { + char command[128]; + int len; + + sprintf(command, "%s\r\n", buf); + + while ( (len=write(fd, command, strlen(command)))<0 ){ + if ( errno==EINTR ){ + continue; + } + else { + perror("putServer"); + return(-1); + } + } + + if (len == 0) { + fprintf(stderr, "connection closed by foreign host\n"); + return(-1); + } + + #ifdef POPDEBUG + fprintf(stderr, "putServer(%d): [%s]\n", len, buf); + fflush(stdout); + #endif + + return(len); } + #endif /* POP */ diff -Nrc oneko/oneko.h oneko-2.0b-pop/oneko.h *** oneko/oneko.h Tue Mar 17 23:09:38 1992 --- oneko-2.0b-pop/oneko.h Mon May 19 19:40:46 1997 *************** *** 95,100 **** --- 95,108 ---- extern Bool AutoRaise; /* auto raise */ extern char *Geometry; /* post geometry */ + #ifdef MAILACTION + extern char *MailActionCmd; /* mail action command */ + #endif + + #ifdef POP + extern char *PopServer; /* pop service hostname */ + #endif + extern Toy Toys[]; /* 0 := Post, 1 := Kotatsu */ extern Pixmap NekoSave; /* copy neko pixmap */ diff -Nrc oneko/patchlevel.h oneko-2.0b-pop/patchlevel.h *** oneko/patchlevel.h Tue Mar 17 23:09:45 1992 --- oneko-2.0b-pop/patchlevel.h Wed Aug 6 18:01:01 1997 *************** *** 1,4 **** /* $Id: patchlevel.h,v 1.9 1992/03/17 14:08:41 kato Exp kato $ */ #define VERSION 2 ! #define MINOR_VERSION "00 beta" #define PATCHLEVEL 5 --- 1,4 ---- /* $Id: patchlevel.h,v 1.9 1992/03/17 14:08:41 kato Exp kato $ */ #define VERSION 2 ! #define MINOR_VERSION "00 beta with pop1.1" #define PATCHLEVEL 5 diff -Nrc oneko/resource.c oneko-2.0b-pop/resource.c *** oneko/resource.c Tue Mar 17 23:09:52 1992 --- oneko-2.0b-pop/resource.c Fri May 30 19:12:19 1997 *************** *** 11,17 **** #include #include #include ! #ifndef SYSV #include #endif /* SYSV */ #include --- 11,17 ---- #include #include #include ! #if (!defined(SYSV) && !defined(SVR4)) #include #endif /* SYSV */ #include *************** *** 21,27 **** #include "oneko.h" #include "patchlevel.h" ! #ifdef SYSV #define rindex(a, b) strrchr(a, b) #endif /* SYSV */ --- 21,27 ---- #include "oneko.h" #include "patchlevel.h" ! #if (defined(SYSV) || defined(SVR4)) #define rindex(a, b) strrchr(a, b) #endif /* SYSV */ *************** *** 117,122 **** --- 117,128 ---- {"+autoraise", ".autoraise", XrmoptionNoArg, (caddr_t) "off"}, {"-file", ".file", XrmoptionSepArg, (caddr_t) NULL}, {"-geometry", ".post.geometry", XrmoptionSepArg, (caddr_t) NULL}, + #ifdef MAILACTION + {"-mailaction", ".mailaction", XrmoptionSepArg, (caddr_t) NULL}, + #endif + #ifdef POP + {"-popserver", ".popserver", XrmoptionSepArg, (caddr_t) NULL}, + #endif }; #define optionNum (sizeof optionRec / sizeof optionRec[0]) *************** *** 187,192 **** --- 193,204 ---- {"file", "File", type_string, NULL, (caddr_t *) &MailFile}, {"post.geometry", "Post.Geometry", type_string, GEOMETRY, (caddr_t *) &Geometry}, + #ifdef MAILACTION + {"mailaction", "Mailaction", type_string, NULL, (caddr_t *) &MailActionCmd}, + #endif + #ifdef POP + {"popserver", "Popserver", type_string, NULL, (caddr_t *) &PopServer}, + #endif }; #define NARGVARS (sizeof resourceValuses / sizeof resourceValuses[0])