@ECHO OFF
REM FLGTSTA.BAT
REM FLAG compare test.
REM
REM Direct part:
REM   OUT    = Novell baseline using \NPUBLIC\FLAG
REM   PUBOUT = our implementation using \PUBLIC\FLAG
REM
REM User-context part:
REM   NOPASSUSER logs in via DLYSTRT helper and runs the same effective tests.
REM   UNOV   = Novell FLAG as NOPASSUSER
REM   UPUB   = Public FLAG as NOPASSUSER
REM
REM For the automatic NOPASSUSER block set:
REM   SET LGNTPWD=your-supervisor-password

IF "%1"=="" GOTO PART1
IF "%1"=="PART2" GOTO PART2
IF "%1"=="part2" GOTO PART2
IF "%1"=="Part2" GOTO PART2
ECHO Usage: FLGTSTA [PART2]
GOTO END

:PART1
F:
CD \

REM --- Clean generated test/result directories. ---
IF EXIST FLGTEST\NUL DELTREE /Y FLGTEST\*.*
IF EXIST FLGCMP\NUL DELTREE /Y FLGCMP\*.*
IF EXIST FLGTMP\NUL DELTREE /Y FLGTMP\*.*

IF NOT EXIST FLGTEST\NUL MD FLGTEST
IF NOT EXIST FLGTMP\NUL MD FLGTMP
IF NOT EXIST FLGCMP\NUL MD FLGCMP
IF NOT EXIST FLGCMP\OUT\NUL MD FLGCMP\OUT
IF NOT EXIST FLGCMP\PUBOUT\NUL MD FLGCMP\PUBOUT
IF NOT EXIST FLGCMP\SETUP\NUL MD FLGCMP\SETUP
IF NOT EXIST FLGCMP\UNOV\NUL MD FLGCMP\UNOV
IF NOT EXIST FLGCMP\UPUB\NUL MD FLGCMP\UPUB
IF NOT EXIST FLGCMP\USETUP\NUL MD FLGCMP\USETUP

IF EXIST F:\FLGCMP\RUN.LOG DEL F:\FLGCMP\RUN.LOG
IF EXIST F:\FLGCMP\SUMMARY.TXT DEL F:\FLGCMP\SUMMARY.TXT
IF EXIST F:\FLGCMP\COMPARE.LOG DEL F:\FLGCMP\COMPARE.LOG
IF EXIST F:\FLGCMP\UCOMP.LOG DEL F:\FLGCMP\UCOMP.LOG
IF EXIST F:\FLGCMP\FLGTSTA.ZIP DEL F:\FLGCMP\FLGTSTA.ZIP
IF EXIST F:\FLGCMP\ZIP.LOG DEL F:\FLGCMP\ZIP.LOG

ECHO FLGTSTA FLAG compare > F:\FLGCMP\RUN.LOG
ECHO Direct compare: NPUBLIC\FLAG vs PUBLIC\FLAG. >> F:\FLGCMP\RUN.LOG
ECHO User context: NOPASSUSER via DLYSTRT if LGNTPWD is set. >> F:\FLGCMP\RUN.LOG
ECHO. >> F:\FLGCMP\RUN.LOG

ECHO ALPHA FILE > F:\FLGTEST\ALPHA.TXT
ECHO BETA FILE > F:\FLGTEST\BETA.TXT
ECHO GAMMA FILE > F:\FLGTEST\GAMMA.DAT
ECHO DELTA FILE > F:\FLGTEST\DELTA.BIN
ECHO EPS FILE > F:\FLGTEST\EPS.TXT

ECHO Starting D10 read normal...
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT N > NUL
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT > F:\FLGCMP\OUT\D10_READ.OUT
PUBLIC\FLAG F:\FLGTEST\ALPHA.TXT > F:\FLGCMP\PUBOUT\D10_READ.OUT

ECHO Starting D11 FLAG N...
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT +H > NUL
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT N > F:\FLGCMP\OUT\D11_N.OUT
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT +H > NUL
PUBLIC\FLAG F:\FLGTEST\ALPHA.TXT N > F:\FLGCMP\PUBOUT\D11_N.OUT

ECHO Starting D12 +H...
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT N > NUL
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT +H > F:\FLGCMP\OUT\D12_H.OUT
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT >> F:\FLGCMP\OUT\D12_H.OUT
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT N > NUL
PUBLIC\FLAG F:\FLGTEST\ALPHA.TXT +H > F:\FLGCMP\PUBOUT\D12_H.OUT
PUBLIC\FLAG F:\FLGTEST\ALPHA.TXT >> F:\FLGCMP\PUBOUT\D12_H.OUT

ECHO Starting D13 +RO...
NPUBLIC\FLAG F:\FLGTEST\BETA.TXT N > NUL
NPUBLIC\FLAG F:\FLGTEST\BETA.TXT +RO > F:\FLGCMP\OUT\D13_RO.OUT
NPUBLIC\FLAG F:\FLGTEST\BETA.TXT >> F:\FLGCMP\OUT\D13_RO.OUT
NPUBLIC\FLAG F:\FLGTEST\BETA.TXT N > NUL
PUBLIC\FLAG F:\FLGTEST\BETA.TXT +RO > F:\FLGCMP\PUBOUT\D13_RO.OUT
PUBLIC\FLAG F:\FLGTEST\BETA.TXT >> F:\FLGCMP\PUBOUT\D13_RO.OUT

ECHO Starting D14 +A...
NPUBLIC\FLAG F:\FLGTEST\GAMMA.DAT N > NUL
NPUBLIC\FLAG F:\FLGTEST\GAMMA.DAT +A > F:\FLGCMP\OUT\D14_A.OUT
NPUBLIC\FLAG F:\FLGTEST\GAMMA.DAT >> F:\FLGCMP\OUT\D14_A.OUT
NPUBLIC\FLAG F:\FLGTEST\GAMMA.DAT N > NUL
PUBLIC\FLAG F:\FLGTEST\GAMMA.DAT +A > F:\FLGCMP\PUBOUT\D14_A.OUT
PUBLIC\FLAG F:\FLGTEST\GAMMA.DAT >> F:\FLGCMP\PUBOUT\D14_A.OUT

ECHO Starting D15 +SY...
NPUBLIC\FLAG F:\FLGTEST\DELTA.BIN N > NUL
NPUBLIC\FLAG F:\FLGTEST\DELTA.BIN +SY > F:\FLGCMP\OUT\D15_SY.OUT
NPUBLIC\FLAG F:\FLGTEST\DELTA.BIN >> F:\FLGCMP\OUT\D15_SY.OUT
NPUBLIC\FLAG F:\FLGTEST\DELTA.BIN N > NUL
PUBLIC\FLAG F:\FLGTEST\DELTA.BIN +SY > F:\FLGCMP\PUBOUT\D15_SY.OUT
PUBLIC\FLAG F:\FLGTEST\DELTA.BIN >> F:\FLGCMP\PUBOUT\D15_SY.OUT

ECHO Starting D16 +DI +RI...
NPUBLIC\FLAG F:\FLGTEST\EPS.TXT N > NUL
NPUBLIC\FLAG F:\FLGTEST\EPS.TXT +DI +RI > F:\FLGCMP\OUT\D16_DIRI.OUT
NPUBLIC\FLAG F:\FLGTEST\EPS.TXT >> F:\FLGCMP\OUT\D16_DIRI.OUT
NPUBLIC\FLAG F:\FLGTEST\EPS.TXT N > NUL
PUBLIC\FLAG F:\FLGTEST\EPS.TXT +DI +RI > F:\FLGCMP\PUBOUT\D16_DIRI.OUT
PUBLIC\FLAG F:\FLGTEST\EPS.TXT >> F:\FLGCMP\PUBOUT\D16_DIRI.OUT

ECHO Starting D17 mixed flags...
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT N > NUL
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT +H +RO +A > F:\FLGCMP\OUT\D17_MIX.OUT
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT >> F:\FLGCMP\OUT\D17_MIX.OUT
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT N > NUL
PUBLIC\FLAG F:\FLGTEST\ALPHA.TXT +H +RO +A > F:\FLGCMP\PUBOUT\D17_MIX.OUT
PUBLIC\FLAG F:\FLGTEST\ALPHA.TXT >> F:\FLGCMP\PUBOUT\D17_MIX.OUT

ECHO Starting D18 clear flags...
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT +H +RO +A > NUL
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT -H -RO -A > F:\FLGCMP\OUT\D18_CLR.OUT
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT >> F:\FLGCMP\OUT\D18_CLR.OUT
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT +H +RO +A > NUL
PUBLIC\FLAG F:\FLGTEST\ALPHA.TXT -H -RO -A > F:\FLGCMP\PUBOUT\D18_CLR.OUT
PUBLIC\FLAG F:\FLGTEST\ALPHA.TXT >> F:\FLGCMP\PUBOUT\D18_CLR.OUT

ECHO Starting D90 missing file...
NPUBLIC\FLAG F:\FLGTEST\NOFILE.TXT > F:\FLGCMP\OUT\D90_MISS.OUT
PUBLIC\FLAG F:\FLGTEST\NOFILE.TXT > F:\FLGCMP\PUBOUT\D90_MISS.OUT

ECHO Comparing direct FLAG outputs... > F:\FLGCMP\COMPARE.LOG
FOR %%F IN (D10_READ.OUT D11_N.OUT D12_H.OUT D13_RO.OUT D14_A.OUT D15_SY.OUT D16_DIRI.OUT D17_MIX.OUT D18_CLR.OUT D90_MISS.OUT) DO FC F:\FLGCMP\OUT\%%F F:\FLGCMP\PUBOUT\%%F >> F:\FLGCMP\COMPARE.LOG

REM Prepare user-context test tree.
ECHO Preparing NOPASSUSER FLAG matrix... >> F:\FLGCMP\RUN.LOG
NPUBLIC\FLAG F:\FLGTEST\ALPHA.TXT N > NUL
NPUBLIC\FLAG F:\FLGTEST\BETA.TXT N > NUL
NPUBLIC\FLAG F:\FLGTEST\GAMMA.DAT N > NUL
NPUBLIC\FLAG F:\FLGTEST\DELTA.BIN N > NUL
NPUBLIC\FLAG F:\FLGTEST\EPS.TXT N > NUL
NPUBLIC\GRANT ALL FOR F:\FLGTEST TO USER NOPASSUSER > F:\FLGCMP\SETUP\S01_GRD.OUT
NPUBLIC\GRANT ALL FOR F:\FLGTEST\ALPHA.TXT TO USER NOPASSUSER /FILES > F:\FLGCMP\SETUP\S02_GRF.OUT
NPUBLIC\GRANT ALL FOR F:\FLGTEST\BETA.TXT TO USER NOPASSUSER /FILES >> F:\FLGCMP\SETUP\S02_GRF.OUT
NPUBLIC\GRANT ALL FOR F:\FLGTEST\GAMMA.DAT TO USER NOPASSUSER /FILES >> F:\FLGCMP\SETUP\S02_GRF.OUT
NPUBLIC\GRANT ALL FOR F:\FLGTEST\DELTA.BIN TO USER NOPASSUSER /FILES >> F:\FLGCMP\SETUP\S02_GRF.OUT
NPUBLIC\GRANT ALL FOR F:\FLGTEST\EPS.TXT TO USER NOPASSUSER /FILES >> F:\FLGCMP\SETUP\S02_GRF.OUT

IF "%LGNTPWD%"=="" GOTO NEEDPWD

IF EXIST C:\FLGTMP DELTREE /Y C:\FLGTMP > NUL
MD C:\FLGTMP
MD C:\FLGTMP\UNOV
MD C:\FLGTMP\UPUB
COPY F:\FLGC.BAT C:\FLGTMP\FLGC.BAT > NUL
COPY F:\PUBLIC\DLYSTRT.EXE C:\FLGTMP\DLYSTRT.EXE > NUL

C:
CD \FLGTMP
DLYSTRT /T:2 FLGC.BAT
GOTO END

:NEEDPWD
ECHO LGNTPWD is not set. User-context FLAG block skipped. >> F:\FLGCMP\RUN.LOG
ECHO.
ECHO LGNTPWD ist nicht gesetzt. User-Kontext wurde nicht gestartet.
ECHO Beispiel:
ECHO   SET LGNTPWD=dein-supervisor-passwort
ECHO   FLGTSTA
GOTO END

:PART2
F:
CD \
IF NOT EXIST FLGCMP\UNOV\NUL MD FLGCMP\UNOV
IF NOT EXIST FLGCMP\UPUB\NUL MD FLGCMP\UPUB
IF EXIST F:\FLGCMP\UCOMP.LOG DEL F:\FLGCMP\UCOMP.LOG
COPY C:\FLGTMP\UNOV\*.OUT F:\FLGCMP\UNOV > NUL
COPY C:\FLGTMP\UPUB\*.OUT F:\FLGCMP\UPUB > NUL
IF EXIST C:\FLGTMP\HELPER.TXT COPY C:\FLGTMP\HELPER.TXT F:\FLGCMP > NUL
ECHO Comparing NOPASSUSER FLAG outputs... > F:\FLGCMP\UCOMP.LOG
FOR %%F IN (U10_READ.OUT U11_N.OUT U12_H.OUT U13_RO.OUT U14_A.OUT U15_SY.OUT U16_DIRI.OUT U17_MIX.OUT U18_CLR.OUT U90_MISS.OUT) DO FC F:\FLGCMP\UNOV\%%F F:\FLGCMP\UPUB\%%F >> F:\FLGCMP\UCOMP.LOG
ECHO FLGTSTA summary > F:\FLGCMP\SUMMARY.TXT
ECHO Direct compare: F:\FLGCMP\COMPARE.LOG >> F:\FLGCMP\SUMMARY.TXT
ECHO User compare:   F:\FLGCMP\UCOMP.LOG >> F:\FLGCMP\SUMMARY.TXT
ECHO Optional: FLGTZIP ausfuehren. >> F:\FLGCMP\SUMMARY.TXT
ECHO.
ECHO FLGTSTA PART2 fertig. Optional FLGTZIP ausfuehren.
GOTO END

:END
