mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-03 12:06:05 +00:00
218 lines
4.3 KiB
Plaintext
218 lines
4.3 KiB
Plaintext
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
|
||
ZPhPW .BS 1
|
||
ZPPWPtr .BS 2
|
||
ZPhStr .BS 1
|
||
ZPStrPtr .BS 2
|
||
ArgIndex .BS 1
|
||
ArgUsername .BS 1
|
||
bDelete .BS 1
|
||
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
|
||
rts
|
||
*--------------------------------------
|
||
* Called until exit with CS
|
||
* if RUN exits with CC, RN entered again
|
||
*--------------------------------------
|
||
CS.RUN >LDYAI S.PW
|
||
>SYSCALL getmem
|
||
bcs .99
|
||
>STYA ZPPWPtr
|
||
stx ZPhPW
|
||
>LDYAI 256
|
||
>SYSCALL getmem
|
||
bcs .99
|
||
>STYA ZPStrPtr
|
||
stx ZPhStr
|
||
jsr CS.RUN.CheckArg
|
||
bcs .99
|
||
>PUSHW ZPPWPtr
|
||
lda ArgUsername
|
||
>SYSCALL ArgV
|
||
>SYSCALL GetPWName
|
||
bcs .99
|
||
ldy #S.PW.PASSWD
|
||
lda #0
|
||
sta (ZPPWPtr),y
|
||
>LDYA ZPPWPtr
|
||
>SYSCALL putpw
|
||
bcs .99
|
||
|
||
>SYSCALL FlushEtcPasswd
|
||
bcs .99
|
||
|
||
jsr CS.RUN.RmDir
|
||
bcs .99
|
||
|
||
lda #0
|
||
sec
|
||
rts
|
||
|
||
.9 >PUSHBI 0
|
||
>LDYA L.MSG.INV
|
||
>SYSCALL printf
|
||
lda #E.IUSR
|
||
sec
|
||
rts
|
||
|
||
.90 lda #E.IPWDDB
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
CS.RUN.CheckArg inc ArgIndex
|
||
lda ArgIndex
|
||
>SYSCALL ArgV
|
||
bcs .8
|
||
>STYA ZPStrPtr
|
||
lda (ZPStrPtr)
|
||
cmp #'-'
|
||
bne .4
|
||
|
||
ldy #1
|
||
lda (ZPStrPtr),y
|
||
|
||
ldx #OptionVars-OptionList-1
|
||
|
||
.2 cmp OptionList,x
|
||
beq .3
|
||
|
||
dex
|
||
bpl .2
|
||
|
||
.9 >PUSHBI 0
|
||
>LDYA L.MSG.USAGE
|
||
>SYSCALL printf
|
||
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 ZPPWPtr
|
||
clc
|
||
adc #S.PW.DIR
|
||
tay
|
||
lda ZPPWPtr+1
|
||
adc /S.PW.DIR
|
||
>SYSCALL remove
|
||
rts
|
||
|
||
.1 >PUSHW L.CMD.RM
|
||
|
||
>LDYA ZPStrPtr
|
||
>SYSCALL strcpy
|
||
lda ZPPWPtr
|
||
clc
|
||
adc #S.PW.DIR
|
||
tay
|
||
lda ZPPWPtr+1
|
||
adc /S.PW.DIR
|
||
>LDYA ZPStrPtr
|
||
>SYSCALL strcat
|
||
>PUSHBI S.PS.F.HOLD
|
||
>LDYA ZPStrPtr
|
||
>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
|
||
.1 lda ZPhPW
|
||
beq .8
|
||
>SYSCALL freemem
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.END
|
||
*--------------------------------------
|
||
OptionList .AS "Rr"
|
||
OptionVars .DA #bDelete,#bDelete
|
||
*--------------------------------------
|
||
* Initialized DATA
|
||
*--------------------------------------
|
||
MSG.USAGE .AS "Usage : USERDEL username\r\n"
|
||
.AZ " -r : Force remove files in home directory\r\n"
|
||
MSG.INV .AZ "Invalid username.\r\n"
|
||
CMD.RM .AZ "${ROOT}BIN/RM -R -Q "
|
||
*--------------------------------------
|
||
* Per Process DATA segment
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
DS.END .ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE USR/SRC/BIN/USERDEL.S
|
||
ASM
|