void tp_new_print (topoprint_t *topo, int nel, param_t *para) { FILE *OUT = para->OUT; int clen = para->seg_len; elprint_t *el = topo->elps; int i; /* header */ (void) fprintf (OUT, "%8s %6s %6s %6s %4s %4s %8s %8s %8s %8s\n", "HEADER ", "START", "STOP", "LEN", "PROB", "HP", "DARGLYS", "DCYTEXT", "DNCHARGE", "DNNEGPOS"); /* topo summary */ if (para->web == 1) { (void) fprintf (OUT, "%8s <A HREF=\"./%s-%d.png\">%3d</A> %3.2f %6.2f %6.2f %8.2f %8.2f\n", "TOPOLOGY", topo->image, topo->nr, topo->nr, topo->prob, (double) topo->kr, topo->cytext, (double) topo->nterm, topo->negpos); } else { (void) fprintf (OUT, "%8s %3d %3.2f %6.2f %6.2f %8.2f %8.2f\n", "TOPOLOGY", topo->nr, topo->prob, (double) topo->kr, topo->cytext, (double) topo->nterm, topo->negpos); } (void) fprintf (OUT, "%8s %7s %7s %8s\n", "TOPOLOGY", new_orientation((double) (topo->kr+topo->ncharge)), new_orientation(topo->cytext * (-1.0)), new_orientation((double) topo->nterm)); /* topo elements */ for (i=0; i<nel; i++) { if (i%2) { /* tmsegment (index impair) */ (void) fprintf(OUT, "%8s %6d %6d %6d %4.2f %4.2f\n", el[i].tm.type, el[i].tm.start+1, el[i].tm.stop, el[i].tm.len, el[i].tm.prob, el[i].tm.H); } else { /* loop (index pair) */ if (el[i].lo.len > clen) { /* cytext value is significant */ (void) fprintf(OUT, "%8s %6d %6d %6d (%6.2f) %6.2f\n", el[i].lo.type, el[i].lo.start+1, el[i].lo.stop, el[i].lo.len, (double) el[i].lo.kr, el[i].lo.cytext); } else if (el[i].lo.len != 0) { /* kr value is significant */ (void) fprintf(OUT, "%8s %6d %6d %6d %6.2f (%6.2f)\n", el[i].lo.type, el[i].lo.start+1, el[i].lo.stop, el[i].lo.len, (double) el[i].lo.kr, el[i].lo.cytext); } } } /* end topology */ (void) fprintf(OUT, "//\n"); return; }
void input_flight_info_from_file(int id, char file_name[], char server_host[], int server_port) { //int year, month, day, hour, minute, second; //double millisecond; double latitude, longitude, altitude; double roll = 0.0 , pitch= 0.0, yaw = 0.0; char buffer[BUFSIZE*sizeof(char)]; FILE *fp = open_file(file_name, "r"); int valid_buffer_start = 0; int valid_buffer_end = fread(buffer, sizeof(char), BUFSIZE, fp); while(valid_buffer_start < valid_buffer_end){ bool has_line = false; int line_size = 0; while(!has_line){ if(valid_buffer_start == valid_buffer_end){ int count = fread(buffer + line_size, sizeof(char), BUFSIZE - line_size, fp); if(count > 0){ valid_buffer_start = line_size; valid_buffer_end = line_size + count; }else{ buffer[valid_buffer_start] = '\n'; } } if(line_size + 2 < BUFSIZE){ buffer[line_size] = buffer[valid_buffer_start++]; if (buffer[line_size] == '#'){ buffer[line_size] = '\0'; }else if (buffer[line_size] == '\n' || buffer[line_size] == '\r'){ buffer[line_size] = '\0'; has_line = true; } }else{ fprintf(stderr, "error: line overflow.\n"); exit(EXIT_FAILURE); } line_size++; } //while(count) int count = sscanf(buffer, "%lf,%lf,%lf ", &latitude, &longitude, &altitude); //if </coordinates> if (count == 3){ Time_stamp time_stamp = new_time_stamp(2008, 01, 01, 00, 01, 00, 00.0); //Time_stamp time_stamp = new_time_stamp(year, month, day, hour, minute, second, millisecond); Position position = new_position(longitude, latitude, feet_to_metres(altitude)); print_position(position); Orientation orientation = new_orientation(roll, pitch, yaw); id = 1; Flight_info flight_info = new_flight_info(id, time_stamp, position, orientation); if (!give_flight_info_to_server(flight_info, server_host, server_port)){ fprintf(stderr, "Give flight info to server failed\n"); } }else if (count > 0){ fprintf(stderr, "Found a sad line in input, parsed %d elements\n", count); } } }