static bool arch_bfdInit(pid_t pid, bfd_t * bfdParams) { char fname[PATH_MAX]; snprintf(fname, sizeof(fname), "/proc/%d/exe", pid); if ((bfdParams->bfdh = bfd_openr(fname, 0)) == NULL) { LOGMSG(l_ERROR, "bfd_openr(%s) failed", fname); return false; } if (!bfd_check_format(bfdParams->bfdh, bfd_object)) { LOGMSG(l_ERROR, "bfd_check_format() failed"); return false; } int storage_needed = bfd_get_symtab_upper_bound(bfdParams->bfdh); if (storage_needed <= 0) { LOGMSG(l_ERROR, "bfd_get_symtab_upper_bound() returned '%d'", storage_needed); return false; } if ((bfdParams->syms = (asymbol **) malloc(storage_needed)) == NULL) { LOGMSG_P(l_ERROR, "malloc(%d) failed", storage_needed); return false; } bfd_canonicalize_symtab(bfdParams->bfdh, bfdParams->syms); if ((bfdParams->section = bfd_get_section_by_name(bfdParams->bfdh, ".text")) == NULL) { LOGMSG(l_ERROR, "bfd_get_section_by_name('.text') failed"); return false; } return true; }
bool arch_prepareParent(honggfuzz_t * hfuzz) { if (!hfuzz->pid) { return true; } #define MAX_THREAD_IN_TASK 4096 int tasks[MAX_THREAD_IN_TASK + 1]; tasks[MAX_THREAD_IN_TASK] = 0; if (!arch_listThreads(tasks, MAX_THREAD_IN_TASK, hfuzz->pid)) { LOGMSG(l_ERROR, "Couldn't read thread list for pid '%d'", hfuzz->pid); return false; } for (int i = 0; i < MAX_THREAD_IN_TASK && tasks[i]; i++) { if (ptrace(PT_ATTACH, tasks[i], NULL, NULL) == -1) { LOGMSG_P(l_ERROR, "Couldn't ptrace() ATTACH to pid: %d", tasks[i]); return false; } int status; while (waitpid(tasks[i], &status, WUNTRACED | __WALL) != tasks[i]) ; if (ptrace(PT_CONTINUE, tasks[i], NULL, NULL) == -1) { LOGMSG_P(l_ERROR, "Couldn't ptrace() CONTINUE pid: %d", tasks[i]); ptrace(PT_DETACH, tasks[i], 0, SIGCONT); return false; } LOGMSG(l_INFO, "Successfully attached to pid/tid: %d", tasks[i]); } return true; }
// interpret exception processed by Utils::HandleException: // filter out some errors like invalid db - users don't want to // see such errors as actual errors int InterpretException ( int64_t rcCodeUtil, bool bSilent, char const* szErrDesc ) { if ( rcCodeUtil == Utils::rcUnknown || rcCodeUtil == Utils::rcErrorStdExc || rcCodeUtil == Utils::rcInvalid) { if ( ! bSilent ) LOGMSG ( klogErr, szErrDesc ); return 3; } else if (rcCodeUtil == SILENT_RC( rcDB,rcMgr,rcOpening,rcDatabase,rcIncorrect ) || rcCodeUtil == SILENT_RC( rcVFS,rcTree,rcResolving,rcPath,rcNotFound )) { if ( ! bSilent ) LOGMSG ( klogWarn, szErrDesc ); return 0; } else { if ( ! bSilent ) LOGMSG ( klogErr, szErrDesc ); return 3; } }
int cRawWriter::Put(eStreamId StreamId, uint64_t StreamPos, const uchar *Data, int DataCount) { if (Running() && StreamId == sidVdr) { // Serialize Put access to keep Data and Header together LOCK_THREAD; if (m_RingBuffer.Free() < DataCount) { if (m_BufferOverflows++ > MAX_OVERFLOWS_BEFORE_DISCONNECT) { LOGMSG("cXinelibServer: Too many TCP buffer overflows, dropping client"); m_RingBuffer.Clear(); Cancel(-1); return 0; } return -DataCount; } int n = m_RingBuffer.Put(Data, DataCount); if (n == DataCount) { m_BufferOverflows = 0; m_PutPos += n; return n; } LOGMSG("cXinelibServer: TCP buffer internal error ?!?"); m_RingBuffer.Clear(); Cancel(-1); } return 0; }
static void arch_ptraceEvent(honggfuzz_t * hfuzz, fuzzer_t * fuzzer, int status, pid_t pid) { unsigned long event_msg; if (ptrace(PTRACE_GETEVENTMSG, pid, NULL, &event_msg) == -1) { LOGMSG(l_ERROR, "ptrace(PTRACE_GETEVENTMSG,%d) failed", pid); return; } LOGMSG(l_DEBUG, "PID: %d, Ptrace event: %d, event_msg: %ld", pid, __WEVENT(status), event_msg); switch (__WEVENT(status)) { case PTRACE_EVENT_EXIT: if (WIFEXITED(event_msg)) { LOGMSG(l_DEBUG, "PID: %d exited with exit_code: %d", pid, WEXITSTATUS(event_msg)); if (WEXITSTATUS(event_msg) == HF_MSAN_EXIT_CODE) { arch_ptraceSaveData(hfuzz, pid, fuzzer); } } else if (WIFSIGNALED(event_msg)) { LOGMSG(l_DEBUG, "PID: %d terminated with signal: %d", pid, WTERMSIG(event_msg)); } else { LOGMSG(l_DEBUG, "PID: %d exited with unknown status: %ld", pid, event_msg); } break; default: break; } ptrace(PT_CONTINUE, pid, 0, 0); return; }
static void _remove_phone(const char* phoneno) { phone_entry_t* entry; phone_entry_t* prev = NULL; //TODO: mutex protection of calling function entry = G_phoneBook.head; while(entry && strcmp(entry->phoneNo, phoneno)) { prev = entry; entry = entry->next; } if (entry == NULL) { LOGMSG(LOG_LEVEL_WARN, "Could not found registered phone no %s. Has been removed or un-registered ?\n", phoneno); return; } if (prev == NULL) { G_phoneBook.head = entry->next; } else { prev->next = entry->next; } //Delete this number delete_phone_entry(&entry); G_phoneBook.size--; LOGMSG(LOG_LEVEL_INFO, "Remove phone no %s success.\n", phoneno); }
int cTcpWriter::Put(const uchar *Header, int HeaderCount, const uchar *Data, int DataCount) { if (Running()) { // Serialize Put access to keep Data and Header together LOCK_THREAD; if (m_RingBuffer.Free() < HeaderCount+DataCount) { //LOGMSG("cXinelibServer: TCP buffer overflow !"); if (m_BufferOverflows++ > MAX_OVERFLOWS_BEFORE_DISCONNECT) { LOGMSG("cXinelibServer: Too many TCP buffer overflows, dropping client"); m_RingBuffer.Clear(); Cancel(-1); return 0; } return -HeaderCount-DataCount; } int n = m_RingBuffer.Put(Header, HeaderCount) + m_RingBuffer.Put(Data, DataCount); if (n == HeaderCount + DataCount) { m_BufferOverflows = 0; m_PutPos += n; return n; } LOGMSG("cXinelibServer: TCP buffer internal error ?!?"); m_RingBuffer.Clear(); Cancel(-1); } return 0; }
static gn_error parse_phonebook(char *text) { cJSON *root; root = cJSON_Parse(text); if (!root) { LOGMSG(LOG_LEVEL_CRIT, "Error before: [%s]\n",cJSON_GetErrorPtr()); return GN_ERR_FAILED; } cJSON* phonebook = cJSON_GetObjectItem(root,"phonebook"); if (!phonebook) { LOGMSG(LOG_LEVEL_CRIT, "Error: could not read phonebook object\n"); return GN_ERR_FAILED; } int i; for (i = 0;i < cJSON_GetArraySize(phonebook);i++) { cJSON *phoneItem = cJSON_GetArrayItem(phonebook,i); // handle subitem. LOGMSG(LOG_LEVEL_DEBUG, "item #%d: name=%s phone=%s\n",i, cJSON_GetObjectItem(phoneItem, "name")->valuestring, cJSON_GetObjectItem(phoneItem, "phone")->valuestring); _add_phone(cJSON_GetObjectItem(phoneItem, "name")->valuestring, cJSON_GetObjectItem(phoneItem, "phone")->valuestring); } cJSON_Delete(root); return GN_ERR_NONE; }
rc_t BufferQPopBuffer (BufferQ * self, const Buffer ** buff, timeout_t * tm) { rc_t rc = 0; timeout_t t; void * p; LOGMSG (klogDebug10, "BufferQPopBuffer"); assert (self != NULL); assert (buff != NULL); if (tm == NULL) { LOGMSG (klogDebug10, "BufferQPopBuffer tm was NULL"); tm = &t; rc = TimeoutInit (tm, self->timeout); } if (rc == 0) { LOGMSG (klogDebug10, "BufferQPopBuffer call KQueuePop"); rc = KQueuePop (self->q, &p, tm); PLOGMSG (klogDebug10, "BufferQPopBuffer back from KQueuePop $(rc)", PLOG_U32(rc), rc); if (rc == 0) *buff = p; else { *buff = NULL; } } LOGMSG (klogDebug10, "leave BufferQPopBuffer"); return rc; }
LRESULT CWindowCredentials::OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { if ( (false == iSplashLaunched) && (::GetFocus() == m_hWnd) ) { LOGMSG("launching splash!!!"); WindowsManager::GetInstnace()->ShowWindow( EWndSplash ); ::SetFocus( WindowsManager::GetInstnace()->GetWindow( EWndSplash )->m_hWnd ); LOGMSG("Launched..."); iSplashLaunched = true; } if ( TRUE == this->IsWindowVisible() ) { bHandled = FALSE; } //SHMENUBARINFO mbi; //ZeroMemory(&mbi, sizeof(SHMENUBARINFO)); //mbi.cbSize = sizeof(SHMENUBARINFO); //mbi.hwndParent = m_hWnd; //mbi.nToolBarId = 201; //mbi.hInstRes = ModuleHelper::GetResourceInstance(); //mbi.dwFlags = SHCMBF_HMENU; //SHCreateMenuBar( &mbi ); //bHandled = TRUE; return 0; }
struct bt_announce4_reply* announce4(struct bt_announce4_request *request) { #if 0 /* TODO: check if connection_id is known */ /* replace 0 (default) ip with the real ip address */ if(ip==0) { ip = cliAddr.sin_addr.s_addr; } /* convert info_hash and peer_id to hex so that they are printable */ info_hash_hex = strToHexStr(info_hash,20); peer_id_hex = strToHexStr(peer_id,20); LOGMSG(LOG_DEBUG,"Connection ID: %lld",connection_id); LOGMSG(LOG_DEBUG,"Info Hash: %s Peer ID: %s",info_hash_hex, peer_id_hex); LOGMSG(LOG_DEBUG,"Downloaded: %lld Left: %lld Uploaded: %lld",downloaded,left,uploaded); LOGMSG(LOG_DEBUG,"Event: %uNumber of Peers wanted: %u",event, num_want); /* TODO: if authentication extension is activated check if auth correct */ /* check if peer has already announced */ int announced = has_peer_announced_in_past(info_hash_hex,peer_id_hex); /* update entry if peer has announced already */ update_database4(info_hash_hex,peer_id_hex,downloaded,uploaded,left,ip,key,port,announced); /* delet old peers from database */ delete_old_entries(interval); /* Get number of seeders and leechers */ seeders_and_leechers(info_hash_hex,&seeders,&leechers); /* get data of the peers from the database */ Peer *peers; peers = get_peer_data4(&num_peers,info_hash_hex,num_want); #endif return NULL; }
bool arch_ptraceAttach(pid_t pid) { #define MAX_THREAD_IN_TASK 4096 int tasks[MAX_THREAD_IN_TASK + 1]; tasks[MAX_THREAD_IN_TASK] = 0; if (!arch_listThreads(tasks, MAX_THREAD_IN_TASK, pid)) { LOGMSG(l_ERROR, "Couldn't read thread list for pid '%d'", pid); return false; } for (int i = 0; i < MAX_THREAD_IN_TASK && tasks[i]; i++) { if (ptrace (PTRACE_SEIZE, tasks[i], NULL, PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK | PTRACE_O_TRACEEXIT) == -1) { LOGMSG_P(l_ERROR, "Couldn't ptrace(PTRACE_SEIZE) to pid: %d", tasks[i]); return false; } LOGMSG(l_DEBUG, "Successfully attached to pid/tid: %d", tasks[i]); } for (int i = 0; i < MAX_THREAD_IN_TASK && tasks[i]; i++) { ptrace(PT_CONTINUE, tasks[i], NULL, NULL); } return true; }
// 删除链路配置信息 defGSReturn CCommLinkManager::Cfg_Delete( const defLinkID LinkID ) { db_Delete_comm_link( LinkID ); Relation_DeleteForLink( LinkID ); struDelCommLink delobj; delobj.delts = timeGetTime(); //defmapCommLinkCfg::const_iterator it = this->m_CfgList.find(LinkID); defmapCommLinkCfg::iterator it = this->m_CfgList.find(LinkID); if( it != this->m_CfgList.end() ) { it->second->enable = 0; delobj.cfgobj = it->second; m_CfgList.erase(it); LOGMSG( "CommLinkMgr:CfgList Del LinkID=%d, aftercount(%d)", LinkID, m_CfgList.size() ); } delobj.runobj = Run_Remove( LinkID ); { gloox::util::MutexGuard mutexguard( m_mutex_CommLinkMgr ); m_DeleteList.push_back( delobj ); } LOGMSG( "CommLinkMgr:DeleteList insert LinkID=%d, aftercount(%d)", LinkID, m_DeleteList.size() ); return defGSReturn_Success; }
void G_SpawnMap( g_map_t *map, char *path ) { // // load classes // SHV_Printf( " ... planes\n" ); map->planehm = G_MapTryClassLoad( path, MAP_CLASS_NAME_PLANES ); SHV_Printf( " ... mapnodes\n" ); map->mapnodehm = G_MapTryClassLoad( path, MAP_CLASS_NAME_MAPNODES ); SHV_Printf( " ... texdefs\n" ); map->texdefhm = G_MapTryClassLoad( path, MAP_CLASS_NAME_TEXDEFS ); SHV_Printf( " ... textures\n" ); map->texturehm = G_MapTryClassLoad( path, MAP_CLASS_NAME_TEXTURES ); SHV_Printf( " ... visleafs\n" ); map->visleafhm = G_MapTryClassLoad( path, MAP_CLASS_NAME_VISLEAFS ); SHV_Printf( " ... blockmap brushes\n" ); map->blockmaphm = G_MapTryClassLoad( path, MAP_CLASS_NAME_BLOCKMAP ); SHV_Printf( " ... shapes\n" ); map->shapehm = G_MapTryClassLoad( path, MAP_CLASS_NAME_SHAPES ); if ( !map->planehm ) __error( "plane class load failed.\n" ); if ( !map->mapnodehm ) __error( "mapnode class load failed.\n" ); if ( !map->texdefhm ) __error( "texdef class load failed.\n" ); if ( !map->texturehm ) __error( "texture class loaf failed.\n" ); if ( !map->visleafhm ) __error( "visleaf class load failed.\n" ); if ( !map->blockmaphm ) __error( "blockmap class load failed.\n" ); if ( !map->shapehm ) __error( "shape class load failed.\n" ); #if 0 LOGMSG( " volume map ...\n" ); map->volume_ccmap3 = G_MapTryCCMap3Load( path, MAP_CCMAP3_NAME_VOLUME ); LOGMSG( " field map ...\n" ); map->field_ccmap3 = G_MapTryCCMap3Load( path, MAP_CCMAP3_NAME_FIELD ); if ( !map->volume_ccmap3 ) __warning( "volume binary load failed.\n" ); if ( !map->field_ccmap3 ) __warning( "field binary load failed.\n" ); #endif }
gn_error db_phone_store(void) { char *begin = strdup(BEGIN_PHONE); char *end = strdup(END_PHONE); int fd; char buffer[256]; int len; snprintf(buffer, sizeof(buffer), "%s.encode", PHONE_FILENAME_BUFFER); LOGMSG(LOG_LEVEL_INFO, "Will save phonebook to file %s\n", buffer); fd = open(buffer, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); if (fd < 0) { LOGMSG(LOG_LEVEL_CRIT, "Could not open file %s for saving phonebook\n", buffer); goto out; } //Reset key reset_key(); encode(begin, strlen(BEGIN_PHONE)); if (safe_write(fd, begin, strlen(BEGIN_PHONE))) { LOGMSG(LOG_LEVEL_CRIT, "Write fail. Could not save phonebook\n"); goto out; } phone_entry_t* entry = G_phoneBook.head; while(entry) { if (entry->next) { len = snprintf(buffer, sizeof(buffer), "{\"name\": \"%s\", \"phone\": \"%s\"},\n", entry->name, entry->phoneNo); } else { len = snprintf(buffer, sizeof(buffer), "{\"name\": \"%s\", \"phone\": \"%s\"}\n", entry->name, entry->phoneNo); } encode(buffer, len); if (safe_write(fd, buffer, len)) { LOGMSG(LOG_LEVEL_CRIT, "Write fail. Could not save phonebook\n"); goto out; } entry = entry->next; } encode(end, strlen(END_PHONE)); if (safe_write(fd, end, strlen(END_PHONE))) { LOGMSG(LOG_LEVEL_CRIT, "Write fail. Could not save phonebook\n"); goto out; } out: if (fd >= 0) { close(fd); } free(begin); free(end); return GN_ERR_NONE; }
char* scrape(int* sbufLen,uint64_t connection_id, uint32_t transaction_id, char msg[],int msgLen) { /* TODO: check if connection_id and transaction_id is known */ int action = 2; int request_num; request_num =(msgLen-16)/20; LOGMSG(LOG_DEBUG,"Number of Requested Hashes: %u",request_num); *sbufLen = 8+request_num*12; char* sbuffer = malloc(*sbufLen); #ifdef LITTLE_ENDIAN action = bswap_32(action); transaction_id = bswap_32(transaction_id); #endif memcpy(sbuffer,&action,4); memcpy(sbuffer+4,&transaction_id,4); #if 0 while(request_num--) { char info_hash[20]; char* info_hash_hex; memcpy(info_hash,msg+16+request_num*20,20); info_hash_hex = strToHexStr(info_hash,20); LOGMSG(LOG_DEBUG," Info-Hash: %s",info_hash_hex); int complete,downloaded,incomplete; /* TODO: number of total downloads is missing EVENT "complete" in announce has to be saved */ seeders_and_leechers(info_hash_hex,&downloaded,&incomplete); complete = 0; LOGMSG(LOG_DEBUG," Down: %u Incomp: %u",downloaded, incomplete); #ifdef LITTLE_ENDIAN complete = bswap_32(complete); downloaded = bswap_32(downloaded); incomplete = bswap_32(incomplete); #endif memcpy(sbuffer+8+request_num*12,&complete,4); memcpy(sbuffer+12+request_num*12,&downloaded,4); memcpy(sbuffer+16+request_num*12,&incomplete,4); } return sbuffer; #endif return NULL; }
N2FCORE_API ControllerWebServices::~ControllerWebServices() { LOGMSG("destructing"); for ( int i = 0; i < iSupportedServices.GetSize(); ++i ) { delete iSupportedServices.GetValueAt(i); } if ( iPhotoOrganise ) delete iPhotoOrganise; LOGMSG("destructed"); }
void Ma57_set_real_parm( Ma57_Data *ma57, int parm, double val ) { switch (parm) { case MA57_D_PIV_THRESH: ma57->cntl[MA57_D_PIV_THRESH] = val; LOGMSG(" Set %-20s = %10.2e\n","D_PIV_THRESH",val); break; case MA57_D_PIV_NONZERO: ma57->cntl[MA57_D_PIV_NONZERO] = val; LOGMSG(" Set %-20s = %10.2e\n","D_PIV_NONZERO",val); break; } return; }
static int gnome_sessionmanager_control(DBusGConnection *connection, int enable) { GError *error; DBusGProxy *proxy; gboolean ret; /* Create a proxy object */ proxy = dbus_g_proxy_new_for_name(connection, SM_SERVICE, SM_PATH, SM_INTERFACE); if (!proxy) { LOGDBG("Failed to get a proxy for " SM_SERVICE); return 0; } error = NULL; if (enable) { ret = dbus_g_proxy_call(proxy, "Uninhibit", &error, G_TYPE_UINT, cookie, G_TYPE_INVALID, G_TYPE_INVALID); } else { ret = dbus_g_proxy_call(proxy, "Inhibit", &error, G_TYPE_STRING, GS_APPLICATION_NAME, G_TYPE_UINT, 0, G_TYPE_STRING, GS_REASON_FOR_INHIBIT, G_TYPE_UINT, 12, G_TYPE_INVALID, G_TYPE_UINT, &cookie, G_TYPE_INVALID); } g_object_unref(proxy); if (!ret) { /* Check if it's a remote exception or a regular GError */ if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) { LOGMSG(MSG_RemoteMethodException, dbus_g_error_get_name(error), error->message); } else { LOGMSG(MSG_GError, error->message); } g_error_free(error); return 0; } LOGMSG(enable ? MSG_GNOMEScreensaverEnabled : MSG_GNOMEScreensaverDisabled); return 1; }
/* Dump config to log in a readable manner */ void DumpConfig(_In_ Config* config) { LOGMSG(("\tCONFIG: { class (%s); testgroup (%s); ", config->className, n_TestGroup[(int)config->testGroup])); LOGMSG(("\t\tInterval (%d ms); fail after (%u); fail result (%d);", config->intervalMS, config->failAfterCount, config->failResult)); LOGMSG(("\t\tInitialize (%s); init code (%d); timeout (%d ms);", n_InitBehavior[(int)config->initBehavior], config->initResultCode, config->initTimeoutMS)); LOGMSG(("\t\tFinalize (%s); finalize code (%d);", n_FinalizeBehavior[(int)config->finalizeBehavior], config->finalizeResultCode)); LOGMSG(("\t\tPost behavior (%s);", n_PostBehavior[(int)config->postBehavior])); LOGMSG(("\t\tMisc test group (%s);", n_MiscTestGroup[(int)config->miscTestSubGroup])); LOGMSG(("\t\tLog Load/Unload API call (%d);", config->logLoadUnloadCall)); LOGMSG(("\t\tLifecycle current types (%d) and supported types (%d)", config->currentSubscriptionTypes, config->supportedSubscriptionTypes)); LOGMSG(("\t\t}")); }
SensorPolar2D::SensorPolar2D(unsigned int size, double angularRes, double phiMin, double maxRange, double minRange, double lowReflectivityRange) : Sensor(2, maxRange, minRange, lowReflectivityRange) { _size = size; _data = new double[_size]; _mask = new bool[_size]; for(unsigned int i=0; i<_size; i++) _mask[i] = true; _angularRes = angularRes; _phiMin = phiMin; // smallest angle that lies in bounds (must be negative) _phiLowerBound = -0.5*_angularRes + _phiMin; // if angle is too large, it might be projected with modulo 2 PI to a valid index _phiUpperBound = _phiMin + ((double)size)*_angularRes; if(_phiMin>=180.0) { LOGMSG(DBG_ERROR, "Valid minimal angle < 180 degree"); } _rays = new Matrix(2, _size); for(unsigned int i=0; i<_size; i++) { double phi = _phiMin + ((double)i) * _angularRes; (*_rays)(0, i) = cos(phi); (*_rays)(1, i) = sin(phi); } _raysLocal = new Matrix(2, size); *_raysLocal = *_rays; }
// 检测需最终删除的对象列表 void CCommLinkManager::CheckDeleteList() { if( timeGetTime()-m_last_CheckDeleteList < 20*1000 ) { return; } if( m_DeleteList.empty() ) { return; } for( std::list<struDelCommLink>::iterator it = m_DeleteList.begin(); it!= m_DeleteList.end(); ++it ) { if( it->runobj ) { if( Run_IsUsingSpec( *(it->runobj) ) ) continue; } g_del_struDelCommLink( *it ); const defLinkID id = it->cfgobj?it->cfgobj->id:-1; m_DeleteList.erase(it); LOGMSG( "CommLinkMgr:DeleteList FinalDel LinkID=%d, aftercount(%d)", id, m_DeleteList.size() ); return; } }
void Trace::addAssignment(Matrix* M, vector<unsigned int> idxM, Matrix* S, vector<unsigned int> idxS, Matrix* STrans, const double score, const unsigned int iterationID) { if(idxM.size() != idxS.size()) { LOGMSG(DBG_ERROR, "Size of model and scene assignment vectors must be equal"); return; } double** rawScene; System<double>::allocate((*STrans).getCols(), 2, rawScene); for(unsigned int j=0; j<(*STrans).getCols(); j++) { rawScene[j][0] = (*STrans)(0, j); rawScene[j][1] = (*STrans)(1, j); } vector<StrTraceCartesianPair> tracePair; for(unsigned int i=0; i<idxM.size(); i++) { StrTraceCartesianPair p; p.first[0] = (*M)(idxM[i], 0); p.first[1] = (*M)(idxM[i], 1); p.second[0] = (*S)(idxS[i], 0); p.second[1] = (*S)(idxS[i], 1); tracePair.push_back(p); } vector<unsigned int> id; id.push_back(iterationID); id.push_back(idxM[0]); id.push_back(idxS[0]); addAssignment(rawScene, STrans->getCols(), tracePair, score, id); System<double>::deallocate(rawScene); }
/**file main.cpp *@brief a main function for QMC simulation. *Actual works are done by QMCApps and its derived classe. *For other simulations, one can derive a class from QMCApps, similarly to MolecuApps. * *Only requirements are the constructor and init function to initialize. */ int main(int argc, char **argv) { OHMMS::Controller->initialize(argc,argv); OhmmsInfo welcome(argc,argv,OHMMS::Controller->mycontext()); ohmmsqmc::MolecuApps qmc(argc,argv); if(argc>1) { // build an XML tree from a the file; xmlDocPtr m_doc = xmlParseFile(argv[1]); if (m_doc == NULL) { ERRORMSG("File " << argv[1] << " is invalid") xmlFreeDoc(m_doc); return 1; } // Check the document is of the right kind xmlNodePtr cur = xmlDocGetRootElement(m_doc); if (cur == NULL) { ERRORMSG("Empty document"); xmlFreeDoc(m_doc); return 1; } qmc.run(cur); } else { WARNMSG("No argument is given. Assume that does not need an input file") qmc.run(NULL); } LOGMSG("Bye") OHMMS::Controller->finalize(); return 0; }
/******************************************************************** helper function to display failure or success message ********************************************************************/ static void display_rescode( const rc_t rc, const char* failure, const char* success ) { if ( rc != 0 ) LOGERR( klogInt, rc, failure ); else if ( success ) LOGMSG( klogInfo, success ); }
N2FCORE_API WebServiceN2FMemberService_v2::~WebServiceN2FMemberService_v2() { if ( NULL != iMemberServices ) delete iMemberServices; LOGMSG("Destructed"); }
/* write config to file */ void writeconfig(_In_ Config* config) { FILE* configfile = File_Open(config->configFilepath, "w"); if (!configfile) { return; } LOGMSG(("created config file (%s)", config->configFilepath)); fprintf(configfile, gformat1, config->testGroup, config->intervalMS, config->failAfterCount, config->failResult, config->initBehavior, config->initResultCode, config->initTimeoutMS, config->finalizeBehavior, config->finalizeResultCode, config->postBehavior, config->miscTestSubGroup, config->evalResult, config->logLoadUnloadCall); fprintf(configfile, gformat2, config->subscribeBookmark, config->providerBookmark, config->dialect, config->expression); File_Close(configfile); }
rc_t search_request ( const request_params * request ) { KService * service = NULL; const struct Kart * response = NULL; rc_t rc = KService_Make ( & service, request ); assert ( request ); if ( request -> params != NULL && * request -> params != NULL ) LOGMSG ( klogWarn, "'--" OPTION_PARAM "' is ignored: " "it used just with '--" OPTION_RAW "' '" FUNCTION_NAMES "' and '" FUNCTION_SEARCH "' funtions") ; if ( rc == 0 ) rc = KServiceSearchExecuteExt ( service, request -> search_url, request -> search_ver, & response ); if ( rc == 0 ) { const KartItem * item = NULL; while ( true ) { rc = KartMakeNextItem ( response, & item ); if ( rc != 0 || item == NULL ) break; KartItem_Print ( item ); RELEASE ( KartItem, item ); } } RELEASE ( Kart, response ); RELEASE ( KService, service ); return rc; }
defGSReturn GSIOTUserMgr::Delete_User( const std::string &jid, const bool FailedIsErr ) { if( jid==XMPP_GSIOTUser_Admin ) { return defGSReturn_Err; } defmapGSIOTUser::const_iterator it = GSIOTUserMgr::usermapFind( m_mapUser, jid ); if( it !=m_mapUser.end() ) { LOGMSG( "Delete_User jid=%s\r\n", jid.c_str() ); db_Delete_user( it->second->GetID() ); this->OnNotify( defNotify_Delete, it->second ); delete (it->second); m_mapUser.erase(it->first); //jyc20170301 notice m_mapUser.erase(it); return defGSReturn_Success; } //LOGMSGEX( defLOGNAME, FailedIsErr?defLOG_ERROR:defLOG_INFO, "Delete_User err, not found! jid=%s\r\n", jid.c_str() ); return defGSReturn_NoExist; }
bool DeviceAddress::ValueWindow( const std::string& newValue, const time_t newValTime, std::string& WindowFinishValue, uint32_t WindowTime, uint32_t WindowTimeMin ) { const uint32_t curts = timeGetTime(); if( 0==m_ValueWindow_StartTs ) { m_ValueWindow_StartTs = curts; m_ValueWindow_MaxValue = newValue; } else { if( atof(newValue.c_str())>atof(m_ValueWindow_MaxValue.c_str()) ) { m_ValueWindow_MaxValue = newValue; } const uint32_t span = curts - m_ValueWindow_StartTs; if( span >= (WindowTime*1000) || ( span>(WindowTimeMin*1000) && g_isTimePoint(newValTime,m_type) && g_TransToTimePoint(newValTime, m_type, false)!=g_TransToTimePoint(m_lastSaveTime, m_type, true) ) ) { WindowFinishValue = m_ValueWindow_MaxValue; m_ValueWindow_StartTs = 0; m_ValueWindow_MaxValue = "0"; LOGMSG( "ValueWindow(%d,%d) %s, WindowTime(%ds, min=%ds)", m_type, this->GetAddress(), WindowFinishValue.c_str(), WindowTime, WindowTimeMin ); return true; } } return false; }