.ad 8
.bm 8
.fm 4
.bt $Copyright by SAP AG, 1997$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $SAP AG$ADABAS FOR R/3$VTT10X$

.tt 2 $$$
.tt 3 $$$1997-10-28$
***********************************************************
.nf


    ========== licence begin  GPL
    Copyright (C) 2001 SAP AG

    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.
    ========== licence end

.fo
.nf
.sp
Module  :
=========
.sp
Purpose :
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :

.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :

.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :

.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : Josef Hasenberger
.sp
.cp 3

Created : 1997-10-28
.sp
.cp 3
Version : 1997-10-28
.sp
.cp 3
Release :      Date :
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:

.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:

.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:

.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
/*PRETTY*/


// F_Shell.cpp
//
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <process.h>

static	int   sinit = 0;
static	int   sexec = 0;
static	char  spath [_MAX_PATH];
static	char  sname [_MAX_FNAME];
static  char *limit = "\"";

int	kshell( const char *command )

{ int	code = -1;
  if ( !sinit )
  { char *shell = getenv ("SHELL");
    if ( shell != NULL )
    { strcpy( spath , shell );
      shell = spath;
      while ( *shell != ' ' && *shell != '\0' )
      { if  ( *shell == '/' )
              *shell  = '\\';
        shell ++;
      }
      _splitpath (spath, NULL, NULL, sname, NULL);
    } else *sname = '\0';
    sinit ++;
  }
  if ( *sname != '\0')
  { char *cmd = (char *)malloc( strlen( command ) + 3 );
    strcpy( cmd , limit );
    strcat( cmd , command );
    strcat( cmd , limit );
    if (sexec) code = execl( spath , sname , "-c" , cmd , NULL );
    else code = spawnl( _P_WAIT , spath , sname , "-c" , cmd , NULL );
    free( cmd );
  } else code = system( command );
  return code;
}

int	ksystem( const char *command )

{ sexec = 0;
  return kshell( command );
}

int	kshexec( const char *command )

{ sexec = 1;
  return kshell( command );
}

int is_device(const char *path)
{
	if (path == NULL)
		return 0;
	if (strlen(path)<2)
		return 0;
	if ( ((path[0] >= 'a' && path[0] <= 'z')
	   || (path[0] >= 'A' && path[0] <= 'Z'))
	   && (path[1] == ':') )
		return 1;
	else
		return 0;
}


.CM *-END-* code ----------------------------------------
.sp 2
***********************************************************
*-PRETTY-*  statements    :           0
*-PRETTY-*  lines of code :           0
*-PRETTY-*  lines in file :           0
.pa

