new diary (SEP 23)
Allan CORNET [Fri, 21 Aug 2009 09:21:05 +0000 (11:21 +0200)]
46 files changed:
scilab/CHANGES_5.2.X
scilab/modules/core/includes/stack-def.h
scilab/modules/core/includes/stack.h.in
scilab/modules/core/includes/stack.h.vc
scilab/modules/core/src/fortran/getlin.f
scilab/modules/core/src/fortran/inisci.f
scilab/modules/fileio/Makefile.am
scilab/modules/fileio/fileio.vcproj
scilab/modules/io/includes/gw_io.h
scilab/modules/io/sci_gateway/c/gw_io.c
scilab/modules/io/sci_gateway/c/sci_getio.c
scilab/modules/io/sci_gateway/io_gateway.xml
scilab/modules/io/src/c/io.vcproj
scilab/modules/localization/tests/unit_tests/unicode_io.dia.ref
scilab/modules/output_stream/help/en_US/diary.xml [moved from scilab/modules/io/help/en_US/diary.xml with 100% similarity]
scilab/modules/output_stream/help/fr_FR/diary.xml [moved from scilab/modules/io/help/fr_FR/diary.xml with 100% similarity]
scilab/modules/output_stream/help/pt_BR/diary.xml [moved from scilab/modules/io/help/pt_BR/diary.xml with 100% similarity]
scilab/modules/output_stream/includes/gw_output_stream.h
scilab/modules/output_stream/sci_gateway/c/gw_output_stream.c
scilab/modules/output_stream/sci_gateway/cpp/sci_diary.cpp [new file with mode: 0644]
scilab/modules/output_stream/sci_gateway/output_stream_gateway.xml
scilab/modules/output_stream/src/c/Localization_Import.def
scilab/modules/output_stream/src/c/api_scilab_Import.def [new file with mode: 0644]
scilab/modules/output_stream/src/c/basout.c
scilab/modules/output_stream/src/c/diary.h [new file with mode: 0644]
scilab/modules/output_stream/src/c/fileio_Import.def
scilab/modules/output_stream/src/c/output_stream.vcproj
scilab/modules/output_stream/src/c/sciprint.c
scilab/modules/output_stream/src/cpp/Diary.cpp [new file with mode: 0644]
scilab/modules/output_stream/src/cpp/Diary.hxx [new file with mode: 0644]
scilab/modules/output_stream/src/cpp/DiaryList.cpp [new file with mode: 0644]
scilab/modules/output_stream/src/cpp/DiaryList.hxx [new file with mode: 0644]
scilab/modules/output_stream/src/cpp/diary_manager.cpp [new file with mode: 0644]
scilab/modules/output_stream/src/cpp/diary_manager.hxx [new file with mode: 0644]
scilab/modules/output_stream/src/cpp/getDiaryDate.cpp [new file with mode: 0644]
scilab/modules/output_stream/src/cpp/getDiaryDate.hxx [new file with mode: 0644]
scilab/modules/output_stream/src/cpp/getFullFilename.cpp [new file with mode: 0644]
scilab/modules/output_stream/src/cpp/getFullFilename.hxx [new file with mode: 0644]
scilab/modules/output_stream/tests/nonreg_tests/bug_557.tst
scilab/modules/output_stream/tests/unit_tests/diary.dia.ref [new file with mode: 0644]
scilab/modules/output_stream/tests/unit_tests/diary.encoding.dia.ref [moved from scilab/modules/io/tests/unit_tests/diary.encoding.dia.ref with 100% similarity]
scilab/modules/output_stream/tests/unit_tests/diary.encoding.tst [moved from scilab/modules/io/tests/unit_tests/diary.encoding.tst with 100% similarity]
scilab/modules/output_stream/tests/unit_tests/diary.tst [new file with mode: 0644]
scilab/modules/output_stream/tests/unit_tests/disp.dia.ref
scilab/modules/shell/src/c/GetCommandLine.c
scilab/modules/shell/src/c/promptecho.c

index fa118aa..2503e39 100644 (file)
@@ -52,7 +52,7 @@ Input/Output functions:
 
  - Rewrite :
     + getenv
-    + diary
+    + diary - SEP 23
 
 Core functions:
 ===============
index 63c3dbf..f0089e2 100644 (file)
@@ -120,7 +120,6 @@ typedef struct
        int lin[lsiz]; /**< @TODO : add comment */
        int lpt[6]; /**< @TODO : add comment */
        int rio; /* Id input (fortran) file descriptor */
-       int wio; /* Id output (fortran) file descriptor */
        int rte; /* Id input (fortran) terminal descriptor (stdin)  */
        int wte; /* Id output (fortran) terminal descriptor (stdout) */
 } IOP_struct;
index 6ca6436..bf09fd0 100644 (file)
@@ -71,8 +71,8 @@ c
       integer icall,krec
       common /recu/ ids,pstk,rstk,pt,niv,macr,paus,icall,krec
 
-      integer ddt,err,lct(8),lin(lsiz),lpt(6),rio,wio,rte,wte
-      common /iop/ ddt,err,lct,lin,lpt,rio,wio,rte,wte
+      integer ddt,err,lct(8),lin(lsiz),lpt(6),rio,rte,wte
+      common /iop/ ddt,err,lct,lin,lpt,rio,rte,wte
 
       integer err1,err2,errct,toperr,errpt,ieee,catch
       common /errgst/ err1,err2,errct,toperr,errpt,ieee,catch
index 9b44d87..80e3db9 100644 (file)
@@ -60,8 +60,8 @@ c
       integer icall,krec
       common /recu/ ids,pstk,rstk,pt,niv,macr,paus,icall,krec
 
-      integer ddt,err,lct(8),lin(lsiz),lpt(6),hio,rio,wio,rte,wte
-      common /iop/ ddt,err,lct,lin,lpt,rio,wio,rte,wte
+      integer ddt,err,lct(8),lin(lsiz),lpt(6),hio,rio,rte,wte
+      common /iop/ ddt,err,lct,lin,lpt,rio,rte,wte
 
       integer err1,err2,errct,toperr,errpt,ieee,catch
       common /errgst/ err1,err2,errct,toperr,errpt,ieee,catch
index 22ab72a..8afd61d 100644 (file)
@@ -117,12 +117,9 @@ c     .     end of file encountered
          call promptecho(wte,buf(1:n),n)
       endif
       if (rio.eq.rte) then
-c     We need to remove wio here (new diary)
 c     -2 equals INPUT for diary (see basout)
-         if(wio.ne.0) then
-            call promptecho(-2,buf(1:n),n)
-         endif
-         lct(1)=1
+        call promptecho(-2,buf(1:n),n)
+        lct(1)=1
       endif
 c
 c     loop on read characters
index b9d0d89..e889cdc 100644 (file)
@@ -123,7 +123,6 @@ c     .  wte = unit number for terminal output
       else
          wte=9999
       endif
-      wio = 0
 c     
       rio=rte
 c     
index 19ae528..e5da953 100644 (file)
@@ -27,7 +27,6 @@ src/c/mputi.c \
 src/c/mputstr.c \
 src/c/mseek.c \
 src/c/mtell.c \
-src/c/diary.c \
 src/c/readline.c \
 src/c/getdrives.c \
 src/c/deleteafile.c \
@@ -148,7 +147,6 @@ includes/mopen.h \
 includes/mtell.h \
 includes/addfile.h \
 includes/delfile.h \
-includes/diary.h \
 includes/getfiledesc.h \
 includes/getfileinfo.h \
 includes/getfiletype.h \
index 56067a1..6cde0ad 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
        ProjectType="Visual C++"
        Version="9,00"
                                >
                        </File>
                        <File
-                               RelativePath=".\src\c\diary.c"
-                               >
-                       </File>
-                       <File
                                RelativePath=".\src\c\DllmainFileio.c"
                                >
                        </File>
                                >
                        </File>
                        <File
-                               RelativePath=".\includes\diary.h"
-                               >
-                       </File>
-                       <File
                                RelativePath=".\src\c\do_xxscanf.h"
                                >
                        </File>
index 597e54b..a0ce9bc 100644 (file)
@@ -18,7 +18,6 @@
 int gw_io(void);
 /*--------------------------------------------------------------------------*/
 int C2F(sci_read)(char *fname,unsigned long fname_len);
-int C2F(sci_diary)(char *fname,unsigned long fname_len);
 int C2F(sci_oldsave)(char *fname,unsigned long fname_len);
 int C2F(sci_write)(char *fname,unsigned long fname_len);
 int C2F(sci_rat)(char *fname,unsigned long fname_len);
@@ -40,7 +39,6 @@ int C2F(sci_setenv)(char *fname,unsigned long fname_len);
 int C2F(intgetenv)(char *fname,unsigned long fname_len);
 int C2F(intload) (int *id1, int *k1); /* FORTRAN subroutine */
 int C2F(intsave)(void);
-int C2F(intdiary)(void);
 int C2F(intfile)(void);
 int C2F(intmgetl)(void);
 int C2F(intrat)(void);
index 98211ee..412b306 100644 (file)
@@ -22,7 +22,7 @@ static gw_generic_table Tab[IO_TAB_SIZE]=
 {C2F(sci_read),"read"},
 {C2F(sci_getenv),"getenv"},
 {C2F(sci_getio),"getio"},
-{C2F(sci_diary),"diary"},
+{NULL,""},
 {C2F(sci_mgetl),"mgetl"},
 {C2F(sci_write),"write"},
 {C2F(sci_rat),"rat"},
index 498a79a..a748c1e 100644 (file)
@@ -13,7 +13,6 @@
 #include "gw_io.h"
 #include "stack-c.h"
 #include "MALLOC.h"
-#include "diary.h"
 /*--------------------------------------------------------------------------*/
 int C2F(sci_getio)(char *fname,unsigned long fname_len)
 {
@@ -28,7 +27,7 @@ int C2F(sci_getio)(char *fname,unsigned long fname_len)
 
        values[0] =  C2F(iop).rio;
        values[1] =  C2F(iop).rte;
-       values[2] =  getdiary();
+       values[2] =  0;
        values[3] =  C2F(iop).wte;
 
        CreateVarFromPtr(Rhs+1,MATRIX_OF_INTEGER_DATATYPE,&one,&four,&values);
index 94e199c..9843eff 100644 (file)
@@ -39,7 +39,7 @@
 <PRIMITIVE gatewayId="5" primitiveId="2" primitiveName="read" />
 <PRIMITIVE gatewayId="5" primitiveId="3" primitiveName="getenv" />
 <PRIMITIVE gatewayId="5" primitiveId="4" primitiveName="getio" />
-<PRIMITIVE gatewayId="5" primitiveId="5" primitiveName="diary" />
+<!-- <PRIMITIVE gatewayId="5" primitiveId="5" primitiveName="diary" />  -->
 <PRIMITIVE gatewayId="5" primitiveId="6" primitiveName="mgetl" />
 <PRIMITIVE gatewayId="5" primitiveId="7" primitiveName="write" />
 <PRIMITIVE gatewayId="5" primitiveId="8" primitiveName="rat" />
index 8e0d159..5f5352e 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
        ProjectType="Visual C++"
        Version="9,00"
                                >
                        </File>
                        <File
-                               RelativePath="..\..\sci_gateway\c\sci_diary.c"
-                               >
-                       </File>
-                       <File
                                RelativePath="..\..\sci_gateway\c\sci_file.c"
                                >
                        </File>
                                >
                        </File>
                        <File
-                               RelativePath="..\..\sci_gateway\c\sci_diary.h"
-                               >
-                       </File>
-                       <File
                                RelativePath="..\..\includes\setenvc.h"
                                >
                        </File>
index 7f8cd24..7508d1b 100644 (file)
@@ -15,8 +15,8 @@ text=[ "中文測試", "азеазеясдвклгхклмвцмзер" ..
 "모든 인간은 태어날 때부터 자유로우며 그 존엄과 권리에 있어 동등하다. 인간은 천부적으로 이성과 양심을 부여받았으며 서로 형제애의 정신으로 행동하여야 한다." ..
 "لد جميع الناس أحرارًا متساوين في الكرامة والحقوق. وقد وهبوا عقلاً وضميرًا وعليهم أن يعامل بعضهم بعضًا بروح الإخاء"..
 "כל בני האדם נולדו בני חורין ושווים בערכם ובזכיותיהם. כולם חוננו בתבונה ובמצפון, לפיכך חובה עליהם לנהג איש ברעהו ברוח של אחוה"
-];
-for i=1:size(text,"*")
+]; 
+for i=1:size(text,"*") 
 if msprintf(text(i)) <> text(i) then bugmes();quit;end
 //  Fortran-Style output<------- no yet fixed in this patch
 //u=file('open','resultsA','unknown') //<--------Test 2 file encoding for Fortran Style output
@@ -26,7 +26,7 @@ if msprintf(text(i)) <> text(i) then bugmes();quit;end
 myFile="resultsA";
 u=mopen(TMPDIR+"/"+myFile,'w');
 mfprintf(u,text(i)+" plus %s",text(i));
-mclose(u);
+mclose(u); 
 if mgetl(TMPDIR+"/"+myFile,1) <> text(i) + " plus "+text(i) then bugmes();quit;end
 myStr=" with another %s";
 myStr2=" with another ";
@@ -41,35 +41,35 @@ end
  
  ድቅስድቅስግጅክልውሽችክልዝ   
  
- ã™ã¹ã¦ã®äººé–“は、生まれながらにして自由であり、ã 
-      ‹ã¤ã€å°ŠåŽ³ã¨æ¨©åˆ©ã¨ ã«ã¤ã„て平等である。人間だ
-      ¯ã€ç†æ€§ã¨è‰¯å¿ƒã¨ã‚’授けられており、互いに同 èƒž 
+ すべての人間は、生まれながらにして自由であり、� 
+      ��つ、尊厳と権利と について平等である。人間� 
+      �、理性と良心とを授けられており、互いに同 胞 
       の精神をもって行動しなければならない。         
  
- äºº äºº ç”Ÿ è€Œ è‡ª ç”±, åœ¨ å°Š ä¸¥ å’Œ æƒ åˆ© ä¸Š ä¸€ å¾‹ å¹³ ç­‰ã€ 
-      ‚ ä»– ä»¬ èµ‹ æœ‰ ç† æ€§ å’Œ è‰¯ å¿ƒ, å¹¶ åº” ä»¥ å…„ å¼Ÿ å…³ ç³ 
-      » çš„ ç²¾ ç¥ž ç›¸ å¯¹ å¾…。                                      
+ 人 人 生 而 自 由, 在 尊 严 和 权 利 上 一 律 平 等� 
+      � 他 们 赋 有 理 性 和 良 心, 并 应 以 兄 弟 关 � 
+      � 的 精 神 相 对 待。                                      
  
  ราทุกคนเกิดมาอย่างอิสระ  
-      à¹€à¸£à¸²à¸—ุกคนมีความคิดและคภ
-      §à¸²à¸¡à¹€à¸‚้าใจเป็นของเราเอง  
-      à¹€à¸£à¸²à¸—ุกคนควรได้รับการปภ
-      à¸´à¸šà¸±à¸•à¸´à¹ƒà¸™à¸—างเดียวกัน.          
+      เราทุกคนมีความคิดและค� 
+      �ามเข้าใจเป็นของเราเอง  
+      เราทุกคนควรได้รับการป� 
+      �ิบัติในทางเดียวกัน.          
  
  모든 인간은 태어날 때부터 자유로우며 그 존엄과 권 
-      ë¦¬ì— ìžˆì–´ ë™ë“±í•˜ë‹¤. ì¸ê°„은 ì²œë¶€ì ìœ¼ë¡œ ì´ì„±ê³¼ ì 
-      –‘심을 ë¶€ì—¬ë°›ì•˜ìœ¼ë©° ì„œë¡œ í˜•ì œì• ì˜ ì •ì‹ ìœ¼ë¡œ í–‰ë 
-      ™í•˜ì—¬ì•¼ í•œë‹¤.                                               
+      리에 있어 동등하다. 인간은 천부적으로 이성과 � 
+      ��심을 부여받았으며 서로 형제애의 정신으로 행� 
+      ��하여야 한다.                                               
  
  لد جميع الناس أحرارًا متساوين في الكرا 
       مة والحقوق. وقد وهبوا عقلاً وضميرًا  
-      ÙˆØ¹Ù„يهم Ø£Ù† ÙŠØ¹Ø§Ù…Ù„ Ø¨Ø¹Ø¶Ù‡Ù… Ø¨Ø¹Ø¶Ù‹Ø§ Ø¨Ø±ÙˆØ­ Ø§Ù„Ø 
-      ¥Ø®Ø§Ø¡"כל ×‘× ×™ ×”אדם × ×•×œ×“ו ×‘× ×™ ×—ורין ×•×©×•× 
-      •×™× ×‘ערכם ×•×‘זכיותיהם. ×›×•×œ× ×—וננו ×‘תב 
+      وعليهم أن يعامل بعضهم بعضًا بروح ال� 
+      �خاء"כל בני האדם נולדו בני חורין ושו� 
+      �ים בערכם ובזכיותיהם. כולם חוננו בתב 
       ונה ובמצפון, לפיכך חובה עליהם לנהג א 
       יש ברעהו ברוח של אחוה                            
 //title('title test'+text); t=0:0.1:2*%pi; //<------Test 7  text drawing test
-//plot2d(t,[sin(t'),cos(t')],[-1,2]);
+//plot2d(t,[sin(t'),cos(t')],[-1,2]); 
 //legends(['legends test'+text ;'text B '+text],[-1,2], opt=3 );
 // ScilabVersion/OS/LANG/CONSOLE = EncodingPatch/WindowsXp/zh_TW.CP950/Dos Console
 //about();                         //<------Test 8  Scilab gettext Test
index f47facd..2aae01b 100644 (file)
@@ -19,6 +19,7 @@ int sci_print(char *fname,unsigned long fname_len);
 int sci_mprintf(char *fname,unsigned long fname_len);
 int sci_msprintf(char *fname,unsigned long fname_len);
 int sci_disp(char *fname,unsigned long fname_len);
+int sci_diary(char *fname,unsigned long fname_len);
 /*--------------------------------------------------------------------------*/
 #endif /* __GW_OUTPUT_STREAM_H__ */
 /*--------------------------------------------------------------------------*/
index 39c510e..2736674 100644 (file)
 #include "callFunctionFromGateway.h"
 #include "recursionFunction.h"
 /*--------------------------------------------------------------------------*/
-#define OUTPUT_STREAM_TAB_SIZE 4
+#define OUTPUT_STREAM_TAB_SIZE 5
 static gw_generic_table Tab[OUTPUT_STREAM_TAB_SIZE]=
 { 
        {sci_print, "print"},
        {sci_mprintf, "mprintf"},
        {sci_msprintf, "msprintf"},
-       {sci_disp, "disp"}
+       {sci_disp, "disp"},
+       {sci_diary, "diary"}
 };
 /*--------------------------------------------------------------------------*/
 int gw_output_stream(void)
diff --git a/scilab/modules/output_stream/sci_gateway/cpp/sci_diary.cpp b/scilab/modules/output_stream/sci_gateway/cpp/sci_diary.cpp
new file mode 100644 (file)
index 0000000..1624510
--- /dev/null
@@ -0,0 +1,1090 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2009 - DIGITEO - Allan CORNET
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+#include "diary_manager.hxx"
+/*--------------------------------------------------------------------------*/
+extern "C"
+{
+#include "gw_output_stream.h"
+#include "stack-c.h"
+#include "api_common.h"
+#include "api_string.h"
+#include "api_double.h"
+#include "api_boolean.h"
+#include "localization.h"
+#include "charEncoding.h"
+#include "Scierror.h"
+#include "MALLOC.h"
+}
+/*--------------------------------------------------------------------------*/
+#define DIARY_SECOND_ARG_LIST L"list"
+#define DIARY_SECOND_ARG_CLOSE L"close"
+#define DIARY_SECOND_ARG_PAUSE L"pause"
+#define DIARY_SECOND_ARG_OFF L"off"
+#define DIARY_SECOND_ARG_RESUME L"resume"
+#define DIARY_SECOND_ARG_ON L"on"
+#define DIARY_SECOND_ARG_NEW L"new"
+#define DIARY_SECOND_ARG_APPEND L"append"
+#define DIARY_SECOND_ARG_EXISTS L"exists"
+#define DIARY_SECOND_ARG_OPEN L"open"
+#define DIARY_THIRD_ARG_FILTER_COMMAND L"filter=command"
+#define DIARY_THIRD_ARG_FILTER_OUTPUT L"filter=output"
+#define DIARY_THIRD_ARG_PREFIX_UNIX_EPOCH L"prefix=U"
+#define DIARY_THIRD_ARG_PREFIX_DEFAULT L"prefix=YYYY-MM-DD hh:mm:ss"
+#define DIARY_THIRD_ARG_PREFIX_ONLY_COMMANDS L"prefix-only-commands"
+/*--------------------------------------------------------------------------*/
+static int sci_diary_no_rhs(char *fname);
+static int sci_diary_one_rhs(char *fname);
+static int sci_diary_two_rhs(char *fname);
+static int sci_diary_three_rhs(char *fname);
+/*--------------------------------------------------------------------------*/
+static double *getInputArgumentOneIDs(char *fname,int *sizeReturnedArray, int *ierror);
+static wchar_t **getInputArgumentOneFilenames(char *fname,int *sizeReturnedArray, int *ierror);
+static wchar_t *getInputArgumentTwo(char *fname, int *ierror);
+static wchar_t **getInputArgumentThree(char *fname,int *sizeReturnedArray, int *ierror);
+static int checkExistByIDs(char *fname, double *IDs, int size_IDs); 
+static int checkExistByFilenames(char *fname, wchar_t **wcFilenames, int size_IDs); 
+static int freeInput( wchar_t **wcInput, int size_IDs);
+static int CloseByFilenames(char *fname);
+static int CloseByIds(char *fname);
+static int PauseByFilenames(char *fname);
+static int PauseByIds(char *fname);
+static int ResumeByFilenames(char *fname);
+static int ResumeByIds(char *fname);
+static int ExistByFilenames(char *fname);
+static int ExistByIds(char *fname);
+static int AppendByFilenames(char *fname, int filterMode, int prefixMode, int prefixModeFilter);
+static int NewByFilenames(char *fname, int filterMode, int prefixMode, int prefixModeFilter);
+/*--------------------------------------------------------------------------*/
+int sci_diary(char *fname,unsigned long fname_len)
+{
+       CheckRhs(0,3);
+       CheckLhs(0,2);
+
+       switch (Rhs)
+       {
+       case 0:
+               return sci_diary_no_rhs(fname);
+       case 1:
+               return sci_diary_one_rhs(fname);
+       case 2:
+               return sci_diary_two_rhs(fname);
+       case 3:
+               return sci_diary_three_rhs(fname);
+       }
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int sci_diary_no_rhs(char *fname)
+{
+       // [ids, filenames] = diary()
+       // [ids, filenames] = diary([],"list")
+
+       int nb_diary_ids = 0;
+       double *diary_ids  = getDiaryIDsAsDouble(&nb_diary_ids);
+
+       if ( (diary_ids) && (nb_diary_ids > 0) )
+       {
+               createMatrixOfDouble(Rhs + 1, nb_diary_ids, 1, diary_ids);
+               LhsVar(1) = Rhs + 1;
+
+               delete [] diary_ids;
+               diary_ids = NULL;
+               nb_diary_ids = 0;
+       }
+       else
+       {
+               if (nb_diary_ids == 0)
+               {
+                       createMatrixOfDouble(Rhs + 1, 0, 0, NULL);
+                       LhsVar(1) = Rhs + 1;
+
+                       if (diary_ids) 
+                       {
+                               delete [] diary_ids;
+                               diary_ids = NULL;
+                               nb_diary_ids = 0;
+                       }
+               }
+               else
+               {
+                       Scierror(999,_("%s : Memory allocation error.\n"),fname);
+                       return 0;
+               }
+       }
+
+       if (Lhs == 2)
+       {
+               int nb_diary_filenames = 0;
+               wchar_t **wcdiary_filenames = getDiaryFilenames(&nb_diary_filenames);
+
+               if ( (wcdiary_filenames) && (nb_diary_filenames > 0) )
+               {
+                       createMatrixOfWideString(Rhs + 2, nb_diary_filenames, 1, wcdiary_filenames);
+                       LhsVar(2) = Rhs + 2;
+
+                       delete [] wcdiary_filenames;
+                       wcdiary_filenames = NULL;
+                       nb_diary_filenames = 0;
+               }
+               else
+               {
+                       if (nb_diary_filenames == 0)
+                       {
+                               createMatrixOfDouble(Rhs + 2, 0, 0, NULL);
+                               LhsVar(2) = Rhs + 2;
+                               if (wcdiary_filenames)
+                               {
+                                       delete [] wcdiary_filenames;
+                                       wcdiary_filenames = NULL;
+                                       nb_diary_filenames = 0;
+                               }
+                       }
+                       else
+                       {
+                               Scierror(999,_("%s : Memory allocation error.\n"),fname);
+                               return 0;
+                       }
+               }
+       }
+
+       C2F(putlhsvar)();
+
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int sci_diary_one_rhs(char *fname)
+{
+       int m1 = 0, n1 = 0;
+       int *piAddressVarOne = NULL;
+
+       getVarAddressFromPosition(1, &piAddressVarOne);
+
+       if (getVarType(piAddressVarOne) == sci_matrix)
+       {
+               int IDs_size = 0;
+               int ierr = 0;
+               double * IDs = getInputArgumentOneIDs(fname, &IDs_size, &ierr);
+               if (ierr) return 0;
+
+               // diary([])
+               // diary(0)
+               // close all
+               if ( (IDs_size == 0) ||
+                        ((IDs_size == 1) && ((int)IDs[0] == 0)))
+               {
+                       diaryCloseAll();
+                       C2F(putlhsvar)();
+               }
+               else
+               {
+                       Scierror(999,_("%s: Wrong value for input argument #%d: 0 expected.\n"),fname,1);
+               }
+       }
+       else if (getVarType(piAddressVarOne) == sci_strings)
+       {
+               int ierr = 0;
+               int sizewcFilenames = 0;
+               wchar_t ** wcFilenames = getInputArgumentOneFilenames(fname,&sizewcFilenames,&ierr);
+               if (ierr) return 0;
+
+               if (sizewcFilenames == 1)
+               {
+                       if (diaryExists(wcFilenames[0]))
+                       {
+                               double dID = (double)diaryNew(wcFilenames[0]);
+                               if (dID == -1)
+                               {
+                                       char *utf_str = wide_string_to_UTF8(wcFilenames[0]);
+                                       if (utf_str)
+                                       {
+                                               Scierror(999,_("%s: error can not create diary: %s.\n"), fname, utf_str);
+                                               FREE(utf_str); utf_str = NULL;
+                                       }
+                                       else
+                                       {
+                                               Scierror(999,_("%s: error can not create diary.\n"),fname);
+                                       }
+                                       return 0;
+                               }
+
+                               createMatrixOfDouble(Rhs + 1, 1, 1, &dID);
+                               LhsVar(1) = Rhs + 1;
+
+                               if (Lhs == 2)
+                               {
+                                       wchar_t **wfilenameUsed = new wchar_t*[1];
+                                       wfilenameUsed[0] = getDiaryFilename((int)dID);
+                                       createMatrixOfWideString(Rhs + 2, 1, 1, wfilenameUsed);
+                                       LhsVar(2) = Rhs + 2;
+                                       if (wfilenameUsed) {delete [] wfilenameUsed; wfilenameUsed = NULL;}
+                               }
+                       }
+                       else // diary(filename) exists (close diary)
+                       {
+                               if (diaryClose(wcFilenames[0]))
+                               {
+                                       if (wcFilenames)
+                                       {
+                                               if (wcFilenames[0]) {FREE(wcFilenames[0]); wcFilenames[0] = NULL;}
+                                               FREE(wcFilenames); wcFilenames = NULL;
+                                               Scierror(999,_("%s: error can not close diary.\n"),fname);
+                                               return 0;
+                                       }
+                               }
+                       }
+
+                       if (wcFilenames)
+                       {
+                               if (wcFilenames[0]) {FREE(wcFilenames[0]); wcFilenames[0] = NULL;}
+                               FREE(wcFilenames); wcFilenames = NULL;
+                       }
+
+                       C2F(putlhsvar)();
+               }
+               else
+               {
+                       Scierror(999,_("%s: Wrong size for input argument #%d.\n"),fname, 1);
+               }
+       }
+       else
+       {
+               Scierror(999,_("%s: Wrong type for input argument #%d.\n"),fname, 1);
+       }
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int sci_diary_two_rhs(char *fname)
+{
+       int ierr = 0;
+       wchar_t *wcArgumentTwo = getInputArgumentTwo(fname, &ierr);
+
+       int *piAddressVarOne = NULL;
+       getVarAddressFromPosition(1, &piAddressVarOne);
+
+       if (ierr) return 0;
+
+       if (wcArgumentTwo)
+       {
+               if (wcscmp(wcArgumentTwo, DIARY_SECOND_ARG_LIST) == 0)
+               {
+                       int m1 = 0, n1 = 0;
+                       getVarDimension(piAddressVarOne,&m1,&n1);
+                       if ( (m1 == n1) && (n1 == 0) )
+                       {
+                               // diary() == diary([], "list")
+                               return sci_diary_no_rhs(fname);
+                       }
+                       else
+                       {
+                               Scierror(999,_("%s: Wrong value for input argument #%d.\n"),fname, 2);
+                       }
+               }
+               else if (wcscmp(wcArgumentTwo, DIARY_SECOND_ARG_CLOSE) == 0)
+               {
+                       if (getVarType(piAddressVarOne) == sci_matrix)
+                       {
+                               return CloseByIds(fname);
+                       }
+                       else if (getVarType(piAddressVarOne) == sci_strings)
+                       {
+                               return CloseByFilenames(fname);
+                       }
+                       else
+                       {
+                               Scierror(999,_("%s: Wrong type for input argument #%d.\n"),fname, 1);
+                               return 0;
+                       }
+               }
+               else if ( (wcscmp(wcArgumentTwo, DIARY_SECOND_ARG_PAUSE) == 0) ||
+                                 (wcscmp(wcArgumentTwo, DIARY_SECOND_ARG_OFF) == 0) )
+               {
+                       if (getVarType(piAddressVarOne) == sci_matrix)
+                       {
+                               return PauseByIds(fname);
+                       }
+                       else if (getVarType(piAddressVarOne) == sci_strings)
+                       {
+                               return PauseByFilenames(fname);
+                       }
+                       else
+                       {
+                               Scierror(999,_("%s: Wrong type for input argument #%d.\n"),fname, 1);
+                               return 0;
+                       }
+               }
+               else if ( (wcscmp(wcArgumentTwo, DIARY_SECOND_ARG_RESUME) == 0) ||
+                                 (wcscmp(wcArgumentTwo, DIARY_SECOND_ARG_ON) == 0) )
+               {
+                       if (getVarType(piAddressVarOne) == sci_matrix)
+                       {
+                               return ResumeByIds(fname);
+                       }
+                       else if (getVarType(piAddressVarOne) == sci_strings)
+                       {
+                               return ResumeByFilenames(fname);
+                       }
+                       else
+                       {
+                               Scierror(999,_("%s: Wrong type for input argument #%d.\n"),fname, 1);
+                               return 0;
+                       }
+               }
+               else if (wcscmp(wcArgumentTwo, DIARY_SECOND_ARG_NEW) == 0)
+               {
+                       if (getVarType(piAddressVarOne) == sci_strings)
+                       {
+                               return NewByFilenames(fname, 0, 0, 3);
+                       }
+                       else
+                       {
+                               Scierror(999,_("%s: Wrong type for input argument #%d.\n"),fname, 1);
+                               return 0;
+                       }
+               }
+               else if (wcscmp(wcArgumentTwo, DIARY_SECOND_ARG_APPEND) == 0)
+               {
+                       if (getVarType(piAddressVarOne) == sci_strings)
+                       {
+                               return AppendByFilenames(fname, 0, 0, 3);
+                       }
+                       else
+                       {
+                               Scierror(999,_("%s: Wrong type for input argument #%d.\n"),fname, 1);
+                               return 0;
+                       }
+               }
+               else if (wcscmp(wcArgumentTwo, DIARY_SECOND_ARG_EXISTS) == 0)
+               {
+                       if (getVarType(piAddressVarOne) == sci_matrix)
+                       {
+                               return ExistByIds(fname);
+                       }
+                       else if (getVarType(piAddressVarOne) == sci_strings)
+                       {
+                               return ExistByFilenames(fname);
+                       }
+                       else
+                       {
+                               Scierror(999,_("%s: Wrong type for input argument #%d.\n"),fname, 1);
+                               return 0;
+                       }
+               }
+               else
+               {
+                       Scierror(999,_("%s: Wrong value for input argument #%d.\n"),fname, 2);
+                       return 0;
+               }
+       }
+       else
+       {
+               Scierror(999,_("%s: Wrong value for input argument #%d.\n"),fname, 2);
+       }
+       
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int sci_diary_three_rhs(char *fname)
+{
+       int ierr = 0;
+       int size_ArgThree = 0;
+       wchar_t **wcArgumentThree = getInputArgumentThree(fname, &size_ArgThree, &ierr);
+       if (ierr) return 0;
+
+       if (wcArgumentThree)
+       {
+               int filterMode = 0;
+               int iPrefixMode = 0;
+               int iPrefixIoModeFilter = 3;
+
+               for (int i = 0; i < size_ArgThree; i++)
+               {
+                       if (wcscmp(wcArgumentThree[i], DIARY_THIRD_ARG_FILTER_COMMAND) == 0)
+                       {
+                               filterMode = 1; // input only
+                       }
+                       else if (wcscmp(wcArgumentThree[i], DIARY_THIRD_ARG_FILTER_OUTPUT) == 0)
+                       {
+                               filterMode = 2; // output only
+                       }
+                       else if (wcscmp(wcArgumentThree[i], DIARY_THIRD_ARG_PREFIX_UNIX_EPOCH) == 0)
+                       {
+                               iPrefixMode = 0;
+                               if (iPrefixIoModeFilter == 3) iPrefixIoModeFilter = 0;
+                       }
+                       else if (wcscmp(wcArgumentThree[i], DIARY_THIRD_ARG_PREFIX_DEFAULT) == 0)
+                       {
+                               iPrefixMode = 1;
+                               if (iPrefixIoModeFilter == 3) iPrefixIoModeFilter = 0;
+                       }
+                       else if (wcscmp(wcArgumentThree[i], DIARY_THIRD_ARG_PREFIX_ONLY_COMMANDS) == 0)
+                       {
+                               iPrefixIoModeFilter = 1;
+                       }
+                       else
+                       {
+                               freeInput(wcArgumentThree, size_ArgThree);
+                               Scierror(999,_("%s: Wrong value for input argument #%d.\n"),fname, 3);
+                               return 0;
+                       }                       
+               }
+               freeInput(wcArgumentThree, size_ArgThree);
+
+               wchar_t *wcArgumentTwo = getInputArgumentTwo(fname, &ierr);
+               if (ierr) return 0;
+               if (wcArgumentTwo)
+               {
+                       int *piAddressVarOne = NULL;
+                       getVarAddressFromPosition(1, &piAddressVarOne);
+
+                       if (wcscmp(wcArgumentTwo, DIARY_SECOND_ARG_NEW) == 0)
+                       {
+                               FREE(wcArgumentTwo); wcArgumentTwo = NULL;
+                               if (getVarType(piAddressVarOne) == sci_strings)
+                               {
+                                       return NewByFilenames(fname, filterMode, iPrefixMode, iPrefixIoModeFilter);
+                               }
+                               else
+                               {
+                                       Scierror(999,_("%s: Wrong type for input argument #%d.\n"),fname, 1);
+                                       return 0;
+                               }
+                       }
+                       else if (wcscmp(wcArgumentTwo, DIARY_SECOND_ARG_APPEND) == 0)
+                       {
+                               FREE(wcArgumentTwo); wcArgumentTwo = NULL;
+                               if (getVarType(piAddressVarOne) == sci_strings)
+                               {
+                                       return AppendByFilenames(fname, filterMode, iPrefixMode, iPrefixIoModeFilter);
+                               }
+                               else
+                               {
+                                       Scierror(999,_("%s: Wrong type for input argument #%d.\n"),fname, 1);
+                                       return 0;
+                               }
+                       }
+                       else
+                       {
+                               FREE(wcArgumentTwo); wcArgumentTwo = NULL;
+                               Scierror(999,_("%s: Wrong value for input argument #%d.\n"),fname, 2);
+                               return 0;
+                       }
+               }
+               else
+               {
+                       Scierror(999,_("%s : Memory allocation error.\n"),fname);
+               }
+       }
+       else
+       {
+               Scierror(999,_("%s : Memory allocation error.\n"),fname);
+       }
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static double *getInputArgumentOneIDs(char *fname,int *sizeReturnedArray, int *ierror)
+{
+       double *IDs = NULL;
+       *sizeReturnedArray = 0;
+       *ierror = 0;
+
+       int m1 = 0, n1 = 0;
+       int *piAddressVarOne = NULL;
+
+       getVarAddressFromPosition(1, &piAddressVarOne);
+
+       if (getVarType(piAddressVarOne) == sci_matrix)
+       {
+               getMatrixOfDouble(piAddressVarOne,&m1,&n1,&IDs);
+               if ( (m1 == 1) || (n1 == 1) )
+               {
+                       *sizeReturnedArray = m1 * n1;
+               }
+               else
+               {
+                       Scierror(999,_("%s: Wrong size for input argument #%d: A vector expected.\n"),fname,1);
+                       *ierror = 1;
+               }
+       }
+       else
+       {
+               Scierror(999,_("%s: Wrong type for input argument #%d: A scalar expected.\n"),fname,1);
+               *ierror = 1;
+       }
+
+       return IDs;
+}
+/*--------------------------------------------------------------------------*/
+static wchar_t **getInputArgumentOneFilenames(char *fname,int *sizeReturnedArray, int *ierror)
+{
+       wchar_t** wcFilenames = NULL;
+       *sizeReturnedArray = 0;
+       *ierror = 0;
+
+       int m1 = 0, n1 = 0;
+       int *piAddressVarOne = NULL;
+
+       getVarAddressFromPosition(1, &piAddressVarOne);
+
+       if (getVarType(piAddressVarOne) == sci_strings)
+       {
+               int *lenStVarOne = NULL;
+
+               getVarDimension(piAddressVarOne,&m1,&n1);
+
+               if (m1*n1 < 1)
+               {
+                       Scierror(999,_("%s: Wrong size for input argument #%d.\n"),fname,1);
+                       *ierror = 1;
+               }
+               else if ( (m1 == 1) || (n1 == 1) )
+               {
+                       lenStVarOne = (int *)MALLOC(sizeof(int) * (m1 * n1));
+                       if (lenStVarOne == NULL)
+                       {
+                               Scierror(999,_("%s : Memory allocation error.\n"),fname);
+                               *ierror = 1;
+                       }
+                       else
+                       {
+                               getMatrixOfWideString(piAddressVarOne, &m1, &n1, lenStVarOne, wcFilenames);
+                               wcFilenames = (wchar_t **)MALLOC(sizeof(wchar_t *) * (m1 * n1));
+                               if (wcFilenames == NULL)
+                               {
+                                       Scierror(999,_("%s : Memory allocation error.\n"),fname);
+                                       *ierror = 1;
+                               }
+                               else
+                               {
+                                       getMatrixOfWideString(piAddressVarOne, &m1, &n1, lenStVarOne, wcFilenames);
+                                       *sizeReturnedArray = m1 * n1;
+                               }
+                       }
+               }
+               else
+               {
+                       Scierror(999,_("%s: Wrong size for input argument #%d: A vector expected.\n"),fname,1);
+                       *ierror = 1;
+               }
+       }
+       else
+       {
+               Scierror(999,_("%s: Wrong type for input argument #%d: A string expected.\n"),fname,1);
+               *ierror = 1;
+       }
+       return wcFilenames;
+}
+/*--------------------------------------------------------------------------*/
+static wchar_t *getInputArgumentTwo(char *fname, int *ierror)
+{
+       wchar_t *wcInputArgumentTwo = NULL;
+       *ierror = 0;
+
+       int m2 = 0, n2 = 0;
+       int *piAddressVarTwo = NULL;
+
+       getVarAddressFromPosition(2, &piAddressVarTwo);
+
+       if (getVarType(piAddressVarTwo) == sci_strings)
+       {
+               int lenStVarTwo = 0;
+
+               getVarDimension(piAddressVarTwo,&m2,&n2);
+               if ( (m2 != n2) && (n2 != 1) ) 
+               {
+                       Scierror(999,_("%s: Wrong size for input argument #%d: A string expected.\n"),fname,2);
+                       *ierror = 1;
+               }
+               else
+               {
+                       getMatrixOfWideString(piAddressVarTwo,&m2,&n2,&lenStVarTwo,&wcInputArgumentTwo);
+                       if (wcInputArgumentTwo == NULL)
+                       {
+                               Scierror(999,_("%s : Memory allocation error.\n"),fname);
+                               *ierror = 1;
+                       }
+               }
+       }
+       else
+       {
+               Scierror(999,_("%s: Wrong type for input argument #%d: A string expected.\n"),fname,2);
+               *ierror = 1;
+       }
+       return wcInputArgumentTwo;
+}
+/*--------------------------------------------------------------------------*/
+static wchar_t** getInputArgumentThree(char *fname,int *sizeReturnedArray, int *ierror)
+{
+       wchar_t** wcInputArgumentThree = NULL;
+       *sizeReturnedArray = 0;
+       *ierror = 0;
+
+       int m3 = 0, n3 = 0;
+       int *piAddressVarThree = NULL;
+
+       getVarAddressFromPosition(3, &piAddressVarThree);
+
+       if (getVarType(piAddressVarThree) == sci_strings)
+       {
+               int *lenStVarThree = NULL;
+
+               getVarDimension(piAddressVarThree,&m3,&n3);
+
+               if (m3*n3 < 1)
+               {
+                       Scierror(999,_("%s: Wrong size for input argument #%d.\n"),fname,3);
+                       *ierror = 1;
+               }
+               else if ( (m3 == 1) || (n3 == 1) )
+               {
+                       lenStVarThree = (int *)MALLOC(sizeof(int) * (m3 * n3));
+                       if (lenStVarThree == NULL)
+                       {
+                               Scierror(999,_("%s : Memory allocation error.\n"),fname);
+                               *ierror = 1;
+                       }
+                       else
+                       {
+                               getMatrixOfWideString(piAddressVarThree, &m3, &n3, lenStVarThree, wcInputArgumentThree);
+                               wcInputArgumentThree = (wchar_t **)MALLOC(sizeof(wchar_t *) * (m3 * n3));
+                               if (wcInputArgumentThree == NULL)
+                               {
+                                       Scierror(999,_("%s : Memory allocation error.\n"),fname);
+                                       *ierror = 1;
+                               }
+                               else
+                               {
+                                       getMatrixOfWideString(piAddressVarThree, &m3, &n3, lenStVarThree, wcInputArgumentThree);
+                                       *sizeReturnedArray = m3 * n3;
+                               }
+                       }
+               }
+               else
+               {
+                       Scierror(999,_("%s: Wrong size for input argument #%d: A vector expected.\n"),fname,3);
+                       *ierror = 1;
+               }
+       }
+       else
+       {
+               Scierror(999,_("%s: Wrong type for input argument #%d: A string expected.\n"),fname,3);
+               *ierror = 1;
+       }
+       return wcInputArgumentThree;
+}
+/*--------------------------------------------------------------------------*/
+static int checkExistByIDs(char *fname, double *IDs, int size_IDs)
+{
+       if (IDs)
+       {
+               for (int i = 0; i < size_IDs; i++)
+               {
+                       if (diaryExists((int)IDs[i]))
+                       {
+                               Scierror(999,_("%s: Wrong value for input argument #%d: diary ID %d not exists.\n"),fname,1, (int)IDs[i]);
+                               return 1;
+                       }
+               }
+               return 0;
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+static int checkExistByFilenames(char *fname, wchar_t **wcFilenames, int size_IDs)
+{
+       if (wcFilenames)
+       {
+               for (int i = 0; i < size_IDs; i++)
+               {
+                       if (diaryExists(wcFilenames[i]))
+                       {
+                               Scierror(999,_("%s: Wrong value for input argument #%d: diary filename not exists.\n"),fname,1);
+                               return 1;
+                       }
+               }
+               return 0;
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+static int freeInput(wchar_t **wcInput, int size_IDs)
+{
+       if (wcInput)
+       {
+               for(int i = 0; i < size_IDs; i++)
+               {
+                       if (wcInput[i])
+                       {
+                               FREE(wcInput[i]);
+                               wcInput[i] = NULL;
+                       }
+               }
+       }
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int CloseByFilenames(char *fname)
+{
+       wchar_t **wcFilenames = NULL;
+       int dIDs_size = 0;
+       int ierr = 0;
+
+       wcFilenames = getInputArgumentOneFilenames(fname, &dIDs_size, &ierr);
+       if (ierr) return 0;
+
+       ierr = checkExistByFilenames(fname, wcFilenames, dIDs_size);
+       if (ierr) 
+       {
+               freeInput(wcFilenames, dIDs_size);
+               return 0;
+       }
+
+       for (int i = 0; i < dIDs_size; i++)
+       {
+               if (diaryClose(wcFilenames[i]))
+               {
+                       freeInput(wcFilenames, dIDs_size);
+                       Scierror(999,_("%s: Wrong value for input argument #%d: error can not close diary.\n"),fname);
+                       return 0;
+               }
+       }
+
+       freeInput(wcFilenames, dIDs_size);
+       C2F(putlhsvar)();
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int CloseByIds(char *fname)
+{
+       double *dIDs = NULL;
+       int dIDs_size = 0;
+       int ierr = 0;
+
+       dIDs = getInputArgumentOneIDs(fname, &dIDs_size, &ierr);
+       if (ierr) return 0;
+
+       ierr = checkExistByIDs(fname, dIDs, dIDs_size);
+       if (ierr) return 0;
+
+       for (int i = 0; i < dIDs_size; i++)
+       {
+               if (diaryClose((int)dIDs[i]))
+               {
+                       Scierror(999,_("%s: Wrong value for input argument #%d: error can not close diary %d.\n"),fname, (int)dIDs[i]);
+                       return 0;
+               }
+       }
+       C2F(putlhsvar)();
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int PauseByFilenames(char *fname)
+{
+       wchar_t **wcFilenames = NULL;
+       int dIDs_size = 0;
+       int ierr = 0;
+
+       wcFilenames = getInputArgumentOneFilenames(fname, &dIDs_size, &ierr);
+       if (ierr) return 0;
+
+       ierr = checkExistByFilenames(fname, wcFilenames, dIDs_size);
+       if (ierr) 
+       {
+               freeInput(wcFilenames, dIDs_size);
+               return 0;
+       }
+
+       for (int i = 0; i < dIDs_size; i++)
+       {
+               if (diaryPause(wcFilenames[i]))
+               {
+                       freeInput(wcFilenames, dIDs_size);
+                       Scierror(999,_("%s: Wrong value for input argument #%d: error can not pause diary.\n"),fname);
+                       return 0;
+               }
+       }
+
+       freeInput(wcFilenames, dIDs_size);
+
+       C2F(putlhsvar)();
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int PauseByIds(char *fname)
+{
+       double *dIDs = NULL;
+       int dIDs_size = 0;
+       int ierr = 0;
+
+       dIDs = getInputArgumentOneIDs(fname, &dIDs_size, &ierr);
+       if (ierr) return 0;
+
+       ierr = checkExistByIDs(fname, dIDs, dIDs_size);
+       if (ierr) return 0;
+
+       for (int i = 0; i < dIDs_size; i++)
+       {
+               if (diaryPause((int)dIDs[i]))
+               {
+                       Scierror(999,_("%s: Wrong value for input argument #%d: error can not pause diary %d.\n"),fname, (int)dIDs[i]);
+                       return 0;
+               }
+       }
+
+       C2F(putlhsvar)();
+
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int ResumeByFilenames(char *fname)
+{
+       wchar_t **wcFilenames = NULL;
+       int dIDs_size = 0;
+       int ierr = 0;
+       wcFilenames = getInputArgumentOneFilenames(fname, &dIDs_size, &ierr);
+       if (ierr) return 0;
+
+       ierr = checkExistByFilenames(fname, wcFilenames, dIDs_size);
+       if (ierr) 
+       {
+               freeInput(wcFilenames, dIDs_size);
+               return 0;
+       }
+
+       for (int i = 0; i < dIDs_size; i++)
+       {
+               if (diaryResume(wcFilenames[i]))
+               {
+                       freeInput(wcFilenames, dIDs_size);
+                       Scierror(999,_("%s: Wrong value for input argument #%d: error can not resume diary.\n"),fname);
+                       return 0;
+               }
+       }
+
+       freeInput(wcFilenames, dIDs_size);
+
+       C2F(putlhsvar)();
+
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int ResumeByIds(char *fname)
+{
+       double *dIDs = NULL;
+       int dIDs_size = 0;
+       int ierr = 0;
+
+       dIDs = getInputArgumentOneIDs(fname, &dIDs_size, &ierr);
+       if (ierr) return 0;
+
+       ierr = checkExistByIDs(fname, dIDs, dIDs_size);
+       if (ierr) return 0;
+
+       for (int i = 0; i < dIDs_size; i++)
+       {
+               if (diaryResume((int)dIDs[i]))
+               {
+                       Scierror(999,_("%s: Wrong value for input argument #%d: error can not resume diary %d.\n"),fname, (int)dIDs[i]);
+                       return 0;
+               }
+       }
+
+       C2F(putlhsvar)();
+
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int ExistByFilenames(char *fname)
+{
+       wchar_t **wcFilenames = NULL;
+       int dIDs_size = 0;
+       int ierr = 0;
+       wcFilenames = getInputArgumentOneFilenames(fname, &dIDs_size, &ierr);
+       if (ierr) return 0;
+
+       int *resultExist = (int*)MALLOC(sizeof(int)*dIDs_size);
+       if (resultExist == NULL)
+       {
+               freeInput(wcFilenames,dIDs_size);
+               Scierror(999,_("%s : Memory allocation error.\n"),fname);
+               return 0;
+       }
+       
+       for(int i=0; i < dIDs_size; i++)
+       {
+               int bExists = diaryExists(wcFilenames[i]);
+               if ( bExists == 0)
+               {
+                       resultExist[i]  = TRUE;
+               }
+               else
+               {
+                       resultExist[i]  = FALSE;
+               }
+       }
+       freeInput(wcFilenames,dIDs_size);
+
+       createMatrixOfBoolean(Rhs + 1, 1, dIDs_size, resultExist);
+       FREE(resultExist); resultExist = NULL;
+       LhsVar(1) = Rhs + 1;
+       C2F(putlhsvar)();
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int ExistByIds(char *fname)
+{
+       double *dIDs = NULL;
+       int dIDs_size = 0;
+       int ierr = 0;
+
+       dIDs = getInputArgumentOneIDs(fname, &dIDs_size, &ierr);
+       if (ierr) return 0;
+
+       int *resultExist = (int*)MALLOC(sizeof(int)*dIDs_size);
+       if (resultExist == NULL)
+       {
+               Scierror(999,_("%s : Memory allocation error.\n"),fname);
+               return 0;
+       }
+
+       for(int i=0; i < dIDs_size; i++)
+       {
+               int bExists = diaryExists((int)dIDs[i]);
+               if ( bExists == 0)
+               {
+                       resultExist[i]  = TRUE;
+               }
+               else
+               {
+                       resultExist[i]  = FALSE;
+               }
+       }
+
+       createMatrixOfBoolean(Rhs + 1, 1, dIDs_size, resultExist);
+       FREE(resultExist); resultExist = NULL;
+       LhsVar(1) = Rhs + 1;
+       C2F(putlhsvar)();
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int AppendByFilenames(char *fname, int filterMode, int prefixMode, int prefixModeFilter)
+{
+       wchar_t **wcFilenames = NULL;
+       int dIDs_size = 0;
+       int ierr = 0;
+
+       wcFilenames = getInputArgumentOneFilenames(fname, &dIDs_size, &ierr);
+       if (ierr) return 0;
+
+       if (dIDs_size == 1)
+       {
+               double dID = (double)diaryAppend(wcFilenames[0]);
+               if (dID == -1)
+               {
+                       char *utf_str = wide_string_to_UTF8(wcFilenames[0]);
+                       if (utf_str)
+                       {
+                               Scierror(999,_("%s: error can not create diary: %s.\n"), fname, utf_str);
+                               FREE(utf_str); utf_str = NULL;
+                       }
+                       else
+                       {
+                               Scierror(999,_("%s: error can not create diary.\n"),fname);
+                       }
+                       freeInput(wcFilenames, dIDs_size);
+                       return 0;
+               }
+
+               freeInput(wcFilenames, dIDs_size);
+
+               diarySetFilterMode((int)dID, filterMode);
+               diarySetPrefixMode((int)dID, prefixMode);
+               diarySetPrefixIoModeFilter((int)dID, prefixModeFilter);
+
+               createMatrixOfDouble(Rhs + 1, 1, 1, &dID);
+               LhsVar(1) = Rhs + 1;
+
+               if (Lhs == 2)
+               {
+                       wchar_t **wfilenameUsed = new wchar_t*[1];
+                       wfilenameUsed[0] = getDiaryFilename((int)dID);
+                       createMatrixOfWideString(Rhs + 2, 1, 1, wfilenameUsed);
+                       LhsVar(2) = Rhs + 2;
+                       if (wfilenameUsed) {delete [] wfilenameUsed; wfilenameUsed = NULL;}
+               }
+               C2F(putlhsvar)();
+       }
+       else
+       {
+               freeInput(wcFilenames, dIDs_size);
+               Scierror(999,_("%s: Wrong size for input argument #%d: A string expected.\n"),fname,1);
+       }
+
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+static int NewByFilenames(char *fname, int filterMode, int prefixMode, int prefixModeFilter)
+{
+       wchar_t **wcFilenames = NULL;
+       int dIDs_size = 0;
+       int ierr = 0;
+
+       wcFilenames = getInputArgumentOneFilenames(fname, &dIDs_size, &ierr);
+       if (ierr) return 0;
+
+       if (dIDs_size == 1)
+       {
+               double dID = (double)diaryNew(wcFilenames[0]);
+               if (dID == -1)
+               {
+                       char *utf_str = wide_string_to_UTF8(wcFilenames[0]);
+                       if (utf_str)
+                       {
+                               Scierror(999,_("%s: error can not create diary: %s.\n"), fname, utf_str);
+                               FREE(utf_str); utf_str = NULL;
+                       }
+                       else
+                       {
+                               Scierror(999,_("%s: error can not create diary.\n"),fname);
+                       }
+                       freeInput(wcFilenames, dIDs_size);
+                       return 0;
+               }
+
+               freeInput(wcFilenames, dIDs_size);
+
+               diarySetFilterMode((int)dID, filterMode);
+               diarySetPrefixMode((int)dID, prefixMode);
+               diarySetPrefixIoModeFilter((int)dID, prefixModeFilter);
+
+               createMatrixOfDouble(Rhs + 1, 1, 1, &dID);
+               LhsVar(1) = Rhs + 1;
+
+               if (Lhs == 2)
+               {
+                       wchar_t **wfilenameUsed = new wchar_t*[1];
+                       wfilenameUsed[0] = getDiaryFilename((int)dID);
+                       createMatrixOfWideString(Rhs + 2, 1, 1, wfilenameUsed);
+                       LhsVar(2) = Rhs + 2;
+                       if (wfilenameUsed) {delete [] wfilenameUsed; wfilenameUsed = NULL;}
+               }
+               C2F(putlhsvar)();
+       }
+       else
+       {
+               freeInput(wcFilenames, dIDs_size);
+               Scierror(999,_("%s: Wrong size for input argument #%d: A string expected.\n"),fname,1);
+       }
+
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
index 21761a8..8392208 100644 (file)
@@ -36,4 +36,5 @@
 <PRIMITIVE gatewayId="33" primitiveId="2" primitiveName="mprintf" />
 <PRIMITIVE gatewayId="33" primitiveId="3" primitiveName="msprintf" />
 <PRIMITIVE gatewayId="33" primitiveId="4" primitiveName="disp" />
+<PRIMITIVE gatewayId="33" primitiveId="5" primitiveName="diary" />  
 </GATEWAY>
\ No newline at end of file
diff --git a/scilab/modules/output_stream/src/c/api_scilab_Import.def b/scilab/modules/output_stream/src/c/api_scilab_Import.def
new file mode 100644 (file)
index 0000000..de0b713
--- /dev/null
@@ -0,0 +1,13 @@
+       LIBRARY    api_scilab.dll
+
+
+EXPORTS
+       getMatrixOfDouble
+       getVarType
+       getVarAddressFromPosition
+       getMatrixOfWideString
+       createMatrixOfDouble
+       createMatrixOfWideString
+       createMatrixOfBoolean
+       getVarDimension
+       
\ No newline at end of file
index 37ebfe0..b9945b4 100644 (file)
@@ -17,8 +17,9 @@
 #include "stack-def.h"
 #include "basout.h"
 #include "MALLOC.h"
-#include "../../../fileio/includes/diary.h"
+#include "diary.h"
 #include "sciprint.h"
+#include "charEncoding.h"
 #include "../../../shell/includes/more.h"
 #include "../../../shell/includes/scilines.h"
 /*--------------------------------------------------------------------------*/ 
@@ -75,10 +76,10 @@ int C2F(basout)(int *io, int *lunit, char *string,long int nbcharacters)
                        if (nbcharacters > 1)
                        {
                                /* on linux , q=[] crashs with previous version 
-                                 in printf.f line 102 
-                                 call basout(io,lunit,'     []')
-                                 if we do basout(io,lunit,'     []',7) it works ...
-                                 temp workaround , we returns to old version with a allocation
+                               in printf.f line 102 
+                               call basout(io,lunit,'     []')
+                               if we do basout(io,lunit,'     []',7) it works ...
+                               temp workaround , we returns to old version with a allocation
                                */
                                char *buffer = (char *)MALLOC(sizeof(char)*(nbcharacters+1));
                                if (buffer)
@@ -108,20 +109,34 @@ int C2F(basout)(int *io, int *lunit, char *string,long int nbcharacters)
        {
                if (*lunit == -2)
                {
-                       // it write a INPUT command line in diary
+                       wchar_t *wcBuffer = NULL;
+
+                       string[nbcharacters] = '\0';
+
+                       /* remove blanks at end of line */
+                       if (*lunit == -2)
+                       {
+                               int i = 0;
+                               int len = (int) strlen(string) - 2;
+                               for (i = len; i >= 0; i--)
+                               {
+                                       if (string[i] == ' ') string[i] = '\0';
+                                       else break;
+                               }
+                       }
+
+                       wcBuffer = to_wide_string(string);
+                       if (wcBuffer)
+                       {
+                               if (wcscmp(wcBuffer,L"")) diaryWriteln(wcBuffer, TRUE);
+                               FREE(wcBuffer);
+                               wcBuffer = NULL;
+                       }
                }
                else
-                 {
-                   if (*lunit == C2F(iop).wio)
-                     {
-                       string[nbcharacters] = '\0';
-                       diary(string,TRUE);
-                     }
-                   else
-                     {
+               {
                        C2F(basouttofile)(lunit, string,nbcharacters);
-                     }
-                 }
+               }
        }
        return 0;
 } 
diff --git a/scilab/modules/output_stream/src/c/diary.h b/scilab/modules/output_stream/src/c/diary.h
new file mode 100644 (file)
index 0000000..f0fe580
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2009 - DIGITEO - Allan CORNET
+* 
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at    
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+#ifndef __DIARY_H__
+#define __DIARY_H__
+
+#include <wchar.h>
+#include "BOOL.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+int diaryWrite(wchar_t *wstr, BOOL bInput);
+
+int diaryWriteln(wchar_t *wstr, BOOL bInput);
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif /* __DIARY_H__ */
+/*--------------------------------------------------------------------------*/
\ No newline at end of file
index 60531a5..7b65f01 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
        ProjectType="Visual C++"
        Version="9,00"
@@ -6,6 +6,7 @@
        ProjectGUID="{A5911CD7-F8E8-440C-A23E-4843A0636F3A}"
        RootNamespace="output_stream"
        Keyword="Win32Proj"
+       TargetFrameworkVersion="0"
        >
        <Platforms>
                <Platform
@@ -43,7 +44,7 @@
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories=".;../../includes;../jni;../../../../libs/MALLOC/includes;../../../core/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../shell/src/c/windows;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes"
+                               AdditionalIncludeDirectories=".;../../includes;../jni;../cpp;../../../../libs/MALLOC/includes;../../../core/includes;../../../api_scilab/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../shell/src/c/windows;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;OUTPUT_STREAM_EXPORTS"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="0"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)fileio_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)fileio.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Console_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)sciconsole.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Shell_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)libshell.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)String_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)string.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Localization_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)scilocalization.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Output_stream_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Output_stream_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n scioutput_stream.dll %%f &gt;nul&#x0D;&#x0A;copy *.def output_streamtmp.def &gt;nul&#x0D;&#x0A;copy ..\output_stream_header.def+output_streamtmp.def  ..\output_stream.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)fileio_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)fileio.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Console_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)sciconsole.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Shell_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)libshell.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)String_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)string.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Localization_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)scilocalization.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Output_stream_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Output_stream_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)api_scilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)api_scilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n scioutput_stream.dll %%f &gt;nul&#x0D;&#x0A;copy *.def output_streamtmp.def &gt;nul&#x0D;&#x0A;copy ..\output_stream_header.def+output_streamtmp.def  ..\output_stream.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib fileio.lib sciconsole.lib libshell.lib string.lib scilocalization.lib scilab_windows.lib output_stream_f.lib"
+                               AdditionalDependencies="LibScilab.lib fileio.lib sciconsole.lib libshell.lib string.lib scilocalization.lib scilab_windows.lib output_stream_f.lib api_scilab.lib"
                                OutputFile="../../../../bin/output_stream.dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="output_stream.def"
                        OutputDirectory="$(SolutionDir)$(ConfigurationName)"
                        IntermediateDirectory="$(ConfigurationName)"
                        ConfigurationType="2"
-                       CharacterSet="2"
+                       CharacterSet="1"
                        >
                        <Tool
                                Name="VCPreBuildEventTool"
                        <Tool
                                Name="VCCLCompilerTool"
                                Optimization="0"
-                               AdditionalIncludeDirectories=".;../../includes;../jni;../../../../libs/MALLOC/includes;../../../core/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../shell/src/c/windows;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes"
+                               AdditionalIncludeDirectories=".;../../includes;../jni;../cpp;../../../../libs/MALLOC/includes;../../../core/includes;../../../api_scilab/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../shell/src/c/windows;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;OUTPUT_STREAM_EXPORTS"
                                MinimalRebuild="true"
                                BasicRuntimeChecks="0"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)fileio_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)fileio.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Console_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)sciconsole.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Shell_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)libshell.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)String_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)string.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Localization_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)scilocalization.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Output_stream_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Output_stream_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n scioutput_stream.dll %%f &gt;nul&#x0D;&#x0A;copy *.def output_streamtmp.def &gt;nul&#x0D;&#x0A;copy ..\output_stream_header.def+output_streamtmp.def  ..\output_stream.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)fileio_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)fileio.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Console_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)sciconsole.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Shell_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)libshell.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)String_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)string.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Localization_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)scilocalization.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Output_stream_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Output_stream_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)api_scilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)api_scilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n scioutput_stream.dll %%f &gt;nul&#x0D;&#x0A;copy *.def output_streamtmp.def &gt;nul&#x0D;&#x0A;copy ..\output_stream_header.def+output_streamtmp.def  ..\output_stream.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib fileio.lib sciconsole.lib libshell.lib string.lib scilocalization.lib scilab_windows.lib output_stream_f.lib"
+                               AdditionalDependencies="LibScilab.lib fileio.lib sciconsole.lib libshell.lib string.lib scilocalization.lib scilab_windows.lib output_stream_f.lib api_scilab.lib"
                                OutputFile="../../../../bin/output_stream.dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="output_stream.def"
                                InlineFunctionExpansion="1"
                                FavorSizeOrSpeed="1"
                                WholeProgramOptimization="false"
-                               AdditionalIncludeDirectories=".;../../includes;../jni;../../../../libs/MALLOC/includes;../../../core/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../shell/src/c/windows;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes"
+                               AdditionalIncludeDirectories=".;../../includes;../jni;../cpp;../../../../libs/MALLOC/includes;../../../core/includes;../../../api_scilab/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../shell/src/c/windows;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;OUTPUT_STREAM_EXPORTS"
                                StringPooling="true"
                                RuntimeLibrary="2"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)fileio_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)fileio.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Console_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)sciconsole.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Shell_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)libshell.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)String_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)string.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Localization_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)scilocalization.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Output_stream_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Output_stream_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n scioutput_stream.dll %%f &gt;nul&#x0D;&#x0A;copy *.def output_streamtmp.def &gt;nul&#x0D;&#x0A;copy ..\output_stream_header.def+output_streamtmp.def  ..\output_stream.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)fileio_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)fileio.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Console_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)sciconsole.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Shell_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)libshell.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)String_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)string.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Localization_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)scilocalization.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Output_stream_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)Output_stream_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)api_scilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)api_scilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n scioutput_stream.dll %%f &gt;nul&#x0D;&#x0A;copy *.def output_streamtmp.def &gt;nul&#x0D;&#x0A;copy ..\output_stream_header.def+output_streamtmp.def  ..\output_stream.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib fileio.lib sciconsole.lib libshell.lib string.lib scilocalization.lib scilab_windows.lib output_stream_f.lib"
+                               AdditionalDependencies="LibScilab.lib fileio.lib sciconsole.lib libshell.lib string.lib scilocalization.lib scilab_windows.lib output_stream_f.lib api_scilab.lib"
                                OutputFile="../../../../bin/output_stream.dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="output_stream.def"
                                InlineFunctionExpansion="1"
                                FavorSizeOrSpeed="1"
                                WholeProgramOptimization="false"
-                               AdditionalIncludeDirectories=".;../../includes;../jni;../../../../libs/MALLOC/includes;../../../core/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../shell/src/c/windows;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes"
+                               AdditionalIncludeDirectories=".;../../includes;../jni;../cpp;../../../../libs/MALLOC/includes;../../../core/includes;../../../api_scilab/includes;../../../jvm/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;../../../shell/src/c/windows;../../../localization/includes;../../../../libs/intl;../../../string/includes;../../../windows_tools/includes"
                                PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;OUTPUT_STREAM_EXPORTS"
                                StringPooling="true"
                                RuntimeLibrary="2"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)fileio_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)fileio.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Console_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)sciconsole.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Shell_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)libshell.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)String_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)string.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Localization_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)scilocalization.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Output_stream_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Output_stream_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n scioutput_stream.dll %%f &gt;nul&#x0D;&#x0A;copy *.def output_streamtmp.def &gt;nul&#x0D;&#x0A;copy ..\output_stream_header.def+output_streamtmp.def  ..\output_stream.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)fileio_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)fileio.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Console_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)sciconsole.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Shell_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)libshell.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)String_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)string.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Scilab_Windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Localization_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)scilocalization.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)Output_stream_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)Output_stream_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)api_scilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)api_scilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n scioutput_stream.dll %%f &gt;nul&#x0D;&#x0A;copy *.def output_streamtmp.def &gt;nul&#x0D;&#x0A;copy ..\output_stream_header.def+output_streamtmp.def  ..\output_stream.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
-                               AdditionalDependencies="LibScilab.lib fileio.lib sciconsole.lib libshell.lib string.lib scilocalization.lib scilab_windows.lib output_stream_f.lib"
+                               AdditionalDependencies="LibScilab.lib fileio.lib sciconsole.lib libshell.lib string.lib scilocalization.lib scilab_windows.lib output_stream_f.lib api_scilab.lib"
                                OutputFile="../../../../bin/output_stream.dll"
                                LinkIncremental="1"
                                ModuleDefinitionFile="output_stream.def"
                                >
                        </File>
                        <File
+                               RelativePath="..\cpp\Diary.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\cpp\diary_manager.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\cpp\DiaryList.cpp"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\DllmainOutput_Stream.c"
                                >
                        </File>
                                >
                        </File>
                        <File
+                               RelativePath="..\cpp\getDiaryDate.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\cpp\getFullFilename.cpp"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\sci_gateway\c\gw_output_stream.c"
                                >
                        </File>
                                >
                        </File>
                        <File
+                               RelativePath="..\..\sci_gateway\cpp\sci_diary.cpp"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\sci_gateway\c\sci_disp.c"
                                >
                        </File>
                                >
                        </File>
                        <File
+                               RelativePath=".\diary.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\cpp\Diary.hxx"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\cpp\diary_manager.hxx"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\cpp\DiaryList.hxx"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\includes\errmds.h"
                                >
                        </File>
                                >
                        </File>
                        <File
+                               RelativePath="..\cpp\getDiaryDate.hxx"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\cpp\getFullFilename.hxx"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\includes\gw_output_stream.h"
                                >
                        </File>
                                Name="Imports"
                                >
                                <File
+                                       RelativePath=".\api_scilab_Import.def"
+                                       >
+                               </File>
+                               <File
                                        RelativePath=".\Console_Import.def"
                                        >
                                </File>
index 2f6a836..9369ed7 100644 (file)
@@ -12,7 +12,7 @@
 #include <stdio.h>
 #include <string.h>
 #include "sciprint.h"
-#include "../../fileio/includes/diary.h"
+#include "diary.h"
 #include "stack-def.h" /* bsiz */
 #include "scilabmode.h"
 #include "../../console/includes/ConsolePrintf.h"
@@ -20,6 +20,7 @@
 #include "TermPrintf.h"
 #endif
 #include "MALLOC.h"
+#include "charEncoding.h"
 /*--------------------------------------------------------------------------*/
 #ifdef _MSC_VER
   #define vsnprintf _vsnprintf
@@ -66,6 +67,7 @@ static void printf_scilab(char *buffer)
 {
        if (buffer)
        {
+               wchar_t *wcBuffer = NULL;
                if (getScilabMode() == SCILAB_STD)
                {
                        ConsolePrintf(buffer);
@@ -79,10 +81,21 @@ static void printf_scilab(char *buffer)
                        #endif
                }
 
-               if ( getdiary() ) 
+               wcBuffer = to_wide_string(buffer);
+               if (wcBuffer)
                {
-                       // diary output line
-                       diary(buffer,FALSE);
+                       /* remove blanks at end of line */
+                       /*int i = 0;
+                       int len = (int) wcslen(wcBuffer) - 1;
+                       for (i = len; i >= 0; i--)
+                       {
+                               if (wcBuffer[i] == ' ') wcBuffer[i] = L'\0';
+                               else break;
+                       }*/
+               
+                       diaryWrite(wcBuffer, FALSE);
+                       FREE(wcBuffer);
+                       wcBuffer = NULL;
                }
        }
 }
diff --git a/scilab/modules/output_stream/src/cpp/Diary.cpp b/scilab/modules/output_stream/src/cpp/Diary.cpp
new file mode 100644 (file)
index 0000000..c512d81
Binary files /dev/null and b/scilab/modules/output_stream/src/cpp/Diary.cpp differ
diff --git a/scilab/modules/output_stream/src/cpp/Diary.hxx b/scilab/modules/output_stream/src/cpp/Diary.hxx
new file mode 100644 (file)
index 0000000..8606660
--- /dev/null
@@ -0,0 +1,78 @@
+/*--------------------------------------------------------------------------*/ 
+/*
+* ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) DIGITEO - 2009 - Allan CORNET
+* 
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at    
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/ 
+#ifndef __DIARY_HXX__
+#define __DIARY_HXX__
+/*--------------------------------------------------------------------------*/ 
+#include <string>
+/*--------------------------------------------------------------------------*/ 
+
+class Diary
+{
+
+private:
+       std::wstring wfilename;
+       int ID_foutstream;
+
+       int fileAttribMode;
+
+       void setID(int _ID);
+
+       bool suspendwrite;
+
+       // 0 UNIX epoch
+       // 1 ISO_8601
+       int Prefixmode;
+
+       // 0 prefix @ beginning of Input and Output
+       // 1 prefix only @ beginning of Input
+       // 2 prefix only @ beginning of Output
+       // 3 no prefix
+       int PrefixIoModeFilter;
+
+       // 0 all (output and input)
+       // 1 input
+       // 2 output
+       int IoModeFilter;
+
+       /*
+       * used on Windows to replace carriage return
+       */
+       std::wstring Diary::replace(std::wstring text, std::wstring s, std::wstring replacement);
+
+public:
+       Diary(std::wstring _wfilename,int _mode,int ID);
+       ~Diary();
+
+       std::wstring getFilename(void);
+       void setIOMode(int _mode);
+       int getIOMode(void);
+       int getID(void);
+
+       void write(std::wstring _wstr, bool bInput);
+       void writeln(std::wstring _wstr, bool bInput);
+
+       bool setSuspendWrite(bool bWith);
+       bool getSuspendWrite(void);
+
+       void setPrefixMode(int iPrefixMode);
+       int getPrefixMode(void);
+
+       void setPrefixIoModeFilter(int mode);
+       int getPrefixIoModeFilter(void);
+};
+
+#endif /* __DIARY_HXX__ */
+/*--------------------------------------------------------------------------*/ 
+bool compareDiary(Diary first,Diary second);
+/*--------------------------------------------------------------------------*/ 
diff --git a/scilab/modules/output_stream/src/cpp/DiaryList.cpp b/scilab/modules/output_stream/src/cpp/DiaryList.cpp
new file mode 100644 (file)
index 0000000..d3113ba
--- /dev/null
@@ -0,0 +1,313 @@
+/*--------------------------------------------------------------------------*/ 
+/*
+* ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) DIGITEO - 2009 - Allan CORNET
+* 
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at    
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/ 
+#include "DiaryList.hxx"
+#include "getFullFilename.hxx"
+/*--------------------------------------------------------------------------*/ 
+DiaryList::DiaryList()
+{
+}
+/*--------------------------------------------------------------------------*/ 
+DiaryList::~DiaryList()
+{
+       closeAllDiaries();
+}
+/*--------------------------------------------------------------------------*/ 
+int DiaryList::openDiary(std::wstring _wfilename)
+{
+       return openDiary(_wfilename,0);
+}
+/*--------------------------------------------------------------------------*/ 
+int DiaryList::openDiary(std::wstring _wfilename,int _mode)
+{
+       int ID = -1;
+       Diary newDiary(_wfilename, _mode,findFreeID());
+       if (newDiary.getID() != -1)
+       {
+               LSTDIARY.push_back(newDiary);
+               ID = newDiary.getID();
+       }
+       return ID;
+}
+/*--------------------------------------------------------------------------*/ 
+bool DiaryList::closeDiary(int ID_diary)
+{
+       std::list<Diary>::iterator iter = LSTDIARY.begin();
+       while(iter != LSTDIARY.end())
+       {
+               if(iter->getID() == ID_diary)
+               {
+                       LSTDIARY.erase(iter++);
+                       return true;
+               }
+               else
+               {
+                       iter++;
+               }
+       }
+       return false;
+}
+/*--------------------------------------------------------------------------*/ 
+void DiaryList::closeAllDiaries(void)
+{
+       LSTDIARY.clear();
+}
+/*--------------------------------------------------------------------------*/ 
+int * DiaryList::getIDs(int *sizeID)
+{
+       int *IDs  = NULL;
+       *sizeID = 0;
+
+       LSTDIARY.sort(compareDiary);
+
+       *sizeID = (int)LSTDIARY.size();
+
+       if (*sizeID > 0) 
+       {
+               std::list<Diary>::iterator iter;
+               int i = 0;
+               IDs = new int[*sizeID];
+               for( iter = LSTDIARY.begin(); iter != LSTDIARY.end(); iter++)
+               {
+                       IDs[i++] = iter->getID();
+               }
+       }
+       return IDs;
+}
+/*--------------------------------------------------------------------------*/ 
+std::wstring DiaryList::getFilename(int ID_diary)
+{
+       std::wstring wFilename(L"");
+       std::list<Diary>::iterator i;
+       for( i = LSTDIARY.begin(); i != LSTDIARY.end(); i++)
+       {
+               if ( i->getID() == ID_diary ) wFilename = i->getFilename();
+       }
+       return wFilename;
+}
+/*--------------------------------------------------------------------------*/ 
+std::wstring * DiaryList::getFilenames(int *sizeFilenames)
+{
+       std::wstring *wFilenames = NULL;
+       *sizeFilenames = 0;
+
+       LSTDIARY.sort(compareDiary);
+
+       *sizeFilenames = (int)LSTDIARY.size();
+       if (*sizeFilenames > 0)
+       {
+               int i = 0;
+               std::list<Diary>::iterator iter;
+               wFilenames = new std::wstring[*sizeFilenames];
+               
+               for( iter = LSTDIARY.begin(); iter != LSTDIARY.end(); iter++)
+               {
+                       wFilenames[i++] = iter->getFilename();
+               }
+       }
+       return wFilenames;
+}
+/*--------------------------------------------------------------------------*/ 
+void DiaryList::write(std::wstring _wstr, bool bInput)
+{
+       std::list<Diary>::iterator i;
+       for( i = LSTDIARY.begin(); i != LSTDIARY.end(); i++)
+       {
+               i->write(_wstr, bInput);
+       }
+}
+/*--------------------------------------------------------------------------*/ 
+void DiaryList::writeln(std::wstring _wstr, bool bInput)
+{
+       std::list<Diary>::iterator i;
+       for( i = LSTDIARY.begin(); i != LSTDIARY.end(); i++)
+       {
+               i->writeln(_wstr, bInput);
+       }
+}
+/*--------------------------------------------------------------------------*/ 
+bool DiaryList::exists(int ID_diary)
+{
+       std::list<Diary>::iterator i;
+       for( i = LSTDIARY.begin(); i != LSTDIARY.end(); i++)
+       {
+               if ( i->getID() == ID_diary ) return true;
+       }
+       return false;
+}
+/*--------------------------------------------------------------------------*/ 
+bool DiaryList::exists(std::wstring _wfilename)
+{
+       std::list<Diary>::iterator i;
+       for( i = LSTDIARY.begin(); i != LSTDIARY.end(); i++)
+       {
+               if ( i->getFilename().compare(getFullFilename(_wfilename)) == 0 ) return true;
+       }
+       return false;
+}
+/*--------------------------------------------------------------------------*/ 
+int DiaryList::findFreeID(void)
+{
+       int freeID = 1;
+       std::list<Diary>::iterator i;
+
+       LSTDIARY.sort(compareDiary);
+
+       for( i = LSTDIARY.begin(); i != LSTDIARY.end(); i++)
+       {
+               if ( freeID >= i->getID() )
+               {
+                       freeID++;
+               }
+       }
+       return freeID;
+}
+/*--------------------------------------------------------------------------*/ 
+void DiaryList::setSuspendWrite(bool bWith)
+{
+       std::list<Diary>::iterator iter;
+
+       for( iter = LSTDIARY.begin(); iter != LSTDIARY.end(); iter++)
+       {
+               iter->setSuspendWrite(bWith);
+       }
+}
+/*--------------------------------------------------------------------------*/ 
+bool *DiaryList::getSuspendWrite(int *sizeboolArray)
+{
+       bool *bSuspend = NULL;
+       *sizeboolArray = 0;
+
+       LSTDIARY.sort(compareDiary);
+
+       *sizeboolArray = (int)LSTDIARY.size();
+       if (*sizeboolArray > 0)
+       {
+               int i = 0;
+               bSuspend = new bool[*sizeboolArray];
+               std::list<Diary>::iterator iter;
+               for( iter = LSTDIARY.begin(); iter != LSTDIARY.end(); iter++)
+               {
+                       bSuspend[i++] = iter->getSuspendWrite();
+               }
+       }
+       return bSuspend;
+}
+/*--------------------------------------------------------------------------*/ 
+void DiaryList::setSuspendWrite(int  ID_diary, bool bWith)
+{
+       std::list<Diary>::iterator iter;
+
+       for( iter = LSTDIARY.begin(); iter != LSTDIARY.end(); iter++)
+       {
+               if (iter->getID() == ID_diary)
+               {
+                       iter->setSuspendWrite(bWith);
+               }
+       }
+}
+/*--------------------------------------------------------------------------*/ 
+bool DiaryList::getSuspendWrite(int  ID_diary)
+{
+       std::list<Diary>::iterator iter;
+
+       for( iter = LSTDIARY.begin(); iter != LSTDIARY.end(); iter++)
+       {
+               if (iter->getID() == ID_diary)
+               {
+                       return iter->getSuspendWrite();
+               }
+       }
+       return false;
+}
+/*--------------------------------------------------------------------------*/ 
+int DiaryList::getID(std::wstring _wfilename)
+{
+       std::list<Diary>::iterator i;
+       for( i = LSTDIARY.begin(); i != LSTDIARY.end(); i++)
+       {
+               if ( i->getFilename().compare(getFullFilename(_wfilename)) == 0 ) return i->getID();
+       }
+       return -1;
+}
+/*--------------------------------------------------------------------------*/ 
+void DiaryList::setFilterMode(int ID_diary, int mode)
+{
+       std::list<Diary>::iterator iter;
+
+       for( iter = LSTDIARY.begin(); iter != LSTDIARY.end(); iter++)
+       {
+               if (iter->getID() == ID_diary)
+               {
+                       return iter->setIOMode(mode);
+               }
+       }
+}
+/*--------------------------------------------------------------------------*/ 
+void DiaryList::setPrefixMode(int ID_diary,int iPrefixMode)
+{
+       std::list<Diary>::iterator iter;
+
+       for( iter = LSTDIARY.begin(); iter != LSTDIARY.end(); iter++)
+       {
+               if (iter->getID() == ID_diary)
+               {
+                       iter->setPrefixMode(iPrefixMode);
+                       break;
+               }
+       }
+}
+/*--------------------------------------------------------------------------*/ 
+int DiaryList::getPrefixMode(int ID_diary)
+{
+       std::list<Diary>::iterator iter;
+
+       for( iter = LSTDIARY.begin(); iter != LSTDIARY.end(); iter++)
+       {
+               if (iter->getID() == ID_diary)
+               {
+                       return iter->getPrefixMode();
+               }
+       }
+       return -1;
+}
+/*--------------------------------------------------------------------------*/ 
+void DiaryList::setPrefixIoModeFilter(int ID_diary,int mode)
+{
+       std::list<Diary>::iterator iter;
+
+       for( iter = LSTDIARY.begin(); iter != LSTDIARY.end(); iter++)
+       {
+               if (iter->getID() == ID_diary)
+               {
+                       iter->setPrefixIoModeFilter(mode);
+                       break;
+               }
+       }
+}
+/*--------------------------------------------------------------------------*/ 
+int DiaryList::getPrefixIoModeFilter(int ID_diary)
+{
+       std::list<Diary>::iterator iter;
+
+       for( iter = LSTDIARY.begin(); iter != LSTDIARY.end(); iter++)
+       {
+               if (iter->getID() == ID_diary)
+               {
+                       return iter->getPrefixIoModeFilter();
+               }
+       }
+       return -1;
+}
+/*--------------------------------------------------------------------------*/ 
+
diff --git a/scilab/modules/output_stream/src/cpp/DiaryList.hxx b/scilab/modules/output_stream/src/cpp/DiaryList.hxx
new file mode 100644 (file)
index 0000000..c6cca19
--- /dev/null
@@ -0,0 +1,67 @@
+/*--------------------------------------------------------------------------*/ 
+/*
+* ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) DIGITEO - 2009 - Allan CORNET
+* 
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at    
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/ 
+#ifndef __DIARYLIST_HXX__
+#define __DIARYLIST_HXX__
+/*--------------------------------------------------------------------------*/ 
+#include <string>
+#include <list>
+#include "Diary.hxx"
+/*--------------------------------------------------------------------------*/ 
+class DiaryList
+{
+public:
+       DiaryList();
+       ~DiaryList();
+
+       int openDiary(std::wstring _wfilename,int _mode);
+       int openDiary(std::wstring _wfilename);
+
+       bool closeDiary(int ID_diary);
+       void closeAllDiaries(void);
+
+       int * getIDs(int *sizeID);
+       std::wstring * getFilenames(int *sizeFilenames);
+
+       std::wstring getFilename(int ID_diary);
+
+       void write(std::wstring _wstr, bool bInput);
+       void writeln(std::wstring _wstr, bool bInput);
+
+       bool exists(int ID_diary);
+       bool exists(std::wstring _wfilename);
+
+       void setSuspendWrite(bool bWith);
+       bool *getSuspendWrite(int *sizeboolArray);
+
+       void setSuspendWrite(int ID_diary, bool bWith);
+       bool getSuspendWrite(int ID_diary);
+
+       int getID(std::wstring _wfilename);
+
+       void setFilterMode(int ID_diary, int mode);
+
+       void setPrefixMode(int ID_diary,int iPrefixMode);
+       int getPrefixMode(int ID_diary);
+
+       void setPrefixIoModeFilter(int ID_diary,int mode);
+       int getPrefixIoModeFilter(int ID_diary);
+
+
+private:
+       std::list<Diary> LSTDIARY;
+       int findFreeID(void);
+};
+#endif /* __DIARYLIST_HXX__ */
+/*--------------------------------------------------------------------------*/ 
+
diff --git a/scilab/modules/output_stream/src/cpp/diary_manager.cpp b/scilab/modules/output_stream/src/cpp/diary_manager.cpp
new file mode 100644 (file)
index 0000000..396cda4
--- /dev/null
@@ -0,0 +1,316 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2009 - DIGITEO - Allan CORNET
+* 
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at    
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+#include "diary_manager.hxx"
+#include "diaryList.hxx"
+#include "diary.h"
+/*--------------------------------------------------------------------------*/
+static DiaryList *SCIDIARY = NULL;
+/*--------------------------------------------------------------------------*/
+static int createDiaryManager(void)
+{
+       if (SCIDIARY == NULL)
+       {
+               SCIDIARY = new DiaryList();
+               return 0;
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+static int destroyDiaryManager(void)
+{
+       if (SCIDIARY)
+       {
+               delete SCIDIARY;
+               SCIDIARY = NULL;
+               return 0;
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+wchar_t *getDiaryFilename(int _Id)
+{
+       wchar_t *wcFilename = NULL;
+       if (SCIDIARY)
+       {
+               if (SCIDIARY->getFilename(_Id).compare(L""))
+               {
+                       wcFilename = new wchar_t[SCIDIARY->getFilename(_Id).length()];
+                       wcscpy(wcFilename, SCIDIARY->getFilename(_Id).c_str());
+               }
+       }
+       return wcFilename;
+}
+/*--------------------------------------------------------------------------*/
+wchar_t **getDiaryFilenames(int *array_size)
+{
+       *array_size = 0;
+       if (SCIDIARY)
+       {
+               std::wstring * wstringFilenames = SCIDIARY->getFilenames(array_size);
+               if (array_size > 0)
+               {
+                       wchar_t **wcFilenames = new wchar_t*[*array_size]; 
+                       for(int i = 0; i < *array_size; i++)
+                       {
+                               wcFilenames[i] = new wchar_t[wstringFilenames[i].length()];
+                               wcscpy(wcFilenames[i], wstringFilenames[i].c_str());
+                       }
+                       return wcFilenames;
+               }
+       }
+       return NULL;
+}
+/*--------------------------------------------------------------------------*/
+int *getDiaryIDs(int *array_size)
+{
+       *array_size = 0;
+       if (SCIDIARY)
+       {
+               int *iIDs = SCIDIARY->getIDs(array_size);
+               return iIDs;
+       }
+       return NULL;
+}
+/*--------------------------------------------------------------------------*/
+double *getDiaryIDsAsDouble(int *array_size)
+{
+       int *iIDs = getDiaryIDs(array_size);
+       if (*array_size > 0)
+       {
+               if (iIDs)
+               {
+                       double *dIDs = new double[*array_size];
+                       for(int i = 0;i < *array_size; i++)
+                       {
+                               dIDs[i] = (double)iIDs[i];
+                       }
+                       delete [] iIDs;
+                       return dIDs;
+               }
+               else
+               {
+                       *array_size = 0;
+               }
+       }
+       return NULL;
+}
+/*--------------------------------------------------------------------------*/
+int diaryCloseAll(void)
+{
+       destroyDiaryManager();
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
+int diaryClose(int _iId)
+{
+       if (SCIDIARY)
+       {
+               if (_iId > 0)
+               {
+                       if (SCIDIARY->closeDiary(_iId)) return 0;
+               }
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+int diaryClose(wchar_t *filename)
+{
+       if (SCIDIARY)
+       {
+               int iID = SCIDIARY->getID(filename);
+               if (iID > 0)
+               {
+                       if (SCIDIARY->closeDiary(iID)) return 0;
+               }
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+int diaryPauseAll(void)
+{
+       if (SCIDIARY)
+       {
+               SCIDIARY->setSuspendWrite(true);
+               return 0;
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+int diaryPause(int _iId)
+{
+       if (SCIDIARY)
+       {
+               SCIDIARY->setSuspendWrite(_iId, true);
+               return 0;
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+int diaryPause(wchar_t *filename)
+{
+       if (SCIDIARY)
+       {
+               int iID = SCIDIARY->getID(std::wstring(filename));
+               if (iID != -1)
+               {
+                       SCIDIARY->setSuspendWrite(iID, true);
+                       return 0;
+               }
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+int diaryResumeAll(void)
+{
+       if (SCIDIARY)
+       {
+               SCIDIARY->setSuspendWrite(false);
+               return 0;
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+int diaryResume(int _iId)
+{
+       if (SCIDIARY)
+       {
+               SCIDIARY->setSuspendWrite(_iId, false);
+               return 0;
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+int diaryResume(wchar_t *filename)
+{
+       if (SCIDIARY)
+       {
+               int iID = SCIDIARY->getID(std::wstring(filename));
+               if (iID != -1)
+               {
+                       SCIDIARY->setSuspendWrite(iID, false);
+                       return 0;
+               }
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+int diaryExists(int _iId)
+{
+       if (SCIDIARY)
+       {
+               if (SCIDIARY->exists(_iId)) return 0;
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+int diaryExists(wchar_t *filename)
+{
+       if (SCIDIARY)
+       {
+               if (SCIDIARY->exists(std::wstring(filename))) return 0;
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+int diaryNew(wchar_t *filename)
+{
+       createDiaryManager();
+
+       if (SCIDIARY)
+       {
+               return SCIDIARY->openDiary(std::wstring(filename));
+       }
+
+       return -1;
+}
+/*--------------------------------------------------------------------------*/
+int diaryAppend(wchar_t *filename)
+{
+       createDiaryManager();
+       if (SCIDIARY)
+       {
+               return SCIDIARY->openDiary(std::wstring(filename),1);
+       }
+       return -1;
+}
+/*--------------------------------------------------------------------------*/
+int diaryWrite(wchar_t *wstr, BOOL bInput)
+{
+       if (SCIDIARY)
+       {
+               if (bInput) SCIDIARY->write(std::wstring(wstr), true);
+               else SCIDIARY->write(std::wstring(wstr), false);
+               return 0;
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+int diaryWriteln(wchar_t *wstr, BOOL bInput)
+{
+       if (SCIDIARY)
+       {
+               if (bInput) SCIDIARY->writeln(std::wstring(wstr), true);
+               else SCIDIARY->writeln(std::wstring(wstr), false);
+               return 0;
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+int diarySetFilterMode(int _iId, int mode)
+{
+       if (SCIDIARY)
+       {
+               SCIDIARY->setFilterMode(_iId, mode);
+               return 0;
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+int diarySetPrefixMode(int ID_diary,int iPrefixMode)
+{
+       if (SCIDIARY)
+       {
+               SCIDIARY->setPrefixMode(ID_diary, iPrefixMode);
+               return 0;
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+int diaryGetPrefixMode(int ID_diary)
+{
+       if (SCIDIARY)
+       {
+               return SCIDIARY->getPrefixMode(ID_diary);
+       }
+       return -1;
+}
+/*--------------------------------------------------------------------------*/
+int diarySetPrefixIoModeFilter(int ID_diary,int mode)
+{
+       if (SCIDIARY)
+       {
+               SCIDIARY->setPrefixIoModeFilter(ID_diary, mode);
+               return 0;
+       }
+       return 1;
+}
+/*--------------------------------------------------------------------------*/
+int diaryGetPrefixIoModeFilter(int ID_diary)
+{
+       if (SCIDIARY)
+       {
+               return SCIDIARY->getPrefixIoModeFilter(ID_diary);
+       }
+       return -1;
+}
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/output_stream/src/cpp/diary_manager.hxx b/scilab/modules/output_stream/src/cpp/diary_manager.hxx
new file mode 100644 (file)
index 0000000..9eb6892
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2009 - DIGITEO - Allan CORNET
+* 
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at    
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+#ifndef __DIARY_MANAGER_HXX__
+#define __DIARY_MANAGER_HXX__
+
+#include <wchar.h>
+
+/**
+*
+*/
+wchar_t *getDiaryFilename(int _Id);
+
+/**
+*
+*/
+wchar_t **getDiaryFilenames(int *array_size);
+
+/**
+*
+*/
+int *getDiaryIDs(int *array_size);
+
+/**
+*
+*/
+double *getDiaryIDsAsDouble(int *array_size);
+
+/**
+*
+*/
+int diaryCloseAll(void);
+
+/**
+*
+*/
+int diaryClose(int _iId);
+
+/**
+*
+*/
+int diaryClose(wchar_t *filename);
+
+/**
+*
+*/
+int diaryPauseAll(void);
+
+/**
+*
+*/
+int diaryPause(int _iId);
+
+/**
+*
+*/
+int diaryPause(wchar_t *filename);
+
+/**
+*
+*/
+int diaryResumeAll(void);
+
+/**
+*
+*/
+int diaryResume(int _iId);
+
+/**
+*
+*/
+int diaryResume(wchar_t *filename);
+
+/**
+*
+*/
+int diaryExists(int _iId);
+
+/**
+*
+*/
+int diaryExists(wchar_t *filename);
+
+/**
+*
+*/
+int diaryNew(wchar_t *filename);
+
+/**
+*
+*/
+int diaryAppend(wchar_t *filename);
+
+/*
+*
+*/
+int diarySetFilterMode(int _iId, int mode);
+
+/*
+*
+*/
+int diarySetPrefixMode(int ID_diary,int iPrefixMode);
+
+/*
+*
+*/
+int diaryGetPrefixMode(int ID_diary);
+
+/*
+*
+*/
+int diarySetPrefixIoModeFilter(int ID_diary,int mode);
+
+/*
+*
+*/
+int diaryGetPrefixIoModeFilter(int ID_diary);
+
+#endif /* __DIARY_MANAGER_HXX__ */
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/output_stream/src/cpp/getDiaryDate.cpp b/scilab/modules/output_stream/src/cpp/getDiaryDate.cpp
new file mode 100644 (file)
index 0000000..e8620c1
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2009 - DIGITEO - Allan CORNET
+* 
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at    
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+#ifdef _MSC_VER
+       #ifndef _WIN64
+               #define _USE_32BIT_TIME_T 1
+       #endif
+#endif
+/*--------------------------------------------------------------------------*/
+#include <sstream>  
+#include "getDiaryDate.hxx"
+/*--------------------------------------------------------------------------*/
+extern "C"
+{
+#include <time.h>
+#ifndef _MSC_VER
+#include <sys/time.h> 
+#endif
+#include <locale.h>
+}
+/*--------------------------------------------------------------------------*/
+std::wstring getDiaryDate(int _mode)
+{
+       std::wstring wstrdate(L"");
+       std::wstringstream StrStream;
+       time_t tDate;
+       time(&tDate);
+
+       switch (_mode)
+       {
+       case 0: default:
+               {
+                       StrStream << (unsigned int)tDate;
+                       wstrdate = StrStream.str();
+               }
+               break;
+       case 1: // http://en.wikipedia.org/wiki/ISO_8601 YYYY-MM-DD hh:mm:ss
+               {
+                       struct tm *nowstruct = localtime(&tDate);
+
+                       unsigned int YEAR = 1900 + nowstruct->tm_year;
+                       unsigned int MONTH = 1 + nowstruct->tm_mon;
+                       unsigned int DAY_OF_MONTH = nowstruct->tm_mday;
+                       unsigned int HOUR_OF_DAY = nowstruct->tm_hour;
+                       unsigned int MINUTES = nowstruct->tm_min;
+                       unsigned int SECONDS = nowstruct->tm_sec;
+
+                       StrStream << YEAR << L"-" << MONTH << L"-" << DAY_OF_MONTH;
+                       StrStream << L" ";
+                       StrStream << HOUR_OF_DAY << L":" << MINUTES << L":" << SECONDS;
+                       wstrdate = StrStream.str();
+               }
+               break;
+       }
+       return wstrdate;
+}
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/output_stream/src/cpp/getDiaryDate.hxx b/scilab/modules/output_stream/src/cpp/getDiaryDate.hxx
new file mode 100644 (file)
index 0000000..38cebf5
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2009 - DIGITEO - Allan CORNET
+* 
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at    
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+#ifndef __GETDIARYDATE_HXX__
+#define __GETDIARYDATE_HXX__
+
+#include <string>
+
+/**
+*
+*
+*/
+std::wstring getDiaryDate(int _mode);
+
+#endif /* __GETDIARYDATE_HXX__ */
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/output_stream/src/cpp/getFullFilename.cpp b/scilab/modules/output_stream/src/cpp/getFullFilename.cpp
new file mode 100644 (file)
index 0000000..024b47b
--- /dev/null
@@ -0,0 +1,129 @@
+/*--------------------------------------------------------------------------*/ 
+/*
+* ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) DIGITEO - 2009 - Allan CORNET
+* 
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at    
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/ 
+#include "getFullFilename.hxx"
+/*--------------------------------------------------------------------------*/ 
+extern "C"
+{
+#include "machine.h"
+#include "PATH_MAX.h"
+#ifndef _MSC_VER
+#include <unistd.h>
+#endif
+}
+/*--------------------------------------------------------------------------*/ 
+static void wcsplitpath(const wchar_t* path, wchar_t* drv, wchar_t* dir, wchar_t* name, wchar_t* ext);
+/*--------------------------------------------------------------------------*/ 
+std::wstring getFullFilename(std::wstring _wfilename)
+{
+       std::wstring wfullfilename(L"");
+       std::wstring tmpWstr;
+       wchar_t wcdrive[MAX_PATH];
+       wchar_t wcdirectory[MAX_PATH];
+       wchar_t wcname[MAX_PATH];
+       wchar_t wcext [MAX_PATH];
+
+       size_t found = _wfilename.rfind(L"\\");
+
+       while (found != std::wstring::npos)
+       {
+               _wfilename.replace (found, 1, L"/");
+               found = _wfilename.rfind(L"\\");
+       }
+       wcsplitpath(_wfilename.c_str(), wcdrive, wcdirectory, wcname, wcext);
+       wfullfilename.append(tmpWstr.assign(wcdrive));
+       wfullfilename.append(tmpWstr.assign(wcdirectory));
+       if (wfullfilename.compare(L"") == 0)
+       {
+               wchar_t wcCurrentDir[PATH_MAX];
+#if _MSC_VER
+               if ( _wgetcwd(wcCurrentDir, PATH_MAX) != NULL)
+#else
+               if (getcwd(wcCurrentDir,PATH_MAX) != NULL)
+#endif
+               {
+                       wfullfilename = tmpWstr.assign(wcCurrentDir);
+                       size_t found = wfullfilename.rfind(L"\\");
+                       while (found != std::wstring::npos)
+                       {
+                               wfullfilename.replace (found, 1, L"/");
+                               found = wfullfilename.rfind(L"\\");
+                       }
+                       wfullfilename.append(L"/");
+               }
+               else
+               {
+                       wfullfilename.assign(L"");
+               }
+
+       }
+       wfullfilename.append(tmpWstr.assign(wcname));
+       wfullfilename.append(tmpWstr.assign(wcext));
+
+       return wfullfilename;
+}
+/*--------------------------------------------------------------------------*/ 
+static void wcsplitpath(const wchar_t* path, wchar_t* drv, wchar_t* dir, wchar_t* name, wchar_t* ext)
+{
+       const wchar_t* end; /* end of processed string */
+       const wchar_t* p;   /* search pointer */
+       const wchar_t* s;   /* copy pointer */
+
+       /* extract drive name */
+       if (path[0] && path[1]==':') 
+       {
+               if (drv) 
+               {
+                       *drv++ = *path++;
+                       *drv++ = *path++;
+                       *drv = L'\0';
+               }
+       } else if (drv) *drv = L'\0';
+
+       /* search for end of string or stream separator */
+       for(end=path; *end && *end!=L':'; )     end++;
+
+       /* search for begin of file extension */
+       for(p=end; p>path && *--p!=L'\\' && *p!=L'/'; )
+       {
+               if (*p == L'.') 
+               {
+                       end = p;
+                       break;
+               }
+       }
+
+       if (ext) for(s=end; (*ext=*s++); ) ext++;
+
+       /* search for end of directory name */
+       for(p=end; p>path; )
+       {
+               if (*--p=='\\' || *p=='/') 
+               {
+                       p++;
+                       break;
+               }
+       }
+       if (name) 
+       {
+               for(s=p; s<end; ) *name++ = *s++;
+               *name = L'\0';
+       }
+
+       if (dir) 
+       {
+               for(s=path; s<p; ) *dir++ = *s++;
+               *dir = L'\0';
+       }
+}
+/*--------------------------------------------------------------------------*/ 
diff --git a/scilab/modules/output_stream/src/cpp/getFullFilename.hxx b/scilab/modules/output_stream/src/cpp/getFullFilename.hxx
new file mode 100644 (file)
index 0000000..1b704da
--- /dev/null
@@ -0,0 +1,22 @@
+/*--------------------------------------------------------------------------*/ 
+/*
+* ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) DIGITEO - 2009 - Allan CORNET
+* 
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at    
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/ 
+#ifndef __GETFULLFILENAME_HXX__
+#define __GETFULLFILENAME_HXX__
+
+#include <string>
+
+std::wstring getFullFilename(std::wstring _wfilename);
+
+#endif /* __GETFULLFILENAME_HXX__ */
+/*--------------------------------------------------------------------------*/ 
index ed2d9b1..1e43c21 100644 (file)
 
 // Génération du fichier de référence
 
-l = [" ";"-->mprintf(''hello world\n'')";"hello world";" ";"-->diary(0)"]
-l2 = ["hello world";" "]
+l = [" ";"-->mprintf(''hello world\n'')";"hello world";" ";"-->diary(TMPDIR+''/bug557.dia'');"];
+l2 = ["hello world";" "];
 mputl(l,TMPDIR+'/bug557.ref');
 
 // Génération du fichier rapport
 
 diary(TMPDIR+'/bug557.dia');
 mprintf('hello world\n')
-diary(0)
+diary(TMPDIR+'/bug557.dia');
 
 // Comparaison
 
@@ -38,5 +38,6 @@ ref=mgetl(u1);mclose(u1);
 dia=mgetl(u2);mclose(u2);
 
 // Affichage du résultat
-
+ref
+dia
 if or(ref<>dia) then pause,end
\ No newline at end of file
diff --git a/scilab/modules/output_stream/tests/unit_tests/diary.dia.ref b/scilab/modules/output_stream/tests/unit_tests/diary.dia.ref
new file mode 100644 (file)
index 0000000..5d8a7e4
--- /dev/null
@@ -0,0 +1,17 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Allan CORNET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+r = [];
+for i = 1:100
+  r = [r, diary(TMPDIR + '/test'+string(i)+'.diary','new');];
+  if ( fileinfo(TMPDIR + '/test'+string(i)+'.diary') == []) then bugmes();quit;end
+end
+if (size(r,'*') <> 100) then bugmes();quit;end
+for i = 1:100
+       diary(i,'close');
+       mdelete(TMPDIR + '/test'+string(i)+'.diary');
+       if ( fileinfo(TMPDIR + '/test'+string(i)+'.diary') <> []) then bugmes();quit;end
+end
diff --git a/scilab/modules/output_stream/tests/unit_tests/diary.tst b/scilab/modules/output_stream/tests/unit_tests/diary.tst
new file mode 100644 (file)
index 0000000..5901cbd
--- /dev/null
@@ -0,0 +1,126 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - Allan CORNET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+r = [];
+for i = 1:100
+  r = [r, diary(TMPDIR + '/test'+string(i)+'.diary','new');];
+  if ( fileinfo(TMPDIR + '/test'+string(i)+'.diary') == []) then pause,end
+end
+
+if (size(r,'*') <> 100) then pause,end
+
+for i = 1:100
+       diary(i,'close');
+       mdelete(TMPDIR + '/test'+string(i)+'.diary');
+       if ( fileinfo(TMPDIR + '/test'+string(i)+'.diary') <> []) then pause,end
+end
+// =============================================================================
+cd(TMPDIR);
+[a1,b1] = diary('log1.txt');
+if (a1 == 0) then pause,end
+
+[a2,b2] = diary('log2.txt');
+if (a2 == 0) then pause,end
+
+diary(a1,'close')
+diary(a2,'close')
+// =============================================================================
+ierr = execstr("diary(10000,''close'')","errcatch");
+if ierr <> 999 then pause,end
+
+[a2,b2] = diary('log2.txt');
+if (a2 == 0) then pause,end
+
+diary('log2.txt','close')
+
+ierr = execstr("diary(''log2.txt'',''close'')","errcatch");
+if ierr <> 999 then pause,end
+// =============================================================================
+[a1,b1] = diary(TMPDIR + '/pause.txt');
+diary(TMPDIR + '/pause.txt','on');
+diary(TMPDIR + '/pause.txt','resume');
+diary(TMPDIR + '/pause.txt','off');
+diary(TMPDIR + '/pause.txt','pause');
+// =============================================================================
+diary(a1,'on');
+diary(a1,'resume');
+diary(a1,'off');
+diary(a1,'pause');
+// =============================================================================
+ierr = execstr("diary(1000,''on'')","errcatch");
+if ierr <> 999 then pause,end
+// =============================================================================
+ierr = execstr("diary(1000,''off'')","errcatch");
+if ierr <> 999 then pause,end
+// =============================================================================
+ierr = execstr("diary(1000,''resume'')","errcatch");
+if ierr <> 999 then pause,end
+// =============================================================================
+ierr = execstr("diary(1000,''pause'')","errcatch");
+if ierr <> 999 then pause,end
+// =============================================================================
+diary(a1,'close')
+// =============================================================================
+ierr = execstr("diary(TMPDIR + ''/pause.txt'',''pausewitherror'');", "errcatch");
+if ierr <> 999 then pause,end
+// =============================================================================
+a = diary(TMPDIR + '/log1.txt');
+b = diary(TMPDIR + '/log2.txt');
+
+if ~diary(a,'exists') then pause,end
+if ~diary(b,'exists') then pause,end
+
+if ~diary(TMPDIR + '/log1.txt','exists') then pause,end
+if ~diary(TMPDIR + '/log2.txt','exists') then pause,end
+
+diary(TMPDIR + '/log1.txt','close')
+diary(TMPDIR + '/log2.txt','close')
+// =============================================================================
+ierr = execstr("diary(TMPDIR + ''/diarydate'',''new'',''prefix=YY-MM-DD hh:mm:ss'')","errcatch");
+if ierr <> 999 then pause,end
+// =============================================================================
+ierr = execstr("diary(TMPDIR + ''/diarydate'',''new'',''prefix=YYYY-MM-DD hh:mm:ss'')","errcatch");
+if ierr <> 0 then pause,end
+if ( fileinfo(TMPDIR + '/diarydate') == []) then pause,end
+diary(TMPDIR + '/diarydate','close')
+mdelete(TMPDIR + '/diarydate');
+// =============================================================================
+ierr = execstr("diary(TMPDIR + ''/diarydate2'',''new'',''prefix=U'')","errcatch");
+if ierr <> 0 then pause,end
+if ( fileinfo(TMPDIR + '/diarydate2') == []) then pause,end
+diary(TMPDIR + '/diarydate2','close')
+mdelete(TMPDIR + '/diarydate');
+// =============================================================================
+ierr = execstr("diary(TMPDIR + ''/diarydate2'',''new'',[''prefix=U'',''prefix-only-commands''])","errcatch");
+if ierr <> 0 then pause,end
+if ( fileinfo(TMPDIR + '/diarydate2') == []) then pause,end
+diary(TMPDIR + '/diarydate2','close')
+mdelete(TMPDIR + '/diarydate');
+// =============================================================================
+ierr = execstr("diary(TMPDIR + ''/diarydate2'',''new'',''filter)command'')","errcatch");
+if ierr <> 999 then pause,end
+// =============================================================================
+ierr = execstr("diary(TMPDIR + ''/diarydate2'',''new'',''filter=command'')","errcatch");
+if ierr <> 0 then pause,end
+if ( fileinfo(TMPDIR + '/diarydate2') == []) then pause,end
+diary(TMPDIR + '/diarydate2','close')
+mdelete(TMPDIR + '/diarydate');
+// =============================================================================
+ierr = execstr("diary(TMPDIR + ''/diarydate2'',''new'',''filter=output'')","errcatch");
+if ierr <> 0 then pause,end
+if ( fileinfo(TMPDIR + '/diarydate2') == []) then pause,end
+diary(TMPDIR + '/diarydate2','close')
+mdelete(TMPDIR + '/diarydate');
+// =============================================================================
+ierr = execstr("diary('''','''','''')","errcatch");
+if ierr <> 999 then pause,end
+// =============================================================================
+ierr = execstr("diary([],[],[])","errcatch");
+if ierr <> 999 then pause,end
+// =============================================================================
+ierr = execstr("diary([],''list'',[])","errcatch");
+if ierr <> 999 then pause,end
+// =============================================================================
index a040be6..11c9409 100644 (file)
@@ -4,6 +4,7 @@
 //
 //  This file is distributed under the same license as the Scilab package.
 // =============================================================================
+// <-- JVM NOT MANDATORY -->
 disp([1 2],3);
  
     3.  
@@ -39,21 +40,21 @@ disp(text);
 !                                                                      !
 !ድቅስድቅስግጅክልውሽችክልዝ                      !
 !                                                                      !
-!すべての人間は、生まれながらにして自由であり、ã!
-!     ‹ã¤ã€å°ŠåŽ³ã¨æ¨©åˆ©ã¨ ã«ã¤ã„て平等である。人間ã!
-!     ¯ã€ç†æ€§ã¨è‰¯å¿ƒã¨ã‚’授けられており、互いに同 èƒž!
+!すべての人間は、生まれながらにして自由であり、�!
+!     ��つ、尊厳と権利と について平等である。人間�!
+!     �、理性と良心とを授けられており、互いに同 胞!
 !     の精神をもって行動しなければならない。        !
 !                                                                      !
-!人 äºº ç”Ÿ è€Œ è‡ª ç”±, åœ¨ å°Š ä¸¥ å’Œ æƒ åˆ© ä¸Š ä¸€ å¾‹ å¹³ ç­‰ã€!
-!     ‚ ä»– ä»¬ èµ‹ æœ‰ ç† æ€§ å’Œ è‰¯ å¿ƒ, å¹¶ åº” ä»¥ å…„ å¼Ÿ å…³ ç³!
-!     » çš„ ç²¾ ç¥ž ç›¸ å¯¹ å¾…。                                     !
+!人 人 生 而 自 由, 在 尊 严 和 权 利 上 一 律 平 等�!
+!     � 他 们 赋 有 理 性 和 良 心, 并 应 以 兄 弟 关 �!
+!     � 的 精 神 相 对 待。                                     !
 !                                                                      !
 !لد جميع الناس أحرارًا متساوين في الكرا!
 !     مة والحقوق. وقد وهبوا عقلاً وضميرًا !
-!     ÙˆØ¹Ù„يهم Ø£Ù† ÙŠØ¹Ø§Ù…Ù„ Ø¨Ø¹Ø¶Ù‡Ù… Ø¨Ø¹Ø¶Ù‹Ø§ Ø¨Ø±ÙˆØ­ Ø§Ù„Ø!
-!     ¥Ø®Ø§Ø¡                                                          !
+!     وعليهم أن يعامل بعضهم بعضًا بروح ال�!
+!     �خاء                                                          !
 !                                                                      !
-!כל ×‘× ×™ ×”אדם × ×•×œ×“ו ×‘× ×™ ×—ורין ×•×©×•×•×™× ×‘ער×!
-!     ›× ×•×‘זכיותיהם. ×›×•×œ× ×—וננו ×‘תבונה ×•×‘מ!
+!כל בני האדם נולדו בני חורין ושווים בער�!
+!     �ם ובזכיותיהם. כולם חוננו בתבונה ובמ!
 !     צפון, לפיכך חובה עליהם לנהג איש ברעה!
 !     ו ברוח של אחוה                                        !
index a8dde58..9c0b1b3 100644 (file)
@@ -29,7 +29,6 @@
 #include "GetCommandLine.h"
 #include "TermReadAndProcess.h"
 #include "stack-def.h"
-#include "diary.h"
 #ifdef _MSC_VER
 #include "strdup_windows.h"
 #endif
index 69d4a30..c14cc95 100644 (file)
@@ -16,7 +16,6 @@
 #include "basout.h"
 #include "MALLOC.h"
 #include "prompt.h"
-#include "diary.h"
 #ifdef _MSC_VER
 #include "strdup_Windows.h"
 #endif