/*SF------------------------------------------------------------------------- * function: OUTkommWrap * wrapper for stamm * call stamm detail functions * In: -aProgramm * out: - * Return: -completion code *--------------------------------------------------------------------------- */ static int OUTkommWrap (int aPrgid, int aArrid ) { extern KOMMISSION *commis ; extern int anzCommis; int i, status, id ; int found ; /*--- init --------*/ status = (int)MPOK; /*--- init mem --------*/ AKTcommisMemobjInit( ); /*--- Get all commissions ------------------------------------*/ status = AKTcommisFindAll((int)UNDEF, (int)UNDEF, (int)UNDEF, (int)UNDEF ); TEST_STATUS(status) /*--- loop for parts of arrgt -------*/ status = OUTkommLoopItems( ); TEST_STATUS(status) /*--- print some statistics -------*/ OUTkommStatistics ( ); AKTlayoutFormFeedPrint( FPout); exit: AKTcommisMemobjFree( ); return(status); }
static void U_CALLCONV myMutexInit(const void *context, UMTX *mutex, UErrorCode *status) { DummyMutex *theMutex; TEST_STATUS(*status, U_ZERO_ERROR); theMutex = (DummyMutex *)malloc(sizeof(DummyMutex)); theMutex->fLockCount = 0; theMutex->fMagic = 123456; gTotalMutexesInitialized++; gTotalMutexesActive++; gMutexContext = context; *mutex = theMutex; }
// // Test procedurecount == 0, invalid actions etc --> KM validation! // void TestInstrumentFailures() { JPFBT_PROCEDURE FailedProcedure; BOOL KernelSupported; JPFBT_PROCEDURE PatchProcedureKm; JPFBT_PROCEDURE PatchProcedureUm; JPKFBT_SESSION Session; JPKFBT_KERNEL_TYPE Type; ULONG KernelsTested = 0; ULONG TrcTypesTested = 0; for ( Type = JpkfbtKernelRetail; Type <= JpkfbtKernelMax; Type++ ) { JPKFBT_TRACING_TYPE TracingType; TEST_SUCCESS( JpkfbtIsKernelTypeSupported( Type, &KernelSupported ) ); if ( ! KernelSupported ) { continue; } TEST_SUCCESS( JpkfbtAttach( Type, &Session ) ); TEST( Session ); //// //// Tracing not initialized yet. //// //TEST_STATUS( STATUS_FBT_NOT_INITIALIZED, // JpkfbtInstrumentProcedure( // Session, // JpfbtAddInstrumentation, // ?, // ?, // &FailedProcedure ) ); // // Init tracing. // PatchProcedureUm.u.ProcedureVa = 0x7F000F00; PatchProcedureKm.u.ProcedureVa = 0x8F000F00; TrcTypesTested = 0; for( TracingType = JpkfbtTracingTypeDefault; TracingType <= JpkfbtTracingTypeMax; TracingType++ ) { NTSTATUS Status; ULONG BufCount; ULONG BufSize; PWSTR LogFile; if ( TracingType == JpkfbtTracingTypeDefault ) { BufCount = 64; BufSize = 64; LogFile = L"__testkfbt.log"; DeleteFile( LogFile ); } else { BufCount = 0; BufSize = 0; LogFile = NULL; } Status = JpkfbtInitializeTracing( Session, TracingType, BufCount, BufSize, LogFile ); if ( STATUS_KFBT_TRCTYPE_NOT_SUPPORTED == Status ) { continue; } TEST_SUCCESS( Status ); // // Mem. // TEST_STATUS( STATUS_NO_MEMORY, JpkfbtInstrumentProcedure( Session, JpfbtAddInstrumentation, 0xF0000000, &PatchProcedureUm, &FailedProcedure ) ); TEST( FailedProcedure.u.Procedure == NULL ); // // Procs. // TEST_STATUS( STATUS_INVALID_PARAMETER, JpkfbtInstrumentProcedure( Session, JpfbtAddInstrumentation, 0, NULL, &FailedProcedure ) ); TEST( FailedProcedure.u.Procedure == NULL ); TEST_STATUS( STATUS_KFBT_PROC_OUTSIDE_SYSTEM_RANGE, JpkfbtInstrumentProcedure( Session, JpfbtAddInstrumentation, 1, &PatchProcedureUm, &FailedProcedure ) ); TEST( FailedProcedure.u.Procedure == PatchProcedureUm.u.Procedure ); TEST_STATUS( STATUS_KFBT_PROC_OUTSIDE_MODULE, JpkfbtInstrumentProcedure( Session, JpfbtAddInstrumentation, 1, &PatchProcedureKm, &FailedProcedure ) ); TEST( FailedProcedure.u.Procedure == PatchProcedureKm.u.Procedure ); TEST_SUCCESS( JpkfbtShutdownTracing( Session ) ); TrcTypesTested++; } TEST_SUCCESS( JpkfbtDetach( Session, TRUE ) ); TEST( TrcTypesTested > 0 ); KernelsTested++; } TEST( KernelsTested > 0 ); }
void TestInitShutdownTracing() { BOOL KernelSupported; JPKFBT_SESSION Session; JPKFBT_KERNEL_TYPE Type; ULONG KernelsTested = 0; ULONG TrcTypesTested; for ( Type = JpkfbtKernelRetail; Type <= JpkfbtKernelMax; Type++ ) { JPKFBT_TRACING_TYPE TracingType; TEST_SUCCESS( JpkfbtIsKernelTypeSupported( Type, &KernelSupported ) ); if ( ! KernelSupported ) { continue; } TEST_SUCCESS( JpkfbtAttach( Type, &Session ) ); TEST( Session ); // // Invalid type. // TEST_STATUS( STATUS_INVALID_PARAMETER, JpkfbtInitializeTracing( Session, JpkfbtTracingTypeMax + 1, 0, 0, NULL ) ); // // Shutdown without being started. // TEST_STATUS( STATUS_FBT_NOT_INITIALIZED, JpkfbtShutdownTracing( Session ) ); // // Init & Shutdown using valid type. // TrcTypesTested = 0; for( TracingType = JpkfbtTracingTypeDefault; TracingType <= JpkfbtTracingTypeMax; TracingType++ ) { NTSTATUS Status; ULONG BufCount; ULONG BufSize; PWSTR LogFile; if ( TracingType == JpkfbtTracingTypeDefault ) { BufCount = 64; BufSize = 64; LogFile = L"__testkfbt.log"; DeleteFile( LogFile ); } else { BufCount = 0; BufSize = 0; LogFile = NULL; } TEST_STATUS( STATUS_INVALID_PARAMETER, JpkfbtInitializeTracing( Session, TracingType, BufCount, BufSize, TracingType == JpkfbtTracingTypeDefault ? NULL : L"foo" ) ); Status = JpkfbtInitializeTracing( Session, TracingType, BufCount, BufSize, LogFile ); CFIX_LOG( L"Status=%x", Status ); TEST( NT_SUCCESS( Status ) || STATUS_KFBT_TRCTYPE_NOT_SUPPORTED == Status ); if ( NT_SUCCESS( Status ) ) { TrcTypesTested++; TEST_SUCCESS( JpkfbtShutdownTracing( Session ) ); } } TEST( TrcTypesTested > 0 ); TEST_SUCCESS( JpkfbtDetach( Session, TRUE ) ); KernelsTested++; } TEST( KernelsTested > 0 ); }
static VOID TestTraceKernel() { ULONG BufferCount; ULONG BufferSize; PROC_SET Set; DWORD_PTR FailedProc; UINT Tracepoints, Count; UINT EnumCount; JPFSV_TRACEPOINT Tracepnt; HRESULT Hr; JPFSV_HANDLE KernelCtx; JPFSV_TRACING_TYPE TracingType; ULONG TypesTested = 0; TEST_OK( CdiagCreateSession( NULL, NULL, &DiagSession ) ); for ( TracingType = JpfsvTracingTypeDefault; TracingType <= JpfsvTracingTypeMax; TracingType++ ) { UINT Index; BOOL Instrumentable; WCHAR LogFile[ MAX_PATH ]; UINT PaddingSize; TEST_OK( StringCchPrintf( LogFile, _countof( LogFile ), L"__kern%d.log", TracingType ) ); // // Start a trace. // KernelCtx = NULL; Hr = JpfsvLoadContext( JPFSV_KERNEL, NULL, &KernelCtx ); if ( Hr == JPFSV_E_UNSUP_ON_WOW64 ) { CFIX_INCONCLUSIVE( L"Not supported on WOW64" ); return; } TEST_OK( Hr ); TEST( JPFSV_E_NO_TRACESESSION == JpfsvGetTracepointContext( KernelCtx, 0xF00, &Tracepnt ) ); DeleteFile( LogFile ); if ( TracingType != JpfsvTracingTypeWmk ) { TEST( E_INVALIDARG == JpfsvAttachContext( KernelCtx, TracingType, NULL ) ); Hr = JpfsvAttachContext( KernelCtx, TracingType, LogFile ); } else { TEST( E_INVALIDARG == JpfsvAttachContext( KernelCtx, TracingType, LogFile ) ); Hr = JpfsvAttachContext( KernelCtx, TracingType, NULL ); } if ( Hr == JPFSV_E_UNSUPPORTED_TRACING_TYPE || Hr == HRESULT_FROM_NT( 0xC0049300L ) ) // STATUS_KFBT_KERNEL_NOT_SUPPORTED { continue; } TEST_OK( Hr ); if ( TracingType == JpfsvTracingTypeWmk ) { BufferCount = 0; BufferSize = 0; } else { BufferCount = 5; BufferSize = 1024; } // // Instrument some procedures. // Set.Count = 0; Set.ContextHandle = KernelCtx; Set.Process = JpfsvGetProcessHandleContext( KernelCtx ); TEST( Set.Process ); // // Not all patchable... // TEST( SymEnumSymbols( Set.Process, 0, L"tcpip!*", AddProcedureSymCallback, &Set ) ); TEST_OK( JpfsvStartTraceContext( KernelCtx, BufferCount, BufferSize, DiagSession ) ); TEST( E_UNEXPECTED == JpfsvStartTraceContext( KernelCtx, BufferCount, BufferSize, DiagSession ) ); TEST( Set.Count > 0 ); TEST_OK( JpfsvCountTracePointsContext( KernelCtx, &Count ) ); TEST( 0 == Count ); TEST_STATUS( ( ULONG ) HRESULT_FROM_NT( STATUS_FBT_PROC_NOT_PATCHABLE ), JpfsvSetTracePointsContext( KernelCtx, JpfsvAddTracepoint, Set.Count, Set.Procedures, &FailedProc ) ); // // Instrumentable... // Set.Count = 0; Set.ContextHandle = KernelCtx; Set.Process = JpfsvGetProcessHandleContext( KernelCtx ); TEST( SymEnumSymbols( Set.Process, 0, IsVistaOrLater() ? L"tcpip!IPReg*" : L"tcpip!IPRc*", AddProcedureSymCallback, &Set ) ); TEST( Set.Count > 0 ); for ( Index = 0; Index < Set.Count; Index++ ) { TEST_OK( JpfsvCheckProcedureInstrumentability( KernelCtx, Set.Procedures[ Index ], &Instrumentable, &PaddingSize ) ); TEST( Instrumentable ); TEST( PaddingSize == 5 ); } // // Not instrumentable... // Set.Count = 0; Set.ContextHandle = KernelCtx; Set.Process = JpfsvGetProcessHandleContext( KernelCtx ); TEST( SymEnumSymbols( Set.Process, 0, IsVistaOrLater() ? L"tcpip!__report_gsfailure" : L"tcpip!_wcsicmp", AddProcedureSymCallback, &Set ) ); TEST( Set.Count > 0 ); TEST_OK( JpfsvCheckProcedureInstrumentability( KernelCtx, Set.Procedures[ 0 ], &Instrumentable, &PaddingSize ) ); TEST( ! Instrumentable ); TEST( PaddingSize == 0 ); // // All patchable... // Set.Count = 0; Set.ContextHandle = KernelCtx; Set.Process = JpfsvGetProcessHandleContext( KernelCtx ); TEST( Set.Process ); TEST( SymEnumSymbols( Set.Process, 0, IsVistaOrLater() ? L"tcpip!IPReg*" : L"tcpip!IPRc*", AddProcedureSymCallback, &Set ) ); TEST( Set.Count >= 3 ); TEST_OK( JpfsvSetTracePointsContext( KernelCtx, JpfsvAddTracepoint, Set.Count, Set.Procedures, &FailedProc ) ); // again - should be a noop. TEST_OK( JpfsvSetTracePointsContext( KernelCtx, JpfsvAddTracepoint, Set.Count, Set.Procedures, &FailedProc ) ); TEST( FailedProc == 0 ); TEST_OK( JpfsvCountTracePointsContext( KernelCtx, &Tracepoints ) ); TEST( Tracepoints > Set.Count / 2 ); // Duplicate-cleaned! TEST( Tracepoints <= Set.Count ); TEST_OK( JpfsvGetTracepointContext( KernelCtx, Set.Procedures[ 0 ], &Tracepnt ) ); TEST( Tracepnt.Procedure == Set.Procedures[ 0 ] ); TEST( wcslen( Tracepnt.SymbolName ) ); TEST( wcslen( Tracepnt.ModuleName ) ); TEST( JPFSV_E_TRACEPOINT_NOT_FOUND == JpfsvGetTracepointContext( KernelCtx, 0xBA2, &Tracepnt ) ); // // Count enum callbacks. // EnumCount = 0; TEST_OK( JpfsvEnumTracePointsContext( KernelCtx, CountTracepointsCallback, &EnumCount ) ); TEST( EnumCount == Tracepoints ); // // Stop while tracing active -> implicitly revoke all tracepoints. // TEST_OK( JpfsvStopTraceContext( KernelCtx, TRUE ) ); TEST_OK( JpfsvCountTracePointsContext( KernelCtx, &Count ) ); TEST( 0 == Count ); // // Trace again. // DeleteFile( LogFile ); TEST_OK( JpfsvStartTraceContext( KernelCtx, BufferCount, BufferSize, DiagSession ) ); TEST_OK( JpfsvSetTracePointsContext( KernelCtx, JpfsvAddTracepoint, Set.Count, Set.Procedures, &FailedProc ) ); TEST( FailedProc == 0 ); TEST_OK( JpfsvCountTracePointsContext( KernelCtx, &Count ) ); TEST( Tracepoints == Count ); // // Clean shutdown. // TEST_OK( JpfsvSetTracePointsContext( KernelCtx, JpfsvRemoveTracepoint, Set.Count, Set.Procedures, &FailedProc ) ); TEST( FailedProc == 0 ); TEST_OK( JpfsvCountTracePointsContext( KernelCtx, &Count ) ); TEST( 0 == Count ); TEST_OK( JpfsvStopTraceContext( KernelCtx, TRUE ) ); TEST_OK( DetachContextSafe( KernelCtx ) ); TEST_OK( JpfsvUnloadContext( KernelCtx ) ); TypesTested++; } TEST_OK( CdiagDereferenceSession( DiagSession ) ); if ( TypesTested == 0 ) { CFIX_INCONCLUSIVE( L"No TracingTypes supported" ); } }
static void TestIncDecFunctions() { UErrorCode status = U_ZERO_ERROR; int32_t t = 1; /* random value to make sure that Inc/dec works */ char *dataDir; /* Save ICU's data dir and tracing functions so that they can be resored after cleanup and reinit. */ dataDir = safeGetICUDataDirectory(); /* Verify that ICU can be cleaned up and reinitialized successfully. * Failure here usually means that some ICU service didn't clean up successfully, * probably because some earlier test accidently left something open. */ ctest_resetICU(); /* Can not set mutex functions if ICU is already initialized */ u_setAtomicIncDecFunctions(&gIncDecContext, myIncFunc, myDecFunc, &status); TEST_STATUS(status, U_INVALID_STATE_ERROR); /* Clean up ICU */ u_cleanup(); /* Can not set functions with NULL values */ status = U_ZERO_ERROR; u_setAtomicIncDecFunctions(&gIncDecContext, NULL, myDecFunc, &status); TEST_STATUS(status, U_ILLEGAL_ARGUMENT_ERROR); status = U_ZERO_ERROR; u_setAtomicIncDecFunctions(&gIncDecContext, myIncFunc, NULL, &status); TEST_STATUS(status, U_ILLEGAL_ARGUMENT_ERROR); /* u_setIncDecFunctions() should work with null or non-null context pointer */ status = U_ZERO_ERROR; gExpectedContext = NULL; u_setAtomicIncDecFunctions(NULL, myIncFunc, myDecFunc, &status); TEST_STATUS(status, U_ZERO_ERROR); gExpectedContext = &gIncDecContext; u_setAtomicIncDecFunctions(&gIncDecContext, myIncFunc, myDecFunc, &status); TEST_STATUS(status, U_ZERO_ERROR); /* After reinitializing ICU, we should not be able to set the inc/dec funcs again. */ status = U_ZERO_ERROR; u_setDataDirectory(dataDir); u_init(&status); TEST_STATUS(status, U_ZERO_ERROR); gExpectedContext = &gIncDecContext; u_setAtomicIncDecFunctions(&gIncDecContext, myIncFunc, myDecFunc, &status); TEST_STATUS(status, U_INVALID_STATE_ERROR); /* Doing ICU operations should cause our functions to be called */ gIncCount = 0; gDecCount = 0; umtx_atomic_inc(&t); TEST_ASSERT(t == 2); umtx_atomic_dec(&t); TEST_ASSERT(t == 1); TEST_ASSERT(gIncCount > 0); TEST_ASSERT(gDecCount > 0); /* Cleanup should cancel use of our inc/dec functions. */ /* Additional ICU operations should not use them */ ctest_resetICU(); gIncCount = 0; gDecCount = 0; status = U_ZERO_ERROR; u_setDataDirectory(dataDir); u_init(&status); TEST_ASSERT(gIncCount == 0); TEST_ASSERT(gDecCount == 0); status = U_ZERO_ERROR; umtx_atomic_inc(&t); umtx_atomic_dec(&t); TEST_STATUS(status, U_ZERO_ERROR); TEST_ASSERT(gIncCount == 0); TEST_ASSERT(gDecCount == 0); free(dataDir); }
static void TestMutexFunctions() { UErrorCode status = U_ZERO_ERROR; UResourceBundle *rb = NULL; char *icuDataDir; gMutexFailures = 0; /* Save initial ICU state so that it can be restored later. * u_cleanup(), which is called in this test, resets ICU's state. */ icuDataDir = safeGetICUDataDirectory(); /* Verify that ICU can be cleaned up and reinitialized successfully. * Failure here usually means that some ICU service didn't clean up successfully, * probably because some earlier test accidently left something open. */ ctest_resetICU(); /* Can not set mutex functions if ICU is already initialized */ u_setMutexFunctions(&gContext, myMutexInit, myMutexDestroy, myMutexLock, myMutexUnlock, &status); TEST_STATUS(status, U_INVALID_STATE_ERROR); /* Un-initialize ICU */ u_cleanup(); /* Can not set Mutex functions with NULL values */ status = U_ZERO_ERROR; u_setMutexFunctions(&gContext, NULL, myMutexDestroy, myMutexLock, myMutexUnlock, &status); TEST_STATUS(status, U_ILLEGAL_ARGUMENT_ERROR); status = U_ZERO_ERROR; u_setMutexFunctions(&gContext, myMutexInit, NULL, myMutexLock, myMutexUnlock, &status); TEST_STATUS(status, U_ILLEGAL_ARGUMENT_ERROR); status = U_ZERO_ERROR; u_setMutexFunctions(&gContext, myMutexInit, myMutexDestroy, NULL, myMutexUnlock, &status); TEST_STATUS(status, U_ILLEGAL_ARGUMENT_ERROR); status = U_ZERO_ERROR; u_setMutexFunctions(&gContext, myMutexInit, myMutexDestroy, myMutexLock, NULL, &status); TEST_STATUS(status, U_ILLEGAL_ARGUMENT_ERROR); /* u_setMutexFunctions() should work with null or non-null context pointer */ status = U_ZERO_ERROR; u_setMutexFunctions(&gContext, myMutexInit, myMutexDestroy, myMutexLock, myMutexUnlock, &status); TEST_STATUS(status, U_ZERO_ERROR); u_setMutexFunctions(&gContext, myMutexInit, myMutexDestroy, myMutexLock, myMutexUnlock, &status); TEST_STATUS(status, U_ZERO_ERROR); /* After reinitializing ICU, we should not be able to set the mutex funcs again. */ status = U_ZERO_ERROR; u_setDataDirectory(icuDataDir); u_init(&status); TEST_STATUS(status, U_ZERO_ERROR); u_setMutexFunctions(&gContext, myMutexInit, myMutexDestroy, myMutexLock, myMutexUnlock, &status); TEST_STATUS(status, U_INVALID_STATE_ERROR); /* Doing ICU operations should cause allocations to come through our test mutexes */ gBlockCount = 0; status = U_ZERO_ERROR; rb = ures_open(NULL, "es", &status); TEST_STATUS(status, U_ZERO_ERROR); TEST_ASSERT(gTotalMutexesInitialized > 0); TEST_ASSERT(gTotalMutexesActive > 0); ures_close(rb); /* Cleanup should destroy all of the mutexes. */ ctest_resetICU(); status = U_ZERO_ERROR; TEST_ASSERT(gTotalMutexesInitialized > 0); TEST_ASSERT(gTotalMutexesActive == 0); /* Additional ICU operations should no longer use our dummy test mutexes */ gTotalMutexesInitialized = 0; gTotalMutexesActive = 0; u_init(&status); TEST_STATUS(status, U_ZERO_ERROR); status = U_ZERO_ERROR; rb = ures_open(NULL, "fr", &status); TEST_STATUS(status, U_ZERO_ERROR); TEST_ASSERT(gTotalMutexesInitialized == 0); TEST_ASSERT(gTotalMutexesActive == 0); ures_close(rb); free(icuDataDir); if(gMutexFailures) { log_info("Note: these failures may be caused by ICU failing to initialize/uninitialize properly.\n"); log_verbose("Check for prior tests which may not have closed all open resources. See the internal function ures_flushCache()\n"); } }
static void TestHeapFunctions() { UErrorCode status = U_ZERO_ERROR; UResourceBundle *rb = NULL; char *icuDataDir; UVersionInfo unicodeVersion = {0,0,0,0}; icuDataDir = safeGetICUDataDirectory(); /* save icu data dir, so we can put it back * after doing u_cleanup(). */ /* Verify that ICU can be cleaned up and reinitialized successfully. * Failure here usually means that some ICU service didn't clean up successfully, * probably because some earlier test accidently left something open. */ ctest_resetICU(); /* Can not set memory functions if ICU is already initialized */ u_setMemoryFunctions(&gContext, myMemAlloc, myMemRealloc, myMemFree, &status); TEST_STATUS(status, U_INVALID_STATE_ERROR); /* Un-initialize ICU */ u_cleanup(); /* Can not set memory functions with NULL values */ status = U_ZERO_ERROR; u_setMemoryFunctions(&gContext, NULL, myMemRealloc, myMemFree, &status); TEST_STATUS(status, U_ILLEGAL_ARGUMENT_ERROR); status = U_ZERO_ERROR; u_setMemoryFunctions(&gContext, myMemAlloc, NULL, myMemFree, &status); TEST_STATUS(status, U_ILLEGAL_ARGUMENT_ERROR); status = U_ZERO_ERROR; u_setMemoryFunctions(&gContext, myMemAlloc, myMemRealloc, NULL, &status); TEST_STATUS(status, U_ILLEGAL_ARGUMENT_ERROR); /* u_setMemoryFunctions() should work with null or non-null context pointer */ status = U_ZERO_ERROR; u_setMemoryFunctions(NULL, myMemAlloc, myMemRealloc, myMemFree, &status); TEST_STATUS(status, U_ZERO_ERROR); u_setMemoryFunctions(&gContext, myMemAlloc, myMemRealloc, myMemFree, &status); TEST_STATUS(status, U_ZERO_ERROR); /* After reinitializing ICU, we should not be able to set the memory funcs again. */ status = U_ZERO_ERROR; u_setDataDirectory(icuDataDir); u_init(&status); TEST_STATUS(status, U_ZERO_ERROR); u_setMemoryFunctions(NULL, myMemAlloc, myMemRealloc, myMemFree, &status); TEST_STATUS(status, U_INVALID_STATE_ERROR); /* Doing ICU operations should cause allocations to come through our test heap */ gBlockCount = 0; status = U_ZERO_ERROR; rb = ures_open(NULL, "es", &status); TEST_STATUS(status, U_ZERO_ERROR); if (gBlockCount == 0) { log_err("Heap functions are not being called from ICU.\n"); } ures_close(rb); /* Cleanup should put the heap back to its default implementation. */ ctest_resetICU(); u_getUnicodeVersion(unicodeVersion); if (unicodeVersion[0] <= 0) { log_err("Properties doesn't reinitialize without u_init.\n"); } status = U_ZERO_ERROR; u_init(&status); TEST_STATUS(status, U_ZERO_ERROR); /* ICU operations should no longer cause allocations to come through our test heap */ gBlockCount = 0; status = U_ZERO_ERROR; rb = ures_open(NULL, "fr", &status); TEST_STATUS(status, U_ZERO_ERROR); if (gBlockCount != 0) { log_err("Heap functions did not reset after u_cleanup.\n"); } ures_close(rb); free(icuDataDir); ctest_resetICU(); }
/*F-------------------------------------------------------------------------- * Function: OUTstatdlt *--------------------------------------------------------------------------- */ int OUTstatdlt(int argc, char *argv[]) { extern DEVICE_PORT devicePort; extern STATUS_WERTE sta; extern int dialogsprache; extern int outputsprache; extern int DebugFlag; extern char sqlquery[]; extern MEMOBJ sqlmem; extern DIENST_TRAEGER dlt; extern KATEGORIE kat; extern TTYP_VIEW ttyp; int status, id, state; int i, anzahl, count; int katcount, katdltcount; int totkatcount, totkatdltcount; int oldkat; int dlt_id; struct tm DateTime; char bezeichnung[_BEZLEN+5]; char tmpbuf[_RECORDLEN]; char tmp_buffer[RECLAENGE]; char tmp_buffer2[RECLAENGE]; char cdate[_DATELEN]; /* Current Date */ char ctime[_DATELEN]; /* Current Time */ char format[_RECORDLEN]; char typbez[_BEZLEN+1]; char dltbez[_BEZLEN+1]; char katbez[_BEZLEN+1]; char dlgbez[_RECORDLEN]; AKT_DETAIL adcntrl; DEVICE_PORT *pDev; DIENST_TRAEGER *Pdlt; KAT_VIEW *Pkatv; MEMOBJ dltmem; DIENSTLEISTUNG MPdl; char fmt_zeile_1[_CHAR80+1]; char fmt_zeile_2[_CHAR80+1]; char fmt_zeile_3[_CHAR80+1]; char fmt_zeile_4[_CHAR80+1]; char fmt_zeile_5[_CHAR80+1]; /*--- init ------*/ pDev = &devicePort; oldkat = (int)_UNDEF; katcount = 0; katdltcount = 0; totkatcount = 0; totkatdltcount = 0; dltmem.buffer = NULL; dltmem.alloclen = 0; dltmem.datalen = 0; status = MPAPIdb_begintrx(SQLISOLATION_RU, SQLPRIO_NORMAL); /*--- Get the Format string from DBMS -------------------*/ (void)AKTobjtxt( (int)_STATDLT_TYP, (int)AKTTXT_FMT_ZEILE_1, fmt_zeile_1, NOMARGIN); (void)AKTobjtxt( (int)_STATDLT_TYP, (int)AKTTXT_FMT_ZEILE_2, fmt_zeile_2, NOMARGIN); (void)AKTobjtxt( (int)_STATDLT_TYP, (int)AKTTXT_FMT_ZEILE_3, fmt_zeile_3, NOMARGIN); (void)AKTobjtxt( (int)_STATDLT_TYP, (int)AKTTXT_FMT_ZEILE_4, fmt_zeile_4, NOMARGIN); (void)AKTobjtxt( (int)_STATDLT_TYP, (int)AKTTXT_FMT_ZEILE_5, fmt_zeile_5, NOMARGIN); /*--- set right language ----------------------------------------------*/ if (outputsprache == (int)_UNDEF) aktuellesprache = dialogsprache; else aktuellesprache = outputsprache; /*--- mailing header --------------------------------------------------*/ status = AKTmailHeader() ; if (status != (int)MPOK) return(status); /*--- check if all needed arguments are set (-h) ----------------*/ if (dltid == (int)_UNDEF) { AKTmsg(ACT_ERROR, MPA_INVALIDARGS, NULL); TEST_STATUS(MPERROR); } /******** B O D Y ****************/ /* get host dlt */ (void)MPAPIselectOneId((int)_DIENST_TRAEGER, (int)dltid, (char *)&dlt); (void)SelectBez((int)_DIENST_TRAEGER, sprache, dlt.bez_id, dltbez); if (dlid != (int)_UNDEF) { (void)memset((void *)&DateTime, NULL, sizeof(DateTime)); DateTime.tm_min = (int)_UNDEF; DateTime.tm_hour = (int)_UNDEF; DateTime.tm_mday = (int)_UNDEF; DateTime.tm_mon = (int)_UNDEF; DateTime.tm_year = (int)_UNDEF; (void)MPAPIselectOneId((int)_DIENSTLEISTUNG, (int)dlid, (char *)&MPdl); (void)WriteDate(&DateTime, (time_t *)&MPdl.a_zeit, tmpbuf); (void)SelectBez((int)_DIENSTLEISTUNG, sprache, MPdl.bez_id, dlgbez); (void)strcat(dlgbez, " => "); (void)strcat(dlgbez, tmpbuf); } /* update mailing with dlt info */ AKTmsgget(MPA_OBJECTDLT, format); (void)sprintf(mailstring, format, dltid, dltbez, " "); AKTmsg(ACT_INFO, (int)_UNDEF, mailstring); /*DEBUG*****************/ if (DebugFlag) printf("%sdebug: START statistic of dlt %d - %s now !%s", _P_EOL_, dltid, dltbez, _P_EOL_); /*DEBUG*****************/ /* get dltt of host dlt */ id = MPAPIselectOneId((int)_TTYP_VIEW, (int)dlt.typ_id, (char *)&ttyp); if (id != (int)_UNDEF) (void)copyTextTo(typbez, ttyp.bez, (int)_BEZLEN); fprintf(FPout, "%s", _P_EOL_); fprintf(FPout, "%s", _P_EOL_); /* !!! dv (void)fprintf(FPout, "%s%sBenutzungsgrad fuer %s: %s%s%s", _P_EOL_, _P_EOL_, typbez, dltbez, _P_EOL_, _P_EOL_); */ (void)fprintf(FPout, fmt_zeile_1, typbez, dltbez); fprintf(FPout, "%s", _P_EOL_); fprintf(FPout, "%s", _P_EOL_); if (dlid != (int)_UNDEF) { fprintf(FPout, "%s", _P_EOL_); fprintf(FPout, "%s", _P_EOL_); /* !!! dv (void)fprintf(FPout, "%s%sfuer Dienstleistung: %s%s%s", _P_EOL_, _P_EOL_, dlgbez, _P_EOL_, _P_EOL_); */ (void)fprintf(FPout, fmt_zeile_2, dlgbez); fprintf(FPout, "%s", _P_EOL_); fprintf(FPout, "%s", _P_EOL_); } /*--- get all needed KATEGORIEs ---------------*/ if (katid != (int)_UNDEF) (void)sprintf(sqlquery, _SEL_KATVIEW_KAT, katid, aktuellesprache); else (void)sprintf(sqlquery, _SEL_KATVIEW, dltid, aktuellesprache); status = MPAPIdb_sqlquery((int)_KAT_VIEW, (char **)&sqlmem.buffer, sqlquery, &anzahl, &sqlmem.datalen, &sqlmem.alloclen); if (status != MPOK || anzahl < 1) { AKTmsg(ACT_SQLERROR, MPA_SELECTERROR, NULL); return(MPERROR); } Pkatv = (KAT_VIEW *)sqlmem.buffer; for (i=0;i<anzahl;i++) { /* write header line */ (void)copyTextTo(katbez, Pkatv[i].bez, (int)_BEZLEN); (void)fprintf(FPout, "%s%s%s:%s%s", _P_EOL_, _P_EOL_, katbez, _P_EOL_, _P_EOL_); katcount = 0; katdltcount = 0; /* write detail kategorie */ status = DLTstatistic(Pkatv[i].kat_id, dltid, dlid, &dltmem, &katcount, &katdltcount); /* write total line */ totkatcount += katcount; totkatdltcount += katdltcount; if (katcount != 0) { fprintf(FPout, "%s", _P_EOL_); /* fprintf(FPout, "%sTOTAL Einheiten in dieser KATEGORIE: %d (%d)", _P_EOL_, katcount, katdltcount); */ fprintf(FPout, fmt_zeile_3, katcount, katdltcount); fprintf(FPout, "%s", _P_EOL_); } if (anzahl != (i+1)) fprintf(FPout, "%s", _P_EOL_); else { fprintf(FPout, "%s", _P_EOL_); fprintf(FPout, "%s", _P_EOL_); /* fprintf(FPout, "%s%sTOTAL Einheiten: %d (%d) %s", _P_EOL_, _P_EOL_, totkatcount, totkatdltcount, _P_EOL_); */ fprintf(FPout, fmt_zeile_4, totkatcount, totkatdltcount); fprintf(FPout, "%s", _P_EOL_); fprintf(FPout, "%s", _P_EOL_); } } MPfree(dltmem.buffer); /*--- Device start output ---------------------------------------------*/ /*--- Device --------------------------------*/ pDev->callnumber[0] = '\0'; (void)AKTobjtxt( (int)_STATDLT_TYP, (int)PRINTCOMMAND, format, NOMARGIN); (void)sprintf(pDev->command, "%s", format); (void)AKTobjtxt( (int)_STATDLT_TYP, (int)PRINTCOMMAND2, format, NOMARGIN); (void)sprintf(pDev->command2, "%s", format); (void)AKTobjtxt( (int)_STATDLT_TYP, (int)PRINTCOMMAND3, format, NOMARGIN); (void)sprintf(pDev->command3, "%s", format); (void)AKTobjtxt( (int)_STATDLT_TYP, (int)PRINTCOMMAND4, format, NOMARGIN); (void)sprintf(pDev->command4, "%s", format); /*--- Device process ------*/ status = AKTdeviceOuput(); if (status != MPOK) AKTmsg(ACT_ERROR, (int)_UNDEF, "Action Program: Device error "); MPAPIdb_committrx(); /*DEBUG*****************/ if (DebugFlag) printf("%s%sdebug: EXIT with status: %d, mailingadr: %s%s%s", _P_EOL_, _P_EOL_, status, userid, _P_EOL_, _P_EOL_); /*DEBUG*****************/ /*--- Mailing foot -------------------------------------------*/ AKTmailFoot(status); exit: return(status); }
/*F-------------------------------------------------------------------------- * Function: OUTkomm() * perform all inits * check pre-conditions * get arrangement or dl id for work * device (fax or tlx) * * In: -argc, argv as action was invoked * out: - * Return: -completion code *--------------------------------------------------------------------------- */ int OUTkomm( int argc, char *argv[]) { extern int aktuellesprache; extern int dialogsprache; extern int outputsprache; extern char language[]; extern FILE *FPout; extern STATUS_WERTE sta; extern DEVICE_PORT devicePort; int status, id1, id2; char format[_RECORDLEN]; DEVICE_PORT *pDev; /*-----------------------------------------------------------------------*/ /* INITIALIZATIONS */ /*-----------------------------------------------------------------------*/ pDev = &devicePort; /*--- Switch for Specific flag if any --*/ /*--- DB begin RU section ------------------------------------------RU-*/ status = MPAPIdb_begintrx(SQLISOLATION_RU, SQLPRIO_NORMAL); TEST_STATUS(status) /*--- set the right language, normal is language of KUNDE ----*/ AKTlanguage((int)_UNDEF, (int)_UNDEF, (int)_UNDEF, (int)_UNDEF); /*--- mailing header ------------------*/ status = AKTmailHeader(); TEST_STATUS_COMMIT(status); /*--- PRE-CONDITIONS check if all needed arguments are set ------------*/ if (akttid == (int)_UNDEF ) { AKTmsg(ACT_ERROR, MPA_INVALIDARGS, NULL); EXIT_COMMIT_WITH_STATUS(MPERROR); } /*--- Page layout stuff -------------------*/ AKTlayoutInit( ); AKTlayoutInitLinesMax( _STAMM_TYP, PAGE_LENGTH ); AKTlayoutInitBottomMargin( _STAMM_TYP, BOTTOM_MARGIN ); /*-----------------------------------------------------------------------*/ /* START list output */ /*-----------------------------------------------------------------------*/ /*--- General Title and Column identifiers -------*/ OUTkommPageHeaderWrite ( ); /*--- Build control list for stamm ------------*/ status = OUTkommWrap( (int)_UNDEF, (int)_UNDEF ); TEST_STATUS_COMMIT(status); /*--- End RU section -----*/ MPAPIdb_committrx(); /*-----------------------------------------------------------------------*/ /* DEVICE */ /*-----------------------------------------------------------------------*/ /*--- begin RU section -----------*/ status = MPAPIdb_begintrx(SQLISOLATION_RU, SQLPRIO_NORMAL); TEST_STATUS(status) /* >>> exit */ /*--- Device start output --------*/ pDev->callnumber[0] = '\0'; (void)AKTobjtxt((int)_STAMM_TYP, (int)PRINTCOMMAND, format, NOMARGIN); (void)sprintf(pDev->command, "%s", format); (void)AKTobjtxt( (int)_STAMM_TYP, (int)PRINTCOMMAND2, format, NOMARGIN); (void)sprintf(pDev->command2, "%s", format); (void)AKTobjtxt( (int)_STAMM_TYP, (int)PRINTCOMMAND3, format, NOMARGIN); (void)sprintf(pDev->command3, "%s", format); (void)AKTobjtxt( (int)_STAMM_TYP, (int)PRINTCOMMAND4, format, NOMARGIN); (void)sprintf(pDev->command4, "%s", format); /*--- Device process -------------*/ status = AKTdeviceOuput(); if (status != MPOK) AKTmsg(ACT_ERROR, (int)_UNDEF, "Action Program: Device error "); /*--- End RU section -------------*/ (void)MPAPIdb_committrx(); /*........ DEBUG .......*/ if (DebugFlag) printf("%s%sdebug: EXIT with status: %d, mailingadr: %s%s%s", _P_EOL_, _P_EOL_, status, userid, _P_EOL_, _P_EOL_); /*-----------------------------------------------------------------------*/ /* CONCLUSION */ /*-----------------------------------------------------------------------*/ /*--- Mailing foot --------------------------*/ AKTmailFoot(status); exit: /*--- free memory ---------------------------*/ return(status); }
NTSTATUS NTAPI EnumDeviceKeys( IN PUNICODE_STRING RegistryPath, IN PWSTR SubKey, IN PREGISTRY_CALLBACK_ROUTINE Callback, IN PVOID Context) /* Description: Enumerate the device subkeys in the driver's registry entry, and call the specified callback routine for each device. Parameters: RegistryPath The location of the registry entry Subkey The device's subkey Callback A routine called for each device Context ??? Return Value: NT status STATUS_SUCCESS if successful */ { NTSTATUS s; OBJECT_ATTRIBUTES oa; HANDLE hKey, hSubKey; UNICODE_STRING SubkeyName; ULONG i; // Attempt to open the key InitializeObjectAttributes(&oa, RegistryPath, OBJ_CASE_INSENSITIVE, NULL, (PSECURITY_DESCRIPTOR)NULL); s = ZwOpenKey(&hKey, KEY_READ, &oa); TEST_STATUS(s); // debugging if (! NT_SUCCESS(s)) return s; // Problem RtlInitUnicodeString(&SubkeyName, SubKey); DPRINT("Subkey: %wZ\n", &SubkeyName); InitializeObjectAttributes(&oa, &SubkeyName, OBJ_CASE_INSENSITIVE, hKey, (PSECURITY_DESCRIPTOR)NULL); s = ZwOpenKey(&hSubKey, KEY_ENUMERATE_SUB_KEYS, &oa); ZwClose(hKey); TEST_STATUS(s); // debugging if (! NT_SUCCESS(s)) return s; // And now, the enumeration for (i = 0;; i ++) { KEY_BASIC_INFORMATION Info; PKEY_BASIC_INFORMATION pInfo; ULONG ResultLength = 0; ULONG Size = 0; PWSTR Pos; PWSTR Name; // Find the length of the subkey data // Info.NameLength = 0; // TEMPORARY! s = ZwEnumerateKey(hSubKey, i, KeyBasicInformation, &Info, sizeof(Info), &ResultLength); if (s == STATUS_NO_MORE_ENTRIES) break; DPRINT("Found an entry, allocating memory...\n"); // Size = Info.NameLength + FIELD_OFFSET(KEY_BASIC_INFORMATION, Name[0]); Size = ResultLength + FIELD_OFFSET(KEY_BASIC_INFORMATION, Name[0]); DPRINT("Size is %d\n", Size); pInfo = (PKEY_BASIC_INFORMATION) ExAllocatePool(PagedPool, Size); if (pInfo == NULL) { DPRINT("INSUFFICIENT RESOURCES!\n"); s = STATUS_INSUFFICIENT_RESOURCES; break; } DPRINT("Re-enumerating...\n"); s = ZwEnumerateKey(hSubKey, i, KeyBasicInformation, pInfo, Size, &ResultLength); // TEST_STATUS(s); // debugging if (! NT_SUCCESS(s)) { ExFreePool((PVOID) pInfo); s = STATUS_INTERNAL_ERROR; break; } DPRINT("Allocating memory for name...\n"); Name = ExAllocatePool(PagedPool, RegistryPath->Length + sizeof(WCHAR) + SubkeyName.Length + sizeof(WCHAR) + pInfo->NameLength + sizeof(UNICODE_NULL)); if (Name == NULL) { DPRINT("INSUFFICIENT RESOURCES!"); ExFreePool((PVOID) pInfo); return STATUS_INSUFFICIENT_RESOURCES; } // Copy the key name RtlCopyMemory((PVOID)Name, (PVOID)RegistryPath->Buffer, RegistryPath->Length); Pos = Name + (RegistryPath->Length / sizeof(WCHAR)); Pos[0] = '\\'; Pos++; // Copy the parameters sub key name RtlCopyMemory((PVOID)Pos, (PVOID)SubKey, SubkeyName.Length); //SubkeyName? Pos += SubkeyName.Length / sizeof(WCHAR); Pos[0] = '\\'; Pos ++; // Copy the device sub key name RtlCopyMemory((PVOID)Pos, (PVOID)pInfo->Name, pInfo->NameLength); Pos += pInfo->NameLength / sizeof(WCHAR); Pos[0] = UNICODE_NULL; ExFreePool((PVOID)pInfo); DPRINT("Calling callback...\n"); s = (*Callback)(Name, Context); if (! NT_SUCCESS(s)) { DPRINT("Callback FAILED\n"); break;} } ZwClose(hSubKey); DPRINT("%d device registry keys found\n", i); if ((i == 0) && (s == STATUS_NO_MORE_ENTRIES)) return STATUS_DEVICE_CONFIGURATION_ERROR; return s == STATUS_NO_MORE_ENTRIES ? STATUS_SUCCESS : s; }