2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2010 - DIGITEO - Allan CORNET
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
7 * This file is hereby licensed under the terms of the GNU GPL v2.0,
8 * pursuant to article 5.3.4 of the CeCILL v.2.1.
9 * This file was originally licensed under the terms of the CeCILL v2.1,
10 * and continues to be available under such terms.
11 * For more information, see the COPYING file which you should have received
12 * along with this program.
15 /*--------------------------------------------------------------------------*/
18 #include "filemanager.hxx"
25 #include "sci_malloc.h"
26 #include "charEncoding.h"
28 /*--------------------------------------------------------------------------*/
29 #define MPUTL_FORMAT "%s\n"
30 /*--------------------------------------------------------------------------*/
31 mputlError mputl(int _iFileId, wchar_t **pstStrings, int _iSizeStrings, BOOL _CR)
34 types::File* pF = NULL;
36 if (pstStrings == NULL)
41 if (_iFileId == STDIN_ID)
43 return MPUTL_INVALID_FILE_DESCRIPTOR;
47 pF = FileManager::getFile(_iFileId);
50 // file opened with fortran open function
51 if (pF->getFileType() == 1)
56 if ((pF->getFileModeAsInt() >= 100) && (pF->getFileModeAsInt() < 200) && ((pF->getFileModeAsInt() % 100) < 10) /* not r+ */)
58 return MPUTL_NO_WRITE_RIGHT;
63 return MPUTL_INVALID_FILE_DESCRIPTOR;
67 for (i = 0; i < _iSizeStrings; i++)
70 pstTemp = wide_string_to_UTF8(pstStrings[i]);
71 int iRet = fputs(pstTemp, pF->getFiledesc());
77 if ((i != _iSizeStrings-1) || _CR)
79 iRet = fputs("\n", pF->getFiledesc());
87 return MPUTL_NO_ERROR;
89 /*--------------------------------------------------------------------------*/