dsniff  2.4b2
About: A collection of tools for network auditing
  Fossies Dox: dsniff-2.4b2.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

decode_imap.c
Go to the documentation of this file.
1 /*
2  * decode_imap.c
3  *
4  * Internet Mail Access Protocol.
5  *
6  * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
7  *
8  * $Id: decode_imap.c,v 1.5 2001/03/15 08:33:00 dugsong Exp $
9  */
10 
11 #include "config.h"
12 
13 #include <sys/types.h>
14 
15 #include <stdio.h>
16 #include <string.h>
17 
18 #include "decode.h"
19 #include "buf.h"
20 
21 int
22 decode_imap(u_char *buf, int len, u_char *obuf, int olen)
23 {
24  struct buf *line, inbuf, outbuf;
25  int i;
26 
27  buf_init(&inbuf, buf, len);
28  buf_init(&outbuf, obuf, olen);
29 
30  while ((i = buf_index(&inbuf, "\r\n", 2)) != -1) {
31  line = buf_tok(&inbuf, NULL, i);
32  buf_skip(&inbuf, 2);
33 
34  if ((i = buf_index(line, " ", 1)) != -1) {
35  buf_skip(line, i + 1);
36 
37  if (buf_cmp(line, "LOGIN ", 6) == 0) {
38  buf_putf(&outbuf, "%.*s\n",
40  }
41  }
42  }
43  buf_end(&outbuf);
44 
45  return (buf_len(&outbuf));
46 }
buf_putf
int buf_putf(buf_t buf, const char *fmt,...)
Definition: buf.c:106
buf_init
void buf_init(buf_t buf, u_char *data, int len)
Definition: buf.c:24
decode_imap
int decode_imap(u_char *buf, int len, u_char *obuf, int olen)
Definition: decode_imap.c:22
buf_end
void buf_end(buf_t buf)
Definition: buf.c:121
decode.h
buf.h
buf
Definition: buf.h:14
buf_tok
buf_t buf_tok(buf_t buf, void *sep, int len)
Definition: buf.c:167
buf_ptr
#define buf_ptr(b)
Definition: buf.h:31
line
Definition: sshow.c:62
buf_cmp
int buf_cmp(buf_t buf, void *ptr, int len)
Definition: buf.c:158
buf_skip
#define buf_skip(b, l)
Definition: buf.h:47
config.h
obuf
static char obuf[4096]
Definition: trigger.c:43
buf_len
#define buf_len(b)
Definition: buf.h:34
buf_index
int buf_index(buf_t buf, void *ptr, int len)
Definition: buf.c:128