bool http_request_parse(HttpRequest* request, const char* text) { // Clear the error buffer. If set during this function, there was an error. clear_error_message(request); // Clear any existing data and reset the object http_request_free(request); // Copy the text char* textcopy = strdup(text); char* textcopy_start = textcopy; // Parse the HTTP request line (the first line): HTTP method, URI, version char* curline = strsep(&textcopy, "\n"); http_request_parse_request_line(request, curline); // Parse headers while(textcopy) { // Get next line. Break if "\r\n" is reached (or in our case, "\r\0"). curline = strsep(&textcopy, "\n"); if(!curline) { set_error_message(request, "Unexpected end of text while parsing HTTP request\n"); break; } if(curline[0] == '\r' && curline[1] == '\0') { break; } // Store header key and value char* curline_orig = curline; if(!http_request_parse_header_line(request, curline)) { set_error_message(request, "Error parsing HTTP header line %s", curline_orig); continue; } } // Store the remaining text as the body if(textcopy && textcopy[0]) { const size_t textlen = strlen(textcopy); request->body = malloc(textlen + 1); memcpy(request->body, textcopy, textlen + 1); request->body[textlen] = 0; } // Clean up our copy of the text free(textcopy_start); // Return success if there was no error return !request->error; }
WatchDiamondWidget::WatchDiamondWidget(int argc, char **argv, QWidget *parent) : QMainWindow(parent) { setupUi(this); setFocusPolicy(Qt::StrongFocus); markWidget = new MarkWidget(argc,argv,wg_mark); coordinate = new Coordinate(lb_x,lb_y,lb_z,lb_a,lb_b); setupDialog= new AlgorithmDialog(this); for(int i=0; i<5; i++) axisPos[i] = 0; doubleValidator = new QDoubleValidator(this); le_setDiamondT->setValidator(doubleValidator); le_getDiamondT->setValidator(doubleValidator); le_glueT->setValidator(doubleValidator); le_afterGlueT->setValidator(doubleValidator); slowVel = markWidget->get_slow_velocity(); fastVel = markWidget->get_fast_velocity(); currentVel = fastVel; //QString vel = double_to_qstring(currentVel); //le_setVelocity->setText(vel); autoRun = false; QAction* clear = new QAction(QString::fromUtf8("清除所有"),this); te_sysMessage->addAction(clear); te_sysMessage->setContextMenuPolicy(Qt::ActionsContextMenu); te_sysMessage->setTextColor(QColor(Qt::red)); te_sysMessage->setReadOnly(true); te_sysMessage->setText(QString("system Message:\n")); jogButtons[0] = bt_xPlus; jogButtons[1] = bt_xReduce; jogButtons[2] = bt_yPlus; jogButtons[3] = bt_yReduce; jogButtons[4] = bt_zPlus; jogButtons[5] = bt_zReduce; jogButtons[6] = bt_aPlus; jogButtons[7] = bt_aReduce; jogButtons[8] = bt_bPlus; jogButtons[9] = bt_bReduce; ioButtons[0] = tb_1; ioButtons[1] = tb_2; ioButtons[2] = tb_3; ioButtons[3] = tb_4; ioButtons[4] = tb_5; ioButtons[5] = tb_6; connect(markWidget,SIGNAL(update_emc_status(MarkEmcStatus)),this,SLOT(update_emc_slot(MarkEmcStatus))); connect(markWidget,SIGNAL(update_infor(Information&)),this,SLOT(update_infor_slot(Information&))); connect(bt_machineRun,SIGNAL(toggled(bool)),this,SLOT(machine_open_toggled(bool))); connect(bt_home,SIGNAL(clicked()),this,SLOT(home())); connect(bt_zero,SIGNAL(clicked()),this,SLOT(zero())); connect(bt_changeVelocity,SIGNAL(toggled(bool)),this,SLOT(change_vel_toggled(bool))); //connect(le_setVelocity,SIGNAL(editingFinished()),this,SLOT(finish_set_velocity())); connect(bt_scanDiamond,SIGNAL(clicked()),this,SLOT(scan_diamond())); connect(bt_scanWatch,SIGNAL(toggled(bool)),this,SLOT(scan_watch(bool))); connect(bt_setGlue,SIGNAL(toggled(bool)),this,SLOT(set_glue(bool))); connect(bt_setDiamond,SIGNAL(toggled(bool)),this,SLOT(set_diamond(bool))); connect(action_open,SIGNAL(triggered()),this,SLOT(open_project())); connect(action_new,SIGNAL(triggered()),this,SLOT(new_project())); connect(action_halConfig,SIGNAL(triggered()),this,SLOT(hal_config())); connect(action_halMeter,SIGNAL(triggered()),this,SLOT(hal_meter())); connect(action_halScope,SIGNAL(triggered()),this,SLOT(hal_scope())); connect(action_algorithm,SIGNAL(triggered()),this,SLOT(setup_algorithm())); connect(bt_autoRun,SIGNAL(toggled(bool)),this,SLOT(auto_run(bool))); connect(bt_pause,SIGNAL(toggled(bool)),this,SLOT(pause(bool))); connect(bt_stop,SIGNAL(clicked()),this,SLOT(stop())); connect(clear,SIGNAL(triggered()),this,SLOT(clear_error_message())); connect(bt_getDiamondZ,SIGNAL(clicked()),this,SLOT(set_height())); connect(bt_setGlueZ,SIGNAL(clicked()),this,SLOT(set_height())); connect(bt_setDiamondZ,SIGNAL(clicked()),this,SLOT(set_height())); connect(sp_getDiamondZ,SIGNAL(editingFinished()),this,SLOT(set_height())); connect(sp_setDiamondZ,SIGNAL(editingFinished()),this,SLOT(set_height())); connect(sp_setGlueZ,SIGNAL(editingFinished()),this,SLOT(set_height())); connect(le_setDiamondT,SIGNAL(editingFinished()),this,SLOT(set_time())); connect(le_getDiamondT,SIGNAL(editingFinished()),this,SLOT(set_time())); connect(le_glueT,SIGNAL(editingFinished()),this,SLOT(set_time())); connect(le_afterGlueT,SIGNAL(editingFinished()),this,SLOT(set_time())); connect(hs_slowVel,SIGNAL(valueChanged(int)),this,SLOT(set_velocity(int))); connect(hs_fastVel,SIGNAL(valueChanged(int)),this,SLOT(set_velocity(int))); connect(sp_pickupOffsetX,SIGNAL(valueChanged(double)),this,SLOT(micro_adjust_offset(double))); connect(sp_pickupOffsetY,SIGNAL(valueChanged(double)),this,SLOT(micro_adjust_offset(double))); connect(sp_glueOffsetX,SIGNAL(valueChanged(double)),this,SLOT(micro_adjust_offset(double))); connect(sp_glueOffsetY,SIGNAL(valueChanged(double)),this,SLOT(micro_adjust_offset(double))); for(int i=0; i<10; i++){ connect(jogButtons[i],SIGNAL(pressed()),this,SLOT(jog())); connect(jogButtons[i],SIGNAL(released()),this,SLOT(end_jog())); } for(int i=0; i<6; i++){ connect(ioButtons[i],SIGNAL(toggled(bool)),this,SLOT(io_button_toggled(bool))); } connect(sp_distance,SIGNAL(valueChanged(double)),this,SLOT(set_diamond_distance(double))); sp_distance->setValue(0.080); bt_machineRun->setChecked(true); timer = new QTimer(this); connect(timer,SIGNAL(timeout()),this,SLOT(ask_home())); timer->start(500); //bt_home->setChecked(true); }