bool configure(int argc, char *argv[]) { #ifndef NO_CONFIG assert(options_okay()); /* I'm not too proud of this. Read command line first, because it may change * where the configuration file is. Then read the configuration file, and * read the command line again to override any options that may be set by * both. */ if (!read_cmdline(argc, argv) || !read_config()) return false; read_cmdline(argc, argv); #else // Unconfigurable build; we only do a minimal options loop. for (int a=1; argv[a]; ++a) { if (argv[a][0] != '-') { fprintf(stderr, "Invalid argument: '%s'. Try the -h option.\n", argv[a]); return false; } switch (argv[a][1]) { case 'd': break; // Quietly ignored case 'e': set_erase(0); break; case 'h': short_usage(); break; // Does not return case 'p': set_pidfile(0); break; case 'q': break; // Quietly ignored case 'v': break; // Quietly ignored case 'V': set_version(0); break; // Does not return default: fprintf(stderr,"Invalid option: '%s'. Try -h instead.\n",argv[a]); return false; } } #endif if (!main_check_config() || !memory_check_config() || !swaps_check_config() || !swapfs_large_enough()) return false; if (inspect) exit(EXIT_SUCCESS); return to_swapdir(); }
void CFeatureDrawer::DrawFadeFeaturesSet(FeatureSet& fadeFeatures, int modelType) { for (FeatureSet::iterator fi = fadeFeatures.begin(); fi != fadeFeatures.end(); ) { const float cols[] = {1.0f, 1.0f, 1.0f, fi->second}; if (modelType != MODELTYPE_3DO) { glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, cols); } // hack, sorting objects by distance would look better glAlphaFunc(GL_GREATER, fi->second / 2.0f); glColor4fv(cols); if (!DrawFeatureNow(fi->first, fi->second)) { fi = set_erase(fadeFeatures, fi); } else { ++fi; } } }
void CMouseHandler::SafeDeleteCursor(CMouseCursor* cursor) { std::map<std::string, CMouseCursor*>::iterator it; for (it = cursorCommandMap.begin(); it != cursorCommandMap.end(); ++it) { if (it->second == cursor) { return; // being used, can't delete } } for (it = cursorFileMap.begin(); it != cursorFileMap.end(); ++it) { if (it->second == cursor) { it = set_erase(cursorFileMap, it); } } if (currentCursor == cursor) { SetCursor("none", true); } delete cursor; }
void CFeatureDrawer::DrawOpaqueFeatures(int modelType) { FeatureRenderBin& featureBin = opaqueModelRenderers[modelType]->GetFeatureBinMutable(); FeatureRenderBin::iterator featureBinIt; FeatureSet::iterator featureSetIt; for (featureBinIt = featureBin.begin(); featureBinIt != featureBin.end(); ++featureBinIt) { if (modelType != MODELTYPE_3DO) { texturehandlerS3O->SetS3oTexture(featureBinIt->first); } FeatureSet& featureSet = featureBinIt->second; for (featureSetIt = featureSet.begin(); featureSetIt != featureSet.end(); ) { if (!DrawFeatureNow(featureSetIt->first)) { featureSetIt = set_erase(featureSet, featureSetIt); } else { ++featureSetIt; } } } }
void thread_ssid_msgio(void) { int ret = pthread_detach(pthread_self()); Debug("pthread_self():%lu, ret[%d]", pthread_self(), ret); char mac[32] = {0}; char ssid[14] = {"FotileAP_"}; int retssid = 0; while (1) { fd_set rset, wset; FD_ZERO(&rset); //FD_ZERO(&wset); int i, maxfd, rcvfd; maxfd = set_get_max(&ssid_fdset); for(i=0;i<set_get_elem_num(&ssid_fdset);i++) { FD_SET(set_at(&ssid_fdset, i),&rset); } //FD_SET(socket_fd,&wset); struct timeval tval; tval.tv_sec = 0; tval.tv_usec = 10000; if(select(maxfd+1, &rset, NULL, NULL,&tval) > 0) { int i; for(i=0;i<set_get_elem_num(&ssid_fdset);i++) { if(FD_ISSET(set_at(&ssid_fdset, i), &rset)) { rcvfd = set_at(&ssid_fdset, i); break; } } char szRcv[MAX_MESSAGE_LEN] = {0}; int len = 0; int lens =0; unsigned char mac_arr[6] = {0}; //not use if (retssid == 0){ retssid = get_eth0_mac(mac, mac_arr, 32); ssid[9] = mac[12]; ssid[10] = mac[13]; ssid[11] = mac[15]; ssid[12] = mac[16]; Debug("first time get ssid!"); }else{ } int ret = recv(rcvfd, szRcv, MAX_MESSAGE_LEN, 0); //Info("ret[%d]%s", ret, szRcv); if (ret > 0) { cJSON *root1 = cJSON_Parse(szRcv); cJSON *root2 = cJSON_CreateObject(); if(strcmp(cJSON_GetObjectItem(root1,"type")->valuestring,"reqssid") == 0) { cJSON_AddItemToObject(root2, "type", cJSON_CreateString("reqssid")); cJSON_AddNumberToObject(root2, "seq", cJSON_GetObjectItem(root1,"seq")->valueint); if(retssid > 0) { cJSON_AddNumberToObject(root2, "respcode", 0); cJSON_AddStringToObject(root2, "respmsg", ssid); } else { cJSON_AddNumberToObject(root2, "respcode", -1); cJSON_AddStringToObject(root2,"respmsg", "error:get ssid failed!"); } char *out = cJSON_Print(root2); //Info("out[%s]", out); lens = strlen(out); send(rcvfd, out , lens ,0); //Info("%s",rendered); cJSON_Delete(root1); cJSON_Delete(root2); free(out); }else{ Warn("param error!"); } } else { //Warn("[fd:%d]rcv error! close socket", rcvfd); set_erase(rcvfd, &ssid_fdset); close(rcvfd); } } } }
void CArchiveScanner::WriteCacheData(const std::string& filename) { if (!isDirty) { return; } FILE* out = fopen(filename.c_str(), "wt"); if (!out) { return; } // First delete all outdated information // TODO: this pattern should be moved into an utility function.. for (std::map<std::string, ArchiveInfo>::iterator i = archiveInfo.begin(); i != archiveInfo.end(); ) { if (!i->second.updated) { i = set_erase(archiveInfo, i); } else { ++i; } } for (std::map<std::string, BrokenArchive>::iterator i = brokenArchives.begin(); i != brokenArchives.end(); ) { if (!i->second.updated) { i = set_erase(brokenArchives, i); } else { ++i; } } fprintf(out, "local archiveCache = {\n\n"); fprintf(out, "\tinternalver = %i,\n\n", INTERNAL_VER); fprintf(out, "\tarchives = { -- count = "_STPF_"\n", archiveInfo.size()); std::map<std::string, ArchiveInfo>::const_iterator arcIt; for (arcIt = archiveInfo.begin(); arcIt != archiveInfo.end(); ++arcIt) { const ArchiveInfo& arcInfo = arcIt->second; fprintf(out, "\t\t{\n"); SafeStr(out, "\t\t\tname = ", arcInfo.origName); SafeStr(out, "\t\t\tpath = ", arcInfo.path); fprintf(out, "\t\t\tmodified = \"%u\",\n", arcInfo.modified); fprintf(out, "\t\t\tchecksum = \"%u\",\n", arcInfo.checksum); SafeStr(out, "\t\t\treplaced = ", arcInfo.replaced); // mod info? const ArchiveData& archData = arcInfo.archiveData; if (!archData.GetName().empty()) { fprintf(out, "\t\t\tarchivedata = {\n"); const std::map<std::string, InfoItem>& info = archData.GetInfo(); std::map<std::string, InfoItem>::const_iterator ii; for (ii = info.begin(); ii != info.end(); ++ii) { switch (ii->second.valueType) { case INFO_VALUE_TYPE_STRING: { SafeStr(out, std::string("\t\t\t\t" + ii->first + " = ").c_str(), ii->second.valueTypeString); } break; case INFO_VALUE_TYPE_INTEGER: { fprintf(out, "\t\t\t\t%s = %d,\n", ii->first.c_str(), ii->second.value.typeInteger); } break; case INFO_VALUE_TYPE_FLOAT: { fprintf(out, "\t\t\t\t%s = %f,\n", ii->first.c_str(), ii->second.value.typeFloat); } break; case INFO_VALUE_TYPE_BOOL: { fprintf(out, "\t\t\t\t%s = %d,\n", ii->first.c_str(), (int)ii->second.value.typeBool); } break; } } std::vector<std::string> deps = archData.GetDependencies(); if (archData.GetModType() == modtype::map) { FilterDep(deps, "Map Helper v1"); } else if (archData.GetModType() == modtype::primary) { FilterDep(deps, "Spring content v1"); } if (!deps.empty()) { fprintf(out, "\t\t\t\tdepend = {\n"); for (unsigned d = 0; d < deps.size(); d++) { SafeStr(out, "\t\t\t\t\t", deps[d]); } fprintf(out, "\t\t\t\t},\n"); } fprintf(out, "\t\t\t},\n"); } fprintf(out, "\t\t},\n"); } fprintf(out, "\t},\n\n"); // close 'archives' fprintf(out, "\tbrokenArchives = { -- count = "_STPF_"\n", brokenArchives.size()); std::map<std::string, BrokenArchive>::const_iterator bai; for (bai = brokenArchives.begin(); bai != brokenArchives.end(); ++bai) { const BrokenArchive& ba = bai->second; fprintf(out, "\t\t{\n"); SafeStr(out, "\t\t\tname = ", bai->first); SafeStr(out, "\t\t\tpath = ", ba.path); fprintf(out, "\t\t\tmodified = \"%u\",\n", ba.modified); SafeStr(out, "\t\t\tproblem = ", ba.problem); fprintf(out, "\t\t},\n"); } fprintf(out, "\t},\n"); // close 'brokenArchives' fprintf(out, "}\n\n"); // close 'archiveCache' fprintf(out, "return archiveCache\n"); fclose(out); isDirty = false; }