void track::fromGarminText(char const* file){ FILE* f = fopen(file, "r"); char datebuff[32]; if(f){ fseek(f, 0, SEEK_END); long size = ftell(f); rewind(f); std::vector<char> buffer; buffer.resize(size+1); size = fread(&buffer[0], 1, size, f); fclose(f); buffer[size] = 0; const char* pos = strstr(&buffer[0], "trkpt\n"); if(!pos) return; pos = lineskip(lineskip(pos)); while(*pos){ trkpoint temp; sscanf(pos, "%u %u %f %f %f %s", &temp.ID, &temp.trksegID, &temp.lat, &temp.lon, &temp.ele, datebuff); parse_date_and_time(datebuff, &temp.timestamp); pos = lineskip(pos); m_data.push_back(temp); } } }
void char_open(void) { char *b; ssize_t s; if (!(b = file2ram(FNTDIR "/devhtml/CHAR", &s))) exit(1); while (1) { char *w, *l; size_t n; int t; if (!(s = lineskip(&b, s))) return; if (!(w = get_word(&b, &s, &n, &t))) return; if (!(l = get_line(&b, &s, NULL))) return; if (n == 1) avl_add(&chrdat, I2BST(*w), S2BST(l)); else if (n != 2 && !(t & ~1)) avl_add(&numdat, I2BST(atoi(w)), S2BST(l)); else avl_add(&namdat, S2BST(w), S2BST(l)); } }