/* * Function: ftpp_ui_client_lookup_next(CLIENT_LOOKUP *ClientLookup, * int *iError) * * Iterates to the next configuration, like a list it just returns * the next config in the config list. * * Purpose: This lookups the next client configuration, so we can * iterate through the configurations. * * Arguments: ClientLookup => pointer to the client lookup structure * iError => pointer to the integer to set for errors * * Returns: FTP_CLIENT_PROTO_CONF* => Pointer to next client configuration * structure * */ FTP_CLIENT_PROTO_CONF *ftpp_ui_client_lookup_next(CLIENT_LOOKUP *ClientLookup, int *iError) { FTP_CLIENT_PROTO_CONF *ClientConf; if(!iError) { return NULL; } if(!ClientLookup) { *iError = FTPP_INVALID_ARG; return NULL; } *iError = FTPP_SUCCESS; ClientConf = (FTP_CLIENT_PROTO_CONF *)KMapFindNext(ClientLookup); if (!ClientConf) { *iError = FTPP_NOT_FOUND; } return ClientConf; }
/** ** Iterates to the next configuration, like a list it just returns ** the next config in the config list. ** ** @param ServerLookup pointer to the server lookup structure ** @param iError pointer to the integer to set for errors ** ** @return integer ** ** @retval HI_INVALID_ARG invalid argument ** @retval HI_NOT_FOUND configuration not found (no first config) ** @retval HI_SUCCESS function successful */ HTTPINSPECT_CONF *hi_ui_server_lookup_next(SERVER_LOOKUP *ServerLookup, int *iError) { HTTPINSPECT_CONF *ServerConf; if(!iError) { return NULL; } if(!ServerLookup) { *iError = HI_INVALID_ARG; return NULL; } *iError = HI_SUCCESS; ServerConf = (HTTPINSPECT_CONF *)KMapFindNext(ServerLookup); if (!ServerConf) { *iError = HI_NOT_FOUND; } return ServerConf; }
/* * Function: ftp_bounce_lookup_next(BOUNCE_LOOKUP *BounceLookup, * int *iError) * * Iterates to the next configuration, like a list it just returns * the next config in the config list. * * Purpose: This lookups the next bounce configuration, so we can * iterate through the configurations. * * Arguments: BounceLookup => pointer to the bounce lookup structure * iError => pointer to the integer to set for errors * * Returns: FTP_BOUNCE_TO* => Pointer to next bounce configuration structure * */ FTP_BOUNCE_TO *ftp_bounce_lookup_next(BOUNCE_LOOKUP *BounceLookup, int *iError) { FTP_BOUNCE_TO *BounceTo; if(!iError) { return NULL; } if(!BounceLookup) { *iError = FTPP_INVALID_ARG; return NULL; } *iError = FTPP_SUCCESS; BounceTo = (FTP_BOUNCE_TO *)KMapFindNext(BounceLookup); if (!BounceTo) { *iError = FTPP_NOT_FOUND; } return BounceTo; }
/* * Function: ftp_cmd_lookup_next(CMD_LOOKUP *CmdLookup, * int *iError) * * Iterates to the next configuration, like a list it just returns * the next config in the config list. * * Purpose: This lookups the next cmd configuration, so we can * iterate through the configurations. * * Arguments: CmdLookup => pointer to the cmd lookup structure * iError => pointer to the integer to set for errors * * Returns: FTP_CMD_CONF* => Pointer to next cmd configuration structure * */ FTP_CMD_CONF *ftp_cmd_lookup_next(CMD_LOOKUP *CmdLookup, int *iError) { FTP_CMD_CONF *FTPCmd; if(!iError) { return NULL; } if(!CmdLookup) { *iError = FTPP_INVALID_ARG; return NULL; } *iError = FTPP_SUCCESS; FTPCmd = (FTP_CMD_CONF *)KMapFindNext(CmdLookup); if (!FTPCmd) { *iError = FTPP_NOT_FOUND; } return FTPCmd; }
/* * Function: http_cmd_lookup_next(CMD_LOOKUP *CmdLookup, * int *iError) * * Iterates to the next configuration, like a list it just returns * the next config in the config list. * * Purpose: This lookups the next cmd configuration, so we can * iterate through the configurations. * * Arguments: CmdLookup => pointer to the cmd lookup structure * iError => pointer to the integer to set for errors * * Returns: HTTP_CMD_CONF* => Pointer to next cmd configuration structure * */ HTTP_CMD_CONF *http_cmd_lookup_next(CMD_LOOKUP *CmdLookup, int *iError) { HTTP_CMD_CONF *HTTPCmd; if(!iError) { return NULL; } if(!CmdLookup) { *iError = -1; return NULL; } *iError = 0; HTTPCmd = (HTTP_CMD_CONF *)KMapFindNext(CmdLookup); if (!HTTPCmd) { *iError = -1; } return HTTPCmd; }
/* * Function: ftpp_ui_server_lookup_next(SERVER_LOOKUP *ServerLookup, * int *iError) * * Iterates to the next configuration, like a list it just returns * the next config in the config list. * * Purpose: This lookups the next server configuration, so we can * iterate through the configurations. * * Arguments: ServerLookup => pointer to the server lookup structure * iError => pointer to the integer to set for errors * * Returns: FTP_SERVER_PROTO_CONF* => Pointer to next server configuration * structure * */ FTP_SERVER_PROTO_CONF *ftpp_ui_server_lookup_next(SERVER_LOOKUP *ServerLookup, int *iError) { FTP_SERVER_PROTO_CONF *ServerConf; if(!iError) { return NULL; } if(!ServerLookup) { *iError = FTPP_INVALID_ARG; return NULL; } *iError = FTPP_SUCCESS; ServerConf = (FTP_SERVER_PROTO_CONF *)KMapFindNext(ServerLookup); if (!ServerConf) { *iError = FTPP_NOT_FOUND; } return ServerConf; }
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; }