/[mailutils]/mailutils/pop3d/extra.c
ViewVC logotype

Diff of /mailutils/pop3d/extra.c

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

revision 1.19 by gray, Mon Jan 6 14:47:06 2003 UTC revision 1.20 by polak, Mon Jan 13 23:01:30 2003 UTC
# Line 19  Line 19 
19    
20  static FILE *ifile;  static FILE *ifile;
21  static FILE *ofile;  static FILE *ofile;
22    #ifdef WITH_TLS
23    static gnutls_session sfile;
24    #endif /* WITH_TLS */
25    
26  /* Takes a string as input and returns either the remainder of the string  /* Takes a string as input and returns either the remainder of the string
27     after the first space, or a zero length string if no space */     after the first space, or a zero length string if no space */
# Line 89  int Line 92  int
92  pop3d_abquit (int reason)  pop3d_abquit (int reason)
93  {  {
94    /* Unlock spool */    /* Unlock spool */
95    pop3d_unlock();    pop3d_unlock ();
96    mailbox_close (mbox);    mailbox_close (mbox);
97    mailbox_destroy (&mbox);    mailbox_destroy (&mbox);
98    
# Line 119  pop3d_abquit (int reason) Line 122  pop3d_abquit (int reason)
122    
123      case ERR_MBOX_SYNC:      case ERR_MBOX_SYNC:
124        syslog (LOG_ERR, _("Mailbox was updated by other party: %s"), username);        syslog (LOG_ERR, _("Mailbox was updated by other party: %s"), username);
125        pop3d_outf ("-ERR [OUT-SYNC] Mailbox updated by other party or corrupt\r\n");        pop3d_outf
126            ("-ERR [OUT-SYNC] Mailbox updated by other party or corrupt\r\n");
127        break;        break;
128    
129      default:      default:
# Line 128  pop3d_abquit (int reason) Line 132  pop3d_abquit (int reason)
132        break;        break;
133      }      }
134    
135    closelog();    closelog ();
136    exit (EXIT_FAILURE);    exit (EXIT_FAILURE);
137  }  }
138    
139  void  void
140  pop3d_setio (FILE *in, FILE *out)  pop3d_setio (FILE * in, FILE * out)
141  {  {
142    if (!in || !out)    if (!in || !out)
143      pop3d_abquit (ERR_NO_OFILE);      pop3d_abquit (ERR_NO_OFILE);
144    
145    ifile = in;    ifile = in;
146    ofile = out;    ofile = out;
147  }      }
148    
149    #ifdef WITH_TLS
150    
151    int
152    pop3d_init_tls_server ()
153    {
154      sfile =
155        (gnutls_session) mu_init_tls_server (fileno (ifile), fileno (ofile));
156      if (!sfile)
157        return 0;
158      return 1;
159    }
160    
161    void
162    pop3d_deinit_tls_server ()
163    {
164      mu_deinit_tls_server (sfile);
165    }
166    
167    #endif /* WITH_TLS */
168    
169  void  void
170  pop3d_flush_output ()  pop3d_flush_output ()
# Line 169  pop3d_outf (const char *fmt, ...) Line 193  pop3d_outf (const char *fmt, ...)
193            free (buf);            free (buf);
194          }          }
195      }      }
196    vfprintf (ofile, fmt, ap);  
197    #ifdef WITH_TLS
198      if (tls_done)
199        {
200          char *buf;
201          vasprintf (&buf, fmt, ap);
202          if (buf)
203            {
204              gnutls_record_send (sfile, buf, strlen (buf));
205              free (buf);
206            }
207        }
208      else
209    #endif /* WITH_TLS */
210        vfprintf (ofile, fmt, ap);
211    
212    va_end (ap);    va_end (ap);
213  }  }
214        
215    
216  /* Gets a line of input from the client, caller should free() */  /* Gets a line of input from the client, caller should free() */
217  char *  char *
# Line 181  pop3d_readline (char *buffer, size_t siz Line 220  pop3d_readline (char *buffer, size_t siz
220    char *ptr;    char *ptr;
221    
222    alarm (daemon_param.timeout);    alarm (daemon_param.timeout);
223    ptr = fgets (buffer, size, ifile);  #ifdef WITH_TLS
224      if (tls_done)
225        {
226          gnutls_record_recv (sfile, buffer, size - 1);
227          ptr = buffer;
228        }
229      else
230    #endif /* WITH_TLS */
231        ptr = fgets (buffer, size, ifile);
232    alarm (0);    alarm (0);
233    
234    /* We should probably check ferror() too, but if ptr is null we    /* We should probably check ferror() too, but if ptr is null we

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

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