home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
cpm
/
pcpursut
/
pisrc.ark
/
CCHAIN.C
< prev
next >
Wrap
Text File
|
1988-07-14
|
2KB
|
90 lines
/************************************************************
* cchain.c - chain to another program
***********************************************************/
#include "stdio.h"
#define TRUE 1
#define FALSE 0
#define LF 10
extern chain();
int cchain(string)
char *string; /* command to execute when chaining */
{
char comfile[12]; /* filename in fcb format */
char tempstr[9]; /* temp string */
int i;
char *cptr;
char *tempptr;
cptr = 0x80; /* where cmnd line arguements go */
/* skip whitespace */
while (*string && iswhite(*string))
string++;
/* check for drive name */
if (string[1] == ':') {
comfile[0] = toupper(string[0]) - 'A' + 1;
string += 2;
}
else comfile[0] = 0;
/******************* get and make comfile ***********************/
/* get filename alone in tempstr, assume it starts with 1st char */
i = 0;
while (*string && !iswhite(*string) && (i < 8))
tempstr[i++] = *string++;
tempstr[i] = NULL;
/* now copy to comfile string */
strcpy(&(comfile[1]), tempstr);
for (i = strlen(tempstr); i < 8; i++) /* fill fcb with spaces */
comfile[i+1] = ' ';
strcpy(&(comfile[9]), "COM");
/* comfile is now in fcb format */
/* now get cmnd line arguements */
/* copy cmnd line to memory */
tempptr = string;
/* fix up 1st fcb */
while(*string && iswhite(*string))
string++;
if (*string)
fcbinit(string, 0x5C);
else
fcbinit(" ", 0x5C);
/* fix up 2nd fcb */
while (*string && !iswhite(*string))
string++;
while (*string && iswhite(*string))
string++;
if (*string)
fcbinit(string, 0x6C);
else
fcbinit(" ", 0x6C);
/* fix up command line area */
*cptr = strlen(tempptr);
cptr++;
strcpy(cptr, tempptr);
/* now jump to assembly routine to finish chain */
chain(comfile);
}
static iswhite(c)
char c;
{
if ((c == ' ') || (c == '\t') || (c == LF))
return(TRUE);
else
return(FALSE);
}