Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199508.adf » !Internet » StarterPak/!Newsbase/Transports/taylor/ScriptLib

StarterPak/!Newsbase/Transports/taylor/ScriptLib

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199508.adf » !Internet
Filename: StarterPak/!Newsbase/Transports/taylor/ScriptLib
Read OK:
File size: 1006 bytes
Load address: 0000
Exec address: 0000
File contents
   10REM >ScriptLib
   20REM basic function library for the Taylor Uucp Support for
   30REM NewsBase.
   40REM If not stated otherwise, the code is (c) by Gunnar ZREPORTtl
   50REM
   60REM Date:           26-Oct-1994
   70REM Last Modified:  04-Jan-1995
   80
   90REM this version of upath is just converted from my c version.
  100REM for comments and such see upath.c
  110REM
  120DEF FNupath(path$)
  130LOCAL UNIXFSP$, rpath$, h$, t$, i
  140UNIXFSP$ = "UucpFS$"
  150IF LEFT$(path$, 1) = "/" THEN
  160    i = INSTR(path$, "/", 2)
  170    t$ = UNIXFSP$
  180    t$=t$ + LEFT$(path$, i-1)
  190    h$ = FNgetenv(t$)
  200    IF h$ <> "" THEN
  210        IF LEFT$(h$, 1) = "/" THEN
  220            rpath$ = MID$(h$, 2)
  230        ELSE
  240            rpath$ = h$
  250        ENDIF
  260        rpath$ = rpath$ + MID$(path$, i)
  270    ELSE
  280        h$ = FNgetenv(UNIXFSP$ + "/")
  290        IF h$ <> "" THEN
  300            IF LEFT$(h$, 1) = "/" THEN
  310                rpath$ = MID$(h$, 2)
  320            ELSE
  330                rpath$ = h$
  340            ENDIF
  350            rpath$ = rpath$ + path$
  360        ELSE
  370            rpath$ = "$" + path$
  380        ENDIF
  390    ENDIF
  400ELSE
  410    rpath$ = path$
  420ENDIF
  430FOR i = 1 TO LEN(rpath$)
  440    IF MID$(rpath$,i,1) = "/" THEN MID$(rpath$,i,1) = "."
  450NEXT i
  460=rpath$
  470
  480REM BASIC is missing a getenv function, sad but true.
  490REM here it is.
  500REM CAUTION: because it used a string as a dynamically allocated
  510REM temporary storage, this version is limited to 254 character
  520REM contents in environment variables!
  530REM
  540DEF FNgetenv(var$)
  550LOCAL res$, size, a
  560size = 0
  570SYS "XOS_ReadVarVal", var$, 0, -1 TO ,,size
  580size = NOTsize
  590IF size>254 THEN size=254
  600res$=STRING$(size, ".")
  610SYS "XOS_ReadVarVal", var$, res$, size, 0 TO ,res$,size
  620=res$
  630
  640------------------------------------------------------------------
  650REM>BasEntry
  660REM Library for implementing argc & argv in BASIC
  670REM LEN1993 HRMills
  680REM Load library with INSTALL "%.BasEntry"
  690REM then do PROCentry. This sets up the variable argc, equal to the number of
  700REM command line arguments of the program, and argv$(), an array of the
  710REM arguments themselves.
  720
  730REM small fix by Gunnar ZREPORTtl, 23-Oct-1994:
  740REM if there was a space after a parameter on the command line,
  750REM it was returned with the string. Is now stripped.
  760
  770DEFPROCentry
  780    LOCAL f%,p%,CommandLine$
  790    SYS"OS_GetEnv" TO CommandLine$
  800    CommandLine$=FNbasentry_strip(CommandLine$,2)
  810    argc=FNbasentry_count(CommandLine$)
  820    DIM argv$(argc)
  830
  840    FOR f%=0 TO argc-1
  850        IF INSTR(CommandLine$," ")<>0 THEN
  860            argv$(f%)=LEFT$(CommandLine$,INSTR(CommandLine$," ")-1)
  870        ELSE
  880            argv$(f%)=CommandLine$
  890        ENDIF
  900        CommandLine$=FNbasentry_strip(CommandLine$,1)
  910        IF LEFT$(CommandLine$,1)=" " THEN
  920            REPEAT
  930                CommandLine$=MID$(CommandLine$,1)
  940            UNTIL LEFT$(CommandLine$,1)<>" "
  950        ENDIF
  960    NEXT
  970    argv$(0)=MID$(argv$(0),2)
  980    argv$(0)=LEFT$(argv$(0),LENargv$(0)-2)
  990ENDPROC
 1000:
 1010DEFFNbasentry_strip(List$,a%)
 1020    LOCAL f%
 1030    FOR f%=1 TO a%
 1040        List$=MID$(List$,INSTR(List$," ")+1)
 1050    NEXT
 1060=List$
 1070:
 1080DEFFNbasentry_count(List$)
 1090    LOCAL r%,p%,spaces%
 1100    spaces%=FALSE
 1110    FOR p%=0 TO LEN List$
 1120        IF spaces% AND MID$(List$,p%,1)<>" " THEN
 1130            r%+=1
 1140            spaces%=FALSE
 1150        ELSE
 1160            IF MID$(List$,p%,1)=" " spaces%=TRUE
 1170        ENDIF
 1180    NEXT
 1190=r%+1
 1200------------------------------------------------------------------
 1210REM end of BasEntry
 1220
 1230REM return the string from the first non-space character upto
 1240REM the first following space.
 1250REM
 1260DEF FNstripspaces(a$)
 1270LOCAL i,j
 1280i=1
 1290WHILE MID$(a$, i, 1) = " "
 1300    i = i + 1
 1310ENDWHILE
 1320j = INSTR(a$, " ", i)
 1330IF j < i THEN j = LEN(a$)
 1340=MID$(a$, i, j)
 1350
 1360REM get the user id for a specified user from /etc/passwd
 1370REM returns -1 if the uid could not be found.
 1380DEF FNgetuid(user$)
 1390    passwd$ = FNupath("/etc/passwd")
 1391    len%=LEN(user$)
 1400    uid% = -1
 1410    if% = OPENIN(passwd$)
 1420    IF if% > 0 THEN
 1430        REPEAT
 1440            c$ = GET$#if%
 1450            IF LEFT$(c$, len%) = user$ THEN
 1460                i% = INSTR(c$, ":")
 1470                i% = INSTR(c$, ":", i% + 1)
 1480                uid% = VAL(MID$(c$, i% + 1))
 1490            ENDIF
 1500        UNTIL c$=""
 1510        CLOSE #if%
 1520    ENDIF
 1530=uid%
 1540

� >ScriptLib
<� basic function library for the Taylor Uucp Support for
� NewsBase.
(=� If not stated otherwise, the code is (c) by Gunnar Z�tl
2�
<!� Date:           26-Oct-1994
F!� Last Modified:  04-Jan-1995
P
Z@� this version of upath is just converted from my c version.
d'� for comments and such see upath.c
n�
x� �upath(path$)
�!� UNIXFSP$, rpath$, h$, t$, i
�UNIXFSP$ = "UucpFS$"
�� �path$, 1) = "/" �
�    i = �path$, "/", 2)
�    t$ = UNIXFSP$
�    t$=t$ + �path$, i-1)
�    h$ = �getenv(t$)
�    � h$ <> "" �
�        � �h$, 1) = "/" �
�             rpath$ = �h$, 2)
�
        �
�            rpath$ = h$
�
        �
(        rpath$ = rpath$ + �path$, i)
	    �
(        h$ = �getenv(UNIXFSP$ + "/")
"        � h$ <> "" �
,!            � �h$, 1) = "/" �
6$                rpath$ = �h$, 2)
@            �
J                rpath$ = h$
T            �
^'            rpath$ = rpath$ + path$
h
        �
r$            rpath$ = "$" + path$
|
        �
�	    �
��
�    rpath$ = path$
��
�� i = 1 � �(rpath$)
�1    � �rpath$,i,1) = "/" � �rpath$,i,1) = "."
�� i
�=rpath$
�
�7� BASIC is missing a getenv function, sad but true.
�� here it is.
�B� CAUTION: because it used a string as a dynamically allocated
�A� temporary storage, this version is limited to 254 character
(� contents in environment variables!
�
� �getenv(var$)
&� res$, size, a
0size = 0
:-ș "XOS_ReadVarVal", var$, 0, -1 � ,,size
Dsize = �size
N� size>254 � size=254
Xres$=�size, ".")
b9ș "XOS_ReadVarVal", var$, res$, size, 0 � ,res$,size
l	=res$
v
�F------------------------------------------------------------------
��>BasEntry
�3� Library for implementing argc & argv in BASIC
�� �1993 HRMills
�,� Load library with INSTALL "%.BasEntry"
�O� then do PROCentry. This sets up the variable argc, equal to the number of
�I� command line arguments of the program, and argv$(), an array of the
�� arguments themselves.
�
�,� small fix by Gunnar Z�tl, 23-Oct-1994:
�A� if there was a space after a parameter on the command line,
�7� it was returned with the string. Is now stripped.
�
��entry
    � f%,p%,CommandLine$
$    ș"OS_GetEnv" � CommandLine$
 4    CommandLine$=�basentry_strip(CommandLine$,2)
**    argc=�basentry_count(CommandLine$)
4    � argv$(argc)
>
H    � f%=0 � argc-1
R%        � �CommandLine$," ")<>0 �
\=            argv$(f%)=�CommandLine$,�CommandLine$," ")-1)
f
        �
p&            argv$(f%)=CommandLine$
z
        �
�8        CommandLine$=�basentry_strip(CommandLine$,1)
�$        � �CommandLine$,1)=" " �
�            �
�1                CommandLine$=�CommandLine$,1)
�'            � �CommandLine$,1)<>" "
�
        �
�	    �
�    argv$(0)=�argv$(0),2)
�'    argv$(0)=�argv$(0),�argv$(0)-2)
��
�:
�ݤbasentry_strip(List$,a%)
�    � f%
    � f%=1 � a%
'        List$=�List$,�List$," ")+1)
	    �
$
=List$
.:
8ݤbasentry_count(List$)
B    � r%,p%,spaces%
L    spaces%=�
V    � p%=0 � � List$
`+        � spaces% � �List$,p%,1)<>" " �
j            r%+=1
t            spaces%=�
~
        �
�,            � �List$,p%,1)=" " spaces%=�
�
        �
�	    �
�	=r%+1
�F------------------------------------------------------------------
�� end of BasEntry
�
�?� return the string from the first non-space character upto
� � the first following space.
��
�� �stripspaces(a$)
�	� i,j
i=1

ȕ �a$, i, 1) = " "
    i = i + 1
�
(j = �a$, " ", i)
2� j < i � j = �(a$)
<=�a$, i, j)
F
P;� get the user id for a specified user from /etc/passwd
Z/� returns -1 if the uid could not be found.
d� �getuid(user$)
n'    passwd$ = �upath("/etc/passwd")
o    len%=�(user$)
x    uid% = -1
�    if% = �(passwd$)
�    � if% > 0 �
�
        �
�            c$ = �#if%
�&            � �c$, len%) = user$ �
�"                i% = �c$, ":")
�*                i% = �c$, ":", i% + 1)
�*                uid% = �(�c$, i% + 1))
�            �
�        � c$=""
�        � #if%
�	    �
�	=uid%

�
00000000  0d 00 0a 10 f4 20 3e 53  63 72 69 70 74 4c 69 62  |..... >ScriptLib|
00000010  0d 00 14 3c f4 20 62 61  73 69 63 20 66 75 6e 63  |...<. basic func|
00000020  74 69 6f 6e 20 6c 69 62  72 61 72 79 20 66 6f 72  |tion library for|
00000030  20 74 68 65 20 54 61 79  6c 6f 72 20 55 75 63 70  | the Taylor Uucp|
00000040  20 53 75 70 70 6f 72 74  20 66 6f 72 0d 00 1e 0f  | Support for....|
00000050  f4 20 4e 65 77 73 42 61  73 65 2e 0d 00 28 3d f4  |. NewsBase...(=.|
00000060  20 49 66 20 6e 6f 74 20  73 74 61 74 65 64 20 6f  | If not stated o|
00000070  74 68 65 72 77 69 73 65  2c 20 74 68 65 20 63 6f  |therwise, the co|
00000080  64 65 20 69 73 20 28 63  29 20 62 79 20 47 75 6e  |de is (c) by Gun|
00000090  6e 61 72 20 5a f6 74 6c  0d 00 32 05 f4 0d 00 3c  |nar Z.tl..2....<|
000000a0  21 f4 20 44 61 74 65 3a  20 20 20 20 20 20 20 20  |!. Date:        |
000000b0  20 20 20 32 36 2d 4f 63  74 2d 31 39 39 34 0d 00  |   26-Oct-1994..|
000000c0  46 21 f4 20 4c 61 73 74  20 4d 6f 64 69 66 69 65  |F!. Last Modifie|
000000d0  64 3a 20 20 30 34 2d 4a  61 6e 2d 31 39 39 35 0d  |d:  04-Jan-1995.|
000000e0  00 50 04 0d 00 5a 40 f4  20 74 68 69 73 20 76 65  |.P...Z@. this ve|
000000f0  72 73 69 6f 6e 20 6f 66  20 75 70 61 74 68 20 69  |rsion of upath i|
00000100  73 20 6a 75 73 74 20 63  6f 6e 76 65 72 74 65 64  |s just converted|
00000110  20 66 72 6f 6d 20 6d 79  20 63 20 76 65 72 73 69  | from my c versi|
00000120  6f 6e 2e 0d 00 64 27 f4  20 66 6f 72 20 63 6f 6d  |on...d'. for com|
00000130  6d 65 6e 74 73 20 61 6e  64 20 73 75 63 68 20 73  |ments and such s|
00000140  65 65 20 75 70 61 74 68  2e 63 0d 00 6e 05 f4 0d  |ee upath.c..n...|
00000150  00 78 13 dd 20 a4 75 70  61 74 68 28 70 61 74 68  |.x.. .upath(path|
00000160  24 29 0d 00 82 21 ea 20  55 4e 49 58 46 53 50 24  |$)...!. UNIXFSP$|
00000170  2c 20 72 70 61 74 68 24  2c 20 68 24 2c 20 74 24  |, rpath$, h$, t$|
00000180  2c 20 69 0d 00 8c 18 55  4e 49 58 46 53 50 24 20  |, i....UNIXFSP$ |
00000190  3d 20 22 55 75 63 70 46  53 24 22 0d 00 96 18 e7  |= "UucpFS$".....|
000001a0  20 c0 70 61 74 68 24 2c  20 31 29 20 3d 20 22 2f  | .path$, 1) = "/|
000001b0  22 20 8c 0d 00 a0 1b 20  20 20 20 69 20 3d 20 a7  |" .....    i = .|
000001c0  70 61 74 68 24 2c 20 22  2f 22 2c 20 32 29 0d 00  |path$, "/", 2)..|
000001d0  aa 15 20 20 20 20 74 24  20 3d 20 55 4e 49 58 46  |..    t$ = UNIXF|
000001e0  53 50 24 0d 00 b4 1c 20  20 20 20 74 24 3d 74 24  |SP$....    t$=t$|
000001f0  20 2b 20 c0 70 61 74 68  24 2c 20 69 2d 31 29 0d  | + .path$, i-1).|
00000200  00 be 18 20 20 20 20 68  24 20 3d 20 a4 67 65 74  |...    h$ = .get|
00000210  65 6e 76 28 74 24 29 0d  00 c8 14 20 20 20 20 e7  |env(t$)....    .|
00000220  20 68 24 20 3c 3e 20 22  22 20 8c 0d 00 d2 1d 20  | h$ <> "" ..... |
00000230  20 20 20 20 20 20 20 e7  20 c0 68 24 2c 20 31 29  |       . .h$, 1)|
00000240  20 3d 20 22 2f 22 20 8c  0d 00 dc 20 20 20 20 20  | = "/" ....     |
00000250  20 20 20 20 20 20 20 20  72 70 61 74 68 24 20 3d  |        rpath$ =|
00000260  20 c1 68 24 2c 20 32 29  0d 00 e6 0d 20 20 20 20  | .h$, 2)....    |
00000270  20 20 20 20 cc 0d 00 f0  1b 20 20 20 20 20 20 20  |    .....       |
00000280  20 20 20 20 20 72 70 61  74 68 24 20 3d 20 68 24  |     rpath$ = h$|
00000290  0d 00 fa 0d 20 20 20 20  20 20 20 20 cd 0d 01 04  |....        ....|
000002a0  28 20 20 20 20 20 20 20  20 72 70 61 74 68 24 20  |(        rpath$ |
000002b0  3d 20 72 70 61 74 68 24  20 2b 20 c1 70 61 74 68  |= rpath$ + .path|
000002c0  24 2c 20 69 29 0d 01 0e  09 20 20 20 20 cc 0d 01  |$, i)....    ...|
000002d0  18 28 20 20 20 20 20 20  20 20 68 24 20 3d 20 a4  |.(        h$ = .|
000002e0  67 65 74 65 6e 76 28 55  4e 49 58 46 53 50 24 20  |getenv(UNIXFSP$ |
000002f0  2b 20 22 2f 22 29 0d 01  22 18 20 20 20 20 20 20  |+ "/")..".      |
00000300  20 20 e7 20 68 24 20 3c  3e 20 22 22 20 8c 0d 01  |  . h$ <> "" ...|
00000310  2c 21 20 20 20 20 20 20  20 20 20 20 20 20 e7 20  |,!            . |
00000320  c0 68 24 2c 20 31 29 20  3d 20 22 2f 22 20 8c 0d  |.h$, 1) = "/" ..|
00000330  01 36 24 20 20 20 20 20  20 20 20 20 20 20 20 20  |.6$             |
00000340  20 20 20 72 70 61 74 68  24 20 3d 20 c1 68 24 2c  |   rpath$ = .h$,|
00000350  20 32 29 0d 01 40 11 20  20 20 20 20 20 20 20 20  | 2)..@.         |
00000360  20 20 20 cc 0d 01 4a 1f  20 20 20 20 20 20 20 20  |   ...J.        |
00000370  20 20 20 20 20 20 20 20  72 70 61 74 68 24 20 3d  |        rpath$ =|
00000380  20 68 24 0d 01 54 11 20  20 20 20 20 20 20 20 20  | h$..T.         |
00000390  20 20 20 cd 0d 01 5e 27  20 20 20 20 20 20 20 20  |   ...^'        |
000003a0  20 20 20 20 72 70 61 74  68 24 20 3d 20 72 70 61  |    rpath$ = rpa|
000003b0  74 68 24 20 2b 20 70 61  74 68 24 0d 01 68 0d 20  |th$ + path$..h. |
000003c0  20 20 20 20 20 20 20 cc  0d 01 72 24 20 20 20 20  |       ...r$    |
000003d0  20 20 20 20 20 20 20 20  72 70 61 74 68 24 20 3d  |        rpath$ =|
000003e0  20 22 24 22 20 2b 20 70  61 74 68 24 0d 01 7c 0d  | "$" + path$..|.|
000003f0  20 20 20 20 20 20 20 20  cd 0d 01 86 09 20 20 20  |        .....   |
00000400  20 cd 0d 01 90 05 cc 0d  01 9a 16 20 20 20 20 72  | ..........    r|
00000410  70 61 74 68 24 20 3d 20  70 61 74 68 24 0d 01 a4  |path$ = path$...|
00000420  05 cd 0d 01 ae 17 e3 20  69 20 3d 20 31 20 b8 20  |....... i = 1 . |
00000430  a9 28 72 70 61 74 68 24  29 0d 01 b8 31 20 20 20  |.(rpath$)...1   |
00000440  20 e7 20 c1 72 70 61 74  68 24 2c 69 2c 31 29 20  | . .rpath$,i,1) |
00000450  3d 20 22 2f 22 20 8c 20  c1 72 70 61 74 68 24 2c  |= "/" . .rpath$,|
00000460  69 2c 31 29 20 3d 20 22  2e 22 0d 01 c2 07 ed 20  |i,1) = "."..... |
00000470  69 0d 01 cc 0b 3d 72 70  61 74 68 24 0d 01 d6 04  |i....=rpath$....|
00000480  0d 01 e0 37 f4 20 42 41  53 49 43 20 69 73 20 6d  |...7. BASIC is m|
00000490  69 73 73 69 6e 67 20 61  20 67 65 74 65 6e 76 20  |issing a getenv |
000004a0  66 75 6e 63 74 69 6f 6e  2c 20 73 61 64 20 62 75  |function, sad bu|
000004b0  74 20 74 72 75 65 2e 0d  01 ea 11 f4 20 68 65 72  |t true...... her|
000004c0  65 20 69 74 20 69 73 2e  0d 01 f4 42 f4 20 43 41  |e it is....B. CA|
000004d0  55 54 49 4f 4e 3a 20 62  65 63 61 75 73 65 20 69  |UTION: because i|
000004e0  74 20 75 73 65 64 20 61  20 73 74 72 69 6e 67 20  |t used a string |
000004f0  61 73 20 61 20 64 79 6e  61 6d 69 63 61 6c 6c 79  |as a dynamically|
00000500  20 61 6c 6c 6f 63 61 74  65 64 0d 01 fe 41 f4 20  | allocated...A. |
00000510  74 65 6d 70 6f 72 61 72  79 20 73 74 6f 72 61 67  |temporary storag|
00000520  65 2c 20 74 68 69 73 20  76 65 72 73 69 6f 6e 20  |e, this version |
00000530  69 73 20 6c 69 6d 69 74  65 64 20 74 6f 20 32 35  |is limited to 25|
00000540  34 20 63 68 61 72 61 63  74 65 72 0d 02 08 28 f4  |4 character...(.|
00000550  20 63 6f 6e 74 65 6e 74  73 20 69 6e 20 65 6e 76  | contents in env|
00000560  69 72 6f 6e 6d 65 6e 74  20 76 61 72 69 61 62 6c  |ironment variabl|
00000570  65 73 21 0d 02 12 05 f4  0d 02 1c 13 dd 20 a4 67  |es!.......... .g|
00000580  65 74 65 6e 76 28 76 61  72 24 29 0d 02 26 13 ea  |etenv(var$)..&..|
00000590  20 72 65 73 24 2c 20 73  69 7a 65 2c 20 61 0d 02  | res$, size, a..|
000005a0  30 0c 73 69 7a 65 20 3d  20 30 0d 02 3a 2d c8 99  |0.size = 0..:-..|
000005b0  20 22 58 4f 53 5f 52 65  61 64 56 61 72 56 61 6c  | "XOS_ReadVarVal|
000005c0  22 2c 20 76 61 72 24 2c  20 30 2c 20 2d 31 20 b8  |", var$, 0, -1 .|
000005d0  20 2c 2c 73 69 7a 65 0d  02 44 10 73 69 7a 65 20  | ,,size..D.size |
000005e0  3d 20 ac 73 69 7a 65 0d  02 4e 19 e7 20 73 69 7a  |= .size..N.. siz|
000005f0  65 3e 32 35 34 20 8c 20  73 69 7a 65 3d 32 35 34  |e>254 . size=254|
00000600  0d 02 58 14 72 65 73 24  3d c4 73 69 7a 65 2c 20  |..X.res$=.size, |
00000610  22 2e 22 29 0d 02 62 39  c8 99 20 22 58 4f 53 5f  |".")..b9.. "XOS_|
00000620  52 65 61 64 56 61 72 56  61 6c 22 2c 20 76 61 72  |ReadVarVal", var|
00000630  24 2c 20 72 65 73 24 2c  20 73 69 7a 65 2c 20 30  |$, res$, size, 0|
00000640  20 b8 20 2c 72 65 73 24  2c 73 69 7a 65 0d 02 6c  | . ,res$,size..l|
00000650  09 3d 72 65 73 24 0d 02  76 04 0d 02 80 46 2d 2d  |.=res$..v....F--|
00000660  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
000006a0  0d 02 8a 0e f4 3e 42 61  73 45 6e 74 72 79 0d 02  |.....>BasEntry..|
000006b0  94 33 f4 20 4c 69 62 72  61 72 79 20 66 6f 72 20  |.3. Library for |
000006c0  69 6d 70 6c 65 6d 65 6e  74 69 6e 67 20 61 72 67  |implementing arg|
000006d0  63 20 26 20 61 72 67 76  20 69 6e 20 42 41 53 49  |c & argv in BASI|
000006e0  43 0d 02 9e 13 f4 20 a9  31 39 39 33 20 48 52 4d  |C..... .1993 HRM|
000006f0  69 6c 6c 73 0d 02 a8 2c  f4 20 4c 6f 61 64 20 6c  |ills...,. Load l|
00000700  69 62 72 61 72 79 20 77  69 74 68 20 49 4e 53 54  |ibrary with INST|
00000710  41 4c 4c 20 22 25 2e 42  61 73 45 6e 74 72 79 22  |ALL "%.BasEntry"|
00000720  0d 02 b2 4f f4 20 74 68  65 6e 20 64 6f 20 50 52  |...O. then do PR|
00000730  4f 43 65 6e 74 72 79 2e  20 54 68 69 73 20 73 65  |OCentry. This se|
00000740  74 73 20 75 70 20 74 68  65 20 76 61 72 69 61 62  |ts up the variab|
00000750  6c 65 20 61 72 67 63 2c  20 65 71 75 61 6c 20 74  |le argc, equal t|
00000760  6f 20 74 68 65 20 6e 75  6d 62 65 72 20 6f 66 0d  |o the number of.|
00000770  02 bc 49 f4 20 63 6f 6d  6d 61 6e 64 20 6c 69 6e  |..I. command lin|
00000780  65 20 61 72 67 75 6d 65  6e 74 73 20 6f 66 20 74  |e arguments of t|
00000790  68 65 20 70 72 6f 67 72  61 6d 2c 20 61 6e 64 20  |he program, and |
000007a0  61 72 67 76 24 28 29 2c  20 61 6e 20 61 72 72 61  |argv$(), an arra|
000007b0  79 20 6f 66 20 74 68 65  0d 02 c6 1b f4 20 61 72  |y of the..... ar|
000007c0  67 75 6d 65 6e 74 73 20  74 68 65 6d 73 65 6c 76  |guments themselv|
000007d0  65 73 2e 0d 02 d0 04 0d  02 da 2c f4 20 73 6d 61  |es........,. sma|
000007e0  6c 6c 20 66 69 78 20 62  79 20 47 75 6e 6e 61 72  |ll fix by Gunnar|
000007f0  20 5a f6 74 6c 2c 20 32  33 2d 4f 63 74 2d 31 39  | Z.tl, 23-Oct-19|
00000800  39 34 3a 0d 02 e4 41 f4  20 69 66 20 74 68 65 72  |94:...A. if ther|
00000810  65 20 77 61 73 20 61 20  73 70 61 63 65 20 61 66  |e was a space af|
00000820  74 65 72 20 61 20 70 61  72 61 6d 65 74 65 72 20  |ter a parameter |
00000830  6f 6e 20 74 68 65 20 63  6f 6d 6d 61 6e 64 20 6c  |on the command l|
00000840  69 6e 65 2c 0d 02 ee 37  f4 20 69 74 20 77 61 73  |ine,...7. it was|
00000850  20 72 65 74 75 72 6e 65  64 20 77 69 74 68 20 74  | returned with t|
00000860  68 65 20 73 74 72 69 6e  67 2e 20 49 73 20 6e 6f  |he string. Is no|
00000870  77 20 73 74 72 69 70 70  65 64 2e 0d 02 f8 04 0d  |w stripped......|
00000880  03 02 0b dd f2 65 6e 74  72 79 0d 03 0c 1c 20 20  |.....entry....  |
00000890  20 20 ea 20 66 25 2c 70  25 2c 43 6f 6d 6d 61 6e  |  . f%,p%,Comman|
000008a0  64 4c 69 6e 65 24 0d 03  16 24 20 20 20 20 c8 99  |dLine$...$    ..|
000008b0  22 4f 53 5f 47 65 74 45  6e 76 22 20 b8 20 43 6f  |"OS_GetEnv" . Co|
000008c0  6d 6d 61 6e 64 4c 69 6e  65 24 0d 03 20 34 20 20  |mmandLine$.. 4  |
000008d0  20 20 43 6f 6d 6d 61 6e  64 4c 69 6e 65 24 3d a4  |  CommandLine$=.|
000008e0  62 61 73 65 6e 74 72 79  5f 73 74 72 69 70 28 43  |basentry_strip(C|
000008f0  6f 6d 6d 61 6e 64 4c 69  6e 65 24 2c 32 29 0d 03  |ommandLine$,2)..|
00000900  2a 2a 20 20 20 20 61 72  67 63 3d a4 62 61 73 65  |**    argc=.base|
00000910  6e 74 72 79 5f 63 6f 75  6e 74 28 43 6f 6d 6d 61  |ntry_count(Comma|
00000920  6e 64 4c 69 6e 65 24 29  0d 03 34 15 20 20 20 20  |ndLine$)..4.    |
00000930  de 20 61 72 67 76 24 28  61 72 67 63 29 0d 03 3e  |. argv$(argc)..>|
00000940  04 0d 03 48 17 20 20 20  20 e3 20 66 25 3d 30 20  |...H.    . f%=0 |
00000950  b8 20 61 72 67 63 2d 31  0d 03 52 25 20 20 20 20  |. argc-1..R%    |
00000960  20 20 20 20 e7 20 a7 43  6f 6d 6d 61 6e 64 4c 69  |    . .CommandLi|
00000970  6e 65 24 2c 22 20 22 29  3c 3e 30 20 8c 0d 03 5c  |ne$," ")<>0 ...\|
00000980  3d 20 20 20 20 20 20 20  20 20 20 20 20 61 72 67  |=            arg|
00000990  76 24 28 66 25 29 3d c0  43 6f 6d 6d 61 6e 64 4c  |v$(f%)=.CommandL|
000009a0  69 6e 65 24 2c a7 43 6f  6d 6d 61 6e 64 4c 69 6e  |ine$,.CommandLin|
000009b0  65 24 2c 22 20 22 29 2d  31 29 0d 03 66 0d 20 20  |e$," ")-1)..f.  |
000009c0  20 20 20 20 20 20 cc 0d  03 70 26 20 20 20 20 20  |      ...p&     |
000009d0  20 20 20 20 20 20 20 61  72 67 76 24 28 66 25 29  |       argv$(f%)|
000009e0  3d 43 6f 6d 6d 61 6e 64  4c 69 6e 65 24 0d 03 7a  |=CommandLine$..z|
000009f0  0d 20 20 20 20 20 20 20  20 cd 0d 03 84 38 20 20  |.        ....8  |
00000a00  20 20 20 20 20 20 43 6f  6d 6d 61 6e 64 4c 69 6e  |      CommandLin|
00000a10  65 24 3d a4 62 61 73 65  6e 74 72 79 5f 73 74 72  |e$=.basentry_str|
00000a20  69 70 28 43 6f 6d 6d 61  6e 64 4c 69 6e 65 24 2c  |ip(CommandLine$,|
00000a30  31 29 0d 03 8e 24 20 20  20 20 20 20 20 20 e7 20  |1)...$        . |
00000a40  c0 43 6f 6d 6d 61 6e 64  4c 69 6e 65 24 2c 31 29  |.CommandLine$,1)|
00000a50  3d 22 20 22 20 8c 0d 03  98 11 20 20 20 20 20 20  |=" " .....      |
00000a60  20 20 20 20 20 20 f5 0d  03 a2 31 20 20 20 20 20  |      ....1     |
00000a70  20 20 20 20 20 20 20 20  20 20 20 43 6f 6d 6d 61  |           Comma|
00000a80  6e 64 4c 69 6e 65 24 3d  c1 43 6f 6d 6d 61 6e 64  |ndLine$=.Command|
00000a90  4c 69 6e 65 24 2c 31 29  0d 03 ac 27 20 20 20 20  |Line$,1)...'    |
00000aa0  20 20 20 20 20 20 20 20  fd 20 c0 43 6f 6d 6d 61  |        . .Comma|
00000ab0  6e 64 4c 69 6e 65 24 2c  31 29 3c 3e 22 20 22 0d  |ndLine$,1)<>" ".|
00000ac0  03 b6 0d 20 20 20 20 20  20 20 20 cd 0d 03 c0 09  |...        .....|
00000ad0  20 20 20 20 ed 0d 03 ca  1d 20 20 20 20 61 72 67  |    .....    arg|
00000ae0  76 24 28 30 29 3d c1 61  72 67 76 24 28 30 29 2c  |v$(0)=.argv$(0),|
00000af0  32 29 0d 03 d4 27 20 20  20 20 61 72 67 76 24 28  |2)...'    argv$(|
00000b00  30 29 3d c0 61 72 67 76  24 28 30 29 2c a9 61 72  |0)=.argv$(0),.ar|
00000b10  67 76 24 28 30 29 2d 32  29 0d 03 de 05 e1 0d 03  |gv$(0)-2).......|
00000b20  e8 05 3a 0d 03 f2 1e dd  a4 62 61 73 65 6e 74 72  |..:......basentr|
00000b30  79 5f 73 74 72 69 70 28  4c 69 73 74 24 2c 61 25  |y_strip(List$,a%|
00000b40  29 0d 03 fc 0c 20 20 20  20 ea 20 66 25 0d 04 06  |)....    . f%...|
00000b50  13 20 20 20 20 e3 20 66  25 3d 31 20 b8 20 61 25  |.    . f%=1 . a%|
00000b60  0d 04 10 27 20 20 20 20  20 20 20 20 4c 69 73 74  |...'        List|
00000b70  24 3d c1 4c 69 73 74 24  2c a7 4c 69 73 74 24 2c  |$=.List$,.List$,|
00000b80  22 20 22 29 2b 31 29 0d  04 1a 09 20 20 20 20 ed  |" ")+1)....    .|
00000b90  0d 04 24 0a 3d 4c 69 73  74 24 0d 04 2e 05 3a 0d  |..$.=List$....:.|
00000ba0  04 38 1b dd a4 62 61 73  65 6e 74 72 79 5f 63 6f  |.8...basentry_co|
00000bb0  75 6e 74 28 4c 69 73 74  24 29 0d 04 42 17 20 20  |unt(List$)..B.  |
00000bc0  20 20 ea 20 72 25 2c 70  25 2c 73 70 61 63 65 73  |  . r%,p%,spaces|
00000bd0  25 0d 04 4c 11 20 20 20  20 73 70 61 63 65 73 25  |%..L.    spaces%|
00000be0  3d a3 0d 04 56 18 20 20  20 20 e3 20 70 25 3d 30  |=...V.    . p%=0|
00000bf0  20 b8 20 a9 20 4c 69 73  74 24 0d 04 60 2b 20 20  | . . List$..`+  |
00000c00  20 20 20 20 20 20 e7 20  73 70 61 63 65 73 25 20  |      . spaces% |
00000c10  80 20 c1 4c 69 73 74 24  2c 70 25 2c 31 29 3c 3e  |. .List$,p%,1)<>|
00000c20  22 20 22 20 8c 0d 04 6a  15 20 20 20 20 20 20 20  |" " ...j.       |
00000c30  20 20 20 20 20 72 25 2b  3d 31 0d 04 74 19 20 20  |     r%+=1..t.  |
00000c40  20 20 20 20 20 20 20 20  20 20 73 70 61 63 65 73  |          spaces|
00000c50  25 3d a3 0d 04 7e 0d 20  20 20 20 20 20 20 20 cc  |%=...~.        .|
00000c60  0d 04 88 2c 20 20 20 20  20 20 20 20 20 20 20 20  |...,            |
00000c70  e7 20 c1 4c 69 73 74 24  2c 70 25 2c 31 29 3d 22  |. .List$,p%,1)="|
00000c80  20 22 20 73 70 61 63 65  73 25 3d b9 0d 04 92 0d  | " spaces%=.....|
00000c90  20 20 20 20 20 20 20 20  cd 0d 04 9c 09 20 20 20  |        .....   |
00000ca0  20 ed 0d 04 a6 09 3d 72  25 2b 31 0d 04 b0 46 2d  | .....=r%+1...F-|
00000cb0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000cf0  2d 0d 04 ba 15 f4 20 65  6e 64 20 6f 66 20 42 61  |-..... end of Ba|
00000d00  73 45 6e 74 72 79 0d 04  c4 04 0d 04 ce 3f f4 20  |sEntry.......?. |
00000d10  72 65 74 75 72 6e 20 74  68 65 20 73 74 72 69 6e  |return the strin|
00000d20  67 20 66 72 6f 6d 20 74  68 65 20 66 69 72 73 74  |g from the first|
00000d30  20 6e 6f 6e 2d 73 70 61  63 65 20 63 68 61 72 61  | non-space chara|
00000d40  63 74 65 72 20 75 70 74  6f 0d 04 d8 20 f4 20 74  |cter upto... . t|
00000d50  68 65 20 66 69 72 73 74  20 66 6f 6c 6c 6f 77 69  |he first followi|
00000d60  6e 67 20 73 70 61 63 65  2e 0d 04 e2 05 f4 0d 04  |ng space........|
00000d70  ec 16 dd 20 a4 73 74 72  69 70 73 70 61 63 65 73  |... .stripspaces|
00000d80  28 61 24 29 0d 04 f6 09  ea 20 69 2c 6a 0d 05 00  |(a$)..... i,j...|
00000d90  07 69 3d 31 0d 05 0a 17  c8 95 20 c1 61 24 2c 20  |.i=1...... .a$, |
00000da0  69 2c 20 31 29 20 3d 20  22 20 22 0d 05 14 11 20  |i, 1) = " ".... |
00000db0  20 20 20 69 20 3d 20 69  20 2b 20 31 0d 05 1e 05  |   i = i + 1....|
00000dc0  ce 0d 05 28 14 6a 20 3d  20 a7 61 24 2c 20 22 20  |...(.j = .a$, " |
00000dd0  22 2c 20 69 29 0d 05 32  17 e7 20 6a 20 3c 20 69  |", i)..2.. j < i|
00000de0  20 8c 20 6a 20 3d 20 a9  28 61 24 29 0d 05 3c 0f  | . j = .(a$)..<.|
00000df0  3d c1 61 24 2c 20 69 2c  20 6a 29 0d 05 46 04 0d  |=.a$, i, j)..F..|
00000e00  05 50 3b f4 20 67 65 74  20 74 68 65 20 75 73 65  |.P;. get the use|
00000e10  72 20 69 64 20 66 6f 72  20 61 20 73 70 65 63 69  |r id for a speci|
00000e20  66 69 65 64 20 75 73 65  72 20 66 72 6f 6d 20 2f  |fied user from /|
00000e30  65 74 63 2f 70 61 73 73  77 64 0d 05 5a 2f f4 20  |etc/passwd..Z/. |
00000e40  72 65 74 75 72 6e 73 20  2d 31 20 69 66 20 74 68  |returns -1 if th|
00000e50  65 20 75 69 64 20 63 6f  75 6c 64 20 6e 6f 74 20  |e uid could not |
00000e60  62 65 20 66 6f 75 6e 64  2e 0d 05 64 14 dd 20 a4  |be found...d.. .|
00000e70  67 65 74 75 69 64 28 75  73 65 72 24 29 0d 05 6e  |getuid(user$)..n|
00000e80  27 20 20 20 20 70 61 73  73 77 64 24 20 3d 20 a4  |'    passwd$ = .|
00000e90  75 70 61 74 68 28 22 2f  65 74 63 2f 70 61 73 73  |upath("/etc/pass|
00000ea0  77 64 22 29 0d 05 6f 15  20 20 20 20 6c 65 6e 25  |wd")..o.    len%|
00000eb0  3d a9 28 75 73 65 72 24  29 0d 05 78 11 20 20 20  |=.(user$)..x.   |
00000ec0  20 75 69 64 25 20 3d 20  2d 31 0d 05 82 18 20 20  | uid% = -1....  |
00000ed0  20 20 69 66 25 20 3d 20  8e 28 70 61 73 73 77 64  |  if% = .(passwd|
00000ee0  24 29 0d 05 8c 13 20 20  20 20 e7 20 69 66 25 20  |$)....    . if% |
00000ef0  3e 20 30 20 8c 0d 05 96  0d 20 20 20 20 20 20 20  |> 0 .....       |
00000f00  20 f5 0d 05 a0 1a 20 20  20 20 20 20 20 20 20 20  | .....          |
00000f10  20 20 63 24 20 3d 20 be  23 69 66 25 0d 05 aa 26  |  c$ = .#if%...&|
00000f20  20 20 20 20 20 20 20 20  20 20 20 20 e7 20 c0 63  |            . .c|
00000f30  24 2c 20 6c 65 6e 25 29  20 3d 20 75 73 65 72 24  |$, len%) = user$|
00000f40  20 8c 0d 05 b4 22 20 20  20 20 20 20 20 20 20 20  | ...."          |
00000f50  20 20 20 20 20 20 69 25  20 3d 20 a7 63 24 2c 20  |      i% = .c$, |
00000f60  22 3a 22 29 0d 05 be 2a  20 20 20 20 20 20 20 20  |":")...*        |
00000f70  20 20 20 20 20 20 20 20  69 25 20 3d 20 a7 63 24  |        i% = .c$|
00000f80  2c 20 22 3a 22 2c 20 69  25 20 2b 20 31 29 0d 05  |, ":", i% + 1)..|
00000f90  c8 2a 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.*              |
00000fa0  20 20 75 69 64 25 20 3d  20 bb 28 c1 63 24 2c 20  |  uid% = .(.c$, |
00000fb0  69 25 20 2b 20 31 29 29  0d 05 d2 11 20 20 20 20  |i% + 1))....    |
00000fc0  20 20 20 20 20 20 20 20  cd 0d 05 dc 13 20 20 20  |        .....   |
00000fd0  20 20 20 20 20 fd 20 63  24 3d 22 22 0d 05 e6 12  |     . c$=""....|
00000fe0  20 20 20 20 20 20 20 20  d9 20 23 69 66 25 0d 05  |        . #if%..|
00000ff0  f0 09 20 20 20 20 cd 0d  05 fa 09 3d 75 69 64 25  |..    .....=uid%|
00001000  0d 06 04 04 0d ff                                 |......|
00001006