A2osX/BIN/USERDEL.S.txt
2023-07-14 12:24:49 +02:00

215 lines
4.2 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF bin/userdel
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ArgIndex .BS 1
ArgUsername .BS 1
bDelete .BS 1
ZPhStr .BS 1
ZPStrPtr .BS 2
ZPTmpPtr .BS 2
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
*--------------------------------------
.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
L.CMD.RM .DA CMD.RM
.DA 0
*--------------------------------------
* Called once at process creation
* Put code for loading LIB here
*--------------------------------------
CS.INIT clc
CS.INIT.RTS rts
*--------------------------------------
* Called until exit with CS
* if RUN exits with CC, RN entered again
*--------------------------------------
CS.RUN >LDYAI 256
>SYSCALL GetMem
bcs CS.INIT.RTS
>STYA ZPStrPtr
stx ZPhStr
jsr CS.RUN.CheckArg
bcs .99
lda ArgUsername
>SYSCALL ArgV
>PUSHYA
>PUSHW pData
>SYSCALL GetPWName
bcs .99
ldy #S.PW.PASSWD
lda #0
sta (pData),y
>PUSHW pData
>SYSCALL PutPW
bcs .99
jsr CS.RUN.RmDir
bcs .99
lda #0
sec
rts
.9 >LDYA L.MSG.INV
>SYSCALL PutS
lda #E.IUSR
sec
rts
.90 lda #E.IPWDDB
sec
.99 rts
*--------------------------------------
CS.RUN.CheckArg inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .8
>STYA ZPTmpPtr
lda (ZPTmpPtr)
cmp #'-'
bne .4
ldy #1
lda (ZPTmpPtr),y
ldx #OptionVars-OptionList-1
.2 cmp OptionList,x
beq .3
dex
bpl .2
.9 >LDYA L.MSG.USAGE
>SYSCALL PutS
lda #E.SYN
sec
rts
.3 ldy OptionVars,x
lda #$80
sta 0,y
bra CS.RUN.CheckArg
.4 lda ArgUsername
bne .9
lda ArgIndex
sta ArgUsername
bra CS.RUN.CheckArg
.8 lda ArgUsername
beq .9
clc
rts
*--------------------------------------
CS.RUN.RmDir lda bDelete
bmi .1
lda pData
clc
adc #S.PW.DIR
tay
lda pData+1
adc /S.PW.DIR
>SYSCALL Remove
rts
.1 >PUSHW ZPStrPtr
>PUSHW L.CMD.RM
>SYSCALL StrCpy
>PUSHW ZPStrPtr
lda pData
clc
adc #S.PW.DIR
tay
lda pData+1
adc /S.PW.DIR
>PUSHYA
>SYSCALL StrCat
>PUSHW ZPStrPtr
>PUSHBI S.PS.F.HOLD
>SYSCALL ExecL
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
>SYSCALL FreeMem
.8 clc
rts
*--------------------------------------
CS.END
*--------------------------------------
OptionList .AS "Rr"
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 "
*--------------------------------------
* Per Process DATA segment
*--------------------------------------
.DUMMY
.OR 0
DS.START .BS S.PW
DS.END .ED
*--------------------------------------
MAN
SAVE usr/src/bin/userdel.s
ASM