library/src/network/httpd/BP-HTTPdRequests.cc
// REQUEST REGISTRY: This function is called when a new request is added. It ensures
// that the request registry has request specific tables created.
REQUEST REGISTRY: This function is called when a new request is added. It ensures
that the request registry has request specific tables created.
REQUEST REGISTRY : This function is called when a new request is added . It ensures that the request registry has request specific tables created .
BP_ERROR_T BP_HTTPdCreateInitialRequestArgumentHashRegistryLayout(P_BP_HTTPD_REQUEST request)
{
	if(!request)
		return ERR_FAILURE;
	if(!request->arg_hreg)
		return ERR_FAILURE;
	char * table_path[10] = {0};
	P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = NULL;
	BP_HASH_TABLE_ENTER_CRITICAL_SECTION(request->arg_hreg);
	char * initial_tables[] =
	{
			"POST",
			"GET",
			"COOKIE",
			"HEADER",
			NULL
	};
	size_t n = 0;
	for(; initial_tables[n]; n++)
	{
		table_path[0] = initial_tables[n];
		table_path[1] = NULL;
		tmp_lookup = BP_HashRegLookupTableByPath(request->arg_hreg, table_path);
		if(tmp_lookup)
			break;
		BP_HashRegAddTableByPath(request->arg_hreg, table_path);
		tmp_lookup = BP_HashRegLookupTableByPath(request->arg_hreg, table_path);
		if(!tmp_lookup)
			break;
	}
	BP_HASH_TABLE_LEAVE_CRITICAL_SECTION(request->arg_hreg);
	return ERR_SUCCESS;
}
BP_ERROR_T BP_HTTPdCreateInitialRequestArgumentHashRegistryLayout ( P_BP_HTTPD_REQUEST request ) { if ( ! request ) return ERR_FAILURE ; if ( ! request -> arg_hreg ) return ERR_FAILURE ; char * table_path [ 10 ] = { 0 } ; P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = NULL ; BP_HASH_TABLE_ENTER_CRITICAL_SECTION ( request -> arg_hreg ) ; char * initial_tables [ ] = { " " , " " , " " , " " , NULL } ; size_t n = 0 ; for ( ; initial_tables [ n ] ; n ++ ) { table_path [ 0 ] = initial_tables [ n ] ; table_path [ 1 ] = NULL ; tmp_lookup = BP_HashRegLookupTableByPath ( request -> arg_hreg , table_path ) ; if ( tmp_lookup ) break ; BP_HashRegAddTableByPath ( request -> arg_hreg , table_path ) ; tmp_lookup = BP_HashRegLookupTableByPath ( request -> arg_hreg , table_path ) ; if ( ! tmp_lookup ) break ; } BP_HASH_TABLE_LEAVE_CRITICAL_SECTION ( request -> arg_hreg ) ; return ERR_SUCCESS ; }
REQUEST REGISTRY: This function is called when a new request is added.
REQUEST REGISTRY : This function is called when a new request is added .
// ensure we have a request // ensure we have an argument registry // declare dynamic table path // declare the lookup pointer // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Create Basic Argument Hash Registry Layout %%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // enter critical section before making changes to the httpd hash // table registry. // initial tables to create // attempt to loop and create all required initial paths // set the path // attempt to lookup the table in the table // add the table // check for tmp lookup again after addition // exit if we added things ok, if not return failure immediately // leave critical section before exiting // return indicating success