Atari ST series Technical Reference Manual page 111

Hide thumbs Also See for ST series:
Table of Contents

Advertisement

GEMDOS Device I/O and Process Control
m a i n Q
{
int status;
int len, done=
int index^l;
/ *
Get command line
Cconws("Enter command line [include filename extension]\n\r");
buffer[0]=80;
buf f e r [82]=0;
Cconws("> ");
len = Cconrs(buffer);
Cconws("\n\n\r");
/* Split it into command file and command tail */
while (Sdone)
{
if (buffer[++index]==' ')
2
done =
;
if (index == (len+
(
d o n e = l ;
index++;
)
)
buffer[index]=0;
strcpy(file,buffer+
if (done==l)
command=OL;
else
buffer[index] = len-strlen(buffer+
command=buffer+index;
)
status = Pexec(0, file, command, OL);
printf ("Command status = %lx\n",status);
/ *
}
end of main
/******** end of GPEXEC.C
Again, note that the startup segment (GEMSTART.O on
the Alcyon compiler, or its equivalent on other compilers)
must return enough memory with Mshrink() to make room
for the program to be loaded.
The functions used to terminate a process are mostly of
interest to machine language programmers, since the startup
modules supplied with C language compilers automatically
call one of these functions when the C program terminates.
The first and simplest of the functions used to terminate a
process is called PtermO(). Its calling syntax is
PtermO( );
This terminates the current process, closes all open files, re­
leases any allocated memory, and exits with a return code of
0
;
* /
/ *
prepare buffer for command string entry
/* prompt */
/* get command string */
/ *
skip a couple of lines
1
/* check for
/* if it's there, end
1
))
/* if you're at end of string, end */
/* move index past last character */
/* replace separator with ASCII zero */
2
);
/* put filename in buffer */
/* if there wasn't a command tail */
/ *
set command address to zero */
/ *
if there was, put tail length —
* /
* * * * * /
st space character */
2
) ;
/ *
at beginning of string */
/* and set pointer */
/* execute the program */
* /
* /
* /
*/
103

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents