static void HttpInspectCleanExit(int signal, void *data) { /* Cleanup */ KMapDelete(GlobalConf.server_lookup); xfree(GlobalConf.iis_unicode_map); }
int main( int argc, char ** argv ) { int i,n=10; KMAP * km; char * p; char str[80]; printf("usage: kmap nkeys (default=10)\n\n"); km = KMapNew( free ); /* use 'free' to free 'userdata' */ KMapSetNoCase(km,1); //need to add xlat.... if( argc > 1 ) { n = atoi(argv[1]); } for(i=1;i<=n;i++) { SnortSnprintf(str, sizeof(str), "KeyWord%d",i); KMapAdd( km, str, 0 /* strlen(str) */, strupr(strdup(str)) ); printf("Adding Key=%s\n",str); } printf("xmem: %u bytes, %d chars\n",xmalloc_bytes(),km->nchars); printf("\nKey Find test...\n"); for(i=1;i<=n;i++) { SnortSnprintf(str, sizeof(str), "KeyWord%d",i); p = (char*) KMapFind( km, str, 0 /*strlen(str) */ ); if(p)printf("key=%s, data=%*s\n",str,strlen(str),p); else printf("'%s' NOT found.\n",str); } KMapSetNoCase(km,0); // this should fail all key searches printf("\nKey Find test2...\n"); for(i=1;i<=n;i++) { SnortSnprintf(str, sizeof(str), "KeyWord%d",i); p = (char*) KMapFind( km, str, 0 /*strlen(str) */ ); if(p)printf("key=%s, data=%*s\n",str,strlen(str),p); else printf("'%s' NOT found.\n",str); } printf("\nKey FindFirst/Next test...\n"); for(p = (char*) KMapFindFirst(km); p; p=(char*)KMapFindNext(km) ) printf("data=%s\n",p); printf("\nKey FindFirst/Next test done.\n"); KMapDelete( km ); printf("xmem: %u bytes\n",xmalloc_bytes()); printf("normal pgm finish.\n"); return 0; }
/* * Function: ftp_bounce_lookup_cleanup(BOUNCE_LOOKUP **BounceLookup) * * Purpose: Free the bounce_lookup structure. * We need to free the bounce_lookup structure. * * Arguments: BounceLookup => pointer to the pointer of the bounce * lookup structure. * * Returns: int => return code indicating error or success * */ int ftp_bounce_lookup_cleanup(BOUNCE_LOOKUP **BounceLookup) { KMAP *km; if (BounceLookup == NULL) return FTPP_INVALID_ARG; km = *BounceLookup; if (km) { KMapDelete(km); *BounceLookup = NULL; } return FTPP_SUCCESS; }
/* * Function: ftp_cmd_lookup_cleanup(CMD_LOOKUP **CmdLookup) * * Purpose: Free the cmd_lookup structure. * We need to free the cmd_lookup structure. * * Arguments: CmdLookup => pointer to the pointer of the cmd * lookup structure. * * Returns: int => return code indicating error or success * */ int ftp_cmd_lookup_cleanup(CMD_LOOKUP **CmdLookup) { KMAP *km; if (CmdLookup == NULL) return FTPP_INVALID_ARG; km = *CmdLookup; if (km) { KMapDelete(km); *CmdLookup = NULL; } return FTPP_SUCCESS; }
/* * Function: http_cmd_lookup_cleanup(CMD_LOOKUP **CmdLookup) * * Purpose: Free the cmd_lookup structure. * We need to free the cmd_lookup structure. * * Arguments: CmdLookup => pointer to the pointer of the cmd * lookup structure. * * Returns: int => return code indicating error or success * */ int http_cmd_lookup_cleanup(CMD_LOOKUP **CmdLookup) { KMAP *km; if (CmdLookup == NULL) return -1; km = *CmdLookup; if (km) { KMapDelete(km); *CmdLookup = NULL; } return 0; }