virtual void httpSuccess() { LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); if (regionp) { if (LLAvatarRenderInfoAccountant::logRenderInfo()) { LL_INFOS() << "LRI: Result for avatar weights request for region " << regionp->getName() << ":" << LL_ENDL; } const LLSD& content = getContent(); if (content.isMap()) { if (content.has(KEY_AGENTS)) { const LLSD & agents = content[KEY_AGENTS]; if (agents.isMap()) { LLSD::map_const_iterator report_iter = agents.beginMap(); while (report_iter != agents.endMap()) { LLUUID target_agent_id = LLUUID(report_iter->first); const LLSD & agent_info_map = report_iter->second; LLViewerObject* avatarp = gObjectList.findObject(target_agent_id); if (avatarp && avatarp->isAvatar() && agent_info_map.isMap()) { // Extract the data for this avatar if (LLAvatarRenderInfoAccountant::logRenderInfo()) { LL_INFOS() << "LRI: Agent " << target_agent_id << ": " << agent_info_map << LL_ENDL; } if (agent_info_map.has(KEY_WEIGHT)) { ((LLVOAvatar *) avatarp)->setReportedVisualComplexity(agent_info_map[KEY_WEIGHT].asInteger()); } } report_iter++; } } } // has "agents" else if (content.has(KEY_ERROR)) { const LLSD & error = content[KEY_ERROR]; LL_WARNS() << "Avatar render info GET error: " << error[KEY_IDENTIFIER] << ": " << error[KEY_MESSAGE] << " from region " << regionp->getName() << LL_ENDL; } } } else { LL_INFOS() << "Avatar render weight info recieved but region not found for " << mRegionHandle << LL_ENDL; } }
int Fan::getSpeed() { return (stoi(getContent(getPath() + "/" + getName() + "_input"))); }
void httpFailure() { completedHeader(); FSData::getInstance()->processResponder(getContent(), mURL, false, mLastModified); }
void WebServer::incomingConnection(int socketDescriptor) { qDebug("Spawning Worker..."); Worker* w = new Worker(socketDescriptor, getContent(), this); //TODO: Connect signals/slots from worker }
void WebPathSegment::print(int ident) { cout << string(ident, '-') << getName() << (isEndpoint() ? " | " : "") << (isEndpoint() ? getContent() : "") << endl; for_each(_segmentList.begin(), _segmentList.end(), [ident](auto pair) { pair.second->print(ident + 2); }); }
ContentPtr Panel::getContent( const std::string contentID ) { int index = 0; return getContent( contentID, index ); }
void myre_start_request() { const char *sRaw = gtk_entry_get_text((GtkEntry *)entry); /* vacant entry */ if(strlen(sRaw) < 1) { if(viewsAssembled) gtk_widget_hide(textview1); myre_show_help(); return ; } /* special commands */ if(0 == strcmp(sRaw, ":about")) { gtk_widget_grab_focus(entry); myre_show_about(aboutdialog); return ; } if(0 == strcmp(sRaw, ":help")) { myre_show_help(); return ; } /* HERE WE MASTER UNCOVER THE COMPLETE FORMATION */ gtk_widget_show(GTK_WIDGET(status)); /* char *s defined as gloable */ s = realloc(s, 1024); check( s != NULL, "Memory error."); memcpy(s, sRaw, strlen(sRaw)); s[strlen(sRaw)] = '\0'; /*Pack URL*/ check(getReqStr(s, mark, word) != -1,"Fail to prepare query objective."); /*Show URL in GTK*/ if(strlen(s) < 1) { gtk_widget_grab_focus(entry); return ; } gtk_widget_show(hboxmain); gtk_widget_show(textview1); gtk_widget_show(textview2); gtk_text_buffer_set_text(text1, s, -1); gtk_widget_show(button2); /* update title */ gtk_window_set_title(GTK_WINDOW(window), word); /*Fetch from URL*/ log_info("Request [%s]",s); int res = tract(getConfree = getContent(s, curl_handle), &rslt);/*create string at rslt*/ /* * we want to employ g_threadnew( const char *OptionalNameForThread, * GThreadFunc func, * gpointer data) * to offload getContent * where gpointer (*GThreadFunc) (gpointer data) */ log_info("Tract length %d",res); #ifdef LOGRAW log_info("\n%s",rslt); #endif /*Check Fetch*/ if(0 == res) { gtk_editable_delete_text((GtkEditable *) entry, 0, -1); gtk_text_buffer_set_text(text2, "Fetch returned but got nothing to display.\n"\ "Probably no match.\n", -1); gtk_statusbar_push(status, gtk_statusbar_get_context_id(status, "status"), "NOTHING TO DISPLAY"); return ; } if(-1 == res) { gtk_text_buffer_set_text(text2, "Fetch fail.\n"\ "Check your Internet Service and try again.", -1); gtk_statusbar_push(status, gtk_statusbar_get_context_id(status, "status"), "CURL ERROR"); gtk_widget_grab_focus(entry); return ; } else gtk_statusbar_push(status, gtk_statusbar_get_context_id(status, "status"), "Query success"); /*Site-specific operations */ debug("Start Prepare texts for display"); char *temp = malloc(512); switch(mark[0])/*then display points to slice of rslt*/ { case 'w': case 'z': display = rslt; break; case 'r': if(in("Google+\nShare", rslt)) cropFromMark(rslt, "\nGoogle+\nShare", &display); else if(in("Did you mean", rslt) && in("More suggestions:", rslt)) { cropFromMark(rslt, "Did you mean", &display); break; } else { display = rslt; break; } if(display != NULL) cropFromLine(display, 3, &display); break; case 'p': cropFromMark(rslt,"From en.wikipedia.org:", &display); break; case 'm': cropFromLine(rslt, 7, &display); break; case '1': case '2': case '3': case '4': case '7': case '8': case 'L': case 'l': case '5': display = rslt; break; case 'd': default: temp[0] = 0; strcat(strcat(temp, word), "\n"); #ifdef MinGW cropFromMark(rslt, temp, &display); #else cropFromMarkNoCase(rslt, temp, &display); #endif if (display == NULL) { cropFromLine(rslt, 4, &display); } temp[0] = 0; } debug("Done Prepare texts for display"); /*display on gtk*/ if(display == NULL || strlen(display) < 1) { display = "Fetch success, but myre find nothing to display...\n"\ "Please try again.\n"; } textview2_display(display, mark); debug("Done Display"); /*set starting iter*/ gtk_text_buffer_get_iter_at_offset(text2, &start, 0); /*focus*/ gtk_widget_grab_focus(textview2); current = start; end = start; gtk_text_buffer_place_cursor(text2, &start); /*highlight*/ debug("Start Highlighting..."); my_text_buffer_highlight(text2, word, 0); if(isupper(word[0])) word[0] = tolower(word[0]); else word[0] = toupper(word[0]); my_text_buffer_highlight(text2, word, 0); char *sticker = NULL; switch(mark[0]) { case 'r': sticker = malloc(512); sticker[0] = '\0'; if(isupper(word[0])) word[0] = tolower(word[0]); else word[0] = toupper(word[0]); /*Hide*/ my_text_buffer_highlight(text2, "IPA\nSyllables\nWord Origin", 3); my_text_buffer_highlight(text2, "IPA\nSyllables\n", 3); my_text_buffer_highlight(text2, "Synonyms \nExamples \nWord Origin", 3); my_text_buffer_highlight(text2, "Synonyms \nWord Origin", 3); my_text_buffer_highlight(text2, "Examples \nWord Origin", 3); my_text_buffer_highlight(text2, "Expand\n", 3); /*Highlight section*/ my_text_buffer_highlight(text2, "\nOrigin", 2); my_text_buffer_highlight(text2, "\nWord Origin", 2); my_text_buffer_highlight(text2, "\nWord Origin and History", 2); my_text_buffer_highlight(text2, "\nRelated forms", 2); my_text_buffer_highlight(text2, "\nRelated Terms", 2); my_text_buffer_highlight(text2, "\nDerived Forms", 2); my_text_buffer_highlight(text2, "\nRelated Abbreviations", 2); my_text_buffer_highlight(text2, "\nQuotes", 2); my_text_buffer_highlight(text2, "\nSynonyms", 2); my_text_buffer_highlight(text2, "\nAntonyms", 2); my_text_buffer_highlight(text2, "\nBritish Dictionary definitions", 2); my_text_buffer_highlight(text2, "\nWorld English Dictionary", 2); my_text_buffer_highlight(text2, "\nComputing Dictionary", 2); my_text_buffer_highlight(text2, "\nBible Dictionary", 2); my_text_buffer_highlight(text2, "\nSlang definitions", 2); my_text_buffer_highlight(text2, "\nAbbreviations Acronyms", 2); my_text_buffer_highlight(text2, "\nIdioms", 2); my_text_buffer_highlight(text2, "\nExamples ", 2); my_text_buffer_highlight(text2, "\nEncyclopedia ", 2); my_text_buffer_highlight(text2, "\nalso see:", 2); my_text_buffer_highlight(text2, "in Medicine", 2); my_text_buffer_highlight(text2, "in Culture", 2); my_text_buffer_highlight(text2, "in Science", 2); my_text_buffer_highlight(text2, "in Technology",2); /*Hide*/ my_text_buffer_highlight(text2, "\nCite This Source\n", 3); /* clean up*/ free(sticker); break; case 'p': case 'w': my_text_buffer_highlight(text2, "HomeRandomNearby\n", 3); my_text_buffer_highlight(text2, "Open main menu", 3); my_text_buffer_highlight(text2, "WatchlistSettingsLog in\n", 3); my_text_buffer_highlight(text2, "About WikipediaDisclaimers\n", 3); break; case 'z': my_text_buffer_highlight(text2, "首页随机附近\n", 3); my_text_buffer_highlight(text2, "监视列表设置登录\n", 3); my_text_buffer_highlight(text2, "关于维基百科免责声明\n", 3); break; case 'm': my_text_buffer_highlight(text2, " top", 3); my_text_buffer_highlight(text2, "\nSYNOPSIS", 2); my_text_buffer_highlight(text2, "\nDESCRIPTION", 2); my_text_buffer_highlight(text2, "\nOPTIONS", 2); my_text_buffer_highlight(text2, "\nCONCEPTS", 2); my_text_buffer_highlight(text2, "\nEXAMPLES", 2); my_text_buffer_highlight(text2, "\nEXIT STATUS", 2); my_text_buffer_highlight(text2, "\nSEE ALSO", 2); my_text_buffer_highlight(text2, "\nTERMINOLOGY", 2); my_text_buffer_highlight(text2, "\nDIRECTORIES", 2); my_text_buffer_highlight(text2, "\nSIGNALS", 2); my_text_buffer_highlight(text2, "\nENVIRONMENT", 2); my_text_buffer_highlight(text2, "\nNOTES", 2); break; case '1': case '2': case '3': case '4': case '7': case '8': case 'L': case 'l': case '5': sticker = malloc(512); sticker[0] = '\0'; if(isupper(word[0])) word[0] = tolower(word[0]); strcat(strcat(strcat(sticker, "\n"), word),"("); strcat(strcat(sticker, mark),") - Linux man page\n"); my_text_buffer_highlight(text2, sticker, 3); my_text_buffer_highlight(text2, "\nsite search\n", 3); my_text_buffer_highlight(text2, "Site Search\n", 3); my_text_buffer_highlight(text2, "Google Custom Search", 3); my_text_buffer_highlight(text2, "Library\nlinux docs\nlinux man pages\npage load time\nToys\n"\ "world sunlight\nmoon phase\ntrace explorer", 3); my_text_buffer_highlight(text2, "Prolog\n", 2); my_text_buffer_highlight(text2, "Name\n", 2); my_text_buffer_highlight(text2, "\nSynopsis\n", 2); my_text_buffer_highlight(text2, "\nDescription\n", 2); my_text_buffer_highlight(text2, "\nOptions\n", 2); my_text_buffer_highlight(text2, "\nEnvironment\n", 2); my_text_buffer_highlight(text2, "\nReturn Value\n", 2); my_text_buffer_highlight(text2, "\nReturn value\n", 2); my_text_buffer_highlight(text2, "\nConforming To\n", 2); my_text_buffer_highlight(text2, "\nConforming to\n", 2); my_text_buffer_highlight(text2, "\nAuthor\n", 2); my_text_buffer_highlight(text2, "\nReporting Bugs\n",2); my_text_buffer_highlight(text2, "\nCopyright\n", 2); my_text_buffer_highlight(text2, "\nBugs\n", 2); my_text_buffer_highlight(text2, "\nErrors\n", 2); my_text_buffer_highlight(text2, "\nNotes\n", 2); my_text_buffer_highlight(text2, "\nExample\n", 2); my_text_buffer_highlight(text2, "\nExamples\n", 2); my_text_buffer_highlight(text2, "\nApplication Usage\n", 2); my_text_buffer_highlight(text2, "\nRationale\n", 2); my_text_buffer_highlight(text2, "\nFuture Directions\n", 2); my_text_buffer_highlight(text2, "\nSee Also\n", 2); my_text_buffer_highlight(text2, "\nReferenced by", 2); my_text_buffer_highlight(text2, "\nReferenced By", 2); /* clean up */ free(sticker); break; case 'd': default: my_text_buffer_highlight(text2, "释义常用度分布图\n点击查看", 3); my_text_buffer_highlight(text2, "常用词汇 ", 3); my_text_buffer_highlight(text2, "用例\n", 3); my_text_buffer_highlight(text2, "词组\n", 3); my_text_buffer_highlight(text2, "讲解\n", 3); my_text_buffer_highlight(text2, "更多\n", 3); my_text_buffer_highlight(text2, "极速版|\n触屏版|\n电脑版", 3); my_text_buffer_highlight(text2, "详尽释义\n", 2); my_text_buffer_highlight(text2, "双解释义\n", 2); my_text_buffer_highlight(text2, "英英释义\n", 2); my_text_buffer_highlight(text2, "例句\n", 2); my_text_buffer_highlight(text2, "常见句型\n", 2); my_text_buffer_highlight(text2, "常用短语\n", 2); my_text_buffer_highlight(text2, "经典引文\n", 2); my_text_buffer_highlight(text2, "词汇搭配\n", 2); my_text_buffer_highlight(text2, "词语用法\n", 2); my_text_buffer_highlight(text2, "词义辨析\n", 2); my_text_buffer_highlight(text2, "常见错误\n", 2); my_text_buffer_highlight(text2, "词源解说\n", 2); my_text_buffer_highlight(text2, "近反义词\n", 2); my_text_buffer_highlight(text2, "派生词\n", 2); my_text_buffer_highlight(text2, "缩略词\n", 2); my_text_buffer_highlight(text2, "临近单词\n", 2); } debug("Done Highlighting..."); restore_cursor_pos_after_highlight(); /*clean up*/ /* char *s and char *rslt used in buffer_set, so not yet*/ free(getConfree); free(temp); return ; error: if(getConfree) free(getConfree); gtk_statusbar_push(status, gtk_statusbar_get_context_id(status, "status"), "Error rendering query target, use [m ][d ]word[ m][ d]"); gtk_widget_grab_focus(entry); }
void ChatMessage::hideDate() { ChatLineContent* c = getContent(2); if (c) c->hide(); }
size_t SortManager::getArity(const Sort& sort) const { const SortContent& sc = getContent(sort); if (sc.parameters == nullptr) return 0; return sc.parameters->size(); }
static void parseXML(const char *dir, XML_CONTEXT *context) { const char *tok; char directory[256] = ""; size_t pos = 0; if (!(context->hints & XML_HINT_HTML)) { pos = strlcpy(directory, dir, sizeof(directory)); if (pos >= sizeof(directory)) pos = sizeof(directory) - 1; } do { getContent(context, directory); if (context->token_len) debug_printf("%s=%.*s\n", directory, (int)context->token_len, context->token); if (!(tok = getToken(context))) return; // debug_printf("A Token '%.*s'\n", (int)context->token_len, context->token); if (context->token_len == 1 && *tok == '<') { // get element name and add it to directory int flags = XML_FLG_BEGIN; if (!(tok = getToken(context))) return; // debug_printf("A2 Token '%.*s'\n", (int)context->token_len, context->token); if (!(context->hints & XML_HINT_HTML)) { if (!pos || directory[pos - 1] != '/') snprintf(&directory[pos], sizeof(directory) - pos, "/%.*s", (int)context->token_len, tok); else snprintf(&directory[pos], sizeof(directory) - pos, "%.*s", (int)context->token_len, tok); } else { // snprintf(directory, sizeof(directory), "%.*s", (int)context->token_len, tok); if (context->token_len < sizeof(directory)) { strncpy(directory, tok, context->token_len); directory[context->token_len] = 0; } else { strncpy(directory, tok, sizeof(directory) - 1); directory[sizeof(directory) - 1] = 0; } } while ((tok = getToken(context))) { // debug_printf("C Token %.*s\n", (int)context->token_len, context->token); if (context->token_len == 2 && !strncmp(tok, "/>", 2)) { if (context->callback) context->callback(context->user_ctx, flags | XML_FLG_END, directory, NULL, NULL, 0, 0); break; // stay in this level } else if (context->token_len == 1 && *tok == '>') { if (context->callback) context->callback(context->user_ctx, flags | XML_FLG_CLOSE, directory, NULL, NULL, 0, 0); if (context->hints & XML_HINT_HTML) { if (!mget_strcasecmp_ascii(directory, "script")) { // special HTML <script> content parsing // see http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#the-script-element // 4.3.1.2 Restrictions for contents of script elements debug_printf("*** need special <script> handling\n"); getScriptContent(context); if (context->token_len) debug_printf("%s=%.*s\n", directory, (int)context->token_len, context->token); } } else parseXML(directory, context); // descend one level break; } else { // snprintf(attribute, sizeof(attribute), "%.*s", (int)context->token_len, tok); char attribute[context->token_len + 1]; strncpy(attribute, tok, context->token_len); attribute[context->token_len] = 0; if (getValue(context) == 0) return; if (context->token_len) { debug_printf("%s/@%s=%.*s\n", directory, attribute, (int)context->token_len, context->token); if (context->callback) context->callback(context->user_ctx, flags | XML_FLG_ATTRIBUTE, directory, attribute, context->token, context->token_len, context->token - context->buf); } else { debug_printf("%s/@%s\n", directory, attribute); if (context->callback) context->callback(context->user_ctx, flags | XML_FLG_ATTRIBUTE, directory, attribute, NULL, 0, 0); } flags = 0; } } directory[pos] = 0; } else if (context->token_len == 2) { if (!strncmp(tok, "</", 2)) { // ascend one level // cleanup - get name and '>' if (!(tok = getToken(context))) return; // debug_printf("X Token %s\n",tok); if (context->callback) { if (!(context->hints & XML_HINT_HTML)) context->callback(context->user_ctx, XML_FLG_END, directory, NULL, NULL, 0, 0); else { char tag[context->token_len + 1]; // we need to \0 terminate tok memcpy(tag, tok, context->token_len); tag[context->token_len] = 0; context->callback(context->user_ctx, XML_FLG_END, tag, NULL, NULL, 0, 0); } } if (!(tok = getToken(context))) return; // debug_printf("Y Token %s\n",tok); if (!(context->hints & XML_HINT_HTML)) return; else continue; } else if (!strncmp(tok, "<?", 2)) { // special info - ignore getProcessing(context); debug_printf("%s=<?%.*s?>\n", directory, (int)context->token_len, context->token); continue; } else if (!strncmp(tok, "<!", 2)) { getSpecial(context); debug_printf("%s=<!%.*s>\n", directory, (int)context->token_len, context->token); } } else if (context->token_len == 4 && !strncmp(tok, "<!--", 4)) { // comment - ignore getComment(context); debug_printf("%s=<!--%.*s-->\n", directory, (int)context->token_len, context->token); continue; } } while (tok); }
void fetchScriptLimitsAttachmentInfoResponder::httpSuccess() { const LLSD& content_ref = getContent(); #ifdef USE_FAKE_RESPONSES // just add the summary, as that's all I'm testing currently! LLSD fake_content = LLSD::emptyMap(); LLSD summary = LLSD::emptyMap(); LLSD available = LLSD::emptyArray(); LLSD available_urls = LLSD::emptyMap(); LLSD available_memory = LLSD::emptyMap(); LLSD used = LLSD::emptyArray(); LLSD used_urls = LLSD::emptyMap(); LLSD used_memory = LLSD::emptyMap(); used_urls["type"] = "urls"; used_urls["amount"] = FAKE_NUMBER_OF_URLS; available_urls["type"] = "urls"; available_urls["amount"] = FAKE_AVAILABLE_URLS; used_memory["type"] = "memory"; used_memory["amount"] = FAKE_AMOUNT_OF_MEMORY; available_memory["type"] = "memory"; available_memory["amount"] = FAKE_AVAILABLE_MEMORY; used.append(used_urls); used.append(used_memory); available.append(available_urls); available.append(available_memory); summary["available"] = available; summary["used"] = used; fake_content["summary"] = summary; fake_content["attachments"] = content_ref["attachments"]; const LLSD& content = fake_content; #else const LLSD& content = content_ref; #endif if (!content.isMap()) { failureResult(HTTP_INTERNAL_ERROR_OTHER, "Malformed response contents", content); return; } #ifdef DUMP_REPLIES_TO_LLINFOS LLSDNotationStreamer notation_streamer(content); std::ostringstream nice_llsd; nice_llsd << notation_streamer; OSMessageBox(nice_llsd.str(), "attachment response:", 0); LL_INFOS() << "attachment response:" << content << LL_ENDL; #endif LLFloaterScriptLimits* instance = LLFloaterScriptLimits::findInstance(); if(!instance) { LL_WARNS() << "Failed to get llfloaterscriptlimits instance" << LL_ENDL; } else { LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); if(tab) { LLPanelScriptLimitsAttachment* panel = (LLPanelScriptLimitsAttachment*)tab->getChild<LLPanel>("script_limits_my_avatar_panel"); if(panel) { panel->getChild<LLUICtrl>("loading_text")->setValue(LLSD(std::string(""))); LLButton* btn = panel->getChild<LLButton>("refresh_list_btn"); if(btn) { btn->setEnabled(true); } panel->setAttachmentDetails(content); } else { LL_WARNS() << "Failed to get script_limits_my_avatar_panel" << LL_ENDL; } } else { LL_WARNS() << "Failed to get scriptlimits_panels" << LL_ENDL; } } }
void fetchScriptLimitsRegionDetailsResponder::httpSuccess() { const LLSD& content_ref = getContent(); #ifdef USE_FAKE_RESPONSES /* Updated detail service, ** denotes field added: result (map) +-parcels (array of maps) +-id (uuid) +-local_id (S32)** +-name (string) +-owner_id (uuid) (in ERS as owner, but owner_id in code) +-objects (array of maps) +-id (uuid) +-name (string) +-owner_id (uuid) (in ERS as owner, in code as owner_id) +-owner_name (sting)** +-location (map)** +-x (float) +-y (float) +-z (float) +-resources (map) (this is wrong in the ERS but right in code) +-type (string) +-amount (int) */ LLSD fake_content; LLSD resource = LLSD::emptyMap(); LLSD location = LLSD::emptyMap(); LLSD object = LLSD::emptyMap(); LLSD objects = LLSD::emptyArray(); LLSD parcel = LLSD::emptyMap(); LLSD parcels = LLSD::emptyArray(); resource["urls"] = FAKE_NUMBER_OF_URLS; resource["memory"] = FAKE_AMOUNT_OF_MEMORY; location["x"] = 128.0f; location["y"] = 128.0f; location["z"] = 0.0f; object["id"] = LLUUID("d574a375-0c6c-fe3d-5733-da669465afc7"); object["name"] = "Gabs fake Object!"; object["owner_id"] = LLUUID("8dbf2d41-69a0-4e5e-9787-0c9d297bc570"); object["owner_name"] = "Gabs Linden"; object["location"] = location; object["resources"] = resource; objects.append(object); parcel["id"] = LLUUID("da05fb28-0d20-e593-2728-bddb42dd0160"); parcel["local_id"] = 42; parcel["name"] = "Gabriel Linden\'s Sub Plot"; parcel["objects"] = objects; parcels.append(parcel); fake_content["parcels"] = parcels; const LLSD& content = fake_content; #else const LLSD& content = content_ref; #endif if (!content.isMap()) { failureResult(HTTP_INTERNAL_ERROR_OTHER, "Malformed response contents", content); return; } #ifdef DUMP_REPLIES_TO_LLINFOS LLSDNotationStreamer notation_streamer(content); std::ostringstream nice_llsd; nice_llsd << notation_streamer; OSMessageBox(nice_llsd.str(), "details response:", 0); LL_INFOS() << "details response:" << content << LL_ENDL; #endif LLFloaterScriptLimits* instance = LLFloaterScriptLimits::findInstance(); if(!instance) { LL_WARNS() << "Failed to get llfloaterscriptlimits instance" << LL_ENDL; } else { LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); if(tab) { LLPanelScriptLimitsRegionMemory* panel_memory = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); if(panel_memory) { panel_memory->setRegionDetails(content); } else { LL_WARNS() << "Failed to get scriptlimits memory panel" << LL_ENDL; } } else { LL_WARNS() << "Failed to get scriptlimits_panels" << LL_ENDL; } } }
void fetchScriptLimitsRegionSummaryResponder::httpSuccess() { const LLSD& content_ref = getContent(); #ifdef USE_FAKE_RESPONSES LLSD fake_content; LLSD summary = LLSD::emptyMap(); LLSD available = LLSD::emptyArray(); LLSD available_urls = LLSD::emptyMap(); LLSD available_memory = LLSD::emptyMap(); LLSD used = LLSD::emptyArray(); LLSD used_urls = LLSD::emptyMap(); LLSD used_memory = LLSD::emptyMap(); used_urls["type"] = "urls"; used_urls["amount"] = FAKE_NUMBER_OF_URLS; available_urls["type"] = "urls"; available_urls["amount"] = FAKE_AVAILABLE_URLS; used_memory["type"] = "memory"; used_memory["amount"] = FAKE_AMOUNT_OF_MEMORY; available_memory["type"] = "memory"; available_memory["amount"] = FAKE_AVAILABLE_MEMORY; //summary response:{'summary':{'available':[{'amount':i731,'type':'urls'},{'amount':i895577,'type':'memory'},{'amount':i731,'type':'urls'},{'amount':i895577,'type':'memory'}],'used':[{'amount':i329,'type':'urls'},{'amount':i66741,'type':'memory'}]}} used.append(used_urls); used.append(used_memory); available.append(available_urls); available.append(available_memory); summary["available"] = available; summary["used"] = used; fake_content["summary"] = summary; const LLSD& content = fake_content; #else const LLSD& content = content_ref; #endif if (!content.isMap()) { failureResult(HTTP_INTERNAL_ERROR_OTHER, "Malformed response contents", content); return; } #ifdef DUMP_REPLIES_TO_LLINFOS LLSDNotationStreamer notation_streamer(content); std::ostringstream nice_llsd; nice_llsd << notation_streamer; OSMessageBox(nice_llsd.str(), "summary response:", 0); LL_WARNS() << "summary response:" << *content << LL_ENDL; #endif LLFloaterScriptLimits* instance = LLFloaterScriptLimits::findInstance(); if(!instance) { LL_WARNS() << "Failed to get llfloaterscriptlimits instance" << LL_ENDL; } else { LLTabContainer* tab = instance->getChild<LLTabContainer>("scriptlimits_panels"); if(tab) { LLPanelScriptLimitsRegionMemory* panel_memory = (LLPanelScriptLimitsRegionMemory*)tab->getChild<LLPanel>("script_limits_region_memory_panel"); if(panel_memory) { panel_memory->getChild<LLUICtrl>("loading_text")->setValue(LLSD(std::string(""))); LLButton* btn = panel_memory->getChild<LLButton>("refresh_list_btn"); if(btn) { btn->setEnabled(true); } panel_memory->setRegionSummary(content); } } } }
int Fan::getPlannedSpeed() { return (stoi(getContent(getPath() + "/" + getName() + "_output"))); }
void HtmlExtractor::saveTo(const QString &path) { WriteFile(path, getContent()); }
void ChatMessage::hideSender() { ChatLineContent* c = getContent(0); if (c) c->hide(); }
/*virtual*/ void httpFailure() { LL_WARNS() << "experience responder failed [status:" << getStatus() << "]: " << getContent() << LL_ENDL; }
int main(int argc, char **argv){ int amountForFirst; int amountFound; unsigned amountNumbers; int amountPcs; int amountPerPC; int counter; int rank; int target; int totalFound; char *content; int *founds; int **numbers; int *slaveNumbers; MPI_Status status; if(argc != 3) goto ERROR; MPI_Init(&argc, &argv); amountForFirst = 0; amountFound = 0; amountNumbers = 0; amountPcs = 0; amountPerPC = 0; counter = 0; rank = 0; target = 0; totalFound = 0; content = NULL; founds = NULL; numbers = NULL; slaveNumbers = NULL; memset(&status, 0, sizeof(MPI_Status)); MPI_Comm_size(MPI_COMM_WORLD, &amountPcs); MPI_Comm_rank(MPI_COMM_WORLD, &rank); target = atoi(argv[2]); if(rank == 0){ if(getContent(argv[1], &content)){ amountNumbers = splitNumbers(content, amountPcs, &amountForFirst, &amountPerPC, &numbers); if(amountNumbers){ for(counter = 1; counter < amountPcs; counter++){ MPI_Send(&amountPerPC, 1, MPI_INT, counter, 0, MPI_COMM_WORLD); MPI_Send(numbers[counter], amountPerPC, MPI_INT, counter, 0, MPI_COMM_WORLD); } /* Search and save in node 0 */ if(searchNumber(numbers[0], amountForFirst, target, &founds, &amountFound)){ if(!savePositions(founds, amountFound, 0)) goto ERROR; printf("Rank %d found %d\n", rank, amountFound); }else{ goto ERROR; } totalFound += amountFound; /* Receive founds in other nodes and save. */ for(counter = 1; counter < amountPcs; counter++){ amountFound = 0; free(founds); MPI_Recv(&amountFound, 1, MPI_INT, counter, 0, MPI_COMM_WORLD, &status); totalFound += amountFound; founds = (int*) calloc(amountFound, sizeof(int)); if(!founds) goto ERROR; MPI_Recv(founds, amountFound, MPI_INT, counter, 0, MPI_COMM_WORLD, &status); if(!savePositions(founds, amountFound, amountForFirst + (counter * amountPerPC))) goto ERROR; printf("Rank %d found %d\n", status.MPI_SOURCE, amountFound); } printf("Total found: %d\n", totalFound); }else{ goto ERROR; } }else{ goto ERROR; } }else{ MPI_Recv(&amountPerPC, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status); slaveNumbers = (int*) calloc(amountPerPC, sizeof(int)); if(!slaveNumbers) goto ERROR; MPI_Recv(slaveNumbers, amountPerPC, MPI_INT, 0, 0, MPI_COMM_WORLD, &status); if(searchNumber(slaveNumbers, amountPerPC, target, &founds, &amountFound)){ MPI_Send(&amountFound, 1, MPI_INT, 0, 0, MPI_COMM_WORLD); MPI_Send(slaveNumbers, amountFound, MPI_INT, 0, 0, MPI_COMM_WORLD); }else{ goto ERROR; } } goto END; ERROR: printf("%d - Deu ruim!!!\n", rank); END: if(content) free(content); if(founds) free(founds); if(slaveNumbers) free(slaveNumbers); memset(&status, 0, sizeof(MPI_Status)); for(counter = 0; counter < amountPcs; counter++){ if(numbers){ if(numbers[counter]) free(numbers[counter]); } } if(numbers) free(numbers); MPI_Finalize(); return 0; }
/* ** Try to figure out how every page in the database file is being used. */ static void page_usage_report(const char *zDbName){ int i, j; int rc; sqlite3 *db; sqlite3_stmt *pStmt; unsigned char *a; char zQuery[200]; /* Avoid the pathological case */ if( mxPage<1 ){ printf("empty database\n"); return; } /* Open the database file */ rc = sqlite3_open(zDbName, &db); if( rc ){ printf("cannot open database: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); return; } /* Set up global variables zPageUse[] and mxPage to record page ** usages */ zPageUse = sqlite3_malloc( sizeof(zPageUse[0])*(mxPage+1) ); if( zPageUse==0 ) out_of_memory(); memset(zPageUse, 0, sizeof(zPageUse[0])*(mxPage+1)); /* Discover the usage of each page */ a = getContent(0, 100); page_usage_freelist(decodeInt32(a+32)); page_usage_ptrmap(a); free(a); page_usage_btree(1, 0, 0, "sqlite_master"); sqlite3_exec(db, "PRAGMA writable_schema=ON", 0, 0, 0); for(j=0; j<2; j++){ sqlite3_snprintf(sizeof(zQuery), zQuery, "SELECT type, name, rootpage FROM SQLITE_MASTER WHERE rootpage" " ORDER BY rowid %s", j?"DESC":""); rc = sqlite3_prepare_v2(db, zQuery, -1, &pStmt, 0); if( rc==SQLITE_OK ){ while( sqlite3_step(pStmt)==SQLITE_ROW ){ int pgno = sqlite3_column_int(pStmt, 2); page_usage_btree(pgno, 0, 0, (const char*)sqlite3_column_text(pStmt,1)); } }else{ printf("ERROR: cannot query database: %s\n", sqlite3_errmsg(db)); } rc = sqlite3_finalize(pStmt); if( rc==SQLITE_OK ) break; } sqlite3_close(db); /* Print the report and free memory used */ for(i=1; i<=mxPage; i++){ printf("%5d: %s\n", i, zPageUse[i] ? zPageUse[i] : "???"); sqlite3_free(zPageUse[i]); } sqlite3_free(zPageUse); zPageUse = 0; }
void HttpSession::readContent() { int size = impl->cntSize - impl->data.in_avail(); if(size <= 0) { if(impl->data.in_avail() > 0) { LOGD("ALL IN BUFFER"); vector<uint8_t> buffer(impl->data.size()); auto bufs = impl->data.data(); copy(asio::buffers_begin(bufs), asio::buffers_end(bufs), buffer.begin()); impl->total = impl->data.size(); impl->state = DONE; impl->callback(*this, buffer); } else { LOGD("EMPTY"); impl->state = EMPTY; if(!isRedirect()) { vector<uint8_t> v; impl->callback(*this, v); } } return; } if(!impl->callback || impl->oneShot) { LOGD("ALL AT ONCE"); asio::async_read(impl->c.getSocket(), impl->data, asio::transfer_exactly(size), [&](const asio::error_code &e, size_t n) { impl->state = DONE; if(impl->oneShot) { auto v8 = getContent(); impl->callback(*this, v8); } }); return; } //filled = data.in_avail(); impl->total = 0; //buffer.reserve(chunkSize); impl->handler = [=](const asio::error_code &e, size_t n) { //asio::deadline_timer t(io, boost::posix_time::seconds(5)); //t->async_wait( impl->data.commit(n); //LOGD("Read %d bytes, avail %d", n, impl->data.size()); //n += filled; vector<uint8_t> buffer(impl->data.size()); auto bufs = impl->data.data(); copy(asio::buffers_begin(bufs), asio::buffers_end(bufs), buffer.begin()); impl->total += impl->data.size(); //LOGD("Total %d", impl->total); if(n == 0 || impl->total == impl->cntSize) { impl->state = DONE; LOGD("Done reading"); } impl->callback(*this, buffer); if(impl->state == DONE) { LOGD("Request stop"); return; } impl->data.consume(impl->data.size()); auto mutableBuffer = impl->data.prepare(16384); impl->c.getSocket().async_read_some(asio::buffer(mutableBuffer), impl->handler); }; auto mutableBuffer = impl->data.prepare(16384); impl->c.getSocket().async_read_some(asio::buffer(mutableBuffer), impl->handler); }
int main(int argc, char **argv){ struct stat sbuf; unsigned char zPgSz[2]; if( argc<2 ){ usage(argv[0]); exit(1); } db = open(argv[1], O_RDONLY); if( db<0 ){ fprintf(stderr,"%s: can't open %s\n", argv[0], argv[1]); exit(1); } zPgSz[0] = 0; zPgSz[1] = 0; lseek(db, 16, SEEK_SET); read(db, zPgSz, 2); pagesize = zPgSz[0]*256 + zPgSz[1]*65536; if( pagesize==0 ) pagesize = 1024; printf("Pagesize: %d\n", pagesize); fstat(db, &sbuf); mxPage = sbuf.st_size/pagesize; printf("Available pages: 1..%d\n", mxPage); if( argc==2 ){ int i; for(i=1; i<=mxPage; i++) print_page(i); }else{ int i; for(i=2; i<argc; i++){ int iStart, iEnd; char *zLeft; if( strcmp(argv[i], "dbheader")==0 ){ print_db_header(); continue; } if( strcmp(argv[i], "pgidx")==0 ){ page_usage_report(argv[1]); continue; } if( strcmp(argv[i], "ptrmap")==0 ){ ptrmap_coverage_report(argv[1]); continue; } if( strcmp(argv[i], "help")==0 ){ usage(argv[0]); continue; } if( !isdigit(argv[i][0]) ){ fprintf(stderr, "%s: unknown option: [%s]\n", argv[0], argv[i]); continue; } iStart = strtol(argv[i], &zLeft, 0); if( zLeft && strcmp(zLeft,"..end")==0 ){ iEnd = mxPage; }else if( zLeft && zLeft[0]=='.' && zLeft[1]=='.' ){ iEnd = strtol(&zLeft[2], 0, 0); }else if( zLeft && zLeft[0]=='b' ){ int ofst, nByte, hdrSize; unsigned char *a; if( iStart==1 ){ ofst = hdrSize = 100; nByte = pagesize-100; }else{ hdrSize = 0; ofst = (iStart-1)*pagesize; nByte = pagesize; } a = getContent(ofst, nByte); decode_btree_page(a, iStart, hdrSize, &zLeft[1]); free(a); continue; }else if( zLeft && zLeft[0]=='t' ){ int detail = 0; int recursive = 0; int i; for(i=1; zLeft[i]; i++){ if( zLeft[i]=='r' ) recursive = 1; if( zLeft[i]=='d' ) detail = 1; } decode_trunk_page(iStart, pagesize, detail, recursive); continue; }else{ iEnd = iStart; } if( iStart<1 || iEnd<iStart || iEnd>mxPage ){ fprintf(stderr, "Page argument should be LOWER?..UPPER?. Range 1 to %d\n", mxPage); exit(1); } while( iStart<=iEnd ){ print_page(iStart); iStart++; } } } close(db); return 0; }
// The first argument of this function is a format string to specify the order and // the content of the returned list // useable format options are // R = Service Reference (as swig object .. this is very slow) // S = Service Reference (as python string object .. same as ref.toString()) // C = Service Reference (as python string object .. same as ref.toCompareString()) // N = Service Name (as python string object) // when exactly one return value per service is selected in the format string, // then each value is directly a list entry // when more than one value is returned per service, then the list is a list of // python tuples // unknown format string chars are returned as python None values ! PyObject *eServiceFS::getContent(const char* format, bool sorted) { ePyObject ret; std::list<eServiceReference> tmplist; int retcount=1; if (!format || !(retcount=strlen(format))) format = "R"; // just return service reference swig object ... if (!getContent(tmplist, sorted)) { int services=tmplist.size(); ePtr<iStaticServiceInformation> sptr; eServiceCenterPtr service_center; if (strchr(format, 'N')) eServiceCenter::getPrivInstance(service_center); ret = PyList_New(services); std::list<eServiceReference>::iterator it(tmplist.begin()); for (int cnt=0; cnt < services; ++cnt) { eServiceReference &ref=*it++; ePyObject tuple = retcount > 1 ? PyTuple_New(retcount) : ePyObject(); for (int i=0; i < retcount; ++i) { ePyObject tmp; switch(format[i]) { case 'R': // service reference (swig)object tmp = NEW_eServiceReference(ref); break; case 'C': // service reference compare string tmp = PyString_FromString(ref.toCompareString().c_str()); break; case 'S': // service reference string tmp = PyString_FromString(ref.toString().c_str()); break; case 'N': // service name if (service_center) { service_center->info(ref, sptr); if (sptr) { std::string name; sptr->getName(ref, name); if (name.length()) tmp = PyString_FromString(name.c_str()); } } if (!tmp) tmp = PyString_FromString("<n/a>"); break; default: if (tuple) { tmp = Py_None; Py_INCREF(Py_None); } break; } if (tmp) { if (tuple) PyTuple_SET_ITEM(tuple, i, tmp); else PyList_SET_ITEM(ret, cnt, tmp); } } if (tuple) PyList_SET_ITEM(ret, cnt, tuple); } } return ret ? (PyObject*)ret : (PyObject*)PyList_New(0); }
void ScrollArea::widgetResized(const gcn::Event &event) { getContent()->setSize(getWidth() - 2 * getFrameSize(), getHeight() - 2 * getFrameSize()); }