void AbstractProcessor::run() { Q_D(AbstractProcessor); if (!d->query.isValid()) { qWarning() << "Warning: the query is not valid"; setError(tr("The query is not valid")); emit error(); return; } PreprocessorData &preprocessorData = d->query.preprocessorData(); bool ok = false; switch (d->processingTask) { case Preprocessing: preprocessorData.setPostData(processPostData(preprocessorData.data())); ok = preprocess(); if (ok) { emit preprocessingFinished(d->needLoading); } else { emit error(); } break; case PostProcessing: if (!d->dataSource) { qWarning() << "Warning: no data source provided"; setError(tr("No data source provided")); emit error(); return; } ok = processDataSource(d->dataSource); d->dataSource->deleteLater(); if (ok) { emit postProcessingFinished(); } else { emit error(); } break; default: qWarning() << "Warning: no processing task set"; setError(tr("No processing task set")); emit error(); return; } }
//main function for web services int main(void) { long n; char strPage[1023]; char strFooters[1023]; char strHeaders[1023]; char strPopup[1023]; char str[1024]; char command[1024] = "echo Welcome to EurekaRom"; char decodedCommand[1024]; char *data; char *token; char *headers; char *page = NULL; const char *key, *value; char *postBuffer = NULL; int postRead; unsigned int postLen; char postData[4096]; char * queryString; char query_action[1024]; char query_section[1024]; char query_field[1024]; char query_value[1024]; data = malloc(QS_LEN); token = malloc(QS_LEN); key = malloc(QS_LEN); value = malloc(QS_LEN); //Operations if POST detected if(compStr(getenv("REQUEST_METHOD"), "POST", sizearray(getenv("REQUEST_METHOD")))) { if (getenv("QUERY_STRING")) { token = strtok (getenv("QUERY_STRING"),"&"); while (token != NULL) { sscanf(token, "%[^=]=%65536s", key, value); if ( compStr(key, "page", sizearray(key) )) { strcpy(strPage, value); } token = strtok (NULL, "&"); } } postRead = getline(&postBuffer, &postLen, stdin); if (-1 != postRead) { strcpy(postData, postBuffer); } if (compStr(strPage, "debug", sizearray(strPage) )) { sscanf(postData, "page=debug&command=%[^,]", command); urldecode2(decodedCommand, command); web_module_headers(strPage); web_module_debug(decodedCommand); web_module_footer(); } if (compStr(strPage, "settings", sizearray(strPage) )) { processPostData(postData); web_module_headers(strPage); web_module_settings(); web_module_footer(); } free(postBuffer); } else { if (!getenv("QUERY_STRING")) { //no query string web_module_headers("home"); web_module_home(); } if (getenv("QUERY_STRING")) { //parse Query_STRING for page //query string present token = strtok (getenv("QUERY_STRING"),"&"); while (token != NULL) { sscanf(token, "%[^=]=%65536s", key, value); if ( compStr(key, "page", sizearray(key) )) { strcpy(strPage, value); } if ( compStr(key, "headers", sizearray(key) )) { strcpy(strHeaders, value); } if ( compStr(key, "footers", sizearray(key) )) { strcpy(strFooters, value); } if ( compStr(key, "popup", sizearray(key) )) { strcpy(strPopup, value); } token = strtok (NULL, "&"); } // Call this before headers if ( compStr(strPage, "dumpstate", sizearray(strPage) )) { dumpstate(); exit(0); } //check for which page to load if ( compStr(strHeaders, "0", sizearray(strHeaders) )) { } else { web_module_headers(strPage); } if ( compStr(strPopup, "1", sizearray(strHeaders) )) { web_module_popup_headers(strPage); } if ( compStr(strPage, "home", sizearray(strPage) )) { web_module_home(); } if ( compStr(strPage, "logcat", sizearray(strPage) )) { web_module_logcat(); } if ( compStr(strPage, "forceeurekaupdate", sizearray(strPage) )) { forceeurekaupdate(); } if ( compStr(strPage, "debug", sizearray(strPage) )) { web_module_debug(command); } if ( compStr(strPage, "settings", sizearray(strPage) )) { web_module_settings(); } if ( compStr(strPage, "status", sizearray(strPage) )) { web_module_status(); } if ( compStr(strPage, "companion", sizearray(strPage) )) { web_module_companion(); } if ( compStr(strPage, "aboutus", sizearray(strPage) )) { web_module_aboutus(); } if ( compStr(strPage, "Reboot", sizearray(strPage) )) { reboot(); } if ( compStr(strPage, "sysupdate", sizearray(strPage) )) { sysupdate(); } if ( compStr(strPage, "factorydatareset", sizearray(strPage) )) { factorydatareset(); } if ( compStr(strFooters, "0", sizearray(strFooters) )) { } else { web_module_footer(); } } } }