GNO_COMMAND(3) Library Routines GNO_COMMAND(3)
~GNO_COMMAND, ~GNO_PARSEARG, ~GNO_FREEARG - command line parsing and
startup from assembly code
~GNO_PARSEARG subroutine (4:commandline,4:argptr)
~GNO_FREEARG subroutine (4:argv,2:argc)
~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
~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_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.
These routines first appeared in GNO v1.0. They are based on actual
gsh(1) parsing code.
~GNO_PARSEARG assumes that the ByteWorks Memory Manager has been
started up and is usable. No such assumption is made with ~GNO_COM-
GNO 27 January 1997 GNO_COMMAND(3)
Man(1) output converted with