From: Patrick M. <ume...@us...> - 2006-12-28 16:07:21
|
Update of /cvsroot/radmind/radmind In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv5822 Modified Files: connect.c connect.h Log Message: Added check_capability to generalize capability checking. Updated ZLIB code to use check_capability. Index: connect.h =================================================================== RCS file: /cvsroot/radmind/radmind/connect.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** connect.h 13 Oct 2006 20:20:20 -0000 1.13 --- connect.h 28 Dec 2006 16:07:18 -0000 1.14 *************** *** 26,27 **** --- 26,28 ---- int stor_response( SNET *sn, int *respcount, struct timeval * ); void v_logger( char *string); + int check_capability( char *type, char **capa ); Index: connect.c =================================================================== RCS file: /cvsroot/radmind/radmind/connect.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** connect.c 13 Oct 2006 20:20:20 -0000 1.28 --- connect.c 28 Dec 2006 16:07:17 -0000 1.29 *************** *** 208,212 **** negotiate_compression( SNET *sn, char **capa ) { - char **p; char *name = NULL; char *line; --- 208,211 ---- *************** *** 218,228 **** if ( zlib_level ) { /* walk through capabilities looking for "ZLIB" */ ! for( p = capa; *p; p++ ) { ! if( !strncasecmp( "ZLIB", *p, MIN( 4, strlen( *p )))) { ! name = "ZLIB"; ! type = SNET_ZLIB; ! level = zlib_level; ! } } if ( level == 0 ) { fprintf( stderr, "compression capability mismatch, " --- 217,226 ---- if ( zlib_level ) { /* walk through capabilities looking for "ZLIB" */ ! if ( check_capability( "ZLIB", capa ) == 1 ) { ! name = "ZLIB"; ! type = SNET_ZLIB; ! level = zlib_level; } + if ( level == 0 ) { fprintf( stderr, "compression capability mismatch, " *************** *** 294,295 **** --- 292,314 ---- } #endif /* HAVE_ZLIB */ + + /* + * check_capabilities: check to see if type is a listed capability + * + * return codes: + * 0: type not in capability list + * 1: type in capability list + */ + int + check_capability( char *type, char **capa ) + { + char **p; + + /* walk through capabilities looking for "REPO" */ + for ( p = capa; *p; p++ ) { + if ( !strncasecmp( type, *p, MIN( 4, strlen( *p )))) { + return( 1 ); + } + } + return( 0 ); + } |