Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*main_viewer.c*/
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "main_viewer.h"
- #include "process_data.h"
- #include "record.h"
- #include "ADT_functions.h"
- int main(int argc,char* argv[]){
- FILE *finput;
- FILE *foutputcsv;
- FILE *foutputkml;
- size_t length;
- size_t status;
- char line[83];
- char aux[60];
- char inputfile[35];
- char outputfile[10];
- char format[4];
- ADT_vector_t* vector;
- void* ptr;
- record_t* record;
- size_t i;
- if((status=process_arguments(argc,argv,&format))!=OK){
- process_error(status);
- return EXIT_FAILURE;
- }
- if((finput=fopen(argv[ARG_INPUT_POSITION],"rt"))==NULL){
- fprintf(stderr, "Error abriendo el archivo\n");
- return EXIT_FAILURE;
- }
- if(format=="csv"){
- if((foutputcsv=fopen(argv[ARG_OUTPUT_POSITION],"wt"))==NULL){
- fprintf(stderr, "Error abriendo el archivo csv\n");
- fclose(finput);
- return EXIT_FAILURE;
- }
- }
- if(format=="kml")
- if((foutputkml=fopen(argv[ARG_OUTPUT_POSITION],"wt"))==NULL){
- fprintf(stderr, "Error abriendo el archivo kml\n");
- fclose(finput);
- return EXIT_FAILURE;
- }
- vector = vector_new(sizeof(record_t));
- while(!feof(finput)){
- if((status = read_line(finput,line)) != OK){
- process_error(status);
- }
- if((status = validateline(line)) != OK){
- process_error(status);
- return EXIT_FAILURE;
- }
- if(strncmp(line, FIELD_COMPARE, 6)!=0)
- continue;
- printf("esta es tu linea %s\n",line);
- record = vector_add(vector);
- if((status = split_line(line,record)) != OK){
- process_error(status);
- return EXIT_FAILURE;
- }
- printf("i: %s \n", record->UTC);
- }
- ptr = vector_ptr(vector);
- /*
- qsort(ptr, vector_length(vector), sizeof(record_t), comparator);
- */
- /*
- for (i=0; i < vector_length(vector); i++) {
- record_t* current = ((record_t*) vector_ptr(vector)) + i;
- printf("id: %s, utc: %s\n", current->ID, current->UTC);
- }
- */
- vector_free(vector);
- puts("se alcanzo el final");
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement