library/src/events/BP-Events.cc
BP_ERROR_T BP_EventMgrEnsureWorkingGlobalHashTableEnvirionment()
{

	// ensure the hash table has been initialized tok
	if(!(BP_GLOBAL_HASH_TABLE_INIT_OK))
	{
		printf("\n [!!] Error: Attempted to operate on blockparty event manager even though the global hash tables were not initialized.  Please call BP_GLOBAL_HASH_TABLE_INIT before attempting to use blockparty event managment.");
		return ERR_FAILURE;
	}

	// enter critical section before lookup
	BP_GHT_ENTER_CRITICAL_SECTION;

	// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	// %%% Hash Table Lookups %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

	// Simple flag to indicate via logic below whether or not the /system/event_managment table
	// exists already.
	size_t eventmgr_table_exists = 0;

    // create a table path on the stack for ease of use
	char * table_path_actual[10] = {0};

	// reference to the local stack
	BP_HASH_TABLE_TRAVERSAL_PATH table_path = (char **) &table_path_actual;

	// set path to /system/event_managment
	table_path[0] = "system";
	table_path[1] = "event_managment";
	table_path[2] = NULL;

	// attempt lookup for /system/semaphores
	P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = BP_HashRegLookupTableByPath(NULL, table_path);

	// display lookup results
	if(tmp_lookup)
		eventmgr_table_exists = BP_TRUE;
	else
		eventmgr_table_exists = BP_FALSE;

	// if the table exists, immediately  return OK
	if(eventmgr_table_exists == BP_TRUE)
		BP_GHT_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(ERR_SUCCESS);


	// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	// %%% Create Tables If Necessary %%%%%%%%%%%%%%%%%%%%%%%%%
	// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

	// First check if the system path exists.  If not, create it.
	table_path[0] = "system";
	table_path[1] = NULL;

	// lookup system
	tmp_lookup = BP_HashRegLookupTableByPath(NULL, table_path);

	// if it's not there, create it
	if(!tmp_lookup)
	{

		// add the table
		BP_HashRegAddTableByPath(NULL, table_path);

		// ensure it exists
		tmp_lookup = BP_HashRegLookupTableByPath(NULL, table_path);

		// ensure we can lookup the table, and exit if we
		// failed for some reason.
		if(!tmp_lookup)
			BP_GHT_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(ERR_FAILURE);

	}

	// now check for the semaphore path
	table_path[0] = "system";
	table_path[1] = "event_managment";
	table_path[2] = NULL;

	// add the table
	BP_HashRegAddTableByPath(NULL, table_path);

	// ensure it exists
	tmp_lookup = BP_HashRegLookupTableByPath(NULL, table_path);

	// ensure we can lookup the table, and exit if we
	// failed for some reason.
	if(!tmp_lookup)
		BP_GHT_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(ERR_FAILURE);

	// leave critical section before returning
	BP_GHT_LEAVE_CRITICAL_SECTION;

	// return indicating success
	return ERR_SUCCESS;

}
// This is called to ensure that the /system/event_managers/ table has
// been setup correctly.  It simply searches for an existing semaphore
// table and if it doesn't exist, adds it to /system/.
This is called to ensure that the /system/event_managers/ table has
been setup correctly.  It simply searches for an existing semaphore
table and if it doesn't exist, adds it to /system/.
This is called to ensure that the / system / event_managers / table has been setup correctly . It simply searches for an existing semaphore table and if it doesn ' t exist adds it to / system / .
BP_ERROR_T BP_EventMgrEnsureWorkingGlobalHashTableEnvirionment()
{
	if(!(BP_GLOBAL_HASH_TABLE_INIT_OK))
	{
		printf("\n [!!] Error: Attempted to operate on blockparty event manager even though the global hash tables were not initialized.  Please call BP_GLOBAL_HASH_TABLE_INIT before attempting to use blockparty event managment.");
		return ERR_FAILURE;
	}
	BP_GHT_ENTER_CRITICAL_SECTION;
	size_t eventmgr_table_exists = 0;
	char * table_path_actual[10] = {0};
	BP_HASH_TABLE_TRAVERSAL_PATH table_path = (char **) &table_path_actual;
	table_path[0] = "system";
	table_path[1] = "event_managment";
	table_path[2] = NULL;
	P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = BP_HashRegLookupTableByPath(NULL, table_path);
	if(tmp_lookup)
		eventmgr_table_exists = BP_TRUE;
	else
		eventmgr_table_exists = BP_FALSE;
	if(eventmgr_table_exists == BP_TRUE)
		BP_GHT_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(ERR_SUCCESS);
	table_path[0] = "system";
	table_path[1] = NULL;
	tmp_lookup = BP_HashRegLookupTableByPath(NULL, table_path);
	if(!tmp_lookup)
	{
		BP_HashRegAddTableByPath(NULL, table_path);
		tmp_lookup = BP_HashRegLookupTableByPath(NULL, table_path);
		if(!tmp_lookup)
			BP_GHT_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(ERR_FAILURE);
	}
	table_path[0] = "system";
	table_path[1] = "event_managment";
	table_path[2] = NULL;
	BP_HashRegAddTableByPath(NULL, table_path);
	tmp_lookup = BP_HashRegLookupTableByPath(NULL, table_path);
	if(!tmp_lookup)
		BP_GHT_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(ERR_FAILURE);
	BP_GHT_LEAVE_CRITICAL_SECTION;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_EventMgrEnsureWorkingGlobalHashTableEnvirionment ( ) { if ( ! ( BP_GLOBAL_HASH_TABLE_INIT_OK ) ) { printf ( " \n " ) ; return ERR_FAILURE ; } BP_GHT_ENTER_CRITICAL_SECTION ; size_t eventmgr_table_exists = 0 ; char * table_path_actual [ 10 ] = { 0 } ; BP_HASH_TABLE_TRAVERSAL_PATH table_path = ( char * * ) & table_path_actual ; table_path [ 0 ] = " " ; table_path [ 1 ] = " " ; table_path [ 2 ] = NULL ; P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = BP_HashRegLookupTableByPath ( NULL , table_path ) ; if ( tmp_lookup ) eventmgr_table_exists = BP_TRUE ; else eventmgr_table_exists = BP_FALSE ; if ( eventmgr_table_exists == BP_TRUE ) BP_GHT_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( ERR_SUCCESS ) ; table_path [ 0 ] = " " ; table_path [ 1 ] = NULL ; tmp_lookup = BP_HashRegLookupTableByPath ( NULL , table_path ) ; if ( ! tmp_lookup ) { BP_HashRegAddTableByPath ( NULL , table_path ) ; tmp_lookup = BP_HashRegLookupTableByPath ( NULL , table_path ) ; if ( ! tmp_lookup ) BP_GHT_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( ERR_FAILURE ) ; } table_path [ 0 ] = " " ; table_path [ 1 ] = " " ; table_path [ 2 ] = NULL ; BP_HashRegAddTableByPath ( NULL , table_path ) ; tmp_lookup = BP_HashRegLookupTableByPath ( NULL , table_path ) ; if ( ! tmp_lookup ) BP_GHT_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( ERR_FAILURE ) ; BP_GHT_LEAVE_CRITICAL_SECTION ; return ERR_SUCCESS ; }
This is called to ensure that the /system/event_managers/ table has
been setup correctly.
This is called to ensure that the / system / event_managers / table has been setup correctly .
// ensure the hash table has been initialized tok // enter critical section before lookup // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Hash Table Lookups %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Simple flag to indicate via logic below whether or not the /system/event_managment table // exists already. // create a table path on the stack for ease of use // reference to the local stack // set path to /system/event_managment // attempt lookup for /system/semaphores // display lookup results // if the table exists, immediately  return OK // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Create Tables If Necessary %%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // First check if the system path exists.  If not, create it. // lookup system // if it's not there, create it // add the table // ensure it exists // ensure we can lookup the table, and exit if we // failed for some reason. // now check for the semaphore path // add the table // ensure it exists // ensure we can lookup the table, and exit if we // failed for some reason. // leave critical section before returning // return indicating success