From a2c534419863b2c09fd122d8d1ef6769398f7cf0 Mon Sep 17 00:00:00 2001 From: yaworsky Date: Fri, 16 Sep 2005 08:33:41 +0000 Subject: Added to repository. --- test/dropcount.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/dropcount.c (limited to 'test/dropcount.c') 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 +#include +#include + +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; +} -- cgit v1.2.3