deconvolutional_layer parse_deconvolutional(list *options, size_params params) { int n = option_find_int(options, "filters",1); int size = option_find_int(options, "size",1); int stride = option_find_int(options, "stride",1); char *activation_s = option_find_str(options, "activation", "logistic"); ACTIVATION activation = get_activation(activation_s); int batch,h,w,c; h = params.h; w = params.w; c = params.c; batch=params.batch; if(!(h && w && c)) error("Layer before deconvolutional layer must output image."); deconvolutional_layer layer = make_deconvolutional_layer(batch,h,w,c,n,size,stride,activation); char *weights = option_find_str(options, "weights", 0); char *biases = option_find_str(options, "biases", 0); parse_data(weights, layer.filters, c*n*size*size); parse_data(biases, layer.biases, n); #ifdef GPU if(weights || biases) push_deconvolutional_layer(layer); #endif return layer; }
convolutional_layer parse_convolutional(list *options, size_params params) { int n = option_find_int(options, "filters",1); int size = option_find_int(options, "size",1); int stride = option_find_int(options, "stride",1); int pad = option_find_int(options, "pad",0); char *activation_s = option_find_str(options, "activation", "logistic"); ACTIVATION activation = get_activation(activation_s); int batch,h,w,c; h = params.h; w = params.w; c = params.c; batch=params.batch; if(!(h && w && c)) error("Layer before convolutional layer must output image."); int batch_normalize = option_find_int_quiet(options, "batch_normalize", 0); int binary = option_find_int_quiet(options, "binary", 0); int xnor = option_find_int_quiet(options, "xnor", 0); convolutional_layer layer = make_convolutional_layer(batch,h,w,c,n,size,stride,pad,activation, batch_normalize, binary, xnor); layer.flipped = option_find_int_quiet(options, "flipped", 0); layer.dot = option_find_float_quiet(options, "dot", 0); char *weights = option_find_str(options, "weights", 0); char *biases = option_find_str(options, "biases", 0); parse_data(weights, layer.filters, c*n*size*size); parse_data(biases, layer.biases, n); #ifdef GPU if(weights || biases) push_convolutional_layer(layer); #endif return layer; }
int handle_data(int fd1, int fd2, int fd3) { char buf1[MAX]; char buf2[MAX]; int data1[3]; int data2[3]; int data3[3]; char result[MAX]; read_line(fd1,buf1,sizeof(buf1));//读第一行 read_line(fd2,buf2,sizeof(buf2)); if(strcmp(buf1,"begin") != 0 || strcmp(buf2,"begin") != 0)//只要buf1 buf2中有一个不是以begin开头的 就不成立 { return -1; } write(fd3,"begin",strlen("begin"));//把begin写到fd3所指的文件中去 write(fd3,"\n",1);//换行 memset(buf1,0,sizeof(buf1));//清空buf指针所指的内存中的内容 memset(buf2,0,sizeof(buf2)); read_line(fd1,buf1,sizeof(buf1));//读下一行 read_line(fd2,buf2,sizeof(buf2)); while(strcmp(buf1,"end") != 0 && strcmp(buf2,"end") != 0)//当buf1 buf2都没有到最后一行(end)时,进入循环 { parse_data(buf1,data1);字符串转换成数字 parse_data(buf2,data2); add(data1,data2,data3); sprintf(result,"%d %d %d%c",data3[0],data3[1],data3[2],'\n'); write(fd3,result,strlen(result));//将进行加法运算后的数据写进fd3所指向的文件中 memset(buf1,0,sizeof(buf1)); memset(buf2,0,sizeof(buf2)); read_line(fd1,buf1,sizeof(buf1)); read_line(fd2,buf2,sizeof(buf2)); } write(fd3,"end",strlen("end"));//将fd3所指的文件在最后面添上end 以表结束 write(fd3,"\n",1);//换行符 }
static int parse_file(const char *name) { int fd, size, result = 0; char *data = 0; fd = open(name, O_RDONLY); if (fd < 0) return 0; size = lseek(fd, 0, SEEK_END); if (size < 0) goto parse_fail; if (lseek(fd, 0, SEEK_SET) != 0) goto parse_fail; data = (char *)malloc(size+1); if (!data) goto parse_fail; if (read(fd, data, size) != size) goto parse_fail; data[size] = '\0'; result = parse_data(data, &confParser); parse_fail: if (data) free(data); close(fd); return result; }
void CheckMKClient::send(connection_data con) { try { NSC_DEBUG_MSG_STD("Connection details: " + con.to_string()); if (con.ssl.enabled) { #ifndef USE_SSL NSC_LOG_ERROR_STD(_T("SSL not avalible (compiled without USE_SSL)")); return response; #endif } socket_helpers::client::client<check_mk::client::protocol> client(con, boost::shared_ptr<client_handler>(new client_handler())); client.connect(); std::string dummy; check_mk::packet packet = client.process_request(dummy); boost::optional<scripts::command_definition<lua::lua_traits> > cmd = scripts_->find_command("check_mk", "c_callback"); if (cmd) { parse_data(cmd->information, cmd->function, packet); } else { NSC_LOG_ERROR_STD("No check_mk callback found!"); } //lua_runtime_->on_query() client.shutdown(); } catch (std::runtime_error &e) { NSC_LOG_ERROR_EXR("Failed to send", e); } catch (std::exception &e) { NSC_LOG_ERROR_EXR("Failed to send", e); } catch (...) { NSC_LOG_ERROR_EX("Failed to send"); } }
int main(int argc, char *argv[]) { int s, t, len; struct sockaddr_un remote; char str[BUFLEN]; char sock_path[256] = { '\0' }; haproxy_dir = getenv("OPENSHIFT_HAPROXY_DIR"); app_name = getenv("OPENSHIFT_APP_NAME"); gear_uuid = getenv("OPENSHIFT_GEAR_UUID"); const char *gear_dns = getenv("OPENSHIFT_GEAR_DNS"); const char *beg = strchr(gear_dns, '-'); const char *end = strchr(gear_dns, '.'); gear_namespace = (char *)malloc(end - beg + 1); strncpy(gear_namespace, beg + 1, end - beg - 1); std::cout << "Gear dns:" << gear_dns << std::endl; std::cout << "Gear namespace:" << gear_namespace << std::endl; snprintf(sock_path, 256, "%s/run/stats", haproxy_dir); signal(SIGPIPE, SIG_IGN); while (1) { if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { perror("socket"); exit(1); } std::cout << "Gathering stats from HAProxy" << std::endl; std::cout << "============================================" << std::endl << std::endl; remote.sun_family = AF_UNIX; strcpy(remote.sun_path, sock_path); len = strlen(remote.sun_path) + sizeof(remote.sun_family); if (connect(s, (struct sockaddr *)&remote, len) == -1) { perror("connect"); exit(1); } //printf("Connected!\n"); if (send(s, STATUS_CMD, strlen(STATUS_CMD), 0) == -1) { perror("send"); exit(1); } std::string data = ""; while ((t = recv(s, str, BUFLEN, 0)) > 0) { //write(STDOUT_FILENO, str, t); data.append(str, t); } parse_data(data); if (t < 0) perror("recv"); close(s); sleep(3); } return 0; }
static void cgi_init_get() { char* buf; if ((buf = getenv("QUERY_STRING")) != NULL && *buf) { has_get = parse_data(buf, GET); } }
void parse_include(char *lumpname) { int lumpnum; char *lump, *end; char *saved_rover; if(-1 == (lumpnum = W_GetNumForName(lumpname)) ) { script_error("include lump '%s' not found!\n", lumpname); return; } lump = W_CacheLumpNum(lumpnum, PU_STATIC); // realloc bigger for NULL at end lump = Z_Realloc(lump, W_LumpLength(lumpnum)+10, PU_STATIC, NULL); saved_rover = rover; // save rover during include rover = lump; end = lump+W_LumpLength(lumpnum); *end = 0; // preprocess the include // we assume that it does not include sections or labels or // other nasty things process_find_char(lump, 0); // now parse the lump parse_data(lump, end); // restore rover rover = saved_rover; // free the lump Z_Free(lump); }
int main() { parse_data(); while(T <= 10){ printf("Test %d:\n", T++); N = extract_int(); extract_string(bracets + 1); M = extract_int(); build(1, 1, N); while(M--){ operation = extract_int(); if(!operation){ printf("%s\n", !NODES[1].opening_excessive && !NODES[1].closing_excessive ? "YES" : "NO"); continue; } // flip it // and let the update propagate through segmented tree. bracets[operation] = bracets[operation] == ')' ? '(' : ')'; update(1, 1, N, operation); } } return 0; }
static gpointer search_artist_thread(SearchData *data) { XmrService *srv = xmr_service_new(); GString *result_data = g_string_new(""); gchar *escape_keyword = curl_escape(data->keyword, 0); gchar *url = g_strdup_printf(SEARCH_URL"%s", escape_keyword); gint result = xmr_service_get_url_data(srv, url, result_data); g_object_unref(srv); if (result == CURLE_OK) parse_data(data->box, result_data); else post_event(data->box, EVENT_NETWORK_ERROR, NULL); g_free(url); curl_free(escape_keyword); g_string_free(result_data, TRUE); post_event(data->box, EVENT_FINISH, NULL); g_free(data->keyword); g_free(data); return NULL; }
int16 get_det_read(int8 store, int8 display) { int8 r, record; for(r=0;r<3;++r){ record = det_read(store, display); if(record==2) break; else{ fprintf(COM_A, "@RTY,%u\r\n", (r+1)); output_bit(VDET,OFF); delay_ms(1000); output_bit(VDET,ON); delay_ms(1000); cmd='K'; arg=detector_ch; det_cmd(); delay_ms(1000); cmd='L'; arg=detector_li; det_cmd(); } } parse_data(); data_available = TRUE; macro_flag = 900; return (record); }
int16 parse_temp() { int16 temp = 0; temp = parse_data(); return (temp); }
retvalue tracking_printall(trackingdb t) { struct cursor *cursor; retvalue result, r; struct trackedpackage *pkg; const char *key, *value, *data; size_t datalen; r = table_newglobalcursor(t->table, &cursor); if (!RET_IS_OK(r)) return r; result = RET_NOTHING; while (cursor_nextpair(t->table, cursor, &key, &value, &data, &datalen)) { r = parse_data(key, value, data, datalen, &pkg); if (RET_IS_OK(r)) { print(t->codename, pkg); trackedpackage_free(pkg); } RET_UPDATE(result, r); } r = cursor_close(t->table, cursor); RET_ENDUPDATE(result, r); return result; }
/* Look up the unique id in the new file, if it is there, compare the * last change times, and ensure that the database uses the newer of * the two */ static int seen_merge_cb(void *rockp, const char *key, size_t keylen, const char *newdata, size_t newlen) { int r = 0; struct seen *seendb = (struct seen *)rockp; struct seendata oldsd, newsd; char *uniqueid = xstrndup(key, keylen); int dirty = 0; parse_data(newdata, newlen, &newsd); if (seen_lockread(seendb, uniqueid, &oldsd)) { dirty = 1; /* no record */ } else { if (newsd.lastuid > oldsd.lastuid) dirty = 1; if (newsd.lastread > oldsd.lastread) dirty = 1; } if (dirty) { /* write back data from new entry */ r = seen_write(seendb, uniqueid, &newsd); } free(uniqueid); return r; }
retvalue tracking_tidyall(trackingdb t) { struct cursor *cursor; retvalue result, r; struct trackedpackage *pkg; const char *key, *value, *data; size_t datalen; r = table_newglobalcursor(t->table, &cursor); if (!RET_IS_OK(r)) return r; result = RET_NOTHING; while (cursor_nextpair(t->table, cursor, &key, &value, &data, &datalen)) { r = parse_data(key, value, data, datalen, &pkg); if (RET_WAS_ERROR(r)) { result = r; break; } r = trackedpackage_tidy(t, pkg); RET_UPDATE(result, r); r = tracking_saveatcursor(t, cursor, pkg); RET_UPDATE(result, r); trackedpackage_free(pkg); } r = cursor_close(t->table, cursor); RET_UPDATE(result, r); return result; }
void parse_data(aClient *robotptr) { int next; while((robotptr->read < robotptr->write) && ((robotptr->buffer[robotptr->read] == '\r') || (robotptr->buffer[robotptr->read] == '\n'))) robotptr->read++; for(next=robotptr->read; next<=robotptr->write; next++) { if ((robotptr->buffer[next] == '\r') || (robotptr->buffer[next] == '\n')) break; } if (next<robotptr->write) { robotptr->buffer[next]=0; next++; parse_line(robotptr); robotptr->read=next; parse_data(robotptr); } if (robotptr->read == robotptr->write) { robotptr->read=robotptr->write=0; } else { bcopy((robotptr->buffer + robotptr->read), (robotptr->buffer), (robotptr->write-robotptr->read)); robotptr->write-=robotptr->read; robotptr->read=0; } }
args_t::args_t( int argc, const char * argv[] ) : output( stdout ), input( stdin ), ambig( DEFAULT_AMBIG ), data ( DEFAULT_DATA ), counts_in_name ( DEFAULT_COUNTS_IN_NAME ), quiet (false) { // skip arg[0], it's just the program name for (int i = 1; i < argc; ++i ) { const char * arg = argv[i]; if ( arg[0] == '-' && arg[1] == '-' ) { if ( !strcmp( &arg[2], "help" ) ) help(); else ERROR( "unknown argument: %s", arg ); } else if ( arg[0] == '-' ) { if ( !strcmp( &arg[1], "h" ) ) help(); else if ( arg[1] == 'o' ) parse_output( next_arg (i, argc, argv) ); else if ( arg[1] == 'a') parse_ambig( next_arg (i, argc, argv) ); else if ( arg[1] == 't') parse_data ( next_arg (i, argc, argv) ); else if ( arg[1] == 'd') parse_counts_in_name( next_arg (i, argc, argv) ); else if ( arg[1] == 'q') parse_quiet ( ); else ERROR( "unknown argument: %s", arg ); } else if (i == argc-1) { parse_input (arg); } else { ERROR( "unknown argument: %s", arg ); } } }
public: ethernet_frame(::boost::uint8_t const* pkt, ::boost::uint32_t sz) : p_hdr_(0), p_hdr_8021q_(0), p_data_(0), data_sz_(0) { parse_data(pkt, sz); }
connected_layer parse_connected(list *options, size_params params) { int output = option_find_int(options, "output",1); char *activation_s = option_find_str(options, "activation", "logistic"); ACTIVATION activation = get_activation(activation_s); connected_layer layer = make_connected_layer(params.batch, params.inputs, output, activation); char *weights = option_find_str(options, "weights", 0); char *biases = option_find_str(options, "biases", 0); parse_data(biases, layer.biases, output); parse_data(weights, layer.weights, params.inputs*output); #ifdef GPU if(weights || biases) push_connected_layer(layer); #endif return layer; }
void on_telemetry_received() { char buf[200]; size_t const data_len = get_telemetry_receiver_buffer_length(); read_telemetry_data(buf,data_len); for (size_t i = 0; i < data_len; ++i){ parse_data(buf[i]); } }
void A2::read_file() { string data; ifstream file; file.open("pages.txt"); getline(file, data); file.close(); parse_data(data); }
int parse_type(t_info info, char *buffer, int *step, t_map *map) { if (info.type == COMMENTARY_TYPE) printf("%s\n", buffer); else if (info.type == COMMAND_TYPE) return (parse_command(buffer, step)); else parse_data(buffer, step, map); return (info.command); }
int main() { parser_t *p = new_simple_parser(stub, 0, 0); int i; for (i = 0; i < count(bufs); i++) { expected_bytes += strlen(bufs[i]); parse_data(p, 0, bufs[i], strlen(bufs[i])); } for (i = 0; i < strlen(otherstring); i++) { expected_bytes ++; parse_data(p, 0, otherstring + i, 1); } if (expect_id != count(expects)) { fprintf(stderr, "FAILED: missed last events (%ld of %ld)\n", (long int) (count(expects) - expect_id), (long int) (count(expects))); } return failed; }
static void cgi_init_post() { char * buf; if((buf = getenv("CONTENT_LENGTH")) != NULL) { int content_length = atoi(buf); char post_buf[content_length]; read(STDIN_FILENO, post_buf, content_length); has_post = parse_data(post_buf, POST); } }
void Library::SimpleLookup(const string &str, TSearchResultList& res_list) { glong ind; res_list.reserve(ndicts()); for (gint idict=0; idict<ndicts(); ++idict) if (SimpleLookupWord(str.c_str(), ind, idict)) res_list.push_back( TSearchResult(dict_name(idict), poGetWord(ind, idict), parse_data(poGetWordData(ind, idict)))); }
retvalue tracking_get(trackingdb t, const char *sourcename, const char *version, /*@out@*/struct trackedpackage **pkg) { const char *data; size_t datalen; retvalue r; assert (pkg != NULL && sourcename != NULL && version != NULL); r = table_getpair(t->table, sourcename, version, &data, &datalen); if (!RET_IS_OK(r)) return r; return parse_data(sourcename, version, data, datalen, pkg); }
int its_get_doc(int64_t doc_num, int64_t* doc_len_out, int64_t* doc_info_len_out, unsigned char** doc_info_out, int64_t* num_doc_headers_out, int64_t** doc_header_lens_out, unsigned char*** doc_headers_out, unsigned char** doc_contents_out) { char* got_path; error_t err; int rc; size_t info_len, doc_len; unsigned char* info_data; unsigned char* doc_data; size_t next_offset; // First, move on to the next file if we need to. while( !data || cur_offset >= data_len ) { got_path = NULL; err = file_find_get_next(&file_find_state, &got_path); if( err ) { warn_if_err(err); return -1; } // No more documents! if( !got_path ) return 0; rc = do_mmap(got_path); if( rc ) return rc; } // Now, get some data from the current file. rc = parse_data(data, data_len, cur_offset, &info_len, &info_data, &doc_len, &doc_data, &next_offset); if( rc ) return rc; cur_offset = next_offset; *doc_len_out = doc_len; *doc_info_len_out = info_len; *doc_info_out = info_data; *num_doc_headers_out = 0; *doc_header_lens_out = NULL; *doc_headers_out = NULL; *doc_contents_out = doc_data; return 1; }
void http_process_reply_bytes (Call *c, char **bufp, size_t *buf_lenp) { Conn *s = c->conn; struct iovec iov; Any_Type arg; iov.iov_base = *bufp; iov.iov_len = *buf_lenp; arg.vp = &iov; event_signal (EV_CALL_RECV_RAW_DATA, (Object *) c, arg); do { switch (s->state) { case S_REPLY_STATUS: parse_status_line (c, bufp, buf_lenp); break; case S_REPLY_HEADER: parse_headers (c, bufp, buf_lenp); break; case S_REPLY_FOOTER: parse_footers (c, bufp, buf_lenp); break; case S_REPLY_DATA: if (parse_data (c, bufp, buf_lenp) && s->state < S_CLOSING) s->state = S_REPLY_DONE; break; case S_REPLY_CONTINUE: parse_headers (c, bufp, buf_lenp); break; case S_REPLY_CHUNKED: xfer_chunked (c, bufp, buf_lenp); break; case S_REPLY_DONE: return; default: fprintf (stderr, "%s.http_process_reply_bytes: bad state %d\n", prog_name, s->state); exit (1); } } while (*buf_lenp > 0 && s->state < S_CLOSING); }
void interface::read_data(){ QByteArray rawdata=my_port->readAll(); ui->txtCommData->insertPlainText(rawdata); if(ui->txtCommData->toPlainText().isEmpty()){return;} if(data_target==TPSFull_target){tps_full(ui->txtCommData->toPlainText());} else if(data_target==TPSOff_target){tps_off(ui->txtCommData->toPlainText());} else if(data_target==TPSRead_target){tps_get(ui->txtCommData->toPlainText());} else if(data_target==parse_target){parse_data(ui->txtCommData->toPlainText());} else if(data_target==INJRead_target){inj_get(ui->txtCommData->toPlainText());} else if(data_target==IGNRead_target){ign_get(ui->txtCommData->toPlainText());} else if(data_target==INJECRead_target){injec_get(ui->txtCommData->toPlainText());} }
/* * Read the bitstream on the DATA line (defined in magstripe.h) */ char *read_data(void) { int i=0; char buffer[255]; char *data = cardinfo; while(CP == 0) { if(CLK == 1) { buffer[i] = DATA; i++; while(CLK == 1); } } data = parse_data(buffer); return data; }