A2osX/BIN/USERDEL.S.txt

215 lines
4.2 KiB
Plaintext
Raw Normal View History

2019-04-29 05:59:01 +00:00
NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
2020-02-11 16:32:33 +00:00
.TF bin/userdel
2019-04-29 05:59:01 +00:00
*--------------------------------------
2020-07-09 15:13:30 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
2019-04-29 05:59:01 +00:00
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ArgIndex .BS 1
ArgUsername .BS 1
2019-10-18 15:07:14 +00:00
bDelete .BS 1
2020-07-09 15:13:30 +00:00
ZPhStr .BS 1
ZPStrPtr .BS 2
ZPTmpPtr .BS 2
2019-04-29 05:59:01 +00:00
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data Segment Size
.DA #64 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
2019-10-03 06:25:27 +00:00
*--------------------------------------
2019-04-29 05:59:01 +00:00
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG.USAGE .DA MSG.USAGE
L.MSG.INV .DA MSG.INV
2019-04-29 15:47:17 +00:00
L.CMD.RM .DA CMD.RM
2019-04-29 05:59:01 +00:00
.DA 0
*--------------------------------------
* Called once at process creation
* Put code for loading LIB here
*--------------------------------------
CS.INIT clc
2020-07-09 15:13:30 +00:00
CS.INIT.RTS rts
2019-04-29 05:59:01 +00:00
*--------------------------------------
* Called until exit with CS
* if RUN exits with CC, RN entered again
*--------------------------------------
2020-07-09 15:13:30 +00:00
CS.RUN >LDYAI 256
2020-02-28 07:21:46 +00:00
>SYSCALL GetMem
2020-07-09 15:13:30 +00:00
bcs CS.INIT.RTS
2019-04-29 05:59:01 +00:00
>STYA ZPStrPtr
stx ZPhStr
jsr CS.RUN.CheckArg
bcs .99
2020-07-09 15:13:30 +00:00
2019-04-29 05:59:01 +00:00
lda ArgUsername
>SYSCALL ArgV
2020-07-09 15:13:30 +00:00
>PUSHYA
>PUSHW pData
2019-04-29 05:59:01 +00:00
>SYSCALL GetPWName
2019-04-29 15:47:17 +00:00
bcs .99
2020-07-09 15:13:30 +00:00
2019-04-29 05:59:01 +00:00
ldy #S.PW.PASSWD
lda #0
2020-07-09 15:13:30 +00:00
sta (pData),y
>PUSHW pData
2020-08-19 19:39:43 +00:00
>SYSCALL PutPW
2019-04-29 05:59:01 +00:00
bcs .99
jsr CS.RUN.RmDir
bcs .99
lda #0
sec
rts
2019-10-18 15:07:14 +00:00
.9 >LDYA L.MSG.INV
>SYSCALL PutS
2019-04-29 05:59:01 +00:00
lda #E.IUSR
sec
rts
.90 lda #E.IPWDDB
sec
.99 rts
*--------------------------------------
CS.RUN.CheckArg inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .8
2020-07-09 15:13:30 +00:00
>STYA ZPTmpPtr
lda (ZPTmpPtr)
2019-04-29 05:59:01 +00:00
cmp #'-'
bne .4
2019-10-18 15:07:14 +00:00
2019-04-29 05:59:01 +00:00
ldy #1
2020-07-09 15:13:30 +00:00
lda (ZPTmpPtr),y
2019-10-18 15:07:14 +00:00
ldx #OptionVars-OptionList-1
2019-04-29 05:59:01 +00:00
.2 cmp OptionList,x
beq .3
2019-10-18 15:07:14 +00:00
2019-04-29 05:59:01 +00:00
dex
2019-10-18 15:07:14 +00:00
bpl .2
.9 >LDYA L.MSG.USAGE
>SYSCALL PutS
2019-04-29 05:59:01 +00:00
lda #E.SYN
sec
rts
2019-10-18 15:07:14 +00:00
.3 ldy OptionVars,x
2019-04-29 05:59:01 +00:00
lda #$80
2019-10-18 15:07:14 +00:00
sta 0,y
2019-04-29 05:59:01 +00:00
bra CS.RUN.CheckArg
2019-10-18 15:07:14 +00:00
2019-04-29 15:47:17 +00:00
.4 lda ArgUsername
2019-04-29 05:59:01 +00:00
bne .9
2019-10-18 15:07:14 +00:00
2019-04-29 15:47:17 +00:00
lda ArgIndex
2019-04-29 05:59:01 +00:00
sta ArgUsername
bra CS.RUN.CheckArg
2019-10-18 15:07:14 +00:00
2019-04-29 05:59:01 +00:00
.8 lda ArgUsername
beq .9
2019-10-18 15:07:14 +00:00
2019-04-29 05:59:01 +00:00
clc
rts
*--------------------------------------
2019-10-18 15:07:14 +00:00
CS.RUN.RmDir lda bDelete
2019-04-29 15:47:17 +00:00
bmi .1
2020-07-09 15:13:30 +00:00
lda pData
2019-04-29 15:47:17 +00:00
clc
adc #S.PW.DIR
tay
2020-07-09 15:13:30 +00:00
lda pData+1
2019-04-29 15:47:17 +00:00
adc /S.PW.DIR
2020-08-19 19:39:43 +00:00
>SYSCALL Remove
2019-04-29 15:47:17 +00:00
rts
2019-10-18 15:07:14 +00:00
2021-05-04 17:31:21 +00:00
.1 >PUSHW ZPStrPtr
>PUSHW L.CMD.RM
2020-08-19 19:39:43 +00:00
>SYSCALL StrCpy
2020-07-09 15:13:30 +00:00
2021-05-04 17:31:21 +00:00
>PUSHW ZPStrPtr
2020-07-09 15:13:30 +00:00
lda pData
2019-04-29 15:47:17 +00:00
clc
adc #S.PW.DIR
tay
2020-07-09 15:13:30 +00:00
lda pData+1
2019-04-29 15:47:17 +00:00
adc /S.PW.DIR
2020-07-09 15:13:30 +00:00
>PUSHYA
2020-08-19 19:39:43 +00:00
>SYSCALL StrCat
2020-07-09 15:13:30 +00:00
2020-01-24 14:21:08 +00:00
>PUSHW ZPStrPtr
2019-04-30 16:08:47 +00:00
>PUSHBI S.PS.F.HOLD
2020-08-19 19:39:43 +00:00
>SYSCALL ExecL
2019-04-29 05:59:01 +00:00
rts
*--------------------------------------
* Called if option S.PS.F.EVENT enabled in Header
* Timer Event : every 10th seconds
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
* Called once, when RUN exited with CS
* Put code for unloading LIB here
*--------------------------------------
CS.QUIT lda ZPhStr
beq .8
2020-02-28 07:21:46 +00:00
>SYSCALL FreeMem
2020-07-09 15:13:30 +00:00
2019-04-29 05:59:01 +00:00
.8 clc
rts
*--------------------------------------
CS.END
*--------------------------------------
2019-10-18 15:07:14 +00:00
OptionList .AS "Rr"
2019-04-29 05:59:01 +00:00
OptionVars .DA #bDelete,#bDelete
*--------------------------------------
* Initialized DATA
*--------------------------------------
MSG.USAGE .CS "Usage : USERDEL username\r\n"
.CZ " -r : Force remove files in home directory\r\n"
MSG.INV .CZ "Invalid username."
CMD.RM .CZ "${ROOT}BIN/RM -R -Q "
2019-04-29 05:59:01 +00:00
*--------------------------------------
* Per Process DATA segment
*--------------------------------------
.DUMMY
.OR 0
2020-07-09 15:13:30 +00:00
DS.START .BS S.PW
2019-10-18 15:07:14 +00:00
DS.END .ED
2019-04-29 05:59:01 +00:00
*--------------------------------------
MAN
2020-07-09 15:13:30 +00:00
SAVE usr/src/bin/userdel.s
2019-04-29 05:59:01 +00:00
ASM