|
From: Andre R. <and...@us...> - 2006-03-09 09:46:32
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4889/Common/source Modified Files: shellsysverbs.c Added Files: sysshellcall.c Log Message: Added sys.winShellCommand, a new kernel verb for calling the system shell on Windows. Complements the Mac OS X only sys.unixShellCommand. --- NEW FILE: sysshellcall.c --- /* $Id: sysshellcall.c,v 1.1 2006/03/09 09:46:29 andreradke Exp $ */ /****************************************************************************** UserLand Frontier(tm) -- High performance Web content management, object database, system-level and Internet scripting environment, including source code editing and debugging. Copyright (C) 1992-2004 UserLand Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ******************************************************************************/ #include "frontier.h" #include "standard.h" #include "memory.h" #include "threads.h" #include "sysshellcall.h" #include <stdio.h> #include <stdlib.h> boolean winshellcall (Handle hcommand, Handle hreturn) { /* 2006-03-09 aradke: call the Windows shell and execute the given command. release thread globals before each sys call in order not to block other kernel threads. */ FILE *f; char buf [1024]; long ct = 0; if (!enlargehandle (hcommand, 1, "\0")) return (false); lockhandle (hcommand); releasethreadglobals (); f = _popen (*hcommand, "r"); unlockhandle (hcommand); grabthreadglobals (); while (true) { releasethreadglobals (); ct = fread (buf, 1, sizeof (buf), f); /*fread*/ grabthreadglobals (); if (ct > 0) if (!insertinhandle (hreturn, gethandlesize (hreturn), buf, ct)) break; if (feof (f)) break; } /*while*/ _pclose (f); return (true); } /*winshellcall*/ Index: shellsysverbs.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/shellsysverbs.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** shellsysverbs.c 17 Feb 2006 18:25:56 -0000 1.7 --- shellsysverbs.c 9 Mar 2006 09:46:29 -0000 1.8 *************** *** 62,65 **** --- 62,68 ---- #include "CallMachOFrameWork.h" #endif + #ifdef WIN95VERSION + #include "sysshellcall.h" + #endif #include "langsystem7.h" //6.1b7 AR: we need coercetolist *************** *** 112,115 **** --- 115,120 ---- unixshellcommandfunc, + winshellcommandfunc, + ctsysverbs } tysystoken; *************** *** 686,691 **** } ! #endif default: --- 691,723 ---- } + #endif ! #ifdef WIN95VERSION ! ! case winshellcommandfunc: { ! Handle hcommand, hreturn; ! ! newemptyhandle (&hreturn); ! ! flnextparamislast = true; ! ! if (!getexempttextvalue (hparam1, 1, &hcommand)) ! return (false); ! ! if (!winshellcall (hcommand, hreturn)) { ! ! disposehandle (hreturn); ! ! disposehandle (hcommand); ! ! return (false); ! } /*if*/ ! ! disposehandle (hcommand); ! ! return (setheapvalue (hreturn, stringvaluetype, v)); ! } ! ! #endif //WIN95VERSION default: |