library/src/javascript/BP-Javascript.cc
// This is called to ensure that the /system/javascript 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/javascript 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 / javascript 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_JSEnsureWorkingGlobalHashTableEnvirionment()
{
	if(!(BP_GLOBAL_HASH_TABLE_INIT_OK))
	{
		printf("\n [!!] Error: Attempted to create a semaphore even though the global hash tables were not initialized.  Please call BP_GLOBAL_HASH_TABLE_INIT before attempting to use blockparty semaphores.");
		return ERR_FAILURE;
	}
	size_t semaphore_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] = "javascript";
	table_path[2] = "managers";
	table_path[3] = NULL;
	if(BP_HashRegLookupTableByPath(NULL, table_path))
		return ERR_SUCCESS;
	table_path[0] = "system";
	table_path[1] = NULL;
	P_BP_HASH_TABLE_KEYED_ENTRY 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)
			return ERR_FAILURE;
	}
	table_path[0] = "system";
	table_path[1] = "javascript";
	table_path[2] = NULL;
	BP_HashRegAddTableByPath(NULL, table_path);
	tmp_lookup = BP_HashRegLookupTableByPath(NULL, table_path);
	if(!tmp_lookup)
		return ERR_FAILURE;
	table_path[0] = "system";
	table_path[1] = "javascript";
	table_path[2] = "managers";
	table_path[3] = NULL;
	BP_HashRegAddTableByPath(NULL, table_path);
	tmp_lookup = BP_HashRegLookupTableByPath(NULL, table_path);
	if(!tmp_lookup)
		return ERR_FAILURE;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_JSEnsureWorkingGlobalHashTableEnvirionment ( ) { if ( ! ( BP_GLOBAL_HASH_TABLE_INIT_OK ) ) { printf ( " \n " ) ; return ERR_FAILURE ; } size_t semaphore_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 ] = " " ; table_path [ 3 ] = NULL ; if ( BP_HashRegLookupTableByPath ( NULL , table_path ) ) return ERR_SUCCESS ; table_path [ 0 ] = " " ; table_path [ 1 ] = NULL ; P_BP_HASH_TABLE_KEYED_ENTRY 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 ) return 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 ) return ERR_FAILURE ; table_path [ 0 ] = " " ; table_path [ 1 ] = " " ; table_path [ 2 ] = " " ; table_path [ 3 ] = NULL ; BP_HashRegAddTableByPath ( NULL , table_path ) ; tmp_lookup = BP_HashRegLookupTableByPath ( NULL , table_path ) ; if ( ! tmp_lookup ) return ERR_FAILURE ; return ERR_SUCCESS ; }
This is called to ensure that the /system/javascript table has
been setup correctly.
This is called to ensure that the / system / javascript table has been setup correctly .
// ensure the hash table has been initialized tok // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Hash Table Lookups %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Simple flag to indicate via logic below whether or not the /system/semaphores table // exists already. // create a table path on the stack for ease of use // reference to the local stack // set path to /system/javascript // attempt lookup for /system/semaphores // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% 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. // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Lookups %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // now check for the javascript path // add the table // ensure it exists // ensure we can lookup the table, and exit if we // failed for some reason. // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Lookups %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // now check for the javascript path // add the table // ensure it exists // ensure we can lookup the table, and exit if we // failed for some reason. // return indicating success