//------------------------------------------------------------------------\r
Mootcher:: Mootcher(const char *saveLocation)\r
: curl( NULL )\r
- , connection( NULL )\r
+ , connection( 0 )\r
{\r
changeWorkingDir(saveLocation);\r
};\r
\r
// create Freesound directory and sound dir\r
std::string sndLocation = basePath;\r
- mkdir(sndLocation.c_str(), 0x777); \r
+ mkdir(sndLocation.c_str(), 0777); \r
sndLocation += "snd";\r
- mkdir(sndLocation.c_str(), 0x777); \r
+ mkdir(sndLocation.c_str(), 0777); \r
\r
return basePath.c_str();\r
}\r
//------------------------------------------------------------------------\r
void Mootcher::toLog(std::string input)\r
{\r
-//printf("%s", input.c_str());// for debugging\r
+printf("%s\n", input.c_str());// for debugging\r
}\r
\r
\r
\r
struct MemoryStruct xml_page;\r
xml_page.memory = NULL;\r
- xml_page.size = NULL;\r
+ xml_page.size = 0;\r
\r
// create the post message from the login and password\r
std::string postMessage;\r
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, -1);\r
\r
// the url to get\r
- std::string login_url = "http://freesound.iua.upf.edu/forum/login.php";\r
+ std::string login_url = "http://www.freesound.org/forum/login.php";\r
curl_easy_setopt(curl, CURLOPT_URL, login_url.c_str() );\r
\r
// perform online request\r
if (connection == 1){\r
std::string check_page = xml_page.memory;\r
int test = (int)check_page.find("login"); //logged\r
- if( test != -1){\r
- sprintf(message, "Login: %s\n", xml_page.memory);\r
- toLog(message);\r
- }\r
+ if( strcmp(xml_page.memory, "login") == 0 )\r
+ toLog("Logged in.\n");\r
else {\r
- sprintf(message, "Login: Check username and password\n");\r
- toLog(message);\r
+ toLog("Login failed: Check username and password.\n");\r
connection = 0;\r
}\r
}\r
if(xml_page.memory){ \r
free( xml_page.memory );\r
xml_page.memory = NULL;\r
- xml_page.size = NULL;\r
+ xml_page.size = 0;\r
}\r
\r
+ std::cerr << "Login was cool, connection = " << connection << std::endl;\r
return connection;\r
}\r
else return 3; // will be returned if a curl related problem ocurrs\r
{\r
struct MemoryStruct xml_page;\r
xml_page.memory = NULL;\r
- xml_page.size = NULL;\r
+ xml_page.size = 0;\r
\r
std::string result;\r
\r
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, -1);\r
\r
// the url to get\r
- std::string search_url = "http://freesound.iua.upf.edu/searchTextXML.php";\r
+ std::string search_url = "http://www.freesound.org/searchTextXML.php";\r
curl_easy_setopt(curl, CURLOPT_URL, search_url.c_str());\r
\r
// perform the online search \r
if(xml_page.memory){\r
free( xml_page.memory );\r
xml_page.memory = NULL;\r
- xml_page.size = NULL;\r
+ xml_page.size = 0;\r
}\r
\r
}\r
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&xml_page);\r
\r
// URL to get\r
- std::string getxml_url = "http://freesound.iua.upf.edu/samplesViewSingleXML.php?id=";\r
+ std::string getxml_url = "http://www.freesound.org/samplesViewSingleXML.php?id=";\r
getxml_url += ID;\r
\r
curl_easy_setopt(curl, CURLOPT_URL, getxml_url.c_str() );\r
\r
// create the download url, this url will also update the download statics on the site\r
std::string audioURL;\r
- audioURL += "http://freesound.iua.upf.edu/samplesDownload.php?id=";\r
+ audioURL += "http://www.freesound.org/samplesDownload.php?id=";\r
audioURL += ID;\r
\r
setcUrlOptions();\r