Obj FuncCREATE_PTY_IOSTREAM( Obj self, Obj dir, Obj prog, Obj args ) { Obj allargs[MAX_ARGS+1]; Char *argv[MAX_ARGS+2]; UInt i,len; Int pty; len = LEN_LIST(args); if (len > MAX_ARGS) ErrorQuit("Too many arguments",0,0); ConvString(dir); ConvString(prog); for (i = 1; i <=len; i++) { allargs[i] = ELM_LIST(args,i); ConvString(allargs[i]); } /* From here we cannot afford to have a garbage collection */ argv[0] = CSTR_STRING(prog); for (i = 1; i <=len; i++) { argv[i] = CSTR_STRING(allargs[i]); } argv[i] = (Char *)0; pty = StartChildProcess( CSTR_STRING(dir) , CSTR_STRING(prog), argv ); if (pty < 0) return Fail; else return INTOBJ_INT(pty); }
BOOL CmdRedirector::Start() { TCHAR szPath[MAX_PATH] = {0}; ::SHGetSpecialFolderPath( NULL, szPath, CSIDL_SYSTEM, FALSE ); tstring cmdFilepath = szPath; if (cmdFilepath.size() > 0 && cmdFilepath.back() != '\\') cmdFilepath += '\\'; cmdFilepath += _T("cmd.exe"); return StartChildProcess(cmdFilepath.c_str(), FALSE); }
int OpenTelnet (char *host, char *port, ProcRef *pr) { char cmdLine[MSG_SIZ]; if (port[0] == NULLCHAR) { snprintf(cmdLine, sizeof(cmdLine), "%s %s", appData.telnetProgram, host); } else { snprintf(cmdLine, sizeof(cmdLine), "%s %s %s", appData.telnetProgram, host, port); } return StartChildProcess(cmdLine, "", pr); }
static const char * cmd_init(void *frontend_handle, void **backend_handle, Config *cfg, char *unused_host, int unused_port, char **realhost, int nodelay, int keepalive) { pcmd_backend_data local = NULL; if( !backend_handle || !cfg || !realhost ) return "invalid parameter"; local = snew(cmd_backend_data); strcpy(*realhost = smalloc(sizeof CMD_TERM), CMD_TERM); local->frontend = frontend_handle; local->cfg = *cfg; local->echoing = 0; local->editing = 0; memset(local->semdcmd, 0, sizeof(local->semdcmd)); local->historycount = 0; local->histroy.Blink = local->histroy.Flink = NULL; local->current_histroy = NULL; *backend_handle = local; cmd_add_histroy(local, ""); StartChildProcess(local, cfg->host, FALSE, &local->pi); return 0; }