library/src/network/httpd/BP-HTTPdSessions.cc
// Attempts to lookup request handler within the table.
Attempts to lookup request handler within the table.
Attempts to lookup request handler within the table .
P_BP_HTTPD_USER_SESSION BP_HTTPdSessionLookup
(
		P_BP_HTTPD_SESSION httpd,
		char *             session_id
)
{
	if(!httpd)
		return NULL;
	if(!httpd->system_hreg)
		return NULL;
	char * table_path[10] = {0};
	P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = NULL;
	if(!session_id)
		return NULL;
	if(BP_StringIsReasonablePrintableString(session_id, bpstrlen(session_id), BP_FALSE, BP_FALSE) != BP_TRUE)
		return NULL;
	BP_HASH_TABLE_ENTER_CRITICAL_SECTION(httpd->system_hreg);
	P_BP_HASH_TABLE_KEYED_ENTRY lookup_entry = NULL;
	table_path[0] = "sessions";
	table_path[1] = session_id;
	table_path[2] = NULL;
	lookup_entry = BP_HashRegLookupTableEntryByPath(httpd->system_hreg, table_path);
	if(!lookup_entry)
	{
		BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(httpd->system_hreg, NULL);
	}
	P_BP_HTTPD_USER_SESSION session = (P_BP_HTTPD_USER_SESSION) lookup_entry->data;
	%%%%%
	%%%%%
	BP_HASH_TABLE_LEAVE_CRITICAL_SECTION(httpd->system_hreg);
	return session;
}
P_BP_HTTPD_USER_SESSION BP_HTTPdSessionLookup ( P_BP_HTTPD_SESSION httpd , char * session_id ) { if ( ! httpd ) return NULL ; if ( ! httpd -> system_hreg ) return NULL ; char * table_path [ 10 ] = { 0 } ; P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = NULL ; if ( ! session_id ) return NULL ; if ( BP_StringIsReasonablePrintableString ( session_id , bpstrlen ( session_id ) , BP_FALSE , BP_FALSE ) != BP_TRUE ) return NULL ; BP_HASH_TABLE_ENTER_CRITICAL_SECTION ( httpd -> system_hreg ) ; P_BP_HASH_TABLE_KEYED_ENTRY lookup_entry = NULL ; table_path [ 0 ] = " " ; table_path [ 1 ] = session_id ; table_path [ 2 ] = NULL ; lookup_entry = BP_HashRegLookupTableEntryByPath ( httpd -> system_hreg , table_path ) ; if ( ! lookup_entry ) { BP_HASH_TABLE_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( httpd -> system_hreg , NULL ) ; } P_BP_HTTPD_USER_SESSION session = ( P_BP_HTTPD_USER_SESSION ) lookup_entry -> data ; BP_HASH_TABLE_LEAVE_CRITICAL_SECTION ( httpd -> system_hreg ) ; return session ; }
Attempts to lookup request handler within the table.
Attempts to lookup request handler within the table .
// ensure we have a session structure and a registry to work with // declare dynamic table path // declare the lookup pointer // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Run Sanity Checks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Ensure we have a handler // check sanity on non-optional values // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Check if User Exists %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // enter critical section before making changes to the httpd hash // table registry. // declare the lookup entry // set the table path for lookup // attempt to get entry // ensure we can lookup the new entry // set session from lookup // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Unlock and Exit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // leave critical section before exiting // return null if the record cannot be found