' RESET.BAS - EVERLOCK Sample Program
'
'This uses QuickBASIC 4.5 compiled with the /O option for a
'stand alone program.  Linked with EVMOV3.OBJ BCOM45.LIB.
'
'BC RESET.BAS /o;
'
'LINK RESET.OBJ + EVMOV3.OBJ,,,BCOM45 /e;
'
'Last Updated 09/July/96 SSS
'
'  Define the SB block in the included SB.BAS file
'  $INCLUDE: 'SB.BAS'
'
   DIM SB AS SecureBlock
'
   DECLARE FUNCTION EVMOV3% (SEG SB AS SecureBlock)
'
'  CL$      = command line string to be parsed
'  frpth$   = from drive variable max 62 bytes with NULL term.
'  rcode$   = reset code string variable
'  errflg%  = flag to set if an error is encountered
'
'  Pickup the Command Line parms from COMMAND$.
'
   CL$ = COMMAND$
   CL$ = UCASE$(COMMAND$)
'
'  Parse the Command Line parms
'
   IF MID$(CL$, 2, 1) <> ":" THEN
      frpth$ = "$:" + CHR$(0)
   ELSE
      frpth$ = CL$ + CHR$(0)
   END IF
'
'  Initialize the Structure and get Product Disk Info
'  
   GOSUB INIT
'
   IF errflg% = 0 THEN           ' If no error 
      GOSUB RST                  ' Get reset code and perform reset
   END IF
'
   IF errflg% <> 0 THEN          ' If error
      PRINT                      ' Print Error Message
      PRINT "  Error "; HEX$(SB.STAT1); "-"; HEX$(SB.STAT2); "-"; HEX$(SB.STAT3);
      PRINT
   ELSE                          ' Else no error
      PRINT                      ' Print Success Message
      PRINT "  RESET Completed Successfully."
      PRINT
   END IF
'
   END
'
INIT:
'
'  Initialize fields for function 0 call to EVMOV3 to get needed information
'
   SB.ID = "AZSB"                ' Initialize ID field to AZSB
   SB.SOURCE = frpth$            ' Initialize Drive and Path to reset
   SB.TARGET = CHR$(0)           ' Null to path to avoid confusion
   SB.STAT1 = &H7240             ' Initialize Status to EVMOV3 failed
   SB.FUNC = 0                   ' Initialize the function for EVMOV3
   errflg% = EVMOV3%(SB)         ' Call EVMOV3 function
   IF errflg% = 0 THEN           ' Make sure to check the Status field
      errflg% = SB.STAT1         '  for errors
   END IF
'
   RETURN
'
RST:
'
'  Subfunction to perform the function 2 to reset authorization
'
   IF SB.SNP < 0 THEN            ' Convert Serial Number to Double
      ser# = SB.SNP + 4294967296#
   ELSE
      ser# = SB.SNP
   END IF
   
   PRINT                         ' Display Serial Number and Reset use count
   PRINT "         Serial Number: "; ser#; "-"; SB.RUC
   PRINT "           Todays Date: "; SB.CDATE  ' Display todays date

   DO                            ' Get Reset Code input
      INPUT "            Reset Code: "; rcode$

      IF LEN(rcode$) >= 15 AND LEN(rcode$) <= 17 THEN
         EXIT DO
      END IF
   LOOP
'
   IF errflg% = 0 THEN           ' If no error to this point
      SB.STAT1 = &H7240          ' Initialize Status to EVMOV3 failed
      SB.FUNC = 2                ' Initialize the function for EVMOV3
      SB.CODE = rcode$           ' Initialize the code field
      errflg% = EVMOV3%(SB)      ' Call EVMOV3 function
      IF errflg% = 0 THEN        ' Make sure to check the Status field
         errflg% = SB.STAT1      '  for errors
      END IF
   END IF
'
   PRINT
   PRINT
'
   RETURN

