# ifdef VMS
# include "jam.h"
# include "execcmd.h"
# include "lists.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iodef.h>
#include <ssdef.h>
#include <descrip.h>
#include <dvidef.h>
#include <clidef.h>
#define WRTLEN 240
#define MIN( a, b ) ((a) < (b) ? (a) : (b))
char tempnambuf[ L_tmpnam + 1 + 4 ] = {0};
void
execcmd( string, func, closure, shell )
char *string;
void (*func)();
void *closure;
LIST *shell;
{
char *s, *e, *p;
int rstat = EXEC_CMD_OK;
int status;
for( s = string; *s && isspace( *s ); s++ )
;
e = p = strchr( s, '\n' );
while( p && isspace( *p ) )
++p;
if( p && *p || e - s > WRTLEN )
{
FILE *f;
if( !*tempnambuf )
{
tempnambuf[0] = '@';
(void)tmpnam( tempnambuf + 1 );
strcat( tempnambuf, ".com" );
}
if( !( f = fopen( tempnambuf + 1, "w" ) ) )
{
printf( "can't open command file\n" );
(*func)( closure, EXEC_CMD_FAIL );
return;
}
while( *string )
{
char *s = strchr( string, '\n' );
int len = s ? s + 1 - string : strlen( string );
fputc( '$', f );
while( len > 0 )
{
char *q = string;
char *qe = string + MIN( len, WRTLEN );
char *qq = q;
int quote = 0;
for( ; q < qe; q++ )
if( *q == '"' && ( quote = !quote ) )
qq = q;
if( quote )
q = qq;
fwrite( string, ( q - string ), 1, f );
len -= ( q - string );
string = q;
if( len )
{
fputc( '-', f );
fputc( '\n', f );
}
}
}
fclose( f );
status = system( tempnambuf ) & 0x07;
unlink( tempnambuf + 1 );
}
else
{
if( e ) *e = 0;
status = system( s ) & 0x07;
}
if( status == 2 || status == 4 )
rstat = EXEC_CMD_FAIL;
(*func)( closure, rstat );
}
int
execwait()
{
return 0;
}
# endif