46 lines
1.0 KiB
C
46 lines
1.0 KiB
C
/*
|
|
* IGC parser
|
|
* @brief parse IGC file, get all data points, compute average horizontal/vertical speed, print to STDOUT
|
|
*
|
|
* As per standard: https://xp-soaring.github.io/igc_file_format/igc_format_2008.html
|
|
* https://xp-soaring.github.io/igc_file_format/igc_fr_specification_with_al8_2023-2-1_0.pdf
|
|
*
|
|
* @author xamidev <xamidev@riseup.net>
|
|
* @license GNU GPL v3
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
#include "igc.h"
|
|
#include "linkage.h"
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
if (argc < 2)
|
|
{
|
|
printf("Usage: %s <file>\n", argv[0]);
|
|
return -EINVAL;
|
|
}
|
|
|
|
char filename[NAME_MAX] = {0};
|
|
strncpy(filename, argv[1], NAME_MAX-1);
|
|
|
|
FILE* fp = fopen(filename, "r");
|
|
|
|
if (!fp)
|
|
{
|
|
printf("Couldn't open file %s\n", filename);
|
|
return -EINVAL;
|
|
}
|
|
|
|
struct dp_node* head = create_datapoint_list();
|
|
struct IGC_Header* hdr = (struct IGC_Header*)calloc(1, sizeof(struct IGC_Header));
|
|
parse_igc_file(fp, hdr, head);
|
|
|
|
print_datapoint_list(head);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|