Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

util.c File Reference

contains useful utility functions More...

#include "util.h"
#include <stdlib.h>
#include <unistd.h>
#include "def.h"

Go to the source code of this file.

Functions

int DEC_UNTIL_ZERO (int x)
 decrements a signed number by one, but not past zero
errorcode safe_free (void *memory)
 a 'safe' free
errorcode wait_for_flag (flag_t *check_flag, flag_t stop_flags, int timeout)
 waits for a flag to take one of many specified values


Detailed Description

contains useful utility functions

Author:
Daniel Ferullo (ferullo@cmu.edu)

Definition in file util.c.


Function Documentation

int DEC_UNTIL_ZERO int  x  )  [inline]
 

decrements a signed number by one, but not past zero

Parameters:
x The number to decrement
Returns:
The decremented value

Definition at line 31 of file util.c.

Referenced by find_conn2(), get_buddy(), and wait_for_flag().

errorcode safe_free void *  memory  ) 
 

a 'safe' free

Parameters:
memory pointer to the memory to free
Returns:
SUCCESS, errorcode on failure

Definition at line 35 of file util.c.

References CHECK_NOT_NULL, ERROR_NULL_ARG_1, and errorcode.

Referenced by create_new_handler(), list_destroy(), list_remove(), readMsg(), run_direct_conn_connect(), run_helper_fsm_thread(), sendMsg(), and start_direct_conn().

errorcode wait_for_flag flag_t check_flag,
flag_t  stop_flags,
int  timeout
 

waits for a flag to take one of many specified values

Success if the check_flag takes on any one of the stop_flags before timeout

Parameters:
check_flag pointer to the flag to watch
stop_flags all the flags to wait for or'ed together.
timeout the timeout time, in seconds
Returns:
SUCCESS, errorcode on failure

Definition at line 48 of file util.c.

References CHECK_NOT_NEG, CHECK_NOT_NULL, DEC_UNTIL_ZERO(), ERROR_NEG_ARG_3, ERROR_NULL_ARG_1, and errorcode.

Referenced by wait_and_join_find_synack(), wait_for_buddy_bday_port(), wait_for_buddy_port_alloc(), wait_for_buddy_port_known(), wait_for_buddy_syn_flood(), wait_for_buddy_syn_seq_num(), and wait_for_direct_conn().


Generated on Wed Mar 30 23:20:48 2005 for NATBLASTER by  doxygen 1.3.9.1