diff options
author | yaworsky <yaworsky> | 2005-09-16 08:33:41 +0000 |
---|---|---|
committer | yaworsky <yaworsky> | 2005-09-16 08:33:41 +0000 |
commit | a2c534419863b2c09fd122d8d1ef6769398f7cf0 (patch) | |
tree | c58907db78a04c9d4fae9999651e1a7293cf38f1 /test/dropcount.c | |
parent | 7875bee3ddfd14f2128540609519306742a78dec (diff) | |
download | syslog-win32-a2c534419863b2c09fd122d8d1ef6769398f7cf0.tar.gz syslog-win32-a2c534419863b2c09fd122d8d1ef6769398f7cf0.tar.xz syslog-win32-a2c534419863b2c09fd122d8d1ef6769398f7cf0.zip |
Added to repository.
Diffstat (limited to '')
-rw-r--r-- | test/dropcount.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/dropcount.c b/test/dropcount.c new file mode 100644 index 0000000..1345b73 --- /dev/null +++ b/test/dropcount.c @@ -0,0 +1,41 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int main( int argc, char* argv[] ) +{ + FILE *fd; + char buffer[ 256 ]; + int msg_index = 1, drop_count = 0; + + if( argc < 2 ) + { + puts( "required filename" ); + return 1; + } + + fd = fopen( argv[1], "r" ); + if( !fd ) + { + perror( "fopen" ); + return 1; + } + while( fgets( buffer, sizeof(buffer), fd ) ) + { + char *p; + int i; + + p = buffer + strlen( buffer ); + while( *p != ' ' ) p--; + i = strtoul( p, NULL, 10 ); + while( msg_index < i ) + { + msg_index++; + drop_count++; + } + msg_index++; + } + printf( "dropped %d message(s)\n", drop_count ); + fclose( fd ); + return 0; +} |