/* * Condition handler for timeout condition. This function is invoked by * 'cnd_eval()' in order to perform class specific condition checks. * * parameter: cnd - The inititalized timeout condition. * ap - Pointer to user supplied arguments list for this * handler. * returns: TRUE - Condition is true. * FALSE - Condition is false. */ static gboolean _cnd_eval_timeout(condition* cnd, va_list ap _U_) { cnd_timeout_dat* data = (cnd_timeout_dat*)cnd_get_user_data(cnd); gint32 elapsed_time; /* check timeout here */ if(data->timeout_s == 0) return FALSE; /* 0 == infinite */ elapsed_time = (gint32) (time(NULL) - data->start_time); if(elapsed_time >= data->timeout_s) return TRUE; return FALSE; } /* END _cnd_eval_timeout()*/
/* * Condition handler for capturesize condition. This function is invoked by * 'cnd_eval()' in order to perform class specific condition checks. * * parameter: cnd - The inititalized capturesize condition. * ap - Pointer to user supplied arguments list for this * handler. * returns: TRUE - Condition is true. * FALSE - Condition is false. */ static gboolean _cnd_eval_capturesize(condition* cnd, va_list ap){ cnd_capturesize_dat* data = (cnd_capturesize_dat*)cnd_get_user_data(cnd); /* check capturesize here */ if(data->max_capture_size == 0) return FALSE; /* 0 == infinite */ if(va_arg(ap, guint64) >= data->max_capture_size){ return TRUE; } return FALSE; } /* END _cnd_eval_capturesize() */
/* * Call this function to reset this condition to its initial state, i.e. the * state it was in right after creation. * * parameter: cnd - Pointer to an initialized condition. */ static void _cnd_reset_timeout(condition *cnd) { ((cnd_timeout_dat*)cnd_get_user_data(cnd))->start_time = time(NULL); } /* END _cnd_reset_timeout() */
/* * Destroys condition for timeout check. This function is invoked by * 'cnd_delete()' in order to perform class specific clean up. * * parameter: cnd - Pointer to condition passed by 'cnd_delete()'. */ static void _cnd_destr_timeout(condition* cnd) { /* free memory */ g_free(cnd_get_user_data(cnd)); } /* END _cnd_destr_timeout() */
/* * Destroys condition for capturesize check. This function is invoked by * 'cnd_delete()' in order to perform class specific clean up. * * parameter: cnd - Pointer to condition passed by 'cnd_delete()'. */ static void _cnd_destr_capturesize(condition* cnd){ /* free memory */ g_free(cnd_get_user_data(cnd)); } /* END _cnd_destr_capturesize() */