int main(int argc, char** argv) { int res; wchar_t* filename; wchar_t* storename; wchar_t* sourcename; int index; IStorage* storage; if (argc < 4) { (void)do_help(argc, argv); return 1; } filename = strdupwstr(argv[1]); index = atoi(argv[3]); sourcename = strdupwstr(argv[2]); res = OpenStore(filename, TRUE, &storage); if (res == 0) fatal("Error opening store"); free(filename); res = GetStreamName(storage, index, &storename); if (res == 0) fatal("Error geting store name"); res = AddStore(storage, storename, sourcename); if (res == 0) fatal("Error adding store"); (void)free(storename); (void)free(sourcename); (int)CloseStore(storage); return 0; }
BOOL PrePartialWriteImage(TCHAR *pDiskName, DWORD dwLength) {/* ghStore = CreateFile( pDiskName, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );*/ ghStore = OpenStore(pDiskName); if(ghStore == INVALID_HANDLE_VALUE) { RETAILMSG(1, (_T("Opening disk %s failed.\r\n"), pDiskName)); return FALSE; } if(g_MediaType == MEDIA_SDMMC) { return SDPrePartialWriteMBRModeImage(g_fwType, dwLength); } else { g_NANDWrtImgInfo.dwIndex = 0; } return TRUE; }
int main(int argc, char** argv) { int res; wchar_t* filename; int index; FILE* out; IStorage* storage; if (argc < 4) { (void)do_help(argc, argv); return 1; } filename = strdupwstr(argv[1]); index = atoi(argv[2]); out = fopen(argv[3], "wb"); if (out == NULL) fatal("Error opening file to save to"); res = OpenStore(filename, FALSE, &storage); if (res == 0) fatal("Error opening store"); free(filename); res = SaveStream(storage, index, out); if (res == 0) fatal("Error saving stream"); (int)CloseStore(storage); (int)fclose(out); return 0; }
/** * Starts CSmsPDUDelete active object * Calls private methd OpenStore * * @param aStatus Reguest status * @param aStoreIndex Index to the store to be read */ void CSmsPDUDelete::Start(CArrayFix<TGsmSmsSlotEntry>& aLocationArray, TRequestStatus& aStatus) { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPDUDELETE_START_1, "CSmsPDUDelete::Start()"); __ASSERT_DEBUG(iState==ESmsPDUDeleteIdle,SmspPanic(KSmspPanicUnexpectedState)); Queue(aStatus); iLocationArray=&aLocationArray; iState=ESmsPDUDeleteOpeningStore; OpenStore(); } // CSmsPDUDelete::Start
int AddStore(IStorage* storage, wchar_t* storename, wchar_t* sourcename) { int res; IStorage* store; IStorage* source; LARGE_INTEGER li; ULARGE_INTEGER uli; memset(&li, 0, sizeof(li)); memset(&uli, 0, sizeof(uli)); assert(storage != NULL); assert(storename != NULL); assert(sourcename != NULL); res = storage->lpVtbl->DestroyElement(storage, storename); if (res == S_OK) fprintf(stderr, "Deleted already existing store %S\n", storename); else if (res != STG_E_FILENOTFOUND) return 0; fprintf(stderr, "Creating store %S\n", storename); res = storage->lpVtbl->CreateStorage(storage, storename, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &store); if (res != S_OK) return 0; res = OpenStore(sourcename, FALSE, &source); if (res == 0) return 0; fprintf(stderr, "Copying source to storage\n"); res = source->lpVtbl->CopyTo(source, 0, NULL, 0, store); if (res != S_OK) return 0; fprintf(stderr, "Committing\n"); res = store->lpVtbl->Commit(store, STGC_DEFAULT); if (res != S_OK) return 0; (ULONG)store->lpVtbl->Release(store); (ULONG)source->lpVtbl->Release(source); fprintf(stderr, "Done\n"); return 1; }
BOOL GetDeviceHandle(TCHAR *pDiskName) { ghStore = OpenStore(pDiskName); if(ghStore == INVALID_HANDLE_VALUE) { RETAILMSG(1, (_T("Opening disk %s failed.Error code is %d\r\n"), pDiskName, GetLastError())); CloseHandle(ghStore); ghStore = NULL; return FALSE; } GetStoreList(); if(g_MediaType == MEDIA_SDMMC) { SDGetHandle(ghStore); } return TRUE; }
void CMapiApi::GetStoreInfo( CMapiFolder *pFolder, long *pSzContents) { HRESULT hr; LPMDB lpMdb; if (pSzContents) *pSzContents = 0; if (!OpenStore( pFolder->GetCBEntryID(), pFolder->GetEntryID(), &lpMdb)) return; LPSPropValue pVal; /* pVal = GetMapiProperty( lpMdb, PR_DISPLAY_NAME); ReportStringProp( " Message store name:", pVal); pVal = GetMapiProperty( lpMdb, PR_MDB_PROVIDER); ReportUIDProp( " Message store provider:", pVal); pVal = GetMapiProperty( lpMdb, PR_COMMENT); ReportStringProp( " Message comment:", pVal); pVal = GetMapiProperty( lpMdb, PR_ACCESS_LEVEL); ReportLongProp( " Message store Access Level:", pVal); pVal = GetMapiProperty( lpMdb, PR_STORE_SUPPORT_MASK); ReportLongProp( " Message store support mask:", pVal); pVal = GetMapiProperty( lpMdb, PR_STORE_STATE); ReportLongProp( " Message store state:", pVal); pVal = GetMapiProperty( lpMdb, PR_OBJECT_TYPE); ReportLongProp( " Message store object type:", pVal); pVal = GetMapiProperty( lpMdb, PR_VALID_FOLDER_MASK); ReportLongProp( " Message store valid folder mask:", pVal); pVal = GetMapiProperty( lpMdb, 0x8001001e); ReportStringProp( " Message prop 0x8001001e:", pVal); // This key appears to be the OMI Account Manager account that corresponds // to this message store. This is important for IMAP accounts // since we may not want to import messages from an IMAP store! // Seems silly if you ask me! // In order to test this, we'll need the registry key to look under to determine // if it contains the "IMAP Server" value, if it does then we are an // IMAP store, if not, then we are a non-IMAP store - which may always mean // a regular store that should be imported. pVal = GetMapiProperty( lpMdb, 0x80000003); ReportLongProp( " Message prop 0x80000003:", pVal); // ListProperties( lpMdb); */ pVal = GetMapiProperty( lpMdb, PR_IPM_SUBTREE_ENTRYID); if (pVal) { ULONG cbEntry; LPENTRYID pEntry; LPMAPIFOLDER lpSubTree = NULL; if (GetEntryIdFromProp( pVal, cbEntry, pEntry)) { // Open up the folder! ULONG ulObjType; hr = lpMdb->OpenEntry( cbEntry, pEntry, NULL, 0, &ulObjType, (LPUNKNOWN *) &lpSubTree); MAPIFreeBuffer( pEntry); if (SUCCEEDED( hr) && lpSubTree) { // Find out if there are any contents in the // tree. LPMAPITABLE lpTable; hr = lpSubTree->GetHierarchyTable( 0, &lpTable); if (HR_FAILED(hr)) { MAPI_TRACE2( "GetStoreInfo: GetHierarchyTable failed: 0x%lx, %d\n", (long)hr, (int)hr); } else { ULONG rowCount; hr = lpTable->GetRowCount( 0, &rowCount); lpTable->Release(); if (SUCCEEDED( hr) && pSzContents) *pSzContents = (long) rowCount; } lpSubTree->Release(); } } } }
/** * Open a message store with read-only access. * * @param[in] sEntryId * The entryid of the store to open. * @param[out] lppMsgStore * Pointer to a IMsgStore pointer that will be assigned the * address of the returned message store. * * @return HRESULT */ HRESULT ArchiverSession::OpenReadOnlyStore(const entryid_t &sEntryId, LPMDB *lppMsgStore) { return OpenStore(sEntryId, fMapiDeferredErrors|MDB_NO_MAIL|MDB_TEMPORARY, lppMsgStore); }
/** * Called by Active Scheduler * * Deletes slots giving in array. Opens new store if store change */ void CSmsPDUDelete::DoRunL() { OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPDUDELETE_DORUNL_1, "CSmsPDUDelete::RunL [iStatus=%d]", iStatus.Int()); switch (iState) { case ESmsPDUDeleteOpeningStore: { // // If the store was opened, then delete the PDU... // if (iStatus.Int() == KErrNone) { DeletePDU(); } } break; case ESmsPDUDeleteDeletingPDU: { // // If deleting the PDU returned not found, then this is a valid // result so assume KErrNone. // if (iStatus.Int() == KErrNotFound || iStatus.Int() == KErrGsmSMSInvalidMemoryIndex) { iStatus = KErrNone; } // // If the delete was successful (or assumed to be) then remove // it from the list. If the next one is the on a different store, // then change stores, otherwise delete it. // if (iStatus.Int() == KErrNone) { iLocationArray->Delete(0); if (iLocationArray->Count() > 0) { if (iLocationArray->At(0).iStore != iCurrentStore) { OpenStore(); } else { DeletePDU(); } } } } break; default: { SmspPanic(KSmspPanicUnexpectedState); } break; } // // DoRunL() will now return to CSmsuActiveBase which if the object // is not active, will call Complete(). // } // CSmsPDUDelete::DoRunL
int main() { printf("******************************************\n"); printf("* Record Manager Application *\n"); printf("* Xinyi He *\n"); printf("******************************************\n"); char c; do { printf("\n"); printf("a. Open database\n"); printf("b. Get first record\n"); printf("c. Get next record \n"); printf("d. Get previous record\n"); printf("e. Get Nth record\n"); printf("f. Insert record\n"); printf("g. Bulk insert records in file\n"); printf("h. Delete record\n"); printf("i. Update record\n"); printf("j. Find record with first attribute value\n"); printf("k. Show catalog file\n"); printf("l. Get first page\n"); printf("m. Get next page\n"); printf("n. Show buf stats\n"); printf("o. Commit changes\n"); printf("p. Exit\n"); printf("Please press letter to choose an action.\n"); c = getchar(); fflush(stdin); char filename[100]; switch (c) { //a. Open database case 'a': { printf("Please input the database name (don't include extension): "); gets(filename); OpenStore(filename); break; } //b. Get first record case 'b': { Output(FirstRec()); break; } //c. Get next record case 'c': { Output(NextRec()); break; } //d. Get previous record case 'd': { Output(PriorRec()); break; } //e. Get Nth record case 'e': { printf("\nInput N: "); int n; scanf("%d", &n); Output(NRec(n)); fflush(stdin); break; } //f. Insert record case 'f': { printf("\nInput a comma-delimited Record:\n"); char statement[100]; scanf("%s", &statement); fflush(stdin); InsertRec(statement); break; } //g. Bulk insert records in file case 'g': { printf("\nInput the filename(include extension): "); char file[100]; scanf("%s", &file); InsertRecFromFile(file); fflush(stdin); break; } //h. Delete record case 'h': { DeleteRec(); break; } //i. Update record case 'i': { printf("\nInput a comma-delimited Record:\n"); char statement[100]; scanf("%s", &statement); fflush(stdin); UpdateRec(statement); break; } //j. Find record with first attribute value case 'j': { printf("\nInput value:\n"); char statement[100]; scanf("%s", &statement); fflush(stdin); SearchRec(statement); break; } //k. Show catalog file case 'k': { DisplyCatFile(filename); break; } //l. Get first page case 'l': { GetPage(0); break; } //m. Get next page case 'm': { GetPage(1); break; } //n. Show buf stats case 'n': { ShowBuf(); break; } //o. Commit changes case 'o': { Commit(filename); break; } //p. Exit case 'p': { CloseStore(filename); } }; }while(c != 'p'); return 0; }