Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.01 KB | None | 0 0
  1. /*main_viewer.c*/
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include "main_viewer.h"
  7. #include "process_data.h"
  8. #include "record.h"
  9. #include "ADT_functions.h"
  10.  
  11.  
  12.  
  13. int main(int argc,char* argv[]){
  14.    
  15.     FILE *finput;
  16.     FILE *foutputcsv;
  17.     FILE *foutputkml;
  18.     size_t length;
  19.     size_t status;
  20.     char line[83]; 
  21.     char aux[60];
  22.     char inputfile[35];
  23.     char outputfile[10];
  24.     char format[4];
  25.     ADT_vector_t* vector;
  26.     void* ptr;
  27.     record_t* record;  
  28.     size_t i;
  29.  
  30.     if((status=process_arguments(argc,argv,&format))!=OK){
  31.         process_error(status);
  32.         return EXIT_FAILURE;
  33.     }
  34.    
  35.     if((finput=fopen(argv[ARG_INPUT_POSITION],"rt"))==NULL){
  36.         fprintf(stderr, "Error abriendo el archivo\n");
  37.         return EXIT_FAILURE;
  38.     }
  39.     if(format=="csv"){
  40.         if((foutputcsv=fopen(argv[ARG_OUTPUT_POSITION],"wt"))==NULL){
  41.             fprintf(stderr, "Error abriendo el archivo csv\n");
  42.             fclose(finput);
  43.              return EXIT_FAILURE;
  44.         }
  45.     }
  46.     if(format=="kml")
  47.     if((foutputkml=fopen(argv[ARG_OUTPUT_POSITION],"wt"))==NULL){
  48.         fprintf(stderr, "Error abriendo el archivo kml\n");
  49.         fclose(finput);
  50.         return EXIT_FAILURE;
  51.     }
  52.    
  53.  
  54.     vector = vector_new(sizeof(record_t));
  55.  
  56.     while(!feof(finput)){
  57.      
  58.  
  59.     if((status = read_line(finput,line)) != OK){
  60.         process_error(status);
  61.        
  62.         }
  63.  
  64.    
  65.     if((status = validateline(line)) != OK){
  66.         process_error(status);
  67.         return EXIT_FAILURE;
  68.     }
  69.    
  70.  
  71.     if(strncmp(line, FIELD_COMPARE, 6)!=0)
  72.         continue;
  73.     printf("esta es tu linea %s\n",line);
  74.    
  75.     record = vector_add(vector);
  76.    
  77.     if((status = split_line(line,record)) != OK){
  78.         process_error(status);
  79.         return EXIT_FAILURE;
  80.  
  81.     }
  82.     printf("i: %s \n", record->UTC);
  83. }
  84. ptr = vector_ptr(vector);
  85. /*
  86.  
  87. qsort(ptr, vector_length(vector), sizeof(record_t), comparator);
  88. */ 
  89. /*
  90. for (i=0; i < vector_length(vector); i++) {
  91.         record_t* current = ((record_t*) vector_ptr(vector)) + i;
  92.         printf("id: %s, utc: %s\n", current->ID, current->UTC);
  93.     }
  94.    
  95. */ 
  96.     vector_free(vector);
  97.     puts("se alcanzo el final");
  98.    
  99. return EXIT_SUCCESS;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement