From ef3551300ad02de99160fa659edf6cd11040b5f3 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 3 Aug 2013 16:41:25 +0200 Subject: remove strtok_r() from video_query_info() for minGW compatibility --- gtk2_ardour/utils_videotl.cc | 48 +++++++++++++------------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/gtk2_ardour/utils_videotl.cc b/gtk2_ardour/utils_videotl.cc index 504fc3d2eb..2a4ce21bdc 100644 --- a/gtk2_ardour/utils_videotl.cc +++ b/gtk2_ardour/utils_videotl.cc @@ -247,47 +247,27 @@ video_query_info ( { char url[2048]; - snprintf(url, sizeof(url), "%s%sinfo/?file=%s&format=plain" + snprintf(url, sizeof(url), "%s%sinfo/?file=%s&format=csv" , video_server_url.c_str() , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/" , filepath.c_str()); char *res = curl_http_get(url, NULL); - int pid=0; - if (res) { - char *pch, *pst; - int version; - pch = strtok_r(res, "\n", &pst); - while (pch) { -#if 0 /* DEBUG */ - printf("VideoFileInfo [%i] -> '%s'\n", pid, pch); -#endif - switch (pid) { - case 0: - version = atoi(pch); - if (version != 1) break; - case 1: - video_file_fps = atof(pch); - break; - case 2: - video_duration = atoll(pch); - break; - case 3: - video_start_offset = atof(pch); - break; - case 4: - video_aspect_ratio = atof(pch); - break; - default: - break; - } - pch = strtok_r(NULL,"\n", &pst); - ++pid; - } - free(res); + if (!res) { + return false; } - if (pid!=5) { + + std::vector > lines; + ParseCSV(std::string(res), lines); + free(res); + + if (lines.empty() || lines.at(0).empty() || lines.at(0).size() != 6) { return false; } + if (atoi(lines.at(0).at(0)) != 1) return false; // version + video_start_offset = 0.0; + video_aspect_ratio = atof (lines.at(0).at(3)); + video_file_fps = atof (lines.at(0).at(4)); + video_duration = atoll(lines.at(0).at(5)); return true; } -- cgit v1.2.3