/[mailutils]/mailutils/mailbox/pop/mbox.c
ViewVC logotype

Diff of /mailutils/mailbox/pop/mbox.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.76 by polak, Mon May 19 18:46:33 2003 UTC revision 1.77 by gray, Thu Aug 28 19:42:13 2003 UTC
# Line 54  Line 54 
54  #include <mailutils/property.h>  #include <mailutils/property.h>
55  #include <mailutils/stream.h>  #include <mailutils/stream.h>
56  #include <mailutils/url.h>  #include <mailutils/url.h>
57    #include <mailutils/tls.h>
58    
59  #include <folder0.h>  #include <folder0.h>
60  #include <mailbox0.h>  #include <mailbox0.h>
# Line 127  int _pop_apop            __P ((authority Line 128  int _pop_apop            __P ((authority
128  static int pop_get_size        __P ((mailbox_t, off_t *));  static int pop_get_size        __P ((mailbox_t, off_t *));
129  /* We use pop_top for retreiving headers.  */  /* We use pop_top for retreiving headers.  */
130  /* static int pop_header_read (header_t, char *, size_t, off_t, size_t *); */  /* static int pop_header_read (header_t, char *, size_t, off_t, size_t *); */
131  static int pop_body_fd         __P ((stream_t, int *));  static int pop_body_fd         __P ((stream_t, int *, int *));
132  static int pop_body_size       __P ((body_t, size_t *));  static int pop_body_size       __P ((body_t, size_t *));
133  static int pop_body_lines      __P ((body_t, size_t *));  static int pop_body_lines      __P ((body_t, size_t *));
134  static int pop_body_read       __P ((stream_t, char *, size_t, off_t, size_t *));  static int pop_body_read       __P ((stream_t, char *, size_t, off_t, size_t *));
135  static int pop_message_read    __P ((stream_t, char *, size_t, off_t, size_t *));  static int pop_message_read    __P ((stream_t, char *, size_t, off_t, size_t *));
136  static int pop_message_size    __P ((message_t, size_t *));  static int pop_message_size    __P ((message_t, size_t *));
137  static int pop_message_fd      __P ((stream_t, int *));  static int pop_message_fd      __P ((stream_t, int *, int *));
138  static int pop_top             __P ((header_t, char *, size_t, off_t, size_t *));  static int pop_top             __P ((header_t, char *, size_t, off_t, size_t *));
139  static int pop_retr            __P ((pop_message_t, char *, size_t, off_t, size_t *));  static int pop_retr            __P ((pop_message_t, char *, size_t, off_t, size_t *));
140  static int pop_get_fd          __P ((pop_message_t, int *));  static int pop_get_fd          __P ((pop_message_t, int *));
# Line 554  _pop_apop (authority_t auth) Line 555  _pop_apop (authority_t auth)
555    return 0;    return 0;
556  }  }
557    
558    static
559    int
560    tls (mailbox_t mbox)
561    {
562    #ifdef WITH_TLS
563      pop_data_t mpd = mbox->data;
564      int status;
565      stream_t str;
566      
567      if (!mu_tls_enable || !(mpd->capa & CAPA_STLS))
568        return -1;
569      
570      status = pop_writeline (mpd, "STLS\r\n");
571      CHECK_ERROR (mpd, status);
572      status = pop_write (mpd);
573      CHECK_EAGAIN (mpd, status);
574      status = pop_read_ack (mpd);
575      CHECK_ERROR (mpd, status);
576      MAILBOX_DEBUG0 (mbox, MU_DEBUG_PROT, mpd->buffer);
577      if (strncasecmp (mpd->buffer, "+OK", 3) != 0)
578        return -1;
579    
580      status = tls_stream_create_client_from_tcp (&str, mbox->stream, 0);
581      CHECK_ERROR (mpd, status);
582      status = stream_open (str);
583      if (status == 0)
584        mbox->stream = str;
585      MAILBOX_DEBUG1 (mbox, MU_DEBUG_PROT, "TLS negotiation %s\n",
586                      status == 0 ? "succeeded" : "failed");
587      return status;
588    #else
589      return -1;
590    #endif  
591    }
592    
593  /* Open the connection to the sever, and send the authentication. */  /* Open the connection to the sever, and send the authentication. */
594  static int  static int
# Line 697  pop_open (mailbox_t mbox, int flags) Line 732  pop_open (mailbox_t mbox, int flags)
732    
733      case POP_STLS:      case POP_STLS:
734      case POP_STLS_ACK:      case POP_STLS_ACK:
735          tls (mbox);
736        mpd->state = POP_AUTH;        mpd->state = POP_AUTH;
737    
738      case POP_AUTH:      case POP_AUTH:
# Line 1344  pop_unset_attribute (attribute_t attr, i Line 1379  pop_unset_attribute (attribute_t attr, i
1379    
1380  /* Stub to call the fd from body object.  */  /* Stub to call the fd from body object.  */
1381  static int  static int
1382  pop_body_fd (stream_t stream, int *pfd)  pop_body_fd (stream_t stream, int *pfd, int *pfd1)
1383  {  {
1384    body_t body = stream_get_owner (stream);    if (pfd1)
1385    message_t msg = body_get_owner (body);      return ENOSYS;
1386    pop_message_t mpm = message_get_owner (msg);    else
1387    return pop_get_fd (mpm, pfd);      {
1388          body_t body = stream_get_owner (stream);
1389          message_t msg = body_get_owner (body);
1390          pop_message_t mpm = message_get_owner (msg);
1391          return pop_get_fd (mpm, pfd);
1392        }
1393  }  }
1394    
1395  /* Stub to call the fd from message object.  */  /* Stub to call the fd from message object.  */
1396  static int  static int
1397  pop_message_fd (stream_t stream, int *pfd)  pop_message_fd (stream_t stream, int *pfd, int *pfd2)
1398  {  {
1399    message_t msg = stream_get_owner (stream);    if (pfd2)
1400    pop_message_t mpm = message_get_owner (msg);      return ENOSYS;
1401    return pop_get_fd (mpm, pfd);    else
1402        {
1403          message_t msg = stream_get_owner (stream);
1404          pop_message_t mpm = message_get_owner (msg);
1405          return pop_get_fd (mpm, pfd);
1406        }
1407  }  }
1408    
1409  /* Finally return the fd.  */  /* Finally return the fd.  */

Legend:
Removed from v.1.76  
changed lines
  Added in v.1.77

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26