static svn_error_t *ra_svn_apply_textdelta(void *file_baton, const char *base_checksum, apr_pool_t *pool, svn_txdelta_window_handler_t *wh, void **wh_baton) { ra_svn_baton_t *b = file_baton; svn_stream_t *diff_stream; /* Tell the other side we're starting a text delta. */ SVN_ERR(check_for_error(b->eb, pool)); SVN_ERR(svn_ra_svn__write_cmd_apply_textdelta(b->conn, pool, b->token, base_checksum)); /* Transform the window stream to an svndiff stream. Reuse the * file baton for the stream handler, since it has all the * needed information. */ diff_stream = svn_stream_create(b, pool); svn_stream_set_write(diff_stream, ra_svn_svndiff_handler); svn_stream_set_close(diff_stream, ra_svn_svndiff_close_handler); /* If the connection does not support SVNDIFF1 or if we don't want to use * compression, use the non-compressing "version 0" implementation */ if ( svn_ra_svn_compression_level(b->conn) > 0 && svn_ra_svn_has_capability(b->conn, SVN_RA_SVN_CAP_SVNDIFF1)) svn_txdelta_to_svndiff3(wh, wh_baton, diff_stream, 1, b->conn->compression_level, pool); else svn_txdelta_to_svndiff3(wh, wh_baton, diff_stream, 0, b->conn->compression_level, pool); return SVN_NO_ERROR; }
void return_simulation_data(mxArray **plhs){ /* Return values */ mxArray *output_struct; mxArray *final_states; mxArray *final_times; if(!collection_status.initialized) ERROR("Attempted to read simulation data without initializing.\n"); collection_status.initialized = 0; /* Read outputs */ if(collection_status.shared_memory){ check_for_error(); output_struct = read_outputs_from_shared_memory(); } else{ output_struct = read_outputs_from_files(); } /* Read final states */ final_states = read_final_states(); /* Read final times */ final_times = read_final_times(); /* Assign return values */ plhs[0] = output_struct; plhs[1] = final_states; plhs[2] = final_times; }
int cmpe207_socket(int ai_family, int ai_socktype, int ai_protocol) { int check; int sockfd_207 = -1; if(ai_family != CMPE207_FAM) die("unsupported family"); else if(ai_socktype != CMPE207_SOC) die("unsupported socket type"); else if (ai_protocol != CMPE207_PROC) die("unsupported protocol"); for(check = 0; check < MAX_SOCKET; check++) { if(gTcp_Block[check].sock_in_use ==0) //if found one that is open { sockfd_207 = check; gTcp_Block[sockfd_207].sock_in_use = 1; struct sockaddr_in *UDP = malloc (sizeof *UDP); gTcp_Block[sockfd_207].pSocket_info = UDP; //create UDP socket gTcp_Block[sockfd_207].sockfd_udp = socket(PF_INET,SOCK_DGRAM, 0); check_for_error(gTcp_Block[sockfd_207].sockfd_udp,"no UDP socket available.\n"); break; } } //check_for_error(sockfd_207, "no socket available."); return sockfd_207; }
static svn_error_t *ra_svn_close_dir(void *dir_baton, apr_pool_t *pool) { ra_svn_baton_t *b = dir_baton; SVN_ERR(check_for_error(b->eb, pool)); SVN_ERR(svn_ra_svn__write_cmd_close_dir(b->conn, pool, b->token)); return SVN_NO_ERROR; }
static svn_error_t *ra_svn_svndiff_close_handler(void *baton) { ra_svn_baton_t *b = baton; SVN_ERR(check_for_error(b->eb, b->pool)); SVN_ERR(svn_ra_svn__write_cmd_textdelta_end(b->conn, b->pool, b->token)); return SVN_NO_ERROR; }
int main(int argc, char** argv) { std::cout << INFO; check_for_error(argc, argv); Manager m; m.read_files(argv); m.ray_trace(); std::cout<<"done\n"; return EXIT_SUCCESS; }
static svn_error_t *ra_svn_target_rev(void *edit_baton, svn_revnum_t rev, apr_pool_t *pool) { ra_svn_edit_baton_t *eb = edit_baton; SVN_ERR(check_for_error(eb, pool)); SVN_ERR(svn_ra_svn__write_cmd_target_rev(eb->conn, pool, rev)); return SVN_NO_ERROR; }
static svn_error_t *ra_svn_delete_entry(const char *path, svn_revnum_t rev, void *parent_baton, apr_pool_t *pool) { ra_svn_baton_t *b = parent_baton; SVN_ERR(check_for_error(b->eb, pool)); SVN_ERR(svn_ra_svn__write_cmd_delete_entry(b->conn, pool, path, rev, b->token)); return SVN_NO_ERROR; }
static svn_error_t *ra_svn_open_root(void *edit_baton, svn_revnum_t rev, apr_pool_t *pool, void **root_baton) { ra_svn_edit_baton_t *eb = edit_baton; const char *token = make_token('d', eb, pool); SVN_ERR(check_for_error(eb, pool)); SVN_ERR(svn_ra_svn__write_cmd_open_root(eb->conn, pool, rev, token)); *root_baton = ra_svn_make_baton(eb->conn, pool, eb, token); return SVN_NO_ERROR; }
static svn_error_t *ra_svn_close_file(void *file_baton, const char *text_checksum, apr_pool_t *pool) { ra_svn_baton_t *b = file_baton; SVN_ERR(check_for_error(b->eb, pool)); SVN_ERR(svn_ra_svn__write_cmd_close_file(b->conn, pool, b->token, text_checksum)); return SVN_NO_ERROR; }
static svn_error_t *ra_svn_change_dir_prop(void *dir_baton, const char *name, const svn_string_t *value, apr_pool_t *pool) { ra_svn_baton_t *b = dir_baton; SVN_ERR(check_for_error(b->eb, pool)); SVN_ERR(svn_ra_svn__write_cmd_change_dir_prop(b->conn, pool, b->token, name, value)); return SVN_NO_ERROR; }
static svn_error_t *ra_svn_svndiff_handler(void *baton, const char *data, apr_size_t *len) { ra_svn_baton_t *b = baton; svn_string_t str; SVN_ERR(check_for_error(b->eb, b->pool)); str.data = data; str.len = *len; return svn_ra_svn__write_cmd_textdelta_chunk(b->conn, b->pool, b->token, &str); }
static svn_error_t *ra_svn_open_dir(const char *path, void *parent_baton, svn_revnum_t rev, apr_pool_t *pool, void **child_baton) { ra_svn_baton_t *b = parent_baton; const char *token = make_token('d', b->eb, pool); SVN_ERR(check_for_error(b->eb, pool)); SVN_ERR(svn_ra_svn__write_cmd_open_dir(b->conn, pool, path, b->token, token, rev)); *child_baton = ra_svn_make_baton(b->conn, pool, b->eb, token); return SVN_NO_ERROR; }
static svn_error_t *ra_svn_absent_file(const char *path, void *parent_baton, apr_pool_t *pool) { ra_svn_baton_t *b = parent_baton; /* Avoid sending an unknown command if the other end doesn't support absent-file. */ if (! svn_ra_svn_has_capability(b->conn, SVN_RA_SVN_CAP_ABSENT_ENTRIES)) return SVN_NO_ERROR; SVN_ERR(check_for_error(b->eb, pool)); SVN_ERR(svn_ra_svn__write_cmd_absent_file(b->conn, pool, path, b->token)); return SVN_NO_ERROR; }
mxArray *read_outputs_from_shared_memory(){ /* Local variables */ mxArray *mat_output; double *mat_data; double *file_data; unsigned int modelid; unsigned int outputid; unsigned int num_samples; int i; /* Return value */ mxArray *output_struct; collection_status.request_data = 1; if(collection_status.num_outputs){ for(i=0;i<NUM_THREADS;i++){ pthread_join(collection_status.collector[i], NULL); collection_status.collector[i] = 0; } } check_for_error(); output_struct = mxCreateStructMatrix(collection_status.num_models, 1, collection_status.num_outputs, (const char **)collection_status.output_names); /* Convert output files to mat format */ for(modelid=0;modelid<collection_status.num_models;modelid++){ for(outputid=0;outputid<collection_status.num_outputs;outputid++){ num_samples = output[modelid * collection_status.num_outputs + outputid].samples; if(num_samples > 0){ /* Allocate mat variable */ mat_output = mxCreateDoubleMatrix(num_samples, collection_status.output_num_quantities[outputid], mxREAL); mat_data = mxGetPr(mat_output); copy_transpose_double(mat_data, output[modelid * collection_status.num_outputs + outputid].data, collection_status.output_num_quantities[outputid], num_samples); free(output[modelid * collection_status.num_outputs + outputid].data); output[modelid * collection_status.num_outputs + outputid].data = NULL; /* Assign mat variable to return structure */ mxDestroyArray(mxGetField(output_struct, modelid, collection_status.output_names[outputid])); mxSetField(output_struct, modelid, collection_status.output_names[outputid], mat_output); } } } return output_struct; }
static svn_error_t *ra_svn_add_dir(const char *path, void *parent_baton, const char *copy_path, svn_revnum_t copy_rev, apr_pool_t *pool, void **child_baton) { ra_svn_baton_t *b = parent_baton; const char *token = make_token('d', b->eb, pool); SVN_ERR_ASSERT((copy_path && SVN_IS_VALID_REVNUM(copy_rev)) || (!copy_path && !SVN_IS_VALID_REVNUM(copy_rev))); SVN_ERR(check_for_error(b->eb, pool)); SVN_ERR(svn_ra_svn__write_cmd_add_dir(b->conn, pool, path, b->token, token, copy_path, copy_rev)); *child_baton = ra_svn_make_baton(b->conn, pool, b->eb, token); return SVN_NO_ERROR; }
/** * Add a given word to the list of known words inside my private dictionary. * You have to call aspell_save_all_wordlists to make sure the list gets persistent. * @param word the word to add. */ static VALUE aspell_add_to_personal(VALUE self, VALUE word) { AspellSpeller *speller = get_speller(self); aspell_speller_add_to_personal(speller, StringValuePtr(word), -1); check_for_error(speller); return self; }
void doit(void) { int ret, suite; gnutls_x509_name_constraints_t nc1, nc2; gnutls_datum_t name; gnutls_global_set_log_function(tls_log_func); if (debug) gnutls_global_set_log_level(1000); /* 0: test the merge permitted name constraints * NC1: permitted DNS org * permitted DNS ccc.com * permitted email ccc.com * NC2: permitted DNS org * permitted DNS aaa.bbb.ccc.com */ suite = 0; ret = gnutls_x509_name_constraints_init(&nc1); check_for_error(ret); ret = gnutls_x509_name_constraints_init(&nc2); check_for_error(ret); set_name("org", &name); ret = gnutls_x509_name_constraints_add_permitted(nc1, GNUTLS_SAN_DNSNAME, &name); check_for_error(ret); set_name("ccc.com", &name); ret = gnutls_x509_name_constraints_add_permitted(nc1, GNUTLS_SAN_DNSNAME, &name); check_for_error(ret); set_name("ccc.com", &name); ret = gnutls_x509_name_constraints_add_permitted(nc1, GNUTLS_SAN_RFC822NAME, &name); check_for_error(ret); set_name("org", &name); ret = gnutls_x509_name_constraints_add_permitted(nc2, GNUTLS_SAN_DNSNAME, &name); check_for_error(ret); set_name("aaa.bbb.ccc.com", &name); ret = gnutls_x509_name_constraints_add_permitted(nc2, GNUTLS_SAN_DNSNAME, &name); check_for_error(ret); ret = _gnutls_x509_name_constraints_merge(nc1, nc2); check_for_error(ret); /* unrelated */ set_name("xxx.example.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("example.org", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_ACCEPTED, &name); set_name("com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("xxx.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("ccc.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); /* check intersection of permitted */ set_name("xxx.aaa.bbb.ccc.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_ACCEPTED, &name); set_name("aaa.bbb.ccc.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_ACCEPTED, &name); set_name("xxx.bbb.ccc.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("xxx.ccc.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("ccc.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("ccc.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_RFC822NAME, &name); check_test_result(suite, ret, NAME_ACCEPTED, &name); set_name("xxx.ccc.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_RFC822NAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); gnutls_x509_name_constraints_deinit(nc1); gnutls_x509_name_constraints_deinit(nc2); /* 1: test the merge of excluded name constraints * NC1: denied DNS example.com * NC2: denied DNS example.net */ suite = 1; ret = gnutls_x509_name_constraints_init(&nc1); check_for_error(ret); ret = gnutls_x509_name_constraints_init(&nc2); check_for_error(ret); set_name("example.com", &name); ret = gnutls_x509_name_constraints_add_excluded(nc1, GNUTLS_SAN_DNSNAME, &name); check_for_error(ret); set_name("example.net", &name); ret = gnutls_x509_name_constraints_add_excluded(nc2, GNUTLS_SAN_DNSNAME, &name); check_for_error(ret); ret = _gnutls_x509_name_constraints_merge(nc1, nc2); check_for_error(ret); set_name("xxx.example.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("xxx.example.net", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("example.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("example.net", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("example.org", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_ACCEPTED, &name); gnutls_x509_name_constraints_deinit(nc1); gnutls_x509_name_constraints_deinit(nc2); /* 2: test permitted constraints with empty intersection * (no permitted nodes remain) * NC1: permitted DNS one.example.com * NC2: permitted DNS two.example.com */ suite = 2; ret = gnutls_x509_name_constraints_init(&nc1); check_for_error(ret); ret = gnutls_x509_name_constraints_init(&nc2); check_for_error(ret); set_name("one.example.com", &name); ret = gnutls_x509_name_constraints_add_permitted(nc1, GNUTLS_SAN_DNSNAME, &name); check_for_error(ret); set_name("two.example.com", &name); ret = gnutls_x509_name_constraints_add_permitted(nc2, GNUTLS_SAN_DNSNAME, &name); check_for_error(ret); ret = _gnutls_x509_name_constraints_merge(nc1, nc2); check_for_error(ret); set_name("one.example.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("two.example.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("three.example.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("example.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("org", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); gnutls_x509_name_constraints_deinit(nc1); gnutls_x509_name_constraints_deinit(nc2); /* 3: test more permitted constraints, some with empty intersection * NC1: permitted DNS foo.com * permitted DNS bar.com * permitted email redhat.com * NC2: permitted DNS sub.foo.com */ suite = 3; ret = gnutls_x509_name_constraints_init(&nc1); check_for_error(ret); ret = gnutls_x509_name_constraints_init(&nc2); check_for_error(ret); set_name("foo.com", &name); ret = gnutls_x509_name_constraints_add_permitted(nc1, GNUTLS_SAN_DNSNAME, &name); check_for_error(ret); set_name("bar.com", &name); ret = gnutls_x509_name_constraints_add_permitted(nc1, GNUTLS_SAN_DNSNAME, &name); check_for_error(ret); set_name("sub.foo.com", &name); ret = gnutls_x509_name_constraints_add_permitted(nc2, GNUTLS_SAN_DNSNAME, &name); check_for_error(ret); ret = _gnutls_x509_name_constraints_merge(nc1, nc2); check_for_error(ret); set_name("foo.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("bar.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("sub.foo.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_ACCEPTED, &name); set_name("anothersub.foo.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); gnutls_x509_name_constraints_deinit(nc1); gnutls_x509_name_constraints_deinit(nc2); /* 4: test permitted constraints with empty intersection * almost identical to 2, but extra name constraint of different type * that remains after intersection * NC1: permitted DNS three.example.com * permitted email redhat.com * NC2: permitted DNS four.example.com */ suite = 4; ret = gnutls_x509_name_constraints_init(&nc1); check_for_error(ret); ret = gnutls_x509_name_constraints_init(&nc2); check_for_error(ret); set_name("three.example.com", &name); ret = gnutls_x509_name_constraints_add_permitted(nc1, GNUTLS_SAN_DNSNAME, &name); check_for_error(ret); set_name("redhat.com", &name); ret = gnutls_x509_name_constraints_add_permitted(nc1, GNUTLS_SAN_RFC822NAME, &name); check_for_error(ret); set_name("four.example.com", &name); ret = gnutls_x509_name_constraints_add_permitted(nc2, GNUTLS_SAN_DNSNAME, &name); check_for_error(ret); ret = _gnutls_x509_name_constraints_merge(nc1, nc2); check_for_error(ret); set_name("three.example.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("four.example.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("five.example.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("example.com", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); set_name("org", &name); ret = gnutls_x509_name_constraints_check(nc1, GNUTLS_SAN_DNSNAME, &name); check_test_result(suite, ret, NAME_REJECTED, &name); gnutls_x509_name_constraints_deinit(nc1); gnutls_x509_name_constraints_deinit(nc2); /* Test footer */ if (debug) success("Test success.\n"); }
/** * Add a given word to the list of known words just for the lifetime of this object. * @param word the word to add. */ static VALUE aspell_add_to_session(VALUE self, VALUE word) { AspellSpeller *speller = get_speller(self); aspell_speller_add_to_session(speller, STR2CSTR(word), -1); check_for_error(speller); return self; }
void initialize(const mxArray **prhs){ /* mexFunction parameters */ const mxArray *iface = prhs[0]; const mxArray *options = prhs[1]; int i; if(!collection_status.initialized){ collection_status.initialized = 1; for(i=0;i<NUM_THREADS;i++){ collection_status.log_outputs_status[i] = LOG_OUTPUTS_OK; } collection_status.request_data = 0; /* Initialize parameter sub fields */ collection_status.outputs_dirname = options_outputs_directory(options); collection_status.num_models = options_instances(options); collection_status.shared_memory = options_shared_memory(options); collection_status.buffer_count = options_buffer_count(options); collection_status.num_outputs = iface_num_outputs(iface); collection_status.num_states = iface_num_states(iface); collection_status.precision = iface_precision(iface); collection_status.pointer_size = iface_pointer_size(iface); collection_status.parallel_models = iface_parallel_models(iface); if(collection_status.num_outputs){ collection_status.output_names = iface_outputs(iface); collection_status.output_num_quantities = iface_output_num_quantities(iface); } else{ collection_status.output_names = NULL; collection_status.output_num_quantities = NULL; } if(collection_status.shared_memory && collection_status.num_outputs){ unsigned int modelid; unsigned int outputid; output = (output_t*)malloc(collection_status.num_models * collection_status.num_outputs * sizeof(output_t)); if(!output){ ERROR(OUT_OF_MEMORY_ERR_MSG); } for(modelid=0;modelid<collection_status.num_models;modelid++){ for(outputid=0;outputid<collection_status.num_outputs;outputid++){ output[modelid*collection_status.num_outputs + outputid].data = (double*)malloc(BASE_BUFFER_SIZE * sizeof(double) * collection_status.output_num_quantities[outputid]); if(!output[modelid*collection_status.num_outputs + outputid].data){ ERROR(OUT_OF_MEMORY_ERR_MSG); } output[modelid*collection_status.num_outputs + outputid].allocated = BASE_BUFFER_SIZE; output[modelid*collection_status.num_outputs + outputid].samples = 0; } } if(pthread_mutex_init(&collection_status.alloc_mutex, NULL)){ ERROR("Unable to initialize allocation mutex.\n"); } pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); for(i=0;i<NUM_THREADS;i++){ if (0 != pthread_create(&collection_status.collector[i], &attr, collect_data, i)) { collection_status.initialized = 0; ERROR("Unable to create collection thread.\n"); } } pthread_attr_destroy(&attr); } } check_for_error(); /* Sleep for 0.1 seconds */ usleep(1e5); }
int main (int argc, char *argv[]){ if ( argc != 3 ){ die("usage: client hostname"); } int sockfd, ret, slen; char buf[MAX]; struct addrinfo hints, *servinfo, *p; struct sockaddr_in s_server; packet_header send_packet; const char *port = argv[2]; slen = sizeof(s_server); bzero (&s_server,sizeof(s_server)); s_server.sin_family = AF_INET; s_server.sin_addr.s_addr = inet_addr (argv[1]); //inet_addr not recommended s_server.sin_port = htons (atoi(argv[2])); printf ("...booting up client...\n"); sockfd = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (sockfd == -1) { die("socket()"); } //printf ("send message to UDP echo server:\n"); //fgets (buf, MAX, stdin); printf ("send syn\n"); send_packet.syn_flag = 1; memcpy (&buf, &send_packet, sizeof (send_packet)); ret = sendto (sockfd, buf, MAX, 0, (struct sockaddr*)&s_server, slen); check_for_error (ret, "sendto()"); printf ("send ack\n"); bzero (&send_packet, sizeof (send_packet)); send_packet.ack_flag = 1; memcpy (&buf, &send_packet, sizeof (send_packet)); ret = sendto (sockfd, buf, MAX, 0, (struct sockaddr*)&s_server, slen); check_for_error (ret, "sendto()"); sleep (2); printf ("send fin\n"); bzero (&send_packet, sizeof (send_packet)); send_packet.fin_flag = 1; memcpy (&buf, &send_packet, sizeof (send_packet)); ret = sendto (sockfd, buf, MAX, 0, (struct sockaddr*)&s_server, slen); check_for_error (ret, "sendto()"); ret = sendto (sockfd, buf, MAX, 0, (struct sockaddr*)&s_server, slen); check_for_error (ret, "sendto()"); sleep (2); printf ("send ack\n"); bzero (&send_packet, sizeof (send_packet)); send_packet.ack_flag = 1; memcpy (&buf, &send_packet, sizeof (send_packet)); ret = sendto (sockfd, buf, MAX, 0, (struct sockaddr*)&s_server, slen); check_for_error (ret, "sendto()"); //ret = recvfrom (sockfd, buf, MAX, 0, (struct sockaddr*)&s_server, &slen); //check_for_error (ret, "recvfrom()"); //printf ("==response==\n%s\n", buf); printf ("goodbye.\n"); close (sockfd); return 0; }
/** * Synchronize all wordlists with the current session. */ static VALUE aspell_save_all_wordlists(VALUE self) { AspellSpeller *speller = get_speller(self); aspell_speller_save_all_word_lists(speller); check_for_error(speller); return self; }
bool Bug1174Layer::init() { if (BugsTestBase::init()) { // // seed // std::srand(0); Vec2 A,B,C,D,p1,p2,p3,p4; float s,t; int err=0; int ok=0; // // Test 1. // log("Test1 - Start"); for( int i=0; i < 10000; i++) { // A | b // ----- // c | d float ax = CCRANDOM_0_1() * -5000; float ay = CCRANDOM_0_1() * 5000; // a | b // ----- // c | D float dx = CCRANDOM_0_1() * 5000; float dy = CCRANDOM_0_1() * -5000; // a | B // ----- // c | d float bx = CCRANDOM_0_1() * 5000; float by = CCRANDOM_0_1() * 5000; // a | b // ----- // C | d float cx = CCRANDOM_0_1() * -5000; float cy = CCRANDOM_0_1() * -5000; A = Vec2(ax,ay); B = Vec2(bx,by); C = Vec2(cx,cy); D = Vec2(dx,dy); if( Vec2::isLineIntersect( A, D, B, C, &s, &t) ) { if( check_for_error(A, D, B, C, s, t) ) err++; else ok++; } } log("Test1 - End. OK=%i, Err=%i", ok, err); // // Test 2. // log("Test2 - Start"); p1 = Vec2(220,480); p2 = Vec2(304,325); p3 = Vec2(264,416); p4 = Vec2(186,416); s = 0.0f; t = 0.0f; if( Vec2::isLineIntersect(p1, p2, p3, p4, &s, &t) ) check_for_error(p1, p2, p3, p4, s,t ); log("Test2 - End"); // // Test 3 // log("Test3 - Start"); ok=0; err=0; for( int i=0;i<10000;i++) { // A | b // ----- // c | d float ax = CCRANDOM_0_1() * -500; float ay = CCRANDOM_0_1() * 500; p1 = Vec2(ax,ay); // a | b // ----- // c | D float dx = CCRANDOM_0_1() * 500; float dy = CCRANDOM_0_1() * -500; p2 = Vec2(dx,dy); ////// float y = ay - ((ay - dy) /2.0f); // a | b // ----- // C | d float cx = CCRANDOM_0_1() * -500; p3 = Vec2(cx,y); // a | B // ----- // c | d float bx = CCRANDOM_0_1() * 500; p4 = Vec2(bx,y); s = 0.0f; t = 0.0f; if( Vec2::isLineIntersect(p1, p2, p3, p4, &s, &t) ) { if( check_for_error(p1, p2, p3, p4, s,t ) ) err++; else ok++; } } log("Test3 - End. OK=%i, err=%i", ok, err); return true; } return false; }
static void process_item(GtkTreeIter *iter, Settings *user_settings, gboolean skip_done, int is_first) { gchar *in_file, *out_full, *ancillary_file, *meta_file, *status, *polsarpro_aux_info, *interferogram_file, *coherence_file, *slave_metadata_file, *baseline_file, *uavsar_type; int pid, isPolSARPro = FALSE; pid = getpid(); gtk_tree_model_get(GTK_TREE_MODEL(list_store), iter, COL_INPUT_FILE, &in_file, COL_ANCILLARY_FILE, &ancillary_file, COL_METADATA_FILE, &meta_file, COL_OUTPUT_FILE, &out_full, COL_STATUS, &status, COL_POLSARPRO_INFO, &polsarpro_aux_info, COL_INTERFEROGRAM, &interferogram_file, COL_COHERENCE, &coherence_file, COL_SLAVE_METADATA, &slave_metadata_file, COL_BASELINE, &baseline_file, COL_UAVSAR_TYPE, &uavsar_type, -1); int image_data_type = extract_image_data_type(polsarpro_aux_info); if (image_data_type >= 0 && image_data_type < 3) isPolSARPro = TRUE; if (strcmp(status, "Done") != 0 || !skip_done) { //char *in_basename = stripExt(in_file); char *out_basename = stripExt(out_full); char *out_nameonly = get_basename(out_full); char *output_dir = getPath(out_full); char *config_file, *cmd_output, *tmp_dir, *intermediates_file; gchar *err_string; /* Ensure we have access to the output directory */ if (!have_access_to_dir(output_dir, &err_string)) { /* We don't -- issue a message in the "Status" column. */ gtk_list_store_set(list_store, iter, COL_STATUS, err_string, -1); g_free(err_string); //free(in_basename); free(out_basename); free(output_dir); return; } tmp_dir = MALLOC(sizeof(char)* (strlen(output_dir)+strlen(out_nameonly)+32)); if (strlen(output_dir) > 0) { sprintf(tmp_dir, "%s%c%s-%s", output_dir, DIR_SEPARATOR, out_nameonly, time_stamp_dir()); } else { sprintf(tmp_dir, "%s-%s", out_nameonly, time_stamp_dir()); } create_clean_dir(tmp_dir); set_asf_tmp_dir(tmp_dir); config_file = settings_to_config_file(user_settings, in_file, ancillary_file, meta_file, out_full, output_dir, tmp_dir, polsarpro_aux_info, interferogram_file, coherence_file, slave_metadata_file, baseline_file, uavsar_type); if (!config_file) { err_string = "Error creating configuration file."; gtk_list_store_set(list_store, iter, COL_STATUS, err_string, -1); free(out_basename); free(output_dir); free(tmp_dir); return; } cmd_output = do_convert(pid, iter, config_file, TRUE, user_settings->keep_files, &intermediates_file); err_string = check_for_error(cmd_output); if (err_string) { // unsuccessful gtk_list_store_set(list_store, iter, COL_STATUS, err_string, COL_LOG, cmd_output, -1); FREE(err_string); } else { // successful -- move to "completed" list GtkTreeIter completed_iter; move_to_completed_files_list(iter, &completed_iter, cmd_output, intermediates_file); set_thumbnail(&completed_iter, tmp_dir, out_full, isPolSARPro); input_data_formats_changed(); refresh_file_names(); } // for subsequent runs, save the imported dem & mask settings_update_dem(user_settings, output_dir); settings_update_mask(user_settings, output_dir); free(config_file); free(out_basename); free(output_dir); free(out_nameonly); free(intermediates_file); g_free(cmd_output); if (!user_settings->keep_files) remove_dir(tmp_dir); free(tmp_dir); } g_free(status); g_free(out_full); g_free(ancillary_file); g_free(meta_file); g_free(in_file); g_free(polsarpro_aux_info); }
int main(int argc, const char *argv[]) { AspellCanHaveError * ret; AspellSpeller * speller; int have; char word[81]; char * p; char * word_end; AspellConfig * config; if (argc < 2) { printf("Usage: %s <language> [<size>|- [[<jargon>|- [<encoding>]]]\n", argv[0]); return 1; } config = new_aspell_config(); aspell_config_replace(config, "lang", argv[1]); if (argc >= 3 && argv[2][0] != '-' && argv[2][1] != '\0') aspell_config_replace(config, "size", argv[2]); if (argc >= 4 && argv[3][0] != '-') aspell_config_replace(config, "jargon", argv[3]); if (argc >= 5 && argv[4][0] != '-') aspell_config_replace(config, "encoding", argv[4]); ret = new_aspell_speller(config); delete_aspell_config(config); if (aspell_error(ret) != 0) { printf("Error: %s\n",aspell_error_message(ret)); delete_aspell_can_have_error(ret); return 2; } speller = to_aspell_speller(ret); config = aspell_speller_config(speller); fputs("Using: ", stdout); fputs(aspell_config_retrieve(config, "lang"), stdout); fputs("-", stdout); fputs(aspell_config_retrieve(config, "jargon"), stdout); fputs("-", stdout); fputs(aspell_config_retrieve(config, "size"), stdout); fputs("-", stdout); fputs(aspell_config_retrieve(config, "module"), stdout); fputs("\n\n", stdout); puts("Type \"h\" for help.\n"); while (fgets(word, 80, stdin) != 0) { /* remove trailing spaces */ word_end = strchr(word, '\0') - 1; while (word_end != word && (*word_end == '\n' || *word_end == ' ')) --word_end; ++word_end; *word_end = '\0'; putchar('\n'); switch (word[0]) { case '\0': break; case 'h': puts( "Usage: \n" " h(elp) help\n" " c <word> check if a word is the correct spelling\n" " s <word> print out a list of suggestions for a word\n" " a <word> add a word to the personal word list\n" " i <word> ignore a word for the rest of the session\n" " d <file> spell checks a document\n" " p dumps the personal word list\n" " P dumps the session word list\n" " m dumps the main word list\n" " o <option> <value> sets a config option\n" " r <option> retrieves a config option\n" " l <option> retrieves a config option as a list\n" " S saves all word lists\n" " C clear the curent sesstion word list\n" " x quite\n" ); break; case 'p': print_word_list(speller, aspell_speller_personal_word_list(speller), '\n'); break; case 'P': print_word_list(speller, aspell_speller_session_word_list(speller), '\n'); break; case 'm': print_word_list(speller, aspell_speller_main_word_list(speller), '\n'); break; case 'S': aspell_speller_save_all_word_lists(speller); check_for_error(speller); break; case 'C': aspell_speller_clear_session(speller); check_for_error(speller); break; case 'x': goto END; case 'c': if (strlen(word) < 3) { printf("Usage: %c <word>\n", word[0]); } else { have = aspell_speller_check(speller, word + 2, -1); if (have == 1) puts("correct"); else if (have == 0) puts("incorrect"); else printf("Error: %s\n", aspell_speller_error_message(speller)); } break; case 's': if (strlen(word) < 3) { printf("Usage: %c <word>\n", word[0]); } else { print_word_list(speller, aspell_speller_suggest(speller, word + 2, -1), '\n'); } break; case 'a': if (strlen(word) < 3) { printf("Usage: %c <word>\n", word[0]); } else { aspell_speller_add_to_personal(speller, word + 2, -1); check_for_error(speller); } break; case 'i': if (strlen(word) < 3) { printf("Usage: %c <word>\n", word[0]); } else { aspell_speller_add_to_session(speller, word + 2, -1); check_for_error(speller); } break; case 'o': word[80] = '\0'; /* to make sure strchr doesn't run off end of string */ p = strchr(word + 3, ' '); if (strlen(word) < 3 || p == 0) { printf("Usage: %c <option> <value>\n", word[0]); } else { *p = '\0'; ++p; aspell_config_replace(config, word + 2, p); check_for_config_error(config); } break; case 'r': if (strlen(word) < 3) { printf("Usage: %c <option>\n", word[0]); } else { const char * val = aspell_config_retrieve(config, word + 2); check_for_config_error(config); if (val) printf("%s = \"%s\"\n", word + 2, val); } break; case 'l': if (strlen(word) < 3) { printf("Usage: %c <option>\n", word[0]); } else { AspellStringList * lst = new_aspell_string_list(); AspellMutableContainer * lst0 = aspell_string_list_to_mutable_container(lst); AspellStringEnumeration * els; const char * val; aspell_config_retrieve_list(config, word + 2, lst0); check_for_config_error(config); els = aspell_string_list_elements(lst); printf("%s:\n", word + 2); while ( (val = aspell_string_enumeration_next(els)) != 0) printf(" %s\n", val); delete_aspell_string_enumeration(els); delete_aspell_string_list(lst); } break; case 'd': if (strlen(word) < 3) { printf("Usage: %c <file>\n", word[0]); } else { check_document(speller, word + 2); printf("\n"); } break; default: printf("Unknown Command: %s\n", word); } putchar('\n'); } END: delete_aspell_speller(speller); return 0; }
/** * Remove all words inside session. */ static VALUE aspell_clear_session(VALUE self) { AspellSpeller *speller = get_speller(self); aspell_speller_clear_session(speller); check_for_error(speller); return self; }