home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
SAAREXX.ZIP
/
XMPSCDLL.C
< prev
next >
Wrap
Text File
|
1991-08-02
|
6KB
|
125 lines
/*******************************************************************/
/* */
/* Module Name: XMPSCDLL */
/* */
/* Description: Example subcommand environment for REXX/2. */
/* */
/* Function: A REXX subcommand environment packaged as a */
/* DLL. */
/* */
/* Notes: */
/* */
/* The entry points obey the calling conventions for REXX */
/* external functions. Please use the following switches */
/* when you compile this module: */
/* */
/* -Alfu -G2s */
/* */
/*******************************************************************/
/* Modifications: */
/* */
/* Date Who Reason */
/* -------- --- ---------------------------------------------- */
/* 08/01/91 WDA Original issue. */
/* */
/*******************************************************************/
#define INCL_DOS
#include <os2.h>
#include <stdlib.h>
#include <string.h>
#define INCL_RXSUBCOM
#include <rexxsaa.h>
#include "xmpscdll.h"
/*******************************************************************/
/* */
/* Internal prototypes follow. */
/* */
/*******************************************************************/
/* none */
/*******************************************************************/
/* */
/* Global variables and defines follow. */
/* */
/*******************************************************************/
static PSZ szVersion = "1.00";
static PSZ szCompDate = __DATE__;
/*******************************************************************/
/* */
/* Function: XmpSubcom() */
/* */
/* Description: This is the XMP subcommand environment for */
/* our example environment. */
/* */
/* Input Parms: Command string */
/* Pointer to return flags */
/* Pointer to return string */
/* */
/* Returns: Error code */
/* */
/* References: */
/* */
/* Notes: */
/* */
/* None. */
/* */
/*******************************************************************/
SHORT APIENTRY XmpSubcom (
PRXSTRING cmd, /* Command string */
PUSHORT flags, /* Return flags */
PRXSTRING retval) { /* Return string */
SHORT len;
CHAR FailName [CCHMAXPATH];
PSZ parm;
RESULTCODES rescode;
static CHAR cmdname[] = "CMD";
static CHAR cmdparm[] = "/C ";
/*******************************************************************/
/* All we are going to do here is pass on the command passed to us */
/* to another copy of CMD.EXE and have it execute the command. */
/*******************************************************************/
parm = malloc ((USHORT) cmd -> strlength + 30);
if (parm == NULL) {
*flags = RXSUBCOM_ERROR;
retval -> strlength = 0L;
return (0);
}
strcpy (parm, cmdname);
len = strlen (cmdname) + 1;
strcpy (parm + len, cmdparm);
len += strlen (cmdparm);
memcpy (parm + len, cmd -> strptr, (USHORT) cmd -> strlength);
len += (USHORT) cmd -> strlength;
*(parm + len) = '\0'; // 2 nulls
*(parm + len + 1) = '\0'; // required
DosExecPgm (FailName, sizeof (FailName), EXEC_SYNC, parm, NULL,
&rescode, "CMD.EXE");
if (rescode.codeTerminate != TC_EXIT)
*flags = RXSUBCOM_ERROR;
else
*flags = RXSUBCOM_OK;
free (parm);
itoa (rescode.codeResult, retval -> strptr, 10);
retval -> strlength = (ULONG) strlen (retval -> strptr);
return (rescode.codeResult);
}