library/src/webchat/BP-WebChat.cc
// Create a event manager.  It will be automatically added in the ght under the provided session name.
Create a event manager.  It will be automatically added in the ght under the provided session name.
Create a event manager . It will be automatically added in the ght under the provided session name .
P_BP_WEBCHAT BP_WebChatCreateSession
(
	P_BP_EVENT_MANAGER evm,
	char              *session_name
)
{
	if(!evm)
		return NULL;
	if(!session_name)
		return NULL;
	P_BP_HASH_TABLE_REGISTRY system_hreg = BP_CreateHashTableRegistry();
	if(!system_hreg)
		return NULL;
	P_BP_WEBCHAT webchat = (P_BP_WEBCHAT) ht_calloc(system_hreg, sizeof(BP_WEBCHAT), 1);
	if(!webchat)
		return NULL;
	webchat->system_hreg = system_hreg;
	if(!BP_WebChatInitCommandRegistry(webchat))
	{
		BP_WebChatDestroySession(webchat);
		return NULL;
	}
	char *table_path[10];
	BP_ZERO_STACK(table_path);
	table_path[0] = "users";
	BP_HashRegAddTableByPath(webchat->system_hreg, (char **) &table_path);
	table_path[0] = "users";
	table_path[1] = "hashed_by_httpd_username";
	BP_HashRegAddTableByPath(webchat->system_hreg, (char **) &table_path);
	table_path[0] = "users";
	table_path[1] = "hashed_by_webchat_username";
	BP_HashRegAddTableByPath(webchat->system_hreg, (char **) &table_path);
	BP_ZERO_STACK(table_path);
	table_path[0] = "classifications";
	BP_HashRegAddTableByPath(webchat->system_hreg, (char **) &table_path);
	table_path[0] = "system";
	BP_HashRegAddTableByPath(webchat->system_hreg, (char **) &table_path);
	table_path[0] = "channels";
	BP_HashRegAddTableByPath(webchat->system_hreg, (char **) &table_path);
	table_path[0] = "references";
	BP_HashRegAddTableByPath(webchat->system_hreg, (char **) &table_path);
	return webchat;
}
P_BP_WEBCHAT BP_WebChatCreateSession ( P_BP_EVENT_MANAGER evm , char * session_name ) { if ( ! evm ) return NULL ; if ( ! session_name ) return NULL ; P_BP_HASH_TABLE_REGISTRY system_hreg = BP_CreateHashTableRegistry ( ) ; if ( ! system_hreg ) return NULL ; P_BP_WEBCHAT webchat = ( P_BP_WEBCHAT ) ht_calloc ( system_hreg , sizeof ( BP_WEBCHAT ) , 1 ) ; if ( ! webchat ) return NULL ; webchat -> system_hreg = system_hreg ; if ( ! BP_WebChatInitCommandRegistry ( webchat ) ) { BP_WebChatDestroySession ( webchat ) ; return NULL ; } char * table_path [ 10 ] ; BP_ZERO_STACK ( table_path ) ; table_path [ 0 ] = " " ; BP_HashRegAddTableByPath ( webchat -> system_hreg , ( char * * ) & table_path ) ; table_path [ 0 ] = " " ; table_path [ 1 ] = " " ; BP_HashRegAddTableByPath ( webchat -> system_hreg , ( char * * ) & table_path ) ; table_path [ 0 ] = " " ; table_path [ 1 ] = " " ; BP_HashRegAddTableByPath ( webchat -> system_hreg , ( char * * ) & table_path ) ; BP_ZERO_STACK ( table_path ) ; table_path [ 0 ] = " " ; BP_HashRegAddTableByPath ( webchat -> system_hreg , ( char * * ) & table_path ) ; table_path [ 0 ] = " " ; BP_HashRegAddTableByPath ( webchat -> system_hreg , ( char * * ) & table_path ) ; table_path [ 0 ] = " " ; BP_HashRegAddTableByPath ( webchat -> system_hreg , ( char * * ) & table_path ) ; table_path [ 0 ] = " " ; BP_HashRegAddTableByPath ( webchat -> system_hreg , ( char * * ) & table_path ) ; return webchat ; }
Create a event manager.
Create a event manager .
// ensure we have an event manager // ensure we have a session name // create new hash registry // attempt to allocate space for webchat structure // set system hreg within the newly created object // initialize command registry // destroy webchat session // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Add Basic Tables to System Hreg %%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // set table path // ---- // set users path // add table // add by httpd username reference table (for faster lookups) // add by httpd username reference table (for faster lookups) // zero out add path before next // ---- // set classifications path // add table // ---- // set system path // add table // ---- // set channels path // add table // ---- // set references path // add table // return with the newly created session