Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
    if(argc < 3) {
        cerr << "Usage: " << argv[0] << " <collection.db> <boffin.db>" << endl;
        return 1;
    }

    try {
        BoffinDb db(argv[2], argv[1]);
            
        // build up the request:
        db.map_tracks_without_tags(track_out);
        ossreq.flush();
        issreq = new istringstream(ossreq.str());

        // setup curl:
        CURL* curl = curl_easy_init();
        CurlChecker cc;

        // io options:
        cc("WRITEFUNCTION") = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_writer);  
        cc("READFUNCTION") = curl_easy_setopt(curl, CURLOPT_READFUNCTION, curl_reader);

        // http options:
        cc("URL") = curl_easy_setopt(curl, CURLOPT_URL, MUSICLOOKUP_URL);  
        cc("HEADER") = curl_easy_setopt(curl, CURLOPT_HEADER, 0);                           // don't include header in response

        cc("FOLLOWLOCATION") = curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);           // follow http redirects
        // leave this to the defaults with older versions of curl
#if defined(CURLOPT_POSTREDIR) && defined(CURL_REDIR_POST_ALL)
        cc("POSTREDIR") = curl_easy_setopt(curl, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL );  // keep on posting when redir'd (301 or 302)
#endif
        cc("POST") = curl_easy_setopt(curl, CURLOPT_POST, 1);
        cc("POSTFIELDSIZE") = curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, issreq->rdbuf()->in_avail());
        cc("USERAGENT") = curl_easy_setopt(curl, CURLOPT_USERAGENT, "playdar boffin tagger");
        struct curl_slist *headers = 0;
        headers = curl_slist_append(headers, "content-type: text/plain; charset=utf-8");
        headers = curl_slist_append(headers, "expect:");
        cc("HTTPHEADER") = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        
        cc("easy_perform") = curl_easy_perform(curl);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);

        ossresp.flush();
        issresp = new istringstream(ossresp.str());
        db.update_tags( parse_line );
    } 
    catch (const std::exception& e) {
        cerr << "failed: " << e.what();
        return 1;
    } 
    //catch (...) {
    //    cerr << "failed with unhandled exception";
    //    return 1;
    //}

}
Ejemplo n.º 2
0
void cbKeyPressed(unsigned char key, int x, int y)
{
    int tmp;
    double tmpd;
    switch (key) {
    
    case 'Q': case 'q': case 27:
        glutDestroyWindow(window_id);
        //        exit(1);
        break;

    // force entropy changes
	case 'a':
		ff_io_entropy_change();
		break;
	
	case 'd':
        Lx *= 1.05;
        Ly *= 1.05;
        Lz *= 1.05;
        break;

    case 'D':
        Lx /= 1.05;
        Ly /= 1.05;
        Lz /= 1.05;
        break;

	case 'V': case 'v':
		show_m = show_m ? 0 : 1;
		show_sphere = show_sphere ? 0 : 1;
		break;

	case 'M': case 'm':
        show_m = show_m?0:1;
        break;

    case 'X': case 'x':
        show_cube = show_cube ? 0 : 1;
        break;

    case '5':
        show_steric = show_steric?0:1;
        break;

    case 'O': case 'o':
        show_droplet = show_droplet?0:1;
        break;

    case 'B': case 'b':
        show_b = show_b?0:1;
        break;

    case 'R': case 'r':
        if (BmanY == 0) {BmanY = BmanX; BmanX = 0;}
        else if (BmanX == 0) {BmanX = -BmanY; BmanY = 0;}
        break;

    case 'l':
        ff_io_load(0);
        break;

    case 'L':
        ff_io_load(100);
        break;

    case 'S': case 's':
        show_sphere = show_sphere?0:1;
        break;

    case 'T': case 't':
        T += 1;
        break;

    case 'C': case 'c':
        T -= 1;
        break;

    case 'P': case 'p':
        projection_type = projection_type ? 0 : 1;
        cbResizeScene(window_width, window_height);
        break;

    case 'E': case 'e':
        show_bext = show_bext?0:1;
        break;
	
	case 'N': case 'n':
		
		out<<"step ="<<step << " V_oleic = " << v_oleic<<" V_car = "<<v_car<<" Bmanz ="<<BmanZ;
		GetScreenShot(out.str());
		out.str("");
		out.flush();
		break;
	case 'z':
		addPosition(x_rot, y_rot, space_k, projection_type);
		break;
	case 'Z':
		delPosition();
		break;
	case 'f':
		ChangePosition();
		break;
	case '0':
		ff_pieces_coord_info();
        BmanX = BmanY = BmanZ = 0;
        break;
    case '1':
        if (manual_field_control)
        {
            BmanX += 10;
        }
        break;
    case '2':
        if (manual_field_control)
        {
            BmanY += 10;
        }
        break;
    case '3':
        if (manual_field_control)
        {
            BmanZ += 10;
        }
        break;
	case '4':
			
			cout << eta_car0 << "-----" << eta_car << "-----------" << eta_oleic <<"------------" <<T<< endl;
			T += 10;
		break;
    case 'i':case 'I':
        show_info = show_info?0:1;
        break;
    case '9':
        Lx /= 2;
        Ly /= 2;
        Lz /= 2;
        break;
    case ' ':
        time_go = time_go?0:1;
		ActiveWindow();
        break;
    
    case '[':
        scaling_cube /= 1.05;
        break;
    
    case ']':
        scaling_cube *= 1.05;
        break;

    case ',':
        gr_quality --;
        break;
    
    case '.':
        gr_quality ++;
        break;

    case 'g':
        gr_x0 -= 0.05;
        break;
    
    case 'h':
        gr_x0 += 0.05;
        break;
    
    case 'j':
        gr_y0 -= 0.05;
        break;
    
    case 'k':
        gr_y0 += 0.05;
        break;

    case ';':
        gr_z0 -= 0.05;
        break;
    
    case '\'':
        gr_z0 += 0.05;
        break;

    case 'u':
        dt *= 1.1;
        break;
    
    case 'y':
        dt /= 1.1;
        break;

    default:
        printf ("KP: No action assigned for %c.\n", key);
        break;
    }
}