forked from joshpfosi/trst_algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwaypoint_expand_main.c
More file actions
37 lines (34 loc) · 849 Bytes
/
waypoint_expand_main.c
File metadata and controls
37 lines (34 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <stdlib.h>
#include "waypoint_expansion.h"
/* in meters */
#define DEFAULT_RAD 1
void read_file(FILE *fp, double rad)
{
Waypoints wp = read_waypts(fp);
expand_waypts(stdout, wp, rad);
}
int main(int argc, char *argv[]) {
double rad = DEFAULT_RAD;
if (argc == 1) {
read_file(stdin, rad);
} else if (argc <= 3) {
FILE *fp = fopen(argv[1], "r");
if (fp == NULL) {
fprintf(stderr, "%s: %s %s %s\n",
argv[0], "Could not open file",
argv[1], "for reading");
exit(1);
}
if (argc == 3) {
rad = atof(argv[2]);
}
read_file(fp, rad);
fclose(fp);
} else {
fprintf(stderr, "%s: %s", argv[0],
"run with too many arguments\n");
exit(1);
}
return 0;
}