Initial revision
[ssr] / StraySrc / Libraries / Sapphire / sh / cmdLine
1 ;
2 ; cmdLine.sh
3 ;
4 ; Command line parsing
5 ;
6 ; © 1994-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's Sapphire library.
12 ;
13 ; Sapphire is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
16 ; any later version.
17 ;
18 ; Sapphire is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ; GNU General Public License for more details.
22 ;
23 ; You should have received a copy of the GNU General Public License
24 ; along with Sapphire. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27 ;----- Overview -------------------------------------------------------------
28 ;
29 ; Functions provided:
30 ;
31 ; cl_next
32
33 [ :LNOT::DEF:cmdLine__dfn
34 GBLL cmdLine__dfn
35
36 ; --- cl_next ---
37 ;
38 ; On entry: R0 == pointer to a command line string (ctrl terminated)
39 ; R1 == pointer to a buffer (may be equal to R0)
40 ;
41 ; On exit: CS if another word found, and
42 ; R0 == updated past next word
43 ; R1 preserved, buffer filled with null terminated string
44 ; R2 == pointer to terminating null character
45 ; else CC and
46 ; R0 == pointer to terminating character
47 ; R1 preserved, buffer preserved
48 ; R2 corrupted
49 ;
50 ; Use: Extracts the next word from a command line string. If the
51 ; string is in a writable buffer, you can set R1 == R0 to
52 ; start with. You can build up a C-like argv array like this:
53 ;
54 ; ; R0 == pointer to command line in writable buffer
55 ;
56 ; MOV R1,R0
57 ; ADR R3,argv
58 ; MOV R4,#0
59 ; loop BL cl_next
60 ; MOVCC R1,#0
61 ; STR R1,[R3],#4
62 ; ADDCS R4,#0
63 ; BCS loop
64 ;
65 ; ; R0-R3 corrupted
66 ; ; R4 == argc
67 ;
68 ; This routine will handle quoted strings, considering them
69 ; to be single arguments. Either type of quote will do,
70 ; quote doubling is required to insert quotes in quoted
71 ; strings.
72
73 IMPORT cl_next
74
75 ]
76
77 ;----- That's all, folks ----------------------------------------------------
78
79 END