library/src/network/httpd/BP-HTTPdSessions.cc
// searches a httpd for an api key (hash table search, very fast)
searches a httpd for an api key (hash table search, very fast)
searches a httpd for an api key ( hash table search very fast )
P_BP_HTTPD_API_KEY BP_HTTPdSessionLookupAPIKeyByIdentifier
(
	P_BP_HTTPD_SESSION httpd,
	char * key_identifier
)
{
	if(!httpd)
		return NULL;
	if(!key_identifier)
		return NULL;
	if(!BP_StringIsReasonablePrintableString(key_identifier, bpstrlen(key_identifier), BP_FALSE, BP_FALSE))
		return NULL;
	BP_HTTPD_ENTER_CRITICAL_SECTION;
	char * lookup_path[]
	{
		"api_keys",
		key_identifier,
		NULL
	};
	P_BP_HASH_TABLE_KEYED_ENTRY api_key_entry = BP_HashRegLookupTableEntryByPath(httpd->system_hreg, (char **) &lookup_path);
	if(!api_key_entry)
		BP_HTTPD_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(NULL);
	P_BP_HTTPD_API_KEY api_key = (P_BP_HTTPD_API_KEY) api_key_entry->data;
	if(!api_key)
		BP_HTTPD_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(NULL);
	BP_HTTPD_LEAVE_CRITICAL_SECTION;
	return api_key;
}
P_BP_HTTPD_API_KEY BP_HTTPdSessionLookupAPIKeyByIdentifier ( P_BP_HTTPD_SESSION httpd , char * key_identifier ) { if ( ! httpd ) return NULL ; if ( ! key_identifier ) return NULL ; if ( ! BP_StringIsReasonablePrintableString ( key_identifier , bpstrlen ( key_identifier ) , BP_FALSE , BP_FALSE ) ) return NULL ; BP_HTTPD_ENTER_CRITICAL_SECTION ; char * lookup_path [ ] { " " , key_identifier , NULL } ; P_BP_HASH_TABLE_KEYED_ENTRY api_key_entry = BP_HashRegLookupTableEntryByPath ( httpd -> system_hreg , ( char * * ) & lookup_path ) ; if ( ! api_key_entry ) BP_HTTPD_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( NULL ) ; P_BP_HTTPD_API_KEY api_key = ( P_BP_HTTPD_API_KEY ) api_key_entry -> data ; if ( ! api_key ) BP_HTTPD_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( NULL ) ; BP_HTTPD_LEAVE_CRITICAL_SECTION ; return api_key ; }
searches a httpd for an api key (hash table search, very fast)
searches a httpd for an api key ( hash table search very fast )
// ensure we have a httpd and a key identifier // ensure the identifier is reasonable // enter critical section // set lookup path // attempt to lookup api key // set api key from data // leave critical section // return looked up key