diff options
author | Yunchih Chen <yunchih.cat@gmail.com> | 2018-03-18 11:06:48 +0800 |
---|---|---|
committer | Yunchih Chen <yunchih.cat@gmail.com> | 2018-03-18 11:06:48 +0800 |
commit | ffd1cc10279ffc4bfe0ff6e37484e5a13e64f619 (patch) | |
tree | 466b3e81e672a4746a8cfba3864d8d5e8a296b02 /lib | |
parent | c0aea9485cb3a6450e15ae471376d72b0af5b340 (diff) | |
download | nfcollect-ffd1cc10279ffc4bfe0ff6e37484e5a13e64f619.tar nfcollect-ffd1cc10279ffc4bfe0ff6e37484e5a13e64f619.tar.gz nfcollect-ffd1cc10279ffc4bfe0ff6e37484e5a13e64f619.tar.bz2 nfcollect-ffd1cc10279ffc4bfe0ff6e37484e5a13e64f619.tar.lz nfcollect-ffd1cc10279ffc4bfe0ff6e37484e5a13e64f619.tar.xz nfcollect-ffd1cc10279ffc4bfe0ff6e37484e5a13e64f619.tar.zst nfcollect-ffd1cc10279ffc4bfe0ff6e37484e5a13e64f619.zip |
Add utility function to calculate filesize
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/common.c b/lib/common.c index bf0b67a..d4e9363 100644 --- a/lib/common.c +++ b/lib/common.c @@ -58,6 +58,15 @@ const char *nfl_get_filename(const char *dir, int id) { return strdup(out); } +uint32_t nfl_get_filesize(FILE *f) { + uint32_t size, prepos; + prepos = ftell(f); + fseek(f, 0, SEEK_END); + size = ftell(f); + fseek(f, prepos, SEEK_SET); + return size; +} + uint32_t nfl_header_cksum(nflog_header_t *header) { register uint64_t s = 3784672181; s += header->id; |