X-Git-Url: http://git.harvie.cz/?p=svn%2FPrometheus-QoS%2F.git;a=blobdiff_plain;f=utils.c;fp=utils.c;h=09ae9f9ff5e405f966e1e957d2ffb75b166851d6;hp=0000000000000000000000000000000000000000;hb=dccb32271f7c04bfcfa0fd44ffff02a0f1b628de;hpb=3856be6ab5f6ada6c64a059a61da74d65122592e diff --git a/utils.c b/utils.c new file mode 100644 index 0000000..09ae9f9 --- /dev/null +++ b/utils.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include + +/* http://stackoverflow.com/questions/4021479/getting-file-modification-time-on-unix-using-utime-in-c */ +time_t get_mtime(const char *path) +{ + struct stat statbuf; + if (stat(path, &statbuf) == -1) + { + perror(path); + exit(1); + } + return statbuf.st_mtime; +} + +/* just text line parsing */ +char *parse_datafile_line(char *str) +{ + char *ptr = strchr(str,' '); + if(!ptr) + { + ptr = strchr(str,'\t'); + } + + if(ptr) + { + *ptr = 0; + ptr++; + while(*ptr == ' ' || *ptr == '\t') + { + ptr++; + } + return ptr; + } + else + { + return NULL; + } +}