/* Performs final sanity checking on all parsed arguments. */ static bool validate_args(void) { return TEST_OK_(continuous_capture || start_specified, "Must specify a start date or continuous capture") && TEST_OK_(!continuous_capture || !start_specified, "Cannot combine continuous and archive capture") && TEST_OK_(continuous_capture || end_specified || sample_count > 0, "Must specify sample count or end for historical data") && TEST_OK_(!continuous_capture || !request_contiguous, "Gap checking not meaningful for subscription data") && TEST_OK_(sample_count == 0 || !end_specified, "Cannot specify both sample count and data end point") && TEST_OK_(!end_specified || compare_ts(&start, &end) < 0, "End time isn't after start") && TEST_OK_(start_specified || data_format == DATA_FA, "Decimated data must be historical") && TEST_OK_(!matlab_format || sample_count <= UINT32_MAX, "Too many samples for matlab format capture") && TEST_OK_(matlab_format || !save_id0, "Can only capture ID0 in matlab format") && TEST_OK_(request_contiguous || !check_id0, "ID0 checking only meaningful with gap checking") && TEST_OK_(!decimated_capture || continuous_decimation > 0, "Continuous decimated data not available from server"); }
void on_message_recived(orfs_message_t *message) { orfs_metadata_t metadata; locker_t *locker; locker = lock_acquire(message->file_name, LOCK_STATE | LOCK_EXISTS | LOCK_OPEN_RW ); metadata_get(message->file_name, &metadata); if (message->type == ORFS_MESSAGE_CREATE_MODIFY) { if(metadata.state == ORFS_STATE_EMPTY) { if(!metadata.exists) { enque_action(ORFS_ACTION_RECEIVE, message); } else { if(!metadata.is_open && compare_ts(metadata.ts, message->ts)<0) { enque_action(ORFS_ACTION_RECEIVE, message); } else if(metadata.is_open && compare_ts(metadata.ts, message->ts)<0) { enque_action(ORFS_ACTION_COC, message); } } } else if(metadata.state == ORFS_STATE_RECEIVE && compare_ts(metadata.message.ts, message->ts)<0) { remove_action(message->file_name); enque_action(ORFS_ACTION_RECEIVE, message); } else if(metadata.state == ORFS_STATE_COC && compre_ts(metadata.message.ts, message->ts)<0) { remove_action(metadata); enqueue_action(ORFS_ACTION_COC, message); } } else { // message->type = ORFS_MESSAGE_DELETE if ( metadata.exists) { if (!metadata.is_open && compare_ts(metadata.ts, message->ts)<0) { if (metadata.state == ORFS_STATE_EMPTY || compare_ts(metadata.message.ts, message->ts)<0) { remove_file(metadata); } } else if (metadata.is_open ) { if (metadata.state == ORFS_STATE_EMPTY && compare_ts(metadata.ts, message->ts) <0) { enqueue_action(ORFS_ACTION_COC, message); } else if (metadata.state == ORFS_STATE_COC && compare_ts(metadata.message.ts, message->ts)<0) { remove_action(metadata); enqueue_action(ORFS_ACTION_COC, message); } else if (!metadata.is_open && metadata.state == ORFS_STATE_RECEIVE && compare_ts(metadata.message.ts, message->ts) <0) { remove_action(metadata); remove_file(metadata); } } } } lock_release(locker); }