static void process_function_actual(int job_type){ struct Job_Queue private_jobs; private_jobs.front = 0; private_jobs.rear = 0; get_jobs(job_type,&private_jobs); struct Job current_job; struct tcp_stream *a_tcp; char tcp_information_dir[100]; char server[100],client[100],promisc[100]; while(!jobqueue_isEmpty(&private_jobs)){ jobqueue_delete(&private_jobs,¤t_job); memset(tcp_information_dir,0,sizeof(tcp_information_dir)); sprintf(tcp_information_dir,"%s/%hu_%hu_%u_%u_%d/",current_dictionary,current_job.ip_and_port.dest,\ current_job.ip_and_port.source,current_job.ip_and_port.daddr,\ current_job.ip_and_port.saddr,current_job.hash_index); create_dirctionary(tcp_information_dir); if(current_job.server_rev != NULL && current_job.server_rev->head != NULL && current_job.server_rev->head->data != NULL){ memset(server,0,100*sizeof(char)); sprintf(server,"%s/log_server",tcp_information_dir); write_data_to_file(server,current_job.server_rev->head->data, current_job.server_rev->head->length); } if(current_job.client_rev != NULL && current_job.client_rev->head != NULL && current_job.client_rev->head->data != NULL){ memset(client,0,100*sizeof(char)); sprintf(client,"%s/log_client",tcp_information_dir); write_data_to_file(client,current_job.client_rev->head->data, current_job.client_rev->head->length); } if(current_job.promisc != NULL && current_job.promisc->head != NULL && current_job.promisc->head->data != NULL){ memset(promisc,0,100*sizeof(char)); sprintf(promisc,"%s/log_promisc",tcp_information_dir); write_data_to_file(promisc,current_job.promisc->head->data, current_job.promisc->head->length); } if(current_job.server_rev!=NULL){ wireless_list_free(current_job.server_rev); free(current_job.server_rev); } if(current_job.client_rev !=NULL){ wireless_list_free(current_job.client_rev); free(current_job.client_rev); } if(current_job.promisc != NULL){ wireless_list_free(current_job.promisc); free(current_job.promisc); } }//while }
/** * extract_data_and_write - wrapper for write_data_to_file * @nlh: pointer to header of netlink message */ int extract_data_and_write(struct nlmsghdr *nlh, FILE *fp, int file_format) { unsigned char *payload = NLMSG_DATA(nlh); write_data_to_file(payload, fp, file_format); memset(payload, 0, PAYLOAD_SIZE); return 0; }
/** * convert_file - converts file with binary data to text * @f_in: input binary file * @f_out: output text file */ int convert_file(FILE *f_in, FILE *f_out) { char buffer[PAYLOAD_SIZE]; print_header(f_out); while (fread(buffer, 1, PAYLOAD_SIZE, f_in)) { write_data_to_file(buffer, f_out, TEXT); } return 0; }
errcode_t profile_flush_file_data_to_file(prf_data_t data, const char *outfile) { errcode_t retval = 0; if (!data || data->magic != PROF_MAGIC_FILE_DATA) return PROF_MAGIC_FILE_DATA; k5_mutex_lock(&data->lock); retval = write_data_to_file(data, outfile, 1); k5_mutex_unlock(&data->lock); return retval; }
int picam_acquire(lua_State *L) { PicamCameraID id; PicamHandle handle = 0, model = 0; PicamError error = 0; PicamAvailableData data; PicamAcquisitionErrorsMask errors; clock_t tick, tock; struct metadata md; pi16u * buf; char * prepend; tick = clock(); id = lua_table_to_camera(L, 1, &handle); prepend = lua_tostring(L, 2); printf("Prepend: %s\n", prepend); Picam_GetParameterFloatingPointValue( handle, PicamParameter_ExposureTime, &md.exptime ); md.exptime /= 1000; Picam_GetParameterFloatingPointValue( handle, PicamParameter_AdcSpeed, &md.adcspeed ); Picam_GetParameterIntegerValue( handle, PicamParameter_AdcBitDepth, &md.bitdepth ); Picam_GetParameterIntegerValue( handle, PicamParameter_AdcAnalogGain, &md.gain ); Picam_GetParameterIntegerValue( handle, PicamParameter_AdcQuality, &md.adc ); Picam_GetParameterFloatingPointValue( handle, PicamParameter_SensorTemperatureReading, &md.temp ); md.id = &id; #define NUM_FRAMES 1 #define NO_TIMEOUT -1 Picam_Acquire(handle, NUM_FRAMES, // Readout count NO_TIMEOUT, // Readout timeout, if 0 not relevant &data, &errors); tock = clock(); buf = data.initial_readout; if(data.readout_count != 1) { lua_pushstring(L, "More than 1 count found"); lua_error(L); } write_data_to_file(buf, &md, prepend, L); printf("Acquisition took %5.2f s\n", ((float) tock-tick)/CLOCKS_PER_SEC); return 0; }
int main() { int value; Trans *transaction; /* ** Establish the point at which we want to resume execution ** after a call to longjmp. */ value = setjmp( restart ); /* ** Figure out what to do after a return from setjmp. */ switch( value ){ default: /* ** longjmp was called -- fatal error */ fputs( "Fatal error.\n", stderr ); break; case 1: /* ** longjmp was called -- minor error */ fputs( "Invalid transaction.\n", stderr ); /* FALL THROUGH and continue processing */ case 0: /* ** Original return from setjmp: perform normal ** processing. */ while( (transaction = get_trans()) != NULL ) process_trans( transaction ); } /* ** Save data and exit the program */ write_data_to_file(); return value == 0 ? EXIT_SUCCESS : EXIT_FAILURE; }
errcode_t profile_flush_file_data(prf_data_t data) { errcode_t retval = 0; if (!data || data->magic != PROF_MAGIC_FILE_DATA) return PROF_MAGIC_FILE_DATA; k5_mutex_lock(&data->lock); if ((data->flags & PROFILE_FILE_DIRTY) == 0) { k5_mutex_unlock(&data->lock); return 0; } retval = write_data_to_file(data, data->filespec, 0); k5_mutex_unlock(&data->lock); return retval; }
int main() { int value; Trans *transaction; value = setjmp(restart); switch(setjmp(restart)){ default: fputs("fatal error.\n", stderr); break; case 1: fputs("Invalid transaction.\n", stderr); case 0: while((transaction = geet_trans()) != NULL ){ process_trans(transaction); } } write_data_to_file(); return value ==0 ? EXIT_SUCCESS:EXIT_FAILURE; }