Beispiel #1
0
static void inbuf_errmsg(void)
{
  if (ibuf_timedout(&inbuf))
    respond(421, 1, "Timed out waiting for command.");
  else if (!ibuf_eof(&inbuf))
    respond_syserr(421, "I/O error");
}
Beispiel #2
0
int main(int argc, char* argv[])
{
  set_timeout();
  if (!startup(argc, argv)) return 0;
  respond(NOTAG, "OK imapfront ready.");
  while (ibuf_getstr_crlf(&inbuf, &line)) {
    if (parse_line())
      dispatch_line();
  }
  if (ibuf_timedout(&inbuf))
    respond(NOTAG, "NO Connection timed out");
  return 0;
}
Beispiel #3
0
static int mainloop(const struct command* commands)
{
  if (!respond_line(220, 1, str_welcome.s, str_welcome.len)) return 0;
  while (ibuf_getstr_crlf(&inbuf, &line))
    if (!smtp_dispatch(commands)) {
      if (ibuf_eof(&inbuf))
	msg1("Connection dropped");
      if (ibuf_timedout(&inbuf))
	msg1("Timed out");
      return 1;
    }
  return 0;
}
Beispiel #4
0
/** Read a line from the \c ibuf into a dynamic string. */
int ibuf_getstr(ibuf* in, struct str* s, char boundary)
{
  iobuf* io;
  int ch;
  
  io = &in->io;
  in->count = 0;
  str_truncate(s, 0);
  if (ibuf_eof(in) || ibuf_error(in) || ibuf_timedout(in)) return 0;
  for (;;) {
    if (io->bufstart >= io->buflen && !ibuf_refill(in)) {
      if (ibuf_eof(in)) break;
      return 0;
    }
    in->count++;
    ch = io->buffer[io->bufstart++];
    if (!str_catc(s, ch)) return 0;
    if (ch == boundary) break;
  }
  return in->count > 0;
}