home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
me34src.zip
/
me3
/
mutt
/
builtin
/
cmdline.mut
< prev
next >
Wrap
Text File
|
1995-01-14
|
2KB
|
66 lines
;; cmdline.mut : mess with the command line (the stuff in argv[]).
;; Routines:
;; process-command-line
;; Call this routine when its time to process the command line. It
;; will call COMMAND-LINE-HOOK for each argv[] until one of the hooks
;; handles the arg. If none do, an error message is issued and
;; processing is stopped. Calling process-command-line again will
;; continue the processing, skipping the bad arg.
;; Hooks and related routines:
;; COMMAND-LINE-HOOK
;; Use (register-hook) to register your command line processor. It
;; will be called for each argv[]. If the arg is for you, process
;; it in some way, shape or form and return TRUE. Else returns
;; FALSE.
;; (next-cmd-line-arg pointer-to-string)
;; If you need another command line arg, use this. If there are args
;; left on the command line, it puts the next one into string and
;; returns TRUE. Else "<no arg>" is put into the string and FALSE
;; is returned.
;; (any-cmd-line-args-left)
;; Returns TRUE if there are any command line args left to be
;; processed.
;; (push-back-cmd-arg)
;; If, for some reason, the arg needs to be processed again, you can
;; call this.
;; (stop-processing-cmd-line)
;; If you want process-command-line to stop (after this arg (or before
;; if you push it back)), call this. Processing will resume when
;; process-command-line is called again.
;;
;; C Durland 10/92 Public Domain
(bool stop-now)
(int nth-arg)
(defun
MAIN { (nth-arg 1) }
process-command-line
{
(string the-arg)
(stop-now FALSE)
(while (next-cmd-line-arg the-arg)
{
(if (not (command-line-hook the-arg))
{
(msg "Unknown command line option: \"" the-arg "\"!")
FALSE
(done)
})
(if stop-now (break))
})
TRUE
}
next-cmd-line-arg (string the-arg)
{
(if (== nth-arg (argc)) { (the-arg "<no arg>") FALSE (done) })
(the-arg (argv nth-arg))
(+= nth-arg 1)
TRUE
}
any-cmd-line-args-left { (< nth-arg (argc)) }
push-back-cmd-arg { (if (> nth-arg 1) (-= nth-arg 1)) }
stop-processing-cmd-line { (stop-now TRUE) }
)