library/src/network/httpd/BP-HTTPdDisplayUtilities.cc
// Display sessions within the system registry
Display sessions within the system registry
Display sessions within the system registry
BP_ERROR_T BP_HTTPdDisplaySessions(P_BP_HTTPD_SESSION httpd)
{
	if(!httpd)
		return ERR_FAILURE;
	if(!httpd->system_hreg)
		return ERR_FAILURE;
	char * table_path[10] = {0};
	P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = NULL;
	table_path[0] = "sessions";
	table_path[1] = NULL;
	BP_HASH_TABLE_ENTER_CRITICAL_SECTION(httpd->system_hreg);
	tmp_lookup = BP_HashRegLookupTableByPath(httpd->system_hreg, table_path);
	if(tmp_lookup->data)
	{
		printf("\n\n\t\t [+] Displaying User Sessions");
		tmp_lookup = (P_BP_HASH_TABLE_KEYED_ENTRY) tmp_lookup->data;
		P_BP_HASH_TABLE_KEYED_ENTRY entry = NULL;
		P_BP_HASH_TABLE_KEYED_ENTRY tmp   = NULL;
		HASH_ITER(hh, tmp_lookup, entry, tmp)
		{
			P_BP_HTTPD_USER_SESSION user_session = (P_BP_HTTPD_USER_SESSION) entry->data;
			if(user_session)
			{
				printf("\n");
				BP_HTTPdDisplayUserSession(user_session);
			}
		}
	}
	BP_HASH_TABLE_LEAVE_CRITICAL_SECTION(httpd->system_hreg);
	return ERR_SUCCESS;
}
BP_ERROR_T BP_HTTPdDisplaySessions ( P_BP_HTTPD_SESSION httpd ) { if ( ! httpd ) return ERR_FAILURE ; if ( ! httpd -> system_hreg ) return ERR_FAILURE ; char * table_path [ 10 ] = { 0 } ; P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = NULL ; table_path [ 0 ] = " " ; table_path [ 1 ] = NULL ; BP_HASH_TABLE_ENTER_CRITICAL_SECTION ( httpd -> system_hreg ) ; tmp_lookup = BP_HashRegLookupTableByPath ( httpd -> system_hreg , table_path ) ; if ( tmp_lookup -> data ) { printf ( " \n \n \t \t " ) ; tmp_lookup = ( P_BP_HASH_TABLE_KEYED_ENTRY ) tmp_lookup -> data ; P_BP_HASH_TABLE_KEYED_ENTRY entry = NULL ; P_BP_HASH_TABLE_KEYED_ENTRY tmp = NULL ; HASH_ITER ( hh , tmp_lookup , entry , tmp ) { P_BP_HTTPD_USER_SESSION user_session = ( P_BP_HTTPD_USER_SESSION ) entry -> data ; if ( user_session ) { printf ( " \n " ) ; BP_HTTPdDisplayUserSession ( user_session ) ; } } } BP_HASH_TABLE_LEAVE_CRITICAL_SECTION ( httpd -> system_hreg ) ; return ERR_SUCCESS ; }
Display sessions within the system registry
Display sessions within the system registry
// ensure we have a httpd and a system registry // declare dynamic table path // declare the lookup pointer // set the table path // enter system hreg critical section // lookup the post table // iterate through users // add header // move the tmp lookup to the hash table children (since it's a table) // temporary iterator values used during the HASH_ITER loop below // iterate through all hashes and display // set variable // if the var is set, destroy its members // display user (add newline before each entry) // printf("\n SYSTEM REG HERE:"); // BP_HashRegDisplay(httpd->system_hreg, BP_FALSE, BP_TRUE); // leave system hreg critical section // return indicating success