version 1.0.0.-a - significat iptables parsing speed improvement
[svn/Prometheus-QoS/.git] / utils.c
CommitLineData
dccb3227 1#include <string.h>
2#include <stdlib.h>
3430e838 3#include <stdio.h>
dccb3227 4#include <sys/types.h>
5#include <sys/stat.h>
6
7/* http://stackoverflow.com/questions/4021479/getting-file-modification-time-on-unix-using-utime-in-c */
8time_t get_mtime(const char *path)
9{
10 struct stat statbuf;
11 if (stat(path, &statbuf) == -1)
12 {
13 perror(path);
14 exit(1);
15 }
16 return statbuf.st_mtime;
17}
18
19/* just text line parsing */
20char *parse_datafile_line(char *str)
21{
22 char *ptr = strchr(str,' ');
23 if(!ptr)
24 {
25 ptr = strchr(str,'\t');
26 }
27
28 if(ptr)
29 {
30 *ptr = 0;
31 ptr++;
32 while(*ptr == ' ' || *ptr == '\t')
33 {
34 ptr++;
35 }
36 return ptr;
37 }
38 else
39 {
40 return NULL;
41 }
42}
This page took 0.185481 seconds and 4 git commands to generate.