コード例 #1
0
ファイル: flytec.c プロジェクト: idaohang/gpsbabel-flytec
	static void
flytec_pbrrts(flytec_t *flytec)
{
	flytec_puts_nmea(flytec, "PBRRTS,");
	flytec_expectc(flytec, XOFF);
	route_head *route = 0;
	char line[128];
	while (flytec_gets_nmea(flytec, line, sizeof line)) {
		const char *p = line;
		p = match_literal(p, "PBRRTS,");
		int index = 0, count = 0, routepoint_index = 0;
		p = match_unsigned(p, &index);
		p = match_char(p, ',');
		p = match_unsigned(p, &count);
		p = match_char(p, ',');
		p = match_unsigned(p, &routepoint_index);
		p = match_char(p, ',');
		if (!p)
			continue;
		if (routepoint_index == 0) {
			char *name = 0;
			p = match_string_until(p, '\0', 0, &name);
			p = match_eos(p);
			if (p) {
				route = route_head_alloc();
				route->rte_num = index + 1;
				route->rte_name = rstrip(name);
				route_add_head(route);
			} else {
				free(name);
			}
		} else {
			char *name = 0;
			p = match_string_until(p, ',', 1, 0);
			p = match_string_until(p, '\0', 0, &name);
			p = match_eos(p);
			if (p) {
				const waypoint *w = find_waypt_by_name(rstrip(name));
				if (w)
					route_add_wpt(route, waypt_dupe(w));
			}
			free(name);
		}
	}
	flytec_expectc(flytec, XON);
}
コード例 #2
0
ファイル: garmin_txt.c プロジェクト: alexbirkett/GPSBabel
static void
parse_route_waypoint(void)
{
    char *str;
    int column = -1;
    waypoint *wpt = NULL;

    bind_fields(rtept_header);

    while ((str = csv_lineparse(NULL, "\t", "", column++))) {
        int field_no = header_fields[rtept_header][column];
        switch(field_no) {
        case 1:
            is_fatal((*str == '\0'), MYNAME ": Route waypoint without name at line %d!\n", current_line);
            wpt = find_waypt_by_name(str);
            is_fatal((wpt == NULL), MYNAME ": Route waypoint \"%s\" not in waypoint list (line %d)!\n", str, current_line);
            wpt = waypt_dupe(wpt);
            break;
        }
    }
    if (wpt != NULL)
        route_add_wpt(current_rte, wpt);
}