; ; cmdLine.sh ; ; Command line parsing ; ; © 1994-1998 Straylight ; ;----- Licensing note ------------------------------------------------------- ; ; This file is part of Straylight's Sapphire library. ; ; Sapphire is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2, or (at your option) ; any later version. ; ; Sapphire is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with Sapphire. If not, write to the Free Software Foundation, ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;----- Overview ------------------------------------------------------------- ; ; Functions provided: ; ; cl_next [ :LNOT::DEF:cmdLine__dfn GBLL cmdLine__dfn ; --- cl_next --- ; ; On entry: R0 == pointer to a command line string (ctrl terminated) ; R1 == pointer to a buffer (may be equal to R0) ; ; On exit: CS if another word found, and ; R0 == updated past next word ; R1 preserved, buffer filled with null terminated string ; R2 == pointer to terminating null character ; else CC and ; R0 == pointer to terminating character ; R1 preserved, buffer preserved ; R2 corrupted ; ; Use: Extracts the next word from a command line string. If the ; string is in a writable buffer, you can set R1 == R0 to ; start with. You can build up a C-like argv array like this: ; ; ; R0 == pointer to command line in writable buffer ; ; MOV R1,R0 ; ADR R3,argv ; MOV R4,#0 ; loop BL cl_next ; MOVCC R1,#0 ; STR R1,[R3],#4 ; ADDCS R4,#0 ; BCS loop ; ; ; R0-R3 corrupted ; ; R4 == argc ; ; This routine will handle quoted strings, considering them ; to be single arguments. Either type of quote will do, ; quote doubling is required to insert quotes in quoted ; strings. IMPORT cl_next ] ;----- That's all, folks ---------------------------------------------------- END