bool GITHUB_GETLIBLIST::Get3DshapesLibsList( wxArrayString* aList, bool (*aFilter)( const wxString& aData ) ) { std::string fullURLCommand; strcpy( m_option_string, "text/html" ); wxString repoURL = m_repoURL; wxString errorMsg; fullURLCommand = repoURL.utf8_str(); bool success = remoteGetJSON( fullURLCommand, &errorMsg ); if( !success ) { wxMessageBox( errorMsg ); return false; } if( aFilter && aList ) { //Convert m_image (std::string) to a wxString for HTML_LINK_PARSER wxString buffer( GetBuffer() ); HTML_LINK_PARSER html_parser( buffer, *aList ); html_parser.ParseLinks( aFilter ); } return true; }
int main(int argc, char* argv[]) { int ret; char buffer[BUFF_MAX] = {0}; char* page; int count, f; if( argc < 2 ){ err_exit("No input"); } char *tmp_file = "./tmp_for_curl"; CURL *curl; curl_global_init(CURL_GLOBAL_ALL); curl=curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, argv[1]); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(curl, CURLOPT_WRITEDATA, tmp_file); ret = curl_easy_perform(curl); if (ret){ err_exit("get page error"); } if( (f = open(tmp_file, 0)) == -1 ){ err_exit("open file error"); } page = (char*)malloc(1); memset(page, 0, 1); while(count = read(f, buffer, BUFF_MAX)){ page = realloc(page, strlen(page) + count + 1); strncat(page, buffer, count); } printf("the page:\n %s", page); html_parser(page); if(page){ free(page); } close(f); //remove(tmp_file); return 0; }