1 /* 2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Copyright (C) 2010 - DIGITEO - Allan CORNET 4 * Copyright (C) 2012 - 2016 - Scilab Enterprises 5 * 6 * This file is hereby licensed under the terms of the GNU GPL v2.0, 7 * pursuant to article 5.3.4 of the CeCILL v.2.1. 8 * This file was originally licensed under the terms of the CeCILL v2.1, 9 * and continues to be available under such terms. 10 * For more information, see the COPYING file which you should have received 11 * along with this program. 12 * 13 */ 14 15 /*--------------------------------------------------------------------------*/ 16 /* Interface with system C function */ 17 /*--------------------------------------------------------------------------*/ 18 #include <stdio.h> 19 #include <stdlib.h> 20 #ifdef _MSC_VER 21 #include "spawncommand.h" 22 #else 23 #include <sys/wait.h> 24 #include "sci_malloc.h" 25 #endif 26 #include "charEncoding.h" 27 #include "systemc.h" 28 /*--------------------------------------------------------------------------*/ systemc(char * command,int * stat)29int systemc(char *command, int *stat) 30 { 31 #ifdef _MSC_VER 32 *stat = CallWindowsShell(command); 33 #else 34 int status = system(command); 35 /* provide exit value of the child */ 36 *stat = WEXITSTATUS(status); 37 #endif 38 return 0; 39 } 40 /*--------------------------------------------------------------------------*/ systemcW(wchar_t * _pstCommand,int * stat)41int systemcW(wchar_t* _pstCommand, int *stat) 42 { 43 #ifdef _MSC_VER 44 *stat = CallWindowsShellW(_pstCommand); 45 #else 46 char* pstTemp = wide_string_to_UTF8(_pstCommand); 47 int status = system(pstTemp); 48 FREE(pstTemp); 49 /* provide exit value of the child */ 50 *stat = WEXITSTATUS(status); 51 #endif 52 return 0; 53 } 54 /*--------------------------------------------------------------------------*/ 55