GNO_COMMAND(3) Library Routines GNO_COMMAND(3)
NAME
~GNO_COMMAND, ~GNO_PARSEARG, ~GNO_FREEARG - command line parsing and
startup from assembly code
SYNOPSIS
~GNO_COMMAND
~GNO_PARSEARG subroutine (4:commandline,4:argptr)
~GNO_FREEARG subroutine (4:argv,2:argc)
DESCRIPTION
~GNO_COMMAND emulates the startup code of a C program, and acts as a
wrapper for the ~GNO_PARSEARG and ~GNO_FREEARG functions, below. To
use this routine, immediately execute a JML to ~GNO_COMMAND from your
first segment. Ensure you have a function main() that conforms to the
following C prototype:
int main (int argc, char **argv);
~GNO_PARSEARG will take the command line passed to a utility and parse
it into an argc, argv structure like those used in C programs. This
was written not as a replacement for a C parser, but for use by assem‐
bly language programmers writing shell commands.
commandline is the raw command line string as passed by the calling
shell in the X and Y registers. argptr is a pointer to an argv[]-style
array.
~GNO_FREEARG frees the region allocated by ~GNO_PARSEARG. argv and
argc should be the region pointed to by argptr and the return value of
~GNO_PARSEARG, respectively.
RETURN VALUE
~GNO_COMMAND returns in the accumulator the value returned by main().
~GNO_PARSEARG returns in the accumulator the number of arguments found.
~GNO_FREEARG does not return a value.
HISTORY
These routines first appeared in GNO v1.0. They are based on actual
gsh(1) parsing code.
CAVEATS
~GNO_PARSEARG assumes that the ByteWorks Memory Manager has been
started up and is usable. No such assumption is made with ~GNO_COM
MAND.
GNO 27 January 1997 GNO_COMMAND(3)
Man(1) output converted with
man2html