mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-09-11 14:54:54 +00:00
82 lines
1.9 KiB
Groff
82 lines
1.9 KiB
Groff
.\"
|
|
.\" $Id: parsearg.3,v 1.1 1997/02/27 07:32:24 gdr Exp $
|
|
.\"
|
|
.TH GNO_COMMAND 3 "27 January 1997" GNO "Library Routines"
|
|
.SH NAME
|
|
.BR ~GNO_COMMAND ,
|
|
.BR ~GNO_PARSEARG ,
|
|
.BR ~GNO_FREEARG
|
|
\- command line parsing and startup from assembly code
|
|
.SH SYNOPSIS
|
|
.BR ~GNO_COMMAND
|
|
.br
|
|
.BR ~GNO_PARSEARG
|
|
subroutine (4:\fIcommandline\fR,4:\fIargptr\fR)
|
|
.br
|
|
.BR ~GNO_FREEARG
|
|
subroutine (4:\fIargv\fR,2:\fIargc\fR)
|
|
.SH DESCRIPTION
|
|
.BR ~GNO_COMMAND
|
|
emulates the startup code of a C program, and acts as a wrapper for the
|
|
.BR ~GNO_PARSEARG
|
|
and
|
|
.BR ~GNO_FREEARG
|
|
functions, below. To use this routine, immediately execute a JML to
|
|
.BR ~GNO_COMMAND
|
|
from your first segment. Ensure you have a function
|
|
.BR main ()
|
|
that conforms to the following C prototype:
|
|
.nf
|
|
|
|
int \fBmain\fR (int \fIargc\fR, char **\fIargv\fR);
|
|
.fi
|
|
.LP
|
|
.BR ~GNO_PARSEARG
|
|
will take the command line passed to a utility and parse it into an
|
|
.IR argc ,
|
|
.IR argv
|
|
structure like those used in C programs. This was written
|
|
.IR not
|
|
as a replacement for a C parser, but for use by assembly language
|
|
programmers writing shell commands.
|
|
.LP
|
|
.IR commandline
|
|
is the raw command line string as passed by the calling shell in the
|
|
X and Y registers.
|
|
.IR argptr
|
|
is a pointer to an
|
|
.IR argv []-style
|
|
array.
|
|
.LP
|
|
.BR ~GNO_FREEARG
|
|
frees the region allocated by
|
|
.BR ~GNO_PARSEARG .
|
|
.IR argv
|
|
and
|
|
.IR argc
|
|
should be the region pointed to by
|
|
.IR argptr
|
|
and the return value of
|
|
.BR ~GNO_PARSEARG ,
|
|
respectively.
|
|
.SH RETURN VALUE
|
|
.BR ~GNO_COMMAND
|
|
returns in the accumulator the value returned by
|
|
.BR main ().
|
|
.LP
|
|
.BR ~GNO_PARSEARG
|
|
returns in the accumulator the number of arguments found.
|
|
.LP
|
|
.BR ~GNO_FREEARG
|
|
does not return a value.
|
|
.SH HISTORY
|
|
These routines first appeared in GNO v1.0. They are based on actual
|
|
.BR gsh (1)
|
|
parsing code.
|
|
.SH CAVEATS
|
|
.BR ~GNO_PARSEARG
|
|
.IR assumes
|
|
that the ByteWorks Memory Manager has been started up and is usable.
|
|
No such assumption is made with
|
|
.BR ~GNO_COMMAND .
|