Example #1
0
static void
gtc_wr_init(const char *fname)
{
        int i;

        ofd = gbfopen(fname, "w", MYNAME);

	if(opt_sport) {
		for(i = 0; i < MAX_SPORTS; i++) {
			if(0 == case_ignore_strncmp(opt_sport, gtc_sportlist[i], 2)) {
				gtc_sport = i;
				break;
			}
		}
	}
	gtc_course_flag = atoi(opt_course);
}
const char *
fix_win_serial_name_r(const char *comname, char *obuf, size_t len)
{
      if (!gbser_is_serial(comname) ||
           ((strlen(comname) == 5) && (comname[4] == ':')) ||
           ((strlen(comname) == 4) && (case_ignore_strncmp(comname, "com", 3) == 0))
         ) {
            strncpy(obuf, comname, len);
         } else {
               size_t l;
               snprintf(obuf, len, DEV_PREFIX "%s", comname);
               l = strlen(obuf);
               if (obuf[l - 1] == ':') {
                     obuf[l - 1] = '\0';
               }
         }

         return obuf;
}
Example #3
0
static void
osm_rte_disp_trail(const route_head *rte)
{
	if (skip_rte) return;

	if (strlen(created_by) !=0) {
		gbfprintf(fout, "    <tag k='created_by' v='%s",created_by);
		if (gpsbabel_time != 0)
			if (strcmp("GPSBabel",created_by)==0)
				gbfprintf(fout, "-%s", gpsbabel_version);
		gbfprintf(fout, "'/>\n");
	}

	osm_write_tag("name", rte->rte_name);
	osm_write_tag("note", rte->rte_desc);

	if (opt_tag && (case_ignore_strncmp(opt_tag, "tagnd", 5) != 0))
		osm_write_opt_tag(opt_tag);

	gbfprintf(fout, "  </way>\n");
}
int gbser_is_serial(const char *port_name) {
      const char *pfx = DEV_PREFIX;
      size_t pfx_l = strlen(pfx);
      const char *com = "COM";
      size_t com_l = strlen(com);
      unsigned digits;

      if (NULL == port_name) {
            return 0;
      }

      /* Skip any prefix */
      if (memcmp(port_name, pfx, pfx_l) == 0) {
            port_name += pfx_l;
      }

      if (case_ignore_strncmp(port_name, com, com_l) != 0) {
            return 0;
      }

      port_name += com_l;
      for (digits = 0; isdigit(*port_name); port_name++, digits++) {
            /* do nothing */
      }

      if (digits == 0) {
            return 0;
      }

      if (*port_name == ':') {
            port_name++;
      }

      if (*port_name != '\0') {
            return 0;
      }

      /* Success! */
      return 1;
}
Example #5
0
static void
magpdb_read_data(const char *data, const size_t data_len)
{
	route_head *route;
	char *cin = (char *)data;
	char *cend = cin + data_len;
	
	route = route_head_alloc();
	route_add_head(route);
	
	while (cin < cend)
	{
		char *lend;
		int len;
		
		lend = strchr(cin, '\x0A');
		if (lend == NULL) break;
		
		len = (lend - cin);
		if (len > 0)
		{
			double distance;
				int hour, min;
			*lend = '\0';
			
			if (case_ignore_strncmp(cin, "Wegname=", 8) == 0)	/* This only works with the german release */
			{							/* test-data created with other releases are welcome */
				cin += 8;
				if (*cin != '\0')
					route->rte_name = xstrdup(cin);
			}
			else if (case_ignore_strncmp(cin, "Fahrzeit=", 9) == 0)
			{
			}
			else if (case_ignore_strncmp(cin, "Kosten=", 7) == 0)
			{
			}
			else if (case_ignore_strncmp(cin, "Entfernung=", 11) == 0)
			{
			}
			/* check, if line starts with time and distance */
			else if (3 == sscanf(cin, "%d:%d %lf", &hour, &min, &distance))
			{
				char *buff, *comma;
				
				/* detect time-format settings, 12,0 or 12.0 */
				
				comma = strchr(cin, '.');
				buff = strchr(cin, ',');
				if (comma == NULL)
					comma = buff;
				else 
					if ((buff != NULL) && (buff < comma))
						comma = buff;
				if (comma != NULL)
				{
					char separator = *comma;

					/* now we are looking for a sequence like 0,1 NE (123456,654321) */
				  
					buff = xmalloc(strlen(cin) + 1);		/* safe target space for sscanf( ... */
			
					comma = cin;
					while ((comma = strchr(comma, separator)))
					{
						int i, xlat, xlon;
						waypoint *wpt;
						char *cx;
				
						comma++;
					
						if (isdigit(*comma) == 0) continue;
						if (isdigit(*(comma - 2)) == 0) continue;
					
						if (4 != sscanf(comma, "%d %s (%d,%d)", &i, buff, &xlon, &xlat)) continue;
						if (strchr("NESW", *buff) == NULL) continue;	/* north, east, ... */
					
						cx = comma - 2;				/* go left over delta distance */
						while (isdigit(*cx) != 0) *cx-- = '\0';
						cin = lrtrim(cin);
					
						for (i = 0; i < 2; i++)			/* skip time and distance at start of line */
						{
							cin = strchr(cin, ' ');
							cin = lrtrim(cin);
						}

						wpt = waypt_new();
					
						wpt->latitude = magpdb_to_degree(xlat);
						wpt->longitude = magpdb_to_degree(xlon);
						wpt->description = xstrdup(cin);
					
						cx = strchr(comma, ')');		/* find tailing notes after the coordinates */
						if (cx != NULL)	
						{
							char *tail = lrtrim(++cx);
							if (*tail != '\0')
							{
								wpt->notes = xstrdup(tail);
							}
						}
						/* generate some waypoints from our route-only format */
						if ((*cin != '-') && (case_ignore_strncmp(cin, "bei ", 4) != 0))
							waypt_add(waypt_dupe(wpt));
						
						route_add_wpt(route, wpt);
						break;
					}
					xfree(buff);
				}
			}

		}
		cin = lend + 1;
	}
}