x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
execvms.c - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\DarkPuzzle\libs\bullet_sdk\jam-2.5\execvms.c
旋转
特效
属性
历史版本
/* * Copyright 1993, 1995 Christopher Seiwald. * * This file is part of Jam - see jam.c for Copyright information. */ /* * execvms.c - execute a shell script, ala VMS * * The approach is this: * * If the command is a single line, and shorter than WRTLEN (what we * believe to be the maximum line length), we just system() it. * * If the command is multi-line, or longer than WRTLEN, we write the * command block to a temp file, splitting long lines (using "-" at * the end of the line to indicate contiuation), and then source that * temp file. We use special logic to make sure we don't continue in * the middle of a quoted string. * * 05/04/94 (seiwald) - async multiprocess interface; noop on VMS * 12/20/96 (seiwald) - rewritten to handle multi-line commands well * 01/14/96 (seiwald) - don't put -'s between "'s * 01/20/00 (seiwald) - Upgraded from K&R to ANSI C */ # include "jam.h" # include "lists.h" # include "execcmd.h" # ifdef OS_VMS #include
#include
#include
#include
#include
#include
#include
#include
#define WRTLEN 240 #define MIN( a, b ) ((a) < (b) ? (a) : (b)) /* 1 for the @ and 4 for the .com */ char tempnambuf[ L_tmpnam + 1 + 4 ] = {0}; void execcmd( char *string, void (*func)( void *closure, int status ), void *closure, LIST *shell ) { char *s, *e, *p; int rstat = EXEC_CMD_OK; int status; /* See if string is more than one line */ /* discounting leading/trailing white space */ for( s = string; *s && isspace( *s ); s++ ) ; e = p = strchr( s, '\n' ); while( p && isspace( *p ) ) ++p; /* If multi line or long, write to com file. */ /* Otherwise, exec directly. */ if( p && *p || e - s > WRTLEN ) { FILE *f; /* Create temp file invocation "@sys$scratch:tempfile.com" */ if( !*tempnambuf ) { tempnambuf[0] = '@'; (void)tmpnam( tempnambuf + 1 ); strcat( tempnambuf, ".com" ); } /* Open tempfile */ if( !( f = fopen( tempnambuf + 1, "w" ) ) ) { printf( "can't open command file\n" ); (*func)( closure, EXEC_CMD_FAIL ); return; } /* For each line of the string */ while( *string ) { char *s = strchr( string, '\n' ); int len = s ? s + 1 - string : strlen( string ); fputc( '$', f ); /* For each chunk of a line that needs to be split */ while( len > 0 ) { char *q = string; char *qe = string + MIN( len, WRTLEN ); char *qq = q; int quote = 0; /* Look for matching "'s */ for( ; q < qe; q++ ) if( *q == '"' && ( quote = !quote ) ) qq = q; /* Back up to opening quote, if in one */ 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 { /* Execute single line command */ /* Strip trailing newline before execing */ if( e ) *e = 0; status = system( s ) & 0x07; } /* Fail for error or fatal error */ /* OK on OK, warning, or info exit */ if( status == 2 || status == 4 ) rstat = EXEC_CMD_FAIL; (*func)( closure, rstat ); } int execwait() { return 0; } # endif /* VMS */
execvms.c
网页地址
文件地址
上一页
12/73
下一页
下载
( 3 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.