Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / uip / RCS / popsbr.c,v
1 head    2.7;
2 access;
3 symbols;
4 locks
5         shettich:2.7; strict;
6 comment @ * @;
7
8
9 2.7
10 date    94.04.19.20.12.14;      author jromine; state Exp;
11 branches;
12 next    2.6;
13
14 2.6
15 date    93.08.26.18.25.52;      author jromine; state Exp;
16 branches;
17 next    2.5;
18
19 2.5
20 date    93.08.25.17.26.40;      author jromine; state Exp;
21 branches;
22 next    2.4;
23
24 2.4
25 date    92.11.24.18.32.32;      author jromine; state Exp;
26 branches;
27 next    2.3;
28
29 2.3
30 date    92.11.02.22.53.37;      author jromine; state Exp;
31 branches;
32 next    2.2;
33
34 2.2
35 date    92.10.26.16.48.22;      author jromine; state Exp;
36 branches;
37 next    2.1;
38
39 2.1
40 date    92.10.20.22.43.35;      author jromine; state Exp;
41 branches;
42 next    2.0;
43
44 2.0
45 date    92.10.20.15.56.14;      author jromine; state Exp;
46 branches;
47 next    1.11;
48
49 1.11
50 date    92.03.03.17.09.57;      author jromine; state Exp;
51 branches;
52 next    1.10;
53
54 1.10
55 date    92.02.11.17.40.13;      author jromine; state Exp;
56 branches;
57 next    1.9;
58
59 1.9
60 date    92.02.04.22.21.02;      author jromine; state Exp;
61 branches;
62 next    1.8;
63
64 1.8
65 date    92.02.04.21.45.44;      author jromine; state Exp;
66 branches;
67 next    1.7;
68
69 1.7
70 date    92.02.04.21.33.20;      author jromine; state Exp;
71 branches;
72 next    1.6;
73
74 1.6
75 date    92.01.31.22.04.36;      author jromine; state Exp;
76 branches;
77 next    1.5;
78
79 1.5
80 date    90.04.09.09.45.16;      author sources; state Exp;
81 branches;
82 next    1.4;
83
84 1.4
85 date    90.04.05.15.35.04;      author sources; state Exp;
86 branches;
87 next    1.3;
88
89 1.3
90 date    90.04.05.14.54.46;      author sources; state Exp;
91 branches;
92 next    1.2;
93
94 1.2
95 date    90.02.06.13.12.55;      author sources; state Exp;
96 branches;
97 next    1.1;
98
99 1.1
100 date    90.02.06.13.12.32;      author sources; state Exp;
101 branches;
102 next    ;
103
104
105 desc
106 @@
107
108
109 2.7
110 log
111 @add MODE IDENTIFY auth command
112 @
113 text
114 @/* popsbr.c - POP client subroutines */
115 #ifndef lint
116 static char ident[] = "@@(#)$Id: popsbr.c,v 2.6 1993/08/26 18:25:52 jromine Exp jromine $";
117 #endif  lint
118
119 #if defined(NNTP) && !defined(PSHSBR)
120 #undef  NNTP
121 #endif
122
123 /* LINTLIBRARY */
124
125 #include "../h/strings.h"
126 #ifdef NNTP                     /* building pshsbr.o from popsbr.c */
127 #include "../h/nntp.h"
128 #endif /* NNTP */
129 #include <stdio.h>
130 #include <signal.h>
131
132 #ifndef POPSERVICE
133 #define POPSERVICE      "pop"
134 #endif
135
136 #define NOTOK   (-1)
137 #define OK      0
138 #define DONE    1
139
140 #define TRM     "."
141 #define TRMLEN  (sizeof TRM - 1)
142
143 extern int  errno;
144 #ifndef BSD44
145 extern int  sys_nerr;
146 extern char *sys_errlist[];
147 #endif
148
149 static int  poprint = 0;
150 static int  pophack = 0;
151
152 char    response[BUFSIZ];
153
154 static FILE *input;
155 static FILE *output;
156
157 #ifdef __STDC__
158 static int  traverse (int (*)(), const char*, char *, char *, char *, char *);
159 #define targ_t  char *
160 #else
161 static int      traverse();
162 #define targ_t  int
163 #endif
164
165 #if !defined(NNTP) && defined(MPOP)
166 #define command pop_command
167 #define multiline pop_multiline
168 int     command(), multiline();
169 #else
170 static  int     command(), multiline();
171 #endif
172
173 static int      getline();
174 static putline();
175
176 #ifdef NNTP
177 #ifdef  BPOP    /* stupid */
178 static  int     xtnd_last = -1,
179                 xtnd_first = 0;
180 static char     xtnd_name[512]; /* INCREDIBLE HACK!! */
181 #endif
182 #endif /* NNTP */
183
184 /* \f */
185
186 #ifndef NNTP
187 #ifdef  APOP
188 #include "md5.c"
189
190 static char *pop_auth (user, pass)
191 char   *user,
192        *pass;
193 {
194     register char *cp,
195                   *lp;
196     register unsigned char *dp;
197     unsigned char *ep,
198                    digest[16];
199     MD5_CTX mdContext;
200     static char buffer[BUFSIZ];
201
202     if ((cp = index (response, '<')) == NULL
203             || (lp = index (cp, '>')) == NULL) {
204         (void) sprintf (buffer, "APOP not available: %s", response);
205         (void) strcpy (response, buffer);
206         return NULL;
207     }
208
209     *++lp = NULL;
210     (void) sprintf (buffer, "%s%s", cp, pass);
211
212     MD5Init (&mdContext);
213     MD5Update (&mdContext, (unsigned char *) buffer,
214                (unsigned int) strlen (buffer));
215     MD5Final (digest, &mdContext);
216
217     (void) sprintf (cp = buffer, "%s ", user);
218     cp += strlen (cp);
219     for (ep = (dp = digest) + sizeof digest / sizeof digest[0];
220              dp < ep;
221              cp += 2)
222         (void) sprintf (cp, "%02x", *dp++ & 0xff);
223     *cp = NULL;
224
225     return buffer;
226 }
227 #endif  /* APOP */
228 #endif  /* !NNTP */
229
230 /* \f */
231
232 #if defined(RPOP) || defined(APOP)
233 int     pop_init (host, user, pass, snoop, rpop)
234 int     rpop;
235 #else
236 int     pop_init (host, user, pass, snoop)
237 #endif
238 char   *host,
239        *user,
240        *pass;
241 int     snoop;
242 {
243 #ifdef  APOP
244     int     apop;
245 #else
246 #ifndef RPOP    /* !APOP && !RPOP */
247     int     rpop = 0;
248 #endif
249 #endif
250     int     fd1,
251             fd2;
252     char    buffer[BUFSIZ];
253
254 #ifdef  APOP
255     if ((apop = rpop) < 0)
256         rpop = 0;
257 #endif  /* APOP */
258
259 #ifndef NNTP
260 #ifndef KPOP
261     if ((fd1 = client (host, "tcp", POPSERVICE, rpop, response)) == NOTOK)
262 #else   /* KPOP */
263     (void) sprintf (buffer, "%s/%s", POPSERVICE, "kpop");
264     if ((fd1 = client (host, "tcp", buffer, rpop, response)) == NOTOK)
265 #endif
266 #else   /* NNTP */
267     if ((fd1 = client (host, "tcp", "nntp", rpop, response)) == NOTOK)
268 #endif
269         return NOTOK;
270
271     if ((fd2 = dup (fd1)) == NOTOK) {
272         (void) sprintf (response, "unable to dup connection descriptor: %s",
273                 errno > 0 && errno < sys_nerr ? sys_errlist[errno]
274                 : "unknown error");
275         (void) close (fd1);
276         return NOTOK;
277     }
278 #ifndef NNTP
279     if (pop_set (fd1, fd2, snoop) == NOTOK)
280 #else   /* NNTP */
281     if (pop_set (fd1, fd2, snoop, (char *)0) == NOTOK)
282 #endif  /* NNTP */
283         return NOTOK;
284
285     (void) signal (SIGPIPE, SIG_IGN);
286
287     switch (getline (response, sizeof response, input)) {
288         case OK: 
289             if (poprint)
290                 fprintf (stderr, "<--- %s\n", response);
291 #ifndef NNTP
292             if (*response == '+') {
293 #ifndef KPOP
294 #ifdef  APOP
295                 if (apop < 0) {
296                     char   *cp = pop_auth (user, pass);
297
298                     if (cp && command ("APOP %s", cp) != NOTOK)
299                         return OK;
300                 }
301                 else
302 #endif  /* apop */
303                 if (command ("USER %s", user) != NOTOK
304                     && command ("%s %s", rpop ? "RPOP" : (pophack++, "PASS"),
305                                         pass) != NOTOK)
306                 return OK;
307 #else   /* KPOP */
308                 if (command ("USER %s", user) != NOTOK
309                     && command ("PASS %s", pass) != NOTOK)
310                 return OK;
311 #endif
312             }
313 #else   /* NNTP */
314             if (*response < CHAR_ERR) {
315                 (void) command ("MODE READER");
316 #ifdef  NEWSAUTH
317                 if (getenv("NEWSAUTH")) /* special for IDENT protocol */
318                     command("MODE IDENTIFY");
319 #endif
320                 return OK;
321             }
322 #endif  /* NNTP */
323             (void) strcpy (buffer, response);
324             (void) command ("QUIT");
325             (void) strcpy (response, buffer);
326                                 /* and fall */
327
328         case NOTOK: 
329         case DONE: 
330             if (poprint)            
331                 fprintf (stderr, "%s\n", response);
332             (void) fclose (input);
333             (void) fclose (output);
334             return NOTOK;
335     }
336 /* NOTREACHED */
337 }
338 /* \f */
339
340 #ifndef NNTP
341 int     pop_set (in, out, snoop)
342 #else   /* NNTP */
343 int     pop_set (in, out, snoop, myname)
344 char   *myname;
345 #endif  /* NNTP */
346 int     in,
347         out,
348         snoop;
349 {
350 #ifdef NNTP
351     if (myname && *myname)
352         strcpy (xtnd_name, myname);     /* interface from bbc to msh */
353
354 #endif  /* NNTP */
355     if ((input = fdopen (in, "r")) == NULL
356             || (output = fdopen (out, "w")) == NULL) {
357         (void) strcpy (response, "fdopen failed on connection descriptor");
358         if (input)
359             (void) fclose (input);
360         else
361             (void) close (in);
362         (void) close (out);
363         return NOTOK;
364     }
365
366     poprint = snoop;
367
368     return OK;
369 }
370
371
372 int     pop_fd (in, out)
373 char   *in,
374        *out;
375 {
376     (void) sprintf (in, "%d", fileno (input));
377     (void) sprintf (out, "%d", fileno (output));
378     return OK;
379 }
380
381 /* \f */
382
383 int     pop_stat (nmsgs, nbytes)
384 int    *nmsgs,
385        *nbytes;
386 {
387 #ifdef NNTP
388     char **ap;
389     extern char **brkstring();
390 #endif  /* NNTP */
391
392 #ifndef NNTP
393     if (command ("STAT") == NOTOK)
394         return NOTOK;
395
396     *nmsgs = *nbytes = 0;
397     (void) sscanf (response, "+OK %d %d", nmsgs, nbytes);
398
399 #else   /* NNTP */
400     if (xtnd_last < 0) {        /* in msh, xtnd_name is set from myname */
401         if (command("GROUP %s", xtnd_name) == NOTOK)
402             return NOTOK;
403
404         ap = brkstring (response, " ", "\n"); /* "211 nart first last ggg" */
405         xtnd_first = atoi (ap[2]);
406         xtnd_last  = atoi (ap[3]);
407     }
408
409     /* nmsgs is not the real nart, but an incredible simuation */
410     if (xtnd_last > 0)
411         *nmsgs = xtnd_last - xtnd_first + 1;    /* because of holes... */
412     else
413         *nmsgs = 0;
414     *nbytes = xtnd_first;       /* for subtracting offset in msh() */
415 #endif  /* NNTP */
416
417     return OK;
418 }
419
420 #ifdef NNTP
421 int     pop_exists (action)
422 int     (*action) ();
423 {
424 #ifdef  XMSGS           /* hacked into NNTP 1.5 */
425     if (traverse (action, "XMSGS %d-%d",
426             (targ_t)xtnd_first, (targ_t)xtnd_last, 0, 0) == OK)
427         return OK;
428 #endif
429     if (traverse (action, "LISTGROUP",  /* provided by INN 1.4 */
430             0, 0, 0, 0) == OK)
431         return OK;
432     return traverse (action, "XHDR NONAME %d-%d",
433             (targ_t)xtnd_first, (targ_t)xtnd_last, 0, 0);
434 }
435 #endif  /* NNTP */
436
437 #ifndef BPOP
438 int     pop_list (msgno, nmsgs, msgs, bytes)
439 #else   BPOP
440 int     pop_list (msgno, nmsgs, msgs, bytes, ids)
441 int    *ids;
442 #endif  BPOP
443 int     msgno,
444        *nmsgs,
445        *msgs,
446        *bytes;
447 {
448     int     i;
449 #ifndef BPOP
450     int    *ids = NULL;
451 #endif
452
453     if (msgno) {
454 #ifndef NNTP
455         if (command ("LIST %d", msgno) == NOTOK)
456             return NOTOK;
457         *msgs = *bytes = 0;
458         if (ids) {
459             *ids = 0;
460             (void) sscanf (response, "+OK %d %d %d", msgs, bytes, ids);
461         }
462         else
463             (void) sscanf (response, "+OK %d %d", msgs, bytes);
464 #else   /* NNTP */
465         *msgs = *bytes = 0;
466         if (command ("STAT %d", msgno) == NOTOK) 
467             return NOTOK;
468         if (ids) {
469             *ids = msgno;
470         }
471 #endif  /* NNTP */
472         return OK;
473     }
474
475 #ifndef NNTP
476     if (command ("LIST") == NOTOK)
477         return NOTOK;
478
479     for (i = 0; i < *nmsgs; i++)
480         switch (multiline ()) {
481             case NOTOK: 
482                 return NOTOK;
483             case DONE: 
484                 *nmsgs = ++i;
485                 return OK;
486             case OK: 
487                 *msgs = *bytes = 0;
488                 if (ids) {
489                     *ids = 0;
490                     (void) sscanf (response, "%d %d %d",
491                             msgs++, bytes++, ids++);
492                 }
493                 else
494                     (void) sscanf (response, "%d %d", msgs++, bytes++);
495                 break;
496         }
497     for (;;)
498         switch (multiline ()) {
499             case NOTOK: 
500                 return NOTOK;
501             case DONE: 
502                 return OK;
503             case OK: 
504                 break;
505         }
506 #else   /* NNTP */
507     return NOTOK;
508 #endif  /* NNTP */
509 }
510
511 /* \f */
512
513 int     pop_retr (msgno, action)
514 int     msgno,
515         (*action) ();
516 {
517 #ifndef NNTP
518     return traverse (action, "RETR %d", (targ_t)msgno, 0, 0, 0);
519 #else   /* NNTP */
520     return traverse (action, "ARTICLE %d", (targ_t)msgno, 0, 0, 0);
521 #endif  /* NNTP */
522 }
523
524
525 /* VARARGS2 */
526
527 static int  traverse (action, fmt, a, b, c, d)
528 int     (*action) ();
529 #ifdef __STDC__
530 const char   *fmt;
531 #else
532 char *fmt;
533 #endif
534 char   *a,
535        *b,
536        *c,
537        *d;
538 {
539     char    buffer[sizeof response];
540
541     if (command (fmt, a, b, c, d) == NOTOK)
542         return NOTOK;
543     (void) strcpy (buffer, response);
544
545     for (;;)
546         switch (multiline ()) {
547             case NOTOK: 
548                 return NOTOK;
549
550             case DONE: 
551                 (void) strcpy (response, buffer);
552                 return OK;
553
554             case OK: 
555                 (*action) (response);
556                 break;
557         }
558 }
559
560 /* \f */
561
562 int     pop_dele (msgno)
563 int     msgno;
564 {
565     return command ("DELE %d", msgno);
566 }
567
568
569 int     pop_noop () {
570     return command ("NOOP");
571 }
572
573
574 #ifndef NNTP
575 #ifdef  MPOP
576 int     pop_last () {
577     return command ("LAST");
578 }
579 #endif  /* MPOP */
580 #endif  /* !NNTP */
581
582 int     pop_rset () {
583     return command ("RSET");
584 }
585
586 /* \f */
587
588 int     pop_top (msgno, lines, action)
589 int     msgno,
590         lines,
591         (*action) ();
592 {
593 #ifndef NNTP
594     return traverse (action, "TOP %d %d", (targ_t)msgno, (targ_t)lines, 0, 0);
595 #else   /* NNTP */
596     return traverse (action, "HEAD %d", (targ_t)msgno, 0, 0, 0);
597 #endif  /* NNTP */
598 }
599
600
601 #ifdef  BPOP
602 int     pop_xtnd (action, fmt, a, b, c, d)
603 int     (*action) ();
604 char   *fmt,
605        *a,
606        *b,
607        *c,
608        *d;
609 {
610     char buffer[BUFSIZ];
611 #ifdef NNTP
612     extern char **brkstring();
613     char  **ap;
614 #endif  /* NNTP */
615
616 #ifndef NNTP
617     (void) sprintf (buffer, "XTND %s", fmt);
618     return traverse (action, buffer, a, b, c, d);
619 #else   /* NNTP */
620     sprintf (buffer, fmt, a, b, c, d);
621     ap = brkstring (buffer, " ", "\n"); /* a hack, i know... */
622
623     if (uleq(ap[0], "x-bboards")) {     /* XTND "X-BBOARDS group */
624         /* most of these parameters are meaningless under NNTP. 
625          * bbc.c was modified to set AKA and LEADERS as appropriate,
626          * the rest are left blank.
627          */
628         return OK;
629     }
630     if (uleq (ap[0], "archive") && ap[1]) {
631         sprintf (xtnd_name, "%s", ap[1]);               /* save the name */
632         xtnd_last = 0;
633         xtnd_first = 1;         /* setup to fail in pop_stat */
634         return OK;
635     }
636     if (uleq (ap[0], "bboards")) {
637
638         if (ap[1]) {                    /* XTND "BBOARDS group" */
639             sprintf (xtnd_name, "%s", ap[1]);           /* save the name */
640             if (command("GROUP %s", xtnd_name) == NOTOK)
641                 return NOTOK;
642
643             strcpy (buffer, response);  /* action must ignore extra args */
644             ap = brkstring (response, " ", "\n");/* "211 nart first last g" */
645             xtnd_first = atoi (ap[2]);
646             xtnd_last  = atoi (ap[3]);
647
648             (*action) (buffer);         
649             return OK;
650
651         } else {                /* XTND "BBOARDS" */
652             return traverse (action, "LIST", a, b, c, d);
653         }
654     }
655     return NOTOK;       /* unknown XTND command */
656 #endif  /* NNTP */
657 }
658 #endif  BPOP
659
660 /* \f */
661
662 int     pop_quit () {
663     int     i;
664
665     i = command ("QUIT");
666     (void) pop_done ();
667
668     return i;
669 }
670
671
672 int     pop_done () {
673     (void) fclose (input);
674     (void) fclose (output);
675
676     return OK;
677 }
678
679 /* \f */
680
681 /* VARARGS1 */
682
683 #if defined(MPOP) && !defined(NNTP)
684 int     command (fmt, a, b, c, d)
685 #else
686 static int  command (fmt, a, b, c, d)
687 #endif
688 char   *fmt,
689        *a,
690        *b,
691        *c,
692        *d;
693 {
694     char   *cp,
695             buffer[BUFSIZ];
696
697     (void) sprintf (buffer, fmt, a, b, c, d);
698     if (poprint)
699         if (pophack) {
700             if (cp = index (buffer, ' '))
701                 *cp = 0;
702             fprintf (stderr, "---> %s ********\n", buffer);
703             if (cp)
704                 *cp = ' ';
705             pophack = 0;
706         }
707         else
708             fprintf (stderr, "---> %s\n", buffer);
709
710     if (putline (buffer, output) == NOTOK)
711         return NOTOK;
712
713     switch (getline (response, sizeof response, input)) {
714         case OK: 
715             if (poprint)
716                 fprintf (stderr, "<--- %s\n", response);
717 #ifndef NNTP
718             return (*response == '+' ? OK : NOTOK);
719 #else   /* NNTP */
720             return (*response < CHAR_ERR ? OK : NOTOK);
721 #endif  /* NNTP */
722
723         case NOTOK: 
724         case DONE: 
725             if (poprint)            
726                 fprintf (stderr, "%s\n", response);
727             return NOTOK;
728     }
729 /* NOTREACHED */
730 }
731
732 #if     defined(MPOP) && !defined(NNTP)
733 int  multiline () {
734 #else
735 static int  multiline () {
736 #endif
737     char    buffer[BUFSIZ + TRMLEN];
738
739     if (getline (buffer, sizeof buffer, input) != OK)
740         return NOTOK;
741 #ifdef  DEBUG
742     if (poprint)
743         fprintf (stderr, "<--- %s\n", response);
744 #endif  DEBUG
745     if (strncmp (buffer, TRM, TRMLEN) == 0) {
746         if (buffer[TRMLEN] == 0)
747             return DONE;
748         else
749             (void) strcpy (response, buffer + TRMLEN);
750     }
751     else
752         (void) strcpy (response, buffer);
753
754     return OK;
755 }
756
757 /* \f */
758
759 static int  getline (s, n, iop)
760 char   *s;
761 int     n;
762 FILE * iop;
763 {
764     int     c;
765     char   *p;
766
767     p = s;
768     while (--n > 0 && (c = fgetc (iop)) != EOF)
769         if ((*p++ = c) == '\n')
770             break;
771     if (ferror (iop) && c != EOF) {
772         (void) strcpy (response, "error on connection");
773         return NOTOK;
774     }
775     if (c == EOF && p == s) {
776         (void) strcpy (response, "connection closed by foreign host");
777         return DONE;
778     }
779     *p = 0;
780     if (*--p == '\n')
781         *p = 0;
782     if (*--p == '\r')
783         *p = 0;
784
785     return OK;
786 }
787
788
789 static  putline (s, iop)
790 char   *s;
791 FILE * iop;
792 {
793     (void) fprintf (iop, "%s\r\n", s);
794     (void) fflush (iop);
795     if (ferror (iop)) {
796         (void) strcpy (response, "lost connection");
797         return NOTOK;
798     }
799
800     return OK;
801 }
802 @
803
804
805 2.6
806 log
807 @update NNTP commands for INN.  Use "MODE READER" and "LISTGROUP".
808 @
809 text
810 @d3 1
811 a3 1
812 static char ident[] = "@@(#)$Id: popsbr.c,v 2.5 1993/08/25 17:26:40 jromine Exp jromine $";
813 d203 4
814 d209 1
815 a209 1
816 #endif
817 @
818
819
820 2.5
821 log
822 @off_t fixes for BSD44
823 @
824 text
825 @d3 1
826 a3 1
827 static char ident[] = "@@(#)$Id: popsbr.c,v 2.4 1992/11/24 18:32:32 jromine Exp jromine $";
828 d201 2
829 a202 1
830             if (*response < CHAR_ERR)
831 d204 1
832 d307 1
833 d310 4
834 @
835
836
837 2.4
838 log
839 @ansi sugar
840 @
841 text
842 @d3 1
843 a3 1
844 static char ident[] = "@@(#)$Id: popsbr.c,v 2.3 1992/11/02 22:53:37 jromine Exp jromine $";
845 d31 1
846 d34 1
847 @
848
849
850 2.3
851 log
852 @fixup APOP/MPOP
853 @
854 text
855 @d3 1
856 a3 1
857 static char ident[] = "@@(#)$Id: popsbr.c,v 2.2 1992/10/26 16:48:22 jromine Exp jromine $";
858 d44 1
859 d47 1
860 d303 2
861 a304 1
862     if (traverse (action, "XMSGS %d-%d", xtnd_first, xtnd_last) == OK)
863 d306 2
864 a307 1
865     return traverse (action, "XHDR NONAME %d-%d", xtnd_first, xtnd_last);
866 d392 1
867 a392 1
868     return traverse (action, "RETR %d", (char *)msgno, 0, 0, 0);
869 d394 1
870 a394 1
871     return traverse (action, "ARTICLE %d", (char *)msgno, 0, 0, 0);
872 d468 1
873 a468 1
874     return traverse (action, "TOP %d %d", (char *)msgno, (char *)lines, 0, 0);
875 d470 1
876 a470 1
877     return traverse (action, "HEAD %d", (char *)msgno, 0, 0, 0);
878 @
879
880
881 2.2
882 log
883 @MD5 API changes (from MTR)
884 @
885 text
886 @d3 1
887 a3 1
888 static char ident[] = "@@(#)$Id: popsbr.c,v 2.1 1992/10/20 22:43:35 jromine Exp jromine $";
889 d48 1
890 a48 1
891 #if !defined(NNTP) && defined(APOP)
892 d445 1
893 a445 1
894 #ifdef  APOP
895 d449 1
896 a449 1
897 #endif  /* APOP */
898 d553 1
899 a553 1
900 #if defined(APOP) && !defined(NNTP)
901 d602 1
902 a602 1
903 #if     defined(APOP) && !defined(NNTP)
904 @
905
906
907 2.1
908 log
909 @NNTP/APOP fixes
910 @
911 text
912 @d3 1
913 a3 1
914 static char ident[] = "@@(#)$Id: popsbr.c,v 2.0 1992/10/20 15:56:14 jromine Exp jromine $";
915 d80 2
916 a81 1
917     unsigned char *ep;
918 d98 1
919 a98 1
920     MD5Final (&mdContext);
921 d102 1
922 a102 2
923     for (ep = (dp = mdContext.digest)
924                         + sizeof mdContext.digest / sizeof mdContext.digest[0];
925 @
926
927
928 2.0
929 log
930 @merge NNTP/APOP/KPOP changes
931 @
932 text
933 @d3 1
934 a3 1
935 static char ident[] = "@@(#)$Id: pshsbr.c,v 2.2 1990/04/05 14:56:13 sources Exp $";
936 d69 1
937 d111 1
938 d127 1
939 a127 1
940     int     apop,
941 d444 1
942 d450 1
943 d553 3
944 a555 1
945 #ifndef APOP
946 d557 1
947 a557 3
948 #else   /* APOP */
949 int     command (fmt, a, b, c, d)
950 #endif  /* APOP */
951 d602 3
952 a604 1
953 #ifndef APOP
954 d606 1
955 a606 3
956 #else   /* APOP */
957 int  multiline () {
958 #endif  /* APOP */
959 @
960
961
962 1.11
963 log
964 @fixes from mtr
965 @
966 text
967 @d3 1
968 a3 1
969 static char ident[] = "@@(#)$Id: popsbr.c,v 1.10 1992/02/11 17:40:13 jromine Exp jromine $";
970 d6 4
971 d13 3
972 a41 3
973 #define command pop_command
974 #define multiline pop_multiline
975
976 d48 8
977 d59 8
978 d109 1
979 a109 1
980 #endif
981 d113 1
982 d115 4
983 d122 1
984 a122 2
985 int     snoop,
986         rpop;
987 d124 1
988 d126 6
989 a131 1
990             fd1,
991 a132 3
992 #ifdef  notdef  /* KPOP */
993     int     kpop = 0;
994 #endif
995 d135 1
996 a135 4
997 #ifdef  notdef
998     if ((kpop = rpop) != 2)             /* 2 => KPOP */
999         rpop = 0;
1000 #endif
1001 d138 6
1002 a143 2
1003 #ifdef KPOP             /* contact a KERBEROS kpop server */
1004     /* should test kpop flag */
1005 d146 4
1006 a150 4
1007 #else
1008     if ((fd1 = client (host, "tcp", POPSERVICE, rpop, response)) == NOTOK)
1009         return NOTOK;
1010 #endif
1011 d159 1
1012 d161 3
1013 d172 1
1014 d174 1
1015 d183 9
1016 d193 4
1017 a196 6
1018                     if (command ("USER %s", user) != NOTOK
1019 #ifndef KPOP
1020                             && command ("%s %s",
1021                                     rpop ? "RPOP" : (pophack++, "PASS"),
1022 #else
1023                             && command ("PASS %s",
1024 a197 3
1025                                         pass) != NOTOK)
1026                         return OK;
1027             }
1028 d201 1
1029 a201 1
1030             /* and fall */
1031 a212 1
1032
1033 d215 1
1034 d217 4
1035 d225 5
1036 d262 6
1037 d273 19
1038 d295 9
1039 d322 1
1040 a324 1
1041
1042 d332 8
1043 d343 1
1044 d374 3
1045 d385 1
1046 d387 3
1047 d442 1
1048 d446 1
1049 a447 1
1050
1051 d459 1
1052 d461 3
1053 d477 4
1054 d482 1
1055 d485 38
1056 d549 3
1057 d553 1
1058 d583 1
1059 d585 3
1060 d598 3
1061 d602 1
1062 d607 4
1063 @
1064
1065
1066 1.10
1067 log
1068 @accomodate KPOP cleanup in client.c
1069 @
1070 text
1071 @d3 1
1072 a3 1
1073 static char ident[] = "@@(#)$Id: popsbr.c,v 1.9 1992/02/04 22:21:02 jromine Exp $";
1074 a102 3
1075 #ifndef RPOP
1076     int     rpop = 0;
1077 #endif  RPOP
1078 @
1079
1080
1081 1.9
1082 log
1083 @fix decls
1084 @
1085 text
1086 @d3 1
1087 a3 1
1088 static char ident[] = "@@(#)$Id: popsbr.c,v 1.8 1992/02/04 21:45:44 jromine Exp jromine $";
1089 d106 3
1090 d111 4
1091 d117 4
1092 a120 2
1093 #ifdef KPOP
1094     if ((fd1 = kclient (host, "tcp", POPSERVICE, rpop, response)) == NOTOK)
1095 @
1096
1097
1098 1.8
1099 log
1100 @contributed patch
1101 @
1102 text
1103 @d3 1
1104 a3 1
1105 static char ident[] = "@@(#)$Id: popsbr.c,v 1.7 1992/02/04 21:33:20 jromine Exp jromine $";
1106 d44 1
1107 a44 1
1108 static int      command(), multiline(), getline();
1109 @
1110
1111
1112 1.7
1113 log
1114 @contributed patch
1115 @
1116 text
1117 @d3 1
1118 a3 1
1119 static char ident[] = "@@(#)$Id: popsbr.c,v 1.6 1992/01/31 22:04:36 jromine Exp jromine $";
1120 d56 2
1121 a57 2
1122     long    clock;
1123     register char *cp;
1124 d63 6
1125 a68 4
1126     (void) time (&clock);
1127     (void) sprintf (cp = buffer, "%s %ld ", user, clock);
1128     cp += strlen (cp);
1129     (void) strcpy (cp, pass);
1130 d70 3
1131 d74 2
1132 a75 1
1133     MD5Update (&mdContext, buffer, strlen (buffer));
1134 d78 2
1135 d137 3
1136 a139 1
1137                     if (command ("APOP %s", pop_auth (user, pass)) != NOTOK)
1138 @
1139
1140
1141 1.6
1142 log
1143 @kerberos
1144 @
1145 text
1146 @d3 1
1147 a3 1
1148 static char ident[] = "@@(#)$Id: popsbr.c,v 1.5 90/04/09 09:45:16 sources Exp Locker: sources $";
1149 d35 3
1150 d43 1
1151 d46 1
1152 d49 36
1153 a84 3
1154 #ifndef RPOP
1155 int     pop_init (host, user, pass, snoop)
1156 #else   RPOP
1157 a85 2
1158 int     rpop;
1159 #endif  RPOP
1160 d89 2
1161 a90 1
1162 int     snoop;
1163 d92 2
1164 a93 1
1165     int     fd1,
1166 d100 2
1167 d126 9
1168 a134 2
1169             if (*response == '+'
1170                 && command ("USER %s", user) != NOTOK
1171 d136 2
1172 a137 1
1173                 && command ("%s %s", rpop ? "RPOP" : (pophack++, "PASS"),
1174 d139 1
1175 a139 1
1176                 && command ("PASS %s",
1177 d142 6
1178 a147 6
1179                 return OK;
1180             if (*response != '+') {
1181                 (void) strcpy (buffer, response);
1182                 (void) command ("QUIT");
1183                 (void) strcpy (response, buffer);
1184             }                   /* fall */
1185 d329 5
1186 d388 1
1187 a388 1
1188 static int  command (fmt, a, b, c, d)
1189 d429 1
1190 a429 1
1191 static int  multiline () {
1192 @
1193
1194
1195 1.5
1196 log
1197 @POPSERVICE define
1198 @
1199 text
1200 @d3 1
1201 a3 1
1202 static char ident[] = "@@(#)$Id: popsbr.c,v 1.4 90/04/05 15:35:04 sources Exp Locker: sources $";
1203 d35 6
1204 a40 1
1205 static int      traverse(), command(), multiline(), getline();
1206 d62 4
1207 d68 1
1208 d87 6
1209 a92 2
1210                     && command ("USER %s", user) != NOTOK
1211                     && command ("%s %s", rpop ? "RPOP" : (pophack++, "PASS"),
1212 d174 1
1213 a174 1
1214 #endif  not BPOP
1215 d228 1
1216 a228 1
1217     return traverse (action, "RETR %d", msgno);
1218 d236 6
1219 a241 2
1220 char   *fmt,
1221        *a,
1222 d292 1
1223 a292 1
1224     return traverse (action, "TOP %d %d", msgno, lines);
1225 d349 1
1226 a349 1
1227                 *cp = NULL;
1228 d382 1
1229 a382 1
1230         if (buffer[TRMLEN] == NULL)
1231 d415 1
1232 a415 1
1233     *p = NULL;
1234 d417 1
1235 a417 1
1236         *p = NULL;
1237 d419 1
1238 a419 1
1239         *p = NULL;
1240 @
1241
1242
1243 1.4
1244 log
1245 @add ID
1246 @
1247 text
1248 @d3 1
1249 a3 1
1250 static char ident[] = "@@(#)$Id:$";
1251 d12 3
1252 d57 1
1253 a57 1
1254     if ((fd1 = client (host, "tcp", "pop", rpop, response)) == NOTOK)
1255 @
1256
1257
1258 1.3
1259 log
1260 @add ID
1261 @
1262 text
1263 @d3 1
1264 a3 1
1265 static char ident[] = "@@(#)$Id:";
1266 @
1267
1268
1269 1.2
1270 log
1271 @ANSI Compilance
1272 @
1273 text
1274 @d2 3
1275 @
1276
1277
1278 1.1
1279 log
1280 @Initial revision
1281 @
1282 text
1283 @d29 2
1284 @