70 lines
1.4 KiB
C
70 lines
1.4 KiB
C
/*
|
|
* IGC parser - data linking module (doubly linked datapoint list)
|
|
* @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 "igc.h"
|
|
#include "linkage.h"
|
|
|
|
struct dp_node* create_datapoint_list()
|
|
{
|
|
struct dp_node* head = (struct dp_node*)calloc(1, sizeof(struct dp_node));
|
|
|
|
head->data = NULL;
|
|
head->prev = NULL;
|
|
head->next = NULL;
|
|
return head;
|
|
}
|
|
|
|
void append_datapoint(struct dp_node* list, struct IGC_DataPoint* dp)
|
|
{
|
|
struct dp_node* new = (struct dp_node*)calloc(1, sizeof(struct dp_node));
|
|
|
|
if (list->next == NULL)
|
|
{
|
|
list->next = new;
|
|
|
|
new->prev = list;
|
|
new->next = NULL;
|
|
new->data = dp;
|
|
return;
|
|
}
|
|
|
|
while (list->next != NULL)
|
|
{
|
|
list = list->next;
|
|
}
|
|
|
|
list->next = new;
|
|
new->prev = list;
|
|
new->next = NULL;
|
|
new->data = dp;
|
|
return;
|
|
}
|
|
|
|
void print_datapoint_list(struct dp_node* list)
|
|
{
|
|
if (list->data == NULL)
|
|
{
|
|
// We're at head!
|
|
list = list->next;
|
|
}
|
|
|
|
while (list->next != NULL)
|
|
{
|
|
show_datapoint(list->data);
|
|
printf(" <-> ");
|
|
list = list->next;
|
|
}
|
|
puts("NULL");
|
|
return;
|
|
}
|