library/src/network/httpd/BP-HTTPdRequests.cc
// Attempts to lookup an argument from the argument registry
Attempts to lookup an argument from the argument registry
Attempts to lookup an argument from the argument registry
P_BP_HTTPD_REQUEST_VAR BP_HTTPdRequestVarArgRegistryLookup
(
		P_BP_HTTPD_REQUEST             request,
		BP_HTTPD_REQUEST_VAR_TYPE      type,
		char *                         name
)
{
	if(!request)
		return NULL;
	if(!request->arg_hreg)
		return NULL;
	if(!name)
		return NULL;
	if(!BP_StringIsReasonablePrintableString(name, bpstrlen(name), BP_FALSE, BP_FALSE))
		return NULL;
	char * var_table = NULL;
	switch(type)
	{
		case BP_HTTPD_REQUEST_VAR_TYPE_POST_DATA:
			var_table = "POST";
			break;
		case BP_HTTPD_REQUEST_VAR_TYPE_POST_TMPFILE:
			var_table = "POST";
			break;
		case BP_HTTPD_REQUEST_VAR_TYPE_HEADER:
			var_table = "HEADER";
			break;
		case BP_HTTPD_REQUEST_VAR_TYPE_GET:
			var_table = "GET";
			break;
		case BP_HTTPD_REQUEST_VAR_TYPE_COOKIE:
			var_table = "COOKIE";
			break;
		default:
			return NULL;
	}
	if(!var_table)
		return NULL;
	char * table_path[10] = {0};
	P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = NULL;
	table_path[0] = var_table;
	table_path[1] = name;
	table_path[2] = NULL;
	BP_HASH_TABLE_ENTER_CRITICAL_SECTION(request->arg_hreg);
	tmp_lookup = BP_HashRegLookupTableEntryByPath(request->arg_hreg, table_path);
	if(!tmp_lookup)
		BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(request->arg_hreg, NULL);
	if(!tmp_lookup->data)
		BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(request->arg_hreg, NULL);
	P_BP_HTTPD_REQUEST_VAR retval = (P_BP_HTTPD_REQUEST_VAR) tmp_lookup->data;
	BP_HASH_TABLE_LEAVE_CRITICAL_SECTION(request->arg_hreg);
	return retval;
}
P_BP_HTTPD_REQUEST_VAR BP_HTTPdRequestVarArgRegistryLookup ( P_BP_HTTPD_REQUEST request , BP_HTTPD_REQUEST_VAR_TYPE type , char * name ) { if ( ! request ) return NULL ; if ( ! request -> arg_hreg ) return NULL ; if ( ! name ) return NULL ; if ( ! BP_StringIsReasonablePrintableString ( name , bpstrlen ( name ) , BP_FALSE , BP_FALSE ) ) return NULL ; char * var_table = NULL ; switch ( type ) { case BP_HTTPD_REQUEST_VAR_TYPE_POST_DATA : var_table = " " ; break ; case BP_HTTPD_REQUEST_VAR_TYPE_POST_TMPFILE : var_table = " " ; break ; case BP_HTTPD_REQUEST_VAR_TYPE_HEADER : var_table = " " ; break ; case BP_HTTPD_REQUEST_VAR_TYPE_GET : var_table = " " ; break ; case BP_HTTPD_REQUEST_VAR_TYPE_COOKIE : var_table = " " ; break ; default : return NULL ; } if ( ! var_table ) return NULL ; char * table_path [ 10 ] = { 0 } ; P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = NULL ; table_path [ 0 ] = var_table ; table_path [ 1 ] = name ; table_path [ 2 ] = NULL ; BP_HASH_TABLE_ENTER_CRITICAL_SECTION ( request -> arg_hreg ) ; tmp_lookup = BP_HashRegLookupTableEntryByPath ( request -> arg_hreg , table_path ) ; if ( ! tmp_lookup ) BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( request -> arg_hreg , NULL ) ; if ( ! tmp_lookup -> data ) BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( request -> arg_hreg , NULL ) ; P_BP_HTTPD_REQUEST_VAR retval = ( P_BP_HTTPD_REQUEST_VAR ) tmp_lookup -> data ; BP_HASH_TABLE_LEAVE_CRITICAL_SECTION ( request -> arg_hreg ) ; return retval ; }
Attempts to lookup an argument from the argument registry
Attempts to lookup an argument from the argument registry
// ensure we have a request and a registry // variable table selected // switch on the type // http post tables // header table // http get table // cookie table // exit immediately if we have a type mismatch // ensure we have a table selected // declare dynamic table path // declare the lookup pointer // set initial path // enter critical section for the argument registry // attempt lookup // ensure we have a lookup // ensure there is data to return // set the return val // leave the critical section for the argument registry // return the value