File: utils.c

package info (click to toggle)
ipgrab 0.8.2-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 540 kB
  • ctags: 555
  • sloc: ansic: 4,608; sh: 1,507; makefile: 120
file content (54 lines) | stat: -rw-r--r-- 1,094 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**************************************************************************** 
** File: utils.c
**
** Author: Mike Borella
**
** Comments: Misc ipgrab utilities
**
*****************************************************************************/

#include <stdio.h>
#include "config.h"

/*----------------------------------------------------------------------------
**
** get_next_line()
**
** Grab the next line terminated by a <CR><LF>
**
** ptr - points to the beginning of the section of the packet to parse
** ep  - points to the last char of the packet
** line - we put the line in here
**
**----------------------------------------------------------------------------
*/

int get_next_line(u_char *ptr, u_char *ep, char *line)
{
  int cnt = 0;

  while (*ptr != '\r' && ptr != ep)
    {
      line[cnt] = *ptr;
      cnt ++;
      ptr ++;

      /*
       * Make sure we don't run off the end of the packet
       */

      if (ptr == ep)
	{
	  line[cnt] = '\0';
	  return cnt-1;
	}
      
    }
  line[cnt] = '\0';
  cnt = cnt + 2;
  if (cnt == 2)
    return 0;
  else 
    return cnt;

}