LSX >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Main Source : /vm/miame/ddsas/160102/testbase64.bas Stats : 517-671-525-761 28-Oct-24 10:36:47 3234 bytes Object : /vm/miame/ddsas/160102/testbase64.run Stats : 163-672-014-114 28-Oct-24 11:19:26 1526 bytes Compiler : 7.0(1046) Switches : /av /i /x:2 /lf /px /m /igoo >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 000000 PROGRAM TESTBASE64,1.0 (101) 000000 000000 000000 000000 000000 DEFINE TEST_PASS = 0 000000 DEFINE TEST_FAIL = -1 000000 000000 ++INCLUDE ddsfunc:base64.bsi ! BASE64.BSI[160,5] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <1_1> 000000 ++IFNDEF _DDSFUNC_BASE64_BSI_INCLUDED_ 000000 DEFINE _DDSFUNC_BASE64_BSI_INCLUDED_ = 0 000000 000000 000000 000000 FUNCTION fn'base64_encode$(in'data as x0:INPUTONLY) as s0 000010 MAP1 func$,s,128,"fn'base64_encode$()" 00002a MAP1 bytes,f,8 00002a MAP1 status,f,8 00002a 00002a bytes = LEN(in'data) 000033 IF bytes > 1 THEN ! check for unwanted trailing null 00003f IF asc(in'data[-1,-1]) = 0 THEN ! (see notes above) 000055 IF asc(in'data[-2,-2]) # 0 THEN ! if only 1 trailing null 00006b bytes -= 1 ! assume it was tacked on and don't count it 000077 ENDIF 000077 ENDIF 000077 ENDIF 000077 .fn = FILL$(CHR(0), INT(bytes*4/3)+3) 000091 XCALL B64ENC, in'data, .fn, status, bytes 0000a5 IF (status <= 0) THEN 0000b1 .fn = "" 0000b8 EXITFUNCTION 0000bc ENDIF 0000bc ENDFUNCTION 0000c2 0000c2 FUNCTION fn'base64_decode$(b64$ as s0:INPUTONLY,num'bytes=0 as b6:OUTPUTONLY) as x0 0000d5 MAP1 func$,s,128,"fn'base64_decode$()" 0000ef MAP1 status,f,8 0000ef 0000ef .fn = FILL$(CHR(0), LEN(b64$)-1) 000101 XCALL B64ENC, b64$, .fn, status, 1 000117 IF (status > 0) THEN 000123 .fn = .fn[1;status] 000132 XPUTARG @num'bytes=status 00013b ELSE 00013f .fn = "" 000146 XPUTARG @num'bytes=0 000151 ENDIF 000151 ENDFUNCTION 000157 000157 ++ENDIF 000157 ! >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> (base64'bsi) ^> main 000157 000157 MAP1 err'occurred,f,8 000157 MAP1 raw'str$,s,0 000157 MAP1 encode$,s,0 000157 MAP1 expected'encode$,s,0 000157 MAP1 val'x,x,0 000157 MAP1 crlf$,s,2,chr(13)+CHR(10) 000165 000165 MAIN'ROUTINE: 000165 CALL SET'SCREEN 000169 000169 000169 000169 000169 raw'str$ = "" 000170 expected'encode$ = "" 000177 CALL fn'test'base64_one_str(raw'str$=raw'str$, expected'encode$=expected'encode$) 000187 000187 CALL EXIT'PROGRAM 00018b END 00018c 00018c FUNCTION fn'test'base64_one_str(raw'str$ as s0,expected'encode$ as s0,dsp$="" as s0:INPUTONLY) as f8 0001a2 MAP1 func$,s,0,"fn'test'base64_one_str()" 0001c1 MAP1 encode$,s,0 0001c1 MAP1 decode,x,0 0001c1 MAP1 num'bytes,b,6 0001c1 0001c1 trace.print (2, "testbase64") func$ + " ", raw'str$, expected'encode$ 00022d encode$ = fn'base64_encode$(raw'str$) 00023b Trace.Pause func$ + " raw'str$=["+raw'str$+"] encode$=["+encode$+"] expected'encode$=["+expected'encode$+"]" 000292 IF (encode$ # expected'encode$) THEN 00029e trace.print (2, "testbase64") func$ + " LEN(expected'encode$)=["+LEN(expected'encode$)+"] LEN(encode$)=["+LEN(encode$)+"] ", expected'encode$, encode$ 000344 ? " Failed: fn'base64_encode$() raw'str$=["+raw'str$+"] encode$=["+encode$+"] expected'encode$=["+expected'encode$+"] " 0003ac .fn = -1 0003b5 ELSE 0003b9 decode = fn'base64_decode$(encode$, num'bytes=num'bytes) 0003ca Trace.Pause "fn'test'base64_one_str() num'bytes=["+num'bytes+"] decode=["+decode+"]" 00041b IF (raw'str$ # decode) THEN 000427 ? " Failed: fn'base64_decode$() raw'str$=["+raw'str$+"] decode=["+decode+"] " 000473 .fn = -1 00047c ENDIF 00047c ENDIF 00047c $exit: 00047c trace.print (2, "testbase64") + "" 0004ac ENDFUNCTION 0004b2 0004b2 SET'SCREEN: 0004b2 PRINT "TEST BASE64 FUNCTIONS" 0004d2 PRINT 0004d9 0004d9 RETURN 0004da 0004da EXIT'PROGRAM: 0004da END ====================================================== Unreferenced Global Variables: err'occurred encode$ val'x crlf$ Procedures, Functions [reference count] ====================================================== fn'base64_encode$(in'data>X) [1] fn'base64_decode$(b64$>S,num'bytes=0 >B) [1] fn'test'base64_one_str(raw'str$>S,expected'encode$>S,dsp$="" >S) [1] Performance Statistics *: ====================================================== Phase 0 (/p, /px prescan): 0.0018 secs Shake out unused routines (/px): 0.0000 secs (3 kept, 0 dropped) Phase 1 (main compilation): 0.0022 secs Phase 2 (emit RUN code): 0.0005 secs Total elapsed time: 0.0105 secs Labels/Functions: 45 searches, 0.6000 ms (24 total defined) Symbol Definitions: 280 searches, 3.7100 ms (18 total defined) Variable Definitions: 110 searches, 1.6800 ms (25 total defined) Structure Definitions: 0 searches, 0.0000 ms (0 total defined) * Total elapsed time should be accurate. All other time values are based on the UNIX kernel realtime clock but may not be precise enough to measure individual searches accurately.