void Image<DataType>::loadVox(const char *filename) { std::ifstream in(filename); if (!in) { CGoGNerr << "Mesh_Base::loadVox: Unable to open file " << CGoGNendl; exit(0); } m_SX = 1.0 ; m_SY = 1.0 ; m_SZ = 1.0 ; // read encoding while(in.good()) { char line[1024] ; in.getline(line, 1024) ; std::istringstream line_input(line) ; std::string keyword ; line_input >> keyword ; if(keyword == "encoding") { std::string encoding_str ; line_input >> encoding_str ; if(encoding_str != "GRAY") { CGoGNerr << "loadVox : invalid encoding: \'" << encoding_str << "\'" << CGoGNendl ; exit(0) ; } } else if(keyword == "nu") {
bool loadPointCloud_ply(char* fileName, PointCloudPtr_RGB cloud){ std::ifstream input(fileName) ; if(input.fail()) { std::cout<<"could not open file!" << std::endl; return false; } int num_header = 14; int num_points = 0; // this line contains point number int line_num = 3; for (int i=0; i<num_header; ++i) { std::string line; getline(input, line); if (i==line_num) { std::istringstream line_input(line); std::string dummy1; std::string dummy2; line_input >> dummy1 >> dummy2 >>num_points; printf("num_points:%d\n",num_points); } }
ucci_comm_enum boot_line() { char line_str[LINE_INPUT_MAX_CHAR]; open_pipe(); while (!line_input(line_str)) { idle(); } if (strcmp(line_str, "ucci") == 0) { return UCCI_COMM_UCCI; } else { return UCCI_COMM_NONE; } }
ucci_comm_enum busy_line() { char line_str[LINE_INPUT_MAX_CHAR]; if (line_input(line_str)) { if (strcmp(line_str, "stop") == 0) { return UCCI_COMM_STOP; } else if (strcmp(line_str, "quit") == 0) { return UCCI_COMM_QUIT; } else { return UCCI_COMM_NONE; } } else { return UCCI_COMM_NONE; } }
int begin_http_relay( SOCKET s ) { char buf[1024]; int result; char *auth_what; g_debug("begin_http_relay()\n"); if (sendf(s,"CONNECT %s:%d HTTP/1.0\r\n", dest_host, dest_port) < 0) return START_ERROR; if (proxy_auth_type == PROXY_AUTH_BASIC && basic_auth (s) < 0) return START_ERROR; if (sendf(s,"\r\n") < 0) return START_ERROR; if ( line_input(s, buf, sizeof(buf)) < 0 ) { g_debug("failed to read http response.\n"); return START_ERROR; } if (!strchr(buf, ' ')) { g_error ("Unexpected http response: '%s'.\n", buf); return START_ERROR; } result = atoi(strchr(buf,' ')); switch ( result ) { case 200: g_debug("connected, start user session.\n"); break; case 302: do { if (line_input(s, buf, sizeof(buf))) break; downcase(buf); if (expect(buf, "Location: ")) { relay_host = cut_token(buf, "//"); cut_token(buf, "/"); relay_port = atoi(cut_token(buf, ":")); } } while (strcmp(buf,"\r\n") != 0); return START_RETRY; case 401: case 407: /*TODO - authentication*/ if (proxy_auth_type != PROXY_AUTH_NONE) { g_error("Authentication failed.\n"); return START_ERROR; } auth_what = (result == 401) ? "WWW-Authenticate:" : "Proxy-Authenticate:"; do { if ( line_input(s, buf, sizeof(buf)) ) { break; } downcase(buf); if (expect(buf, auth_what)) { char *scheme, *realm; scheme = cut_token(buf, " "); realm = cut_token(scheme, " "); if ( scheme == NULL || realm == NULL ) { g_debug("Invalid format of %s field.", auth_what); return START_ERROR; } if (expect(scheme, "basic")) { proxy_auth_type = PROXY_AUTH_BASIC; } else { g_debug("Unsupported authentication type: %s", scheme); } } } while (strcmp(buf,"\r\n") != 0); if ( proxy_auth_type == PROXY_AUTH_NONE ) { g_debug("Can't find %s in response header.", auth_what); return START_ERROR; } else { return START_RETRY; } default: g_debug("http proxy is not allowed.\n"); return START_ERROR; } do { if ( line_input(s, buf, sizeof(buf) ) ) { g_debug("Can't skip response headers\n"); return START_ERROR; } } while ( strcmp(buf,"\r\n") != 0 ); return START_OK; }
ucci_comm_enum idle_line(ucci_comm_struct *ucs_command) { int i; char *line_str; ucci_comm_enum uce_return_value = UCCI_COMM_NONE; while (!line_input(command_line_str)) { idle(); } line_str = command_line_str; if (strcmp(line_str, "isready") == 0) { /* isready */ return UCCI_COMM_ISREADY; } else if (strncmp(line_str, "setoption ", 10) == 0) { /* setoption <option> [<arguments>] */ line_str += 10; if (strncmp(line_str, "newgame", 7) == 0) { ucs_command->option.uo_type = UCCI_OPTION_NEWGAME; } else { ucs_command->option.uo_type = UCCI_OPTION_NONE; } return UCCI_COMM_SETOPTION; } else if (strncmp(line_str, "position ", 9) == 0) { /* position {<special_position> | fen <fen_string>} [moves <move_list>] */ line_str += 9; if (strncmp(line_str, "fen ", 4) == 0) { ucs_command->position.fen_str = line_str + 4; } else { return UCCI_COMM_NONE; } line_str = strstr(line_str, " moves "); ucs_command->position.move_num = 0; if (line_str != NULL) { line_str += 7; ucs_command->position.move_num = ((strlen(line_str) + 1) / 5); for (i = 0; i < ucs_command->position.move_num; ++i) { coord_list[i] = *(long *) line_str; line_str += 5; } ucs_command->position.coord_list = coord_list; } return UCCI_COMM_POSITION; } else if(strncmp(line_str, "banmoves ", 9) == 0) { /* banmoves <move_list> */ line_str += 9; ucs_command->ban_moves.move_num = ((strlen(line_str) + 1) / 5); for (i = 0; i < ucs_command->ban_moves.move_num; ++i) { coord_list[i] = *(long *) line_str; line_str += 5; } ucs_command->ban_moves.coord_list = coord_list; return UCCI_COMM_BANMOVES; } else if (strncmp(line_str, "go ", 3) == 0) { /* go [ponder] {infinite | depth <depth> | time <time> [movestogo <moves_to_go> | increment <inc_time>]} */ line_str += 3; if (strncmp(line_str, "ponder ", 7) == 0) { line_str += 7; uce_return_value = UCCI_COMM_GOPONDER; } else if (strncmp(line_str, "draw ", 5) == 0) { line_str += 5; } else { uce_return_value = UCCI_COMM_GO; } if (strncmp(line_str, "time ", 5) == 0) { line_str += 5; ucs_command->search.depth_time.time = read_digit(line_str, 3600000); } else if (strncmp(line_str, "depth ", 6) == 0) { line_str += 6; ucs_command->search.ut_mode = UCCI_TIME_DEPTH; ucs_command->search.depth_time.depth = read_digit(line_str, UCCI_MAX_DEPTH - 1); } else { ucs_command->search.ut_mode = UCCI_TIME_DEPTH; ucs_command->search.depth_time.depth = UCCI_MAX_DEPTH - 1; } return uce_return_value; } else if (strcmp(line_str, "stop") == 0) { /* stop */ return UCCI_COMM_STOP; } else if (strcmp(line_str, "quit") == 0) { /* quit */ return UCCI_COMM_QUIT; } else { return UCCI_COMM_NONE; } }