nsresult nsDOMStorage::Clear() { if (!CacheStoragePermissions()) return NS_ERROR_DOM_SECURITY_ERR; if (UseDB()) CacheKeysFromDB(); PRBool foundSecureItem = PR_FALSE; mItems.EnumerateEntries(CheckSecure, &foundSecureItem); if (foundSecureItem && !IsCallerSecure()) { return NS_ERROR_DOM_SECURITY_ERR; } #ifdef MOZ_STORAGE if (UseDB()) { nsresult rv = InitDB(); NS_ENSURE_SUCCESS(rv, rv); rv = gStorageDB->ClearStorage(this); NS_ENSURE_SUCCESS(rv, rv); } #endif mItems.Clear(); BroadcastChangeNotification(); return NS_OK; }
nsresult nsDOMStorage::GetDBValue(const nsAString& aKey, nsAString& aValue, PRBool* aSecure) { aValue.Truncate(); #ifdef MOZ_STORAGE if (!UseDB()) return NS_OK; nsresult rv = InitDB(); NS_ENSURE_SUCCESS(rv, rv); nsAutoString value; rv = gStorageDB->GetKeyValue(this, aKey, value, aSecure); if (rv == NS_ERROR_DOM_NOT_FOUND_ERR && mLocalStorage) { SetDOMStringToNull(aValue); } if (NS_FAILED(rv)) return rv; if (!IsCallerSecure() && *aSecure) { return NS_ERROR_DOM_SECURITY_ERR; } aValue.Assign(value); #endif return NS_OK; }
nsresult nsDOMStorage::GetDBValue(const nsAString& aKey, nsAString& aValue, PRBool* aSecure, nsAString& aOwner) { aValue.Truncate(); #ifdef MOZ_STORAGE if (!UseDB()) return NS_OK; nsresult rv = InitDB(); NS_ENSURE_SUCCESS(rv, rv); nsAutoString value; rv = gStorageDB->GetKeyValue(mDomain, aKey, value, aSecure, aOwner); if (NS_FAILED(rv)) return rv; if (!IsCallerSecure() && *aSecure) { return NS_ERROR_DOM_SECURITY_ERR; } aValue.Assign(value); #endif return NS_OK; }
main(int argc, char *argv[]) { if (TestAndLock()) { fprintf(stderr, "Another unwind running or abandoned, please check\n"); exit(EXIT_FAILURE); } ParseArgs(argc, argv); InitSignals(); InitLog(); if (chdir(CodaUserDir)) { RemoveLock(); Die("Could not cd into %s", CodaUserDir); } if (InitDB(DataBaseName)) { RemoveLock(); fprintf(stderr, "Could not connect to database %s", DataBaseName); exit(EXIT_FAILURE); } LogMsg(100, LogLevel, LogFile, "Enter ProcessEachUser"); ProcessEachUser(); RemoveLock(); Log_Done(); }
int main() { InitDB(); CurrentLoad = GetBaseLoad(); //let's init babonet so people can connect to us InitNetwork(); //main program here bool isRunning = true; dkcInit(60); //linux time struct #ifndef WIN32 timespec ts; ts.tv_sec = 0; ts.tv_nsec = 1000000; #endif GetLatestVersion(); while(isRunning) { // On va updater notre timer int nbFrameElapsed = dkcUpdateTimer(); // On va chercher notre delay float delay = dkcGetElapsedf(); while (nbFrameElapsed) { //let's update our NetManager isRunning = Update(delay); nbFrameElapsed--; } //linux sleep #ifndef WIN32 nanosleep(&ts,0); ts.tv_sec = 0; ts.tv_nsec = 1000000; //windows sleep #else Sleep(1); #endif } //cleanup CleanUp(); return 0; }
int F847352(TRUSERID *handle, int iRequest, ST_PACK *in_pack, int *pRetCode, char *szMsg) { int error_code = 0; int money = 0; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack, 0, 1); Save_Info save_info; memset(&save_info, 0, sizeof(save_info)); SetCol(handle,0); SetCol(handle, F_LVOL0, F_LVOL1, F_DAMT0, F_DAMT1, F_SPHONE, F_LVOL10, 0); if (1 == in_pack->lvol3) { // 连接第三方数据库 if (error_code = InitDB()) { error_code = DLLFUN_ERR_TRANSFER_THIRD_PART_FAIL; goto L_RETU; } // 检测第三方帐号 CheckAccountNo(in_pack->lvol4, &money, &error_code); if (0 != error_code) { error_code = DLLFUN_ERR_CHECK_ACC_THIRD_PART_FAIL; } out_pack->lvol0 = money; goto L_RETU; } save_info.cut_id = in_pack->lvol0; save_info.save_Money = in_pack->lvol1; save_info.save_type = in_pack->lvol2; SaveInfo(&save_info, &error_code); if (error_code != 0) { g_LogFile.WriteLogEx(1001, "客户号[%d]--转帐金额[%d]--转账类型[%d]--错误码[%d]--序号[%d]", save_info.cut_id, save_info.save_Money, save_info.save_type, error_code, ++count1); error_code = DLLFUN_ERR_TRANSFER_FAIL; } L_RETU: out_pack->lvol1 = error_code; *pRetCode = error_code; PutRow(handle, out_pack, pRetCode, szMsg); return error_code; }
NS_IMETHODIMP nsDOMStorage::RemoveItem(const nsAString& aKey) { if (!CacheStoragePermissions()) return NS_ERROR_DOM_SECURITY_ERR; if (aKey.IsEmpty()) return NS_OK; nsSessionStorageEntry *entry = mItems.GetEntry(aKey); if (entry && entry->mItem->IsSecure() && !IsCallerSecure()) { return NS_ERROR_DOM_SECURITY_ERR; } if (UseDB()) { #ifdef MOZ_STORAGE nsresult rv = InitDB(); NS_ENSURE_SUCCESS(rv, rv); nsAutoString value; PRBool secureItem; nsAutoString owner; rv = GetDBValue(aKey, value, &secureItem, owner); if (rv == NS_ERROR_DOM_NOT_FOUND_ERR) return NS_OK; NS_ENSURE_SUCCESS(rv, rv); rv = gStorageDB->RemoveKey(mDomain, aKey, owner, aKey.Length() + value.Length()); NS_ENSURE_SUCCESS(rv, rv); mItemsCached = PR_FALSE; BroadcastChangeNotification(); #endif } else if (entry) { // clear string as StorageItems may be referencing this item entry->mItem->ClearValue(); BroadcastChangeNotification(); } if (entry) { mItems.RawRemoveEntry(entry); } return NS_OK; }
nsresult nsDOMStorage::SetDBValue(const nsAString& aKey, const nsAString& aValue, PRBool aSecure) { #ifdef MOZ_STORAGE if (!UseDB()) return NS_OK; nsresult rv = InitDB(); NS_ENSURE_SUCCESS(rv, rv); // Get the current domain for quota enforcement nsCOMPtr<nsIPrincipal> subjectPrincipal; nsContentUtils::GetSecurityManager()-> GetSubjectPrincipal(getter_AddRefs(subjectPrincipal)); nsAutoString currentDomain; if (subjectPrincipal) { nsCOMPtr<nsIURI> uri; rv = subjectPrincipal->GetURI(getter_AddRefs(uri)); if (NS_SUCCEEDED(rv) && uri) { nsCAutoString currentDomainAscii; uri->GetAsciiHost(currentDomainAscii); currentDomain = NS_ConvertUTF8toUTF16(currentDomainAscii); } if (currentDomain.IsEmpty()) { return NS_ERROR_DOM_SECURITY_ERR; } } else { currentDomain = mDomain; } rv = gStorageDB->SetKey(mDomain, aKey, aValue, aSecure, currentDomain, GetQuota(currentDomain)); NS_ENSURE_SUCCESS(rv, rv); mItemsCached = PR_FALSE; BroadcastChangeNotification(); #endif return NS_OK; }
nsresult nsFolderCompactState::Init(nsIMsgFolder *folder, const char *baseMsgUri, nsIMsgDatabase *db, nsIFile *path, nsIMsgWindow *aMsgWindow) { nsresult rv; m_folder = folder; m_baseMessageUri = baseMsgUri; m_file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); m_file->InitWithFile(path); // need to make sure the temp file goes in the same real directory // as the original file, so resolve sym links. m_file->SetFollowLinks(true); m_file->SetNativeLeafName(NS_LITERAL_CSTRING("nstmp")); rv = m_file->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600); //make sure we are not crunching existing nstmp file NS_ENSURE_SUCCESS(rv, rv); m_window = aMsgWindow; m_keyArray = new nsMsgKeyArray; m_size = 0; m_totalMsgSize = 0; rv = InitDB(db); if (NS_FAILED(rv)) { CleanupTempFilesAfterError(); return rv; } m_curIndex = 0; rv = MsgNewBufferedFileOutputStream(getter_AddRefs(m_fileStream), m_file, -1, 00600); if (NS_FAILED(rv)) m_folder->ThrowAlertMsg("compactFolderWriteFailed", m_window); else rv = GetMessageServiceFromURI(nsDependentCString(baseMsgUri), getter_AddRefs(m_messageService)); if (NS_FAILED(rv)) { m_status = rv; } return rv; }
NS_IMETHODIMP nsPermissionManager::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) { if (!nsCRT::strcmp(aTopic, "profile-before-change")) { // The profile is about to change, // or is going away because the application is shutting down. if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) { // clear the permissions file RemoveAllInternal(); } else { RemoveAllFromMemory(); } } else if (!nsCRT::strcmp(aTopic, "profile-do-change")) { // the profile has already changed; init the db from the new location InitDB(PR_FALSE); } return NS_OK; }
nsresult nsPermissionManager::RemoveAllInternal() { RemoveAllFromMemory(); // clear the db if (mDBConn) { nsresult rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING("DELETE FROM moz_hosts")); if (NS_FAILED(rv)) { mStmtInsert = nsnull; mStmtDelete = nsnull; mStmtUpdate = nsnull; mDBConn = nsnull; rv = InitDB(PR_TRUE); return rv; } } return NS_OK; }
nsresult nsDOMStorage::CacheKeysFromDB() { #ifdef MOZ_STORAGE // cache all the keys in the hash. This is used by the Length and Key methods // use this cache for better performance. The disadvantage is that the // order may break if someone changes the keys in the database directly. if (!mItemsCached) { nsresult rv = InitDB(); NS_ENSURE_SUCCESS(rv, rv); rv = gStorageDB->GetAllKeys(mDomain, this, &mItems); NS_ENSURE_SUCCESS(rv, rv); mItemsCached = PR_TRUE; } #endif return NS_OK; }
int F847352(TRUSERID *handle, int iRequest, ST_PACK *in_pack, int *pRetCode, char *szMsg) { int error_code = 0; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack, 0, 1); Save_Info save_info; memset(&save_info, 0, sizeof(save_info)); SetCol(handle,0); SetCol(handle, F_DAMT0, F_DAMT1, F_SPHONE, F_LVOL10, 0); if (1 == in_pack->lvol3) { if (error_code = InitDB()) error_code = DLLFUN_ERR_TRANSFER_THIRD_PART_FAIL; *pRetCode = error_code; PutRow(handle, out_pack, pRetCode, szMsg); return error_code; } save_info.cut_id = in_pack->lvol0; save_info.save_Money = in_pack->lvol1; save_info.save_type = in_pack->lvol2; SaveInfo(&save_info, &error_code); #ifdef _DEBUG g_LogFile.WriteLogEx(1001, "客户号[%d]--转帐金额[%d]--转账类型[%d]--错误码[%d]--序号[%d]", save_info.cut_id, save_info.save_Money, save_info.save_type, error_code, ++count1); #endif if (error_code != 0) error_code = DLLFUN_ERR_TRANSFER_FAIL; *pRetCode = error_code; PutRow(handle, out_pack, pRetCode, szMsg); return error_code; // return 0; }
nsresult nsPermissionManager::Init() { nsresult rv; if (!mHostTable.Init()) { return NS_ERROR_OUT_OF_MEMORY; } // ignore failure here, since it's non-fatal (we can run fine without // persistent storage - e.g. if there's no profile). // XXX should we tell the user about this? InitDB(PR_FALSE); mObserverService = do_GetService("@mozilla.org/observer-service;1", &rv); if (NS_SUCCEEDED(rv)) { mObserverService->AddObserver(this, "profile-before-change", PR_TRUE); mObserverService->AddObserver(this, "profile-do-change", PR_TRUE); } return NS_OK; }
LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { // set icons HICON hIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON)); SetIcon(hIcon, TRUE); HICON hIconSmall = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON)); SetIcon(hIconSmall, FALSE); // register object for message filtering and idle updates CMessageLoop* pLoop = _Module.GetMessageLoop(); ATLASSERT(pLoop != NULL); pLoop->AddMessageFilter(this); pLoop->AddIdleHandler(this); UIAddChildWindowContainer(m_hWnd); initValue(); LoadSetting(); InitDB(); initPreviewDlg(); initDH(); initBottomButton(); initTimeLabel(); initSlide(); initCradleButton(); //默认选中channel 0 FocusChannel(0); //默认布局 SetPreviewDlgLayout(PREVIEWLAYOUT4,0); //计时器 时钟 SetTimer(1,1000); //录像 SetTimer(2,1000); SetWindowPos(NULL,0,0,1000,700,SWP_SHOWWINDOW); CenterWindow(); RegisterStreamDirectReadCallback(StreamDirectReadCallback, this); updateSetting(); return TRUE; }
nsresult nsDOMStorage::SetSecure(const nsAString& aKey, PRBool aSecure) { #ifdef MOZ_STORAGE if (UseDB()) { nsresult rv = InitDB(); NS_ENSURE_SUCCESS(rv, rv); return gStorageDB->SetSecure(this, aKey, aSecure); } #else return NS_ERROR_NOT_IMPLEMENTED; #endif nsSessionStorageEntry *entry = mItems.GetEntry(aKey); NS_ASSERTION(entry, "Don't use SetSecure() with non-existing keys!"); if (entry) { entry->mItem->SetSecureInternal(aSecure); } return NS_OK; }
main (int argc, char *argv[]) { if (TestAndLock()) { fprintf(stderr, "Another unwind running or abandoned, please check\n"); exit(-1); } ParseArgs(argc, argv); InitSignals(); InitLog(); if (chdir(WorkingDir)) { RemoveLock(); Die("Could not cd into %s",WorkingDir); } if (InitDB(DataBaseName)) { RemoveLock(); fprintf(stderr,"Could not connect to database %s",DataBaseName); exit(-1); } GetFilesAndSpool(); RemoveLock(); Log_Done(); }
void wxDatabaseTableData::OnClickSave(wxCommandEvent &event) { if( !this->CreateSql() ) { return; } wxMessageBox( m_sql_insert ); wxSQLite3Database *m_db = InitDB( this->GetDbPath() ); int isinsert = m_db->ExecuteUpdate( m_sql_insert ); CloseDataBase( m_db ); if( isinsert == 0 ) { wxMessageBox( "Erro ao inserir" ); } else { wxMessageBox( "Registro inserido com sucesso!" ); ClearControls(); } }
int main(int argc, char* argv[]) { ::CoInitialize(NULL); // 结合SQL SERVER2000使用 int rtn = 0; time_t cur_time; time_t last_time; time(&last_time); g_pSvrLink = BUPubInitialize(g_XBDefines,CallBDFunc,WriteAppInfo,&g_LogFile); SetLogShowLevel(0); if (argc<2) ReadIni("ksbu.ini"); else ReadIni(argv[1]); ResetBPFunctions(); if (argc>2) { ListBPFunctions(argv[2]); } #ifdef _DYNAMIC_LOAD // 加载对接第三方动态库 if (rtn = g_LoadDll.LoadDataInfo("DataInfo.dll")) { g_LogFile.WriteLogEx(1002, "加载DataInfo.dll失败--错误码:[%d]", rtn); return rtn; } g_LogFile.WriteLogEx(1002, "加载DataInfo.dll成功"); #endif // 初始化第三方数据库信息 #ifdef SYNJONES_FUNC if (rtn = InitDB()) { g_LogFile.WriteLogEx(1002, "初始化第三方数据库失败--错误码:[%d]", rtn); return rtn; } g_LogFile.WriteLogEx(1002, "初始化第三方数据库成功"); #endif // 初始化与BCC连接: do { rtn = g_pSvrLink->ToLink(&g_BUnit); if (rtn==1) { DEBUG_RUNTIME_MSGOUT("与业务调度中心(BCC)的连接成功!\n"); break; } else if (rtn==-100) { DEBUG_RUNTIME_MSGOUT("估计业务调度中心(BCC)尚未正式启动,或者检查配置中的[SERVER]项参数\n"); mysleep(g_BUnit.iHBInterval); } else { // 应该属于故障,或对方并不是BCC return(rtn); } } while (1); #ifdef WIN32 setnoblockgetch(); #endif while (g_pSvrLink->LinkOK()) { #ifdef WIN32 switch (mygetch()) { case '?': case 'h': case 'H': printf("\nCommand List:\n"); printf("\t ? or h: display this Help informations!\n"); printf("\t x: To eXit this business unit.\n"); printf("\t d: Display functions status.\n"); printf("\t l: List functions status into <function.lst>.\n"); printf("Enter command to select:"); break; case 'x': case 'X': g_pSvrLink->bExit = true; continue; break; case 'd': case 'D': ListBPFunctions(NULL); break; case 'l': case 'L': ListBPFunctions("function.lst"); break; } #endif time(&cur_time); if (cur_time - last_time > g_ini_para.flash_dealy) { if (rtn = InitDB()) { g_LogFile.WriteLogEx(1002, "初始化数据库失败:[%d]", rtn); } last_time = cur_time; g_LogFile.WriteLogEx(1002, "初始化数据库成功:[%d]", rtn); } g_pSvrLink->Processing(&g_BUnit); if (g_pSvrLink->bExit) break; } g_pSvrLink->Close(); DEBUG_RUNTIME_MSGOUT("业务处理单元BU系统正常退出!\n"); g_LogFile.Close(); #ifdef _DYNAMIC_LOAD CloseDB(); g_LoadDll.UnLoadAllDll(); #endif ::CoUninitialize(); return(0); }
TLFDBLabeledImages::TLFDBLabeledImages(const char* path) { InitDB(path); }
nsresult nsDOMStorage::SetDBValue(const nsAString& aKey, const nsAString& aValue, PRBool aSecure) { #ifdef MOZ_STORAGE if (!UseDB()) return NS_OK; nsresult rv = InitDB(); NS_ENSURE_SUCCESS(rv, rv); // Get the current domain for quota enforcement nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager(); if (!ssm) return NS_ERROR_FAILURE; nsCOMPtr<nsIPrincipal> subjectPrincipal; ssm->GetSubjectPrincipal(getter_AddRefs(subjectPrincipal)); nsCAutoString currentDomain; if (subjectPrincipal) { nsCOMPtr<nsIURI> unused; rv = GetPrincipalURIAndHost(subjectPrincipal, getter_AddRefs(unused), currentDomain); // Don't bail out on NS_ERROR_DOM_SECURITY_ERR, since we want to allow // trusted file:// URIs below. if (NS_FAILED(rv) && rv != NS_ERROR_DOM_SECURITY_ERR) { return rv; } if (currentDomain.IsEmpty()) { // allow chrome urls and trusted file urls to write using // the storage's domain if (nsContentUtils::IsCallerTrustedForWrite()) currentDomain = mDomain; else return NS_ERROR_DOM_SECURITY_ERR; } } else { currentDomain = mDomain; } PRInt32 quota; PRInt32 warnQuota; GetQuota(currentDomain, "a, &warnQuota); PRInt32 usage; rv = gStorageDB->SetKey(this, aKey, aValue, aSecure, quota, &usage); NS_ENSURE_SUCCESS(rv, rv); mItemsCached = PR_FALSE; if (warnQuota >= 0 && usage > warnQuota) { // try to include the window that exceeded the warn quota nsCOMPtr<nsIDOMWindow> window; JSContext *cx; nsCOMPtr<nsIJSContextStack> stack = do_GetService("@mozilla.org/js/xpc/ContextStack;1"); if (stack && NS_SUCCEEDED(stack->Peek(&cx)) && cx) { nsCOMPtr<nsIScriptContext> scriptContext; scriptContext = GetScriptContextFromJSContext(cx); if (scriptContext) { window = do_QueryInterface(scriptContext->GetGlobalObject()); } } nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1"); os->NotifyObservers(window, "dom-storage-warn-quota-exceeded", NS_ConvertUTF8toUTF16(currentDomain).get()); } BroadcastChangeNotification(); #endif return NS_OK; }