library/src/semaphores/BP-Semaphores.cc
// Will attempt to display a valid semaphore entry in the table.
Will attempt to display a valid semaphore entry in the table.
Will attempt to display a valid semaphore entry in the table .
BP_ERROR_T BP_DisplaySemaphore(P_BP_SEMAPHORE_INFO sem)
{
	BP_SEMAPHORE_VALIDATE_WORKING_ENVIRONMENT(ERR_FAILURE);
	if(!sem)
		return ERR_FAILURE;
	printf("\n\t [+] Sem: %s", sem->uuid_key);
	printf("\n\t\t state:         ");
	switch(sem->state)
	{
		case BP_SEMAPHORE_STATE_LOCKED:
			printf("BP_SEMAPHORE_STATE_LOCKED");
			break;
		case BP_SEMAPHORE_STATE_MULTIPLE_LOCKS_WAITING:
			printf("BP_SEMAPHORE_STATE_MULTIPLE_LOCKS_WAITING");
			break;
		case BP_SEMAPHORE_STATE_UNLOCKED:
			printf("BP_SEMAPHORE_STATE_UNLOCKED");
			break;
		case BP_SEMAPHORE_STATE_UNSET:
			printf("BP_SEMAPHORE_STATE_UNSET");
			break;
		default:
			printf("INVALID ENTRY BADDATA");
			break;
	}
	int value_store = 0;
	sem_getvalue(&sem->sem, &value_store);
	printf("\n\t\t current value: %i", value_store);
	printf("\n\t\t location:      %s:%u - %s", sem->file, sem->line, sem->func);
	return ERR_SUCCESS;
}
BP_ERROR_T BP_DisplaySemaphore ( P_BP_SEMAPHORE_INFO sem ) { BP_SEMAPHORE_VALIDATE_WORKING_ENVIRONMENT ( ERR_FAILURE ) ; if ( ! sem ) return ERR_FAILURE ; printf ( " \n \t " , sem -> uuid_key ) ; printf ( " \n \t \t " ) ; switch ( sem -> state ) { case BP_SEMAPHORE_STATE_LOCKED : printf ( " " ) ; break ; case BP_SEMAPHORE_STATE_MULTIPLE_LOCKS_WAITING : printf ( " " ) ; break ; case BP_SEMAPHORE_STATE_UNLOCKED : printf ( " " ) ; break ; case BP_SEMAPHORE_STATE_UNSET : printf ( " " ) ; break ; default : printf ( " " ) ; break ; } int value_store = 0 ; sem_getvalue ( & sem -> sem , & value_store ) ; printf ( " \n \t \t " , value_store ) ; printf ( " \n \t \t " , sem -> file , sem -> line , sem -> func ) ; return ERR_SUCCESS ; }
Will attempt to display a valid semaphore entry in the table.
Will attempt to display a valid semaphore entry in the table .
// validate that there is a working environment // ensure we have a semaphore // display the uuid key // display the state // create local storage // retrieve the value from the current semaphore // display the current value // display the declaration point // return indicating success