summaryrefslogtreecommitdiff
path: root/modules/spreadsheet/src
diff options
context:
space:
mode:
authorShashank2017-05-29 12:40:26 +0530
committerShashank2017-05-29 12:40:26 +0530
commit0345245e860375a32c9a437c4a9d9cae807134e9 (patch)
treead51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/spreadsheet/src
downloadscilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip
CMSCOPE changed
Diffstat (limited to 'modules/spreadsheet/src')
-rwxr-xr-xmodules/spreadsheet/src/c/.deps/.dirstamp0
-rwxr-xr-xmodules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-checkCsvWriteFormat.Plo109
-rwxr-xr-xmodules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-csvDefault.Plo106
-rwxr-xr-xmodules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-csvRead.Plo205
-rwxr-xr-xmodules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-csvWrite.Plo244
-rwxr-xr-xmodules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-getRange.Plo113
-rwxr-xr-xmodules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-splitLine.Plo146
-rwxr-xr-xmodules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-utftolatin.Plo104
-rwxr-xr-xmodules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-xls.Plo210
-rwxr-xr-xmodules/spreadsheet/src/c/.dirstamp0
-rwxr-xr-xmodules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-checkCsvWriteFormat.obin0 -> 9616 bytes
-rwxr-xr-xmodules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-csvDefault.obin0 -> 25936 bytes
-rwxr-xr-xmodules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-csvRead.obin0 -> 45240 bytes
-rwxr-xr-xmodules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-csvWrite.obin0 -> 45280 bytes
-rwxr-xr-xmodules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-getRange.obin0 -> 15032 bytes
-rwxr-xr-xmodules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-splitLine.obin0 -> 19488 bytes
-rwxr-xr-xmodules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-utftolatin.obin0 -> 9304 bytes
-rwxr-xr-xmodules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-xls.obin0 -> 44280 bytes
-rwxr-xr-xmodules/spreadsheet/src/c/DllmainSpreadsheet.c33
-rwxr-xr-xmodules/spreadsheet/src/c/checkCsvWriteFormat.c99
-rwxr-xr-xmodules/spreadsheet/src/c/checkCsvWriteFormat.h27
-rwxr-xr-xmodules/spreadsheet/src/c/csvDefault.c439
-rwxr-xr-xmodules/spreadsheet/src/c/csvDefault.h45
-rwxr-xr-xmodules/spreadsheet/src/c/csvRead.c723
-rwxr-xr-xmodules/spreadsheet/src/c/csvRead.h55
-rwxr-xr-xmodules/spreadsheet/src/c/csvWrite.c557
-rwxr-xr-xmodules/spreadsheet/src/c/csvWrite.h60
-rwxr-xr-xmodules/spreadsheet/src/c/getRange.c181
-rwxr-xr-xmodules/spreadsheet/src/c/getRange.h47
-rwxr-xr-xmodules/spreadsheet/src/c/libscispreadsheet_algo_la-checkCsvWriteFormat.lo12
-rwxr-xr-xmodules/spreadsheet/src/c/libscispreadsheet_algo_la-csvDefault.lo12
-rwxr-xr-xmodules/spreadsheet/src/c/libscispreadsheet_algo_la-csvRead.lo12
-rwxr-xr-xmodules/spreadsheet/src/c/libscispreadsheet_algo_la-csvWrite.lo12
-rwxr-xr-xmodules/spreadsheet/src/c/libscispreadsheet_algo_la-getRange.lo12
-rwxr-xr-xmodules/spreadsheet/src/c/libscispreadsheet_algo_la-splitLine.lo12
-rwxr-xr-xmodules/spreadsheet/src/c/libscispreadsheet_algo_la-utftolatin.lo12
-rwxr-xr-xmodules/spreadsheet/src/c/libscispreadsheet_algo_la-xls.lo12
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.deps/.dirstamp0
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-bt-int.Plo115
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-bytedecoders.Plo54
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-logger.Plo187
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-ole.Plo195
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-olestream-unwrap.Plo185
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-pldstr.Plo146
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-ripole.Plo150
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.dirstamp0
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-bt-int.obin0 -> 11256 bytes
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-bytedecoders.obin0 -> 6024 bytes
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-logger.obin0 -> 20896 bytes
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-ole.obin0 -> 105712 bytes
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-olestream-unwrap.obin0 -> 23592 bytes
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-pldstr.obin0 -> 31640 bytes
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-ripole.obin0 -> 15536 bytes
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/LICENSE.ripole33
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/bt-int.c130
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/bt-int.h15
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/bytedecoders.c77
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/bytedecoders.h26
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-bt-int.lo12
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-bytedecoders.lo12
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-logger.lo12
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-ole.lo12
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-olestream-unwrap.lo12
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-pldstr.lo12
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-ripole.lo12
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/logger.c379
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/logger.h29
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/ole.c2136
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/ole.h173
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/olestream-unwrap.c400
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/olestream-unwrap.h28
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/pldstr.c908
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/pldstr.h40
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/ripole.c201
-rwxr-xr-xmodules/spreadsheet/src/c/ripole/ripole.h37
-rwxr-xr-xmodules/spreadsheet/src/c/splitLine.c241
-rwxr-xr-xmodules/spreadsheet/src/c/splitLine.h30
-rwxr-xr-xmodules/spreadsheet/src/c/spreadsheet.rc97
-rwxr-xr-xmodules/spreadsheet/src/c/utftolatin.c223
-rwxr-xr-xmodules/spreadsheet/src/c/utftolatin.h27
-rwxr-xr-xmodules/spreadsheet/src/c/xls.c1131
-rwxr-xr-xmodules/spreadsheet/src/c/xls.h30
-rwxr-xr-xmodules/spreadsheet/src/nospreadsheet/nospreadsheet.c23
-rwxr-xr-xmodules/spreadsheet/src/nospreadsheet/nospreadsheet.rc97
-rwxr-xr-xmodules/spreadsheet/src/nospreadsheet/nospreadsheet.vcxproj191
-rwxr-xr-xmodules/spreadsheet/src/nospreadsheet/nospreadsheet.vcxproj.filters30
86 files changed, 11447 insertions, 0 deletions
diff --git a/modules/spreadsheet/src/c/.deps/.dirstamp b/modules/spreadsheet/src/c/.deps/.dirstamp
new file mode 100755
index 000000000..e69de29bb
--- /dev/null
+++ b/modules/spreadsheet/src/c/.deps/.dirstamp
diff --git a/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-checkCsvWriteFormat.Plo b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-checkCsvWriteFormat.Plo
new file mode 100755
index 000000000..e50974652
--- /dev/null
+++ b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-checkCsvWriteFormat.Plo
@@ -0,0 +1,109 @@
+src/c/libscispreadsheet_algo_la-checkCsvWriteFormat.lo: \
+ src/c/checkCsvWriteFormat.c /usr/include/stdc-predef.h \
+ /usr/include/string.h /usr/include/features.h \
+ /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \
+ /usr/include/x86_64-linux-gnu/bits/string.h \
+ /usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/stdlib.h \
+ /usr/include/x86_64-linux-gnu/bits/string3.h /usr/include/ctype.h \
+ src/c/csvDefault.h ../../modules/core/includes/MALLOC.h \
+ ../../modules/core/includes/sci_mem_alloc.h \
+ /usr/include/x86_64-linux-gnu/bits/waitflags.h \
+ /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
+ /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
+ /usr/include/x86_64-linux-gnu/sys/select.h \
+ /usr/include/x86_64-linux-gnu/bits/select.h \
+ /usr/include/x86_64-linux-gnu/bits/sigset.h \
+ /usr/include/x86_64-linux-gnu/bits/time.h \
+ /usr/include/x86_64-linux-gnu/bits/select2.h \
+ /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
+ /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib.h src/c/checkCsvWriteFormat.h
+
+/usr/include/stdc-predef.h:
+
+/usr/include/string.h:
+
+/usr/include/features.h:
+
+/usr/include/x86_64-linux-gnu/sys/cdefs.h:
+
+/usr/include/x86_64-linux-gnu/bits/wordsize.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:
+
+/usr/include/xlocale.h:
+
+/usr/include/x86_64-linux-gnu/bits/string.h:
+
+/usr/include/x86_64-linux-gnu/bits/string2.h:
+
+/usr/include/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap.h:
+
+/usr/include/x86_64-linux-gnu/bits/types.h:
+
+/usr/include/x86_64-linux-gnu/bits/typesizes.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
+
+/usr/include/stdlib.h:
+
+/usr/include/x86_64-linux-gnu/bits/string3.h:
+
+/usr/include/ctype.h:
+
+src/c/csvDefault.h:
+
+../../modules/core/includes/MALLOC.h:
+
+../../modules/core/includes/sci_mem_alloc.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitflags.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
+
+/usr/include/x86_64-linux-gnu/sys/types.h:
+
+/usr/include/time.h:
+
+/usr/include/x86_64-linux-gnu/sys/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/sigset.h:
+
+/usr/include/x86_64-linux-gnu/bits/time.h:
+
+/usr/include/x86_64-linux-gnu/bits/select2.h:
+
+/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
+
+/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
+
+/usr/include/alloca.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib.h:
+
+src/c/checkCsvWriteFormat.h:
diff --git a/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-csvDefault.Plo b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-csvDefault.Plo
new file mode 100755
index 000000000..434b01673
--- /dev/null
+++ b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-csvDefault.Plo
@@ -0,0 +1,106 @@
+src/c/libscispreadsheet_algo_la-csvDefault.lo: src/c/csvDefault.c \
+ /usr/include/stdc-predef.h /usr/include/string.h /usr/include/features.h \
+ /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \
+ /usr/include/x86_64-linux-gnu/bits/string.h \
+ /usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/stdlib.h \
+ /usr/include/x86_64-linux-gnu/bits/string3.h src/c/csvDefault.h \
+ ../../modules/core/includes/MALLOC.h \
+ ../../modules/core/includes/sci_mem_alloc.h \
+ /usr/include/x86_64-linux-gnu/bits/waitflags.h \
+ /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
+ /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
+ /usr/include/x86_64-linux-gnu/sys/select.h \
+ /usr/include/x86_64-linux-gnu/bits/select.h \
+ /usr/include/x86_64-linux-gnu/bits/sigset.h \
+ /usr/include/x86_64-linux-gnu/bits/time.h \
+ /usr/include/x86_64-linux-gnu/bits/select2.h \
+ /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
+ /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib.h src/c/checkCsvWriteFormat.h
+
+/usr/include/stdc-predef.h:
+
+/usr/include/string.h:
+
+/usr/include/features.h:
+
+/usr/include/x86_64-linux-gnu/sys/cdefs.h:
+
+/usr/include/x86_64-linux-gnu/bits/wordsize.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:
+
+/usr/include/xlocale.h:
+
+/usr/include/x86_64-linux-gnu/bits/string.h:
+
+/usr/include/x86_64-linux-gnu/bits/string2.h:
+
+/usr/include/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap.h:
+
+/usr/include/x86_64-linux-gnu/bits/types.h:
+
+/usr/include/x86_64-linux-gnu/bits/typesizes.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
+
+/usr/include/stdlib.h:
+
+/usr/include/x86_64-linux-gnu/bits/string3.h:
+
+src/c/csvDefault.h:
+
+../../modules/core/includes/MALLOC.h:
+
+../../modules/core/includes/sci_mem_alloc.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitflags.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
+
+/usr/include/x86_64-linux-gnu/sys/types.h:
+
+/usr/include/time.h:
+
+/usr/include/x86_64-linux-gnu/sys/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/sigset.h:
+
+/usr/include/x86_64-linux-gnu/bits/time.h:
+
+/usr/include/x86_64-linux-gnu/bits/select2.h:
+
+/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
+
+/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
+
+/usr/include/alloca.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib.h:
+
+src/c/checkCsvWriteFormat.h:
diff --git a/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-csvRead.Plo b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-csvRead.Plo
new file mode 100755
index 000000000..5d3fe2f5b
--- /dev/null
+++ b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-csvRead.Plo
@@ -0,0 +1,205 @@
+src/c/libscispreadsheet_algo_la-csvRead.lo: src/c/csvRead.c \
+ /usr/include/stdc-predef.h /usr/include/string.h /usr/include/features.h \
+ /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \
+ /usr/include/x86_64-linux-gnu/bits/string.h \
+ /usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/stdlib.h \
+ /usr/include/x86_64-linux-gnu/bits/string3.h /usr/include/stdio.h \
+ /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
+ /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio2.h src/c/csvRead.h \
+ ../../modules/core/includes/MALLOC.h \
+ ../../modules/core/includes/sci_mem_alloc.h \
+ /usr/include/x86_64-linux-gnu/bits/waitflags.h \
+ /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
+ /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
+ /usr/include/x86_64-linux-gnu/sys/select.h \
+ /usr/include/x86_64-linux-gnu/bits/select.h \
+ /usr/include/x86_64-linux-gnu/bits/sigset.h \
+ /usr/include/x86_64-linux-gnu/bits/time.h \
+ /usr/include/x86_64-linux-gnu/bits/select2.h \
+ /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
+ /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib.h \
+ ../../modules/core/includes/freeArrayOfString.h \
+ /usr/include/x86_64-linux-gnu/bits/wchar.h \
+ /usr/include/x86_64-linux-gnu/bits/wchar2.h \
+ ../../modules/core/includes/BOOL.h ../../modules/fileio/includes/mopen.h \
+ ../../modules/fileio/includes/dynlib_fileio.h \
+ ../../modules/core/includes/machine.h \
+ ../../modules/fileio/includes/mgetl.h \
+ ../../modules/localization/includes/charEncoding.h \
+ /usr/include/x86_64-linux-gnu/sys/stat.h \
+ /usr/include/x86_64-linux-gnu/bits/stat.h \
+ ../../modules/core/includes/BOOL.h \
+ ../../modules/localization/includes/localization.h \
+ /usr/include/libintl.h /usr/include/locale.h \
+ /usr/include/x86_64-linux-gnu/bits/locale.h \
+ ../../modules/fileio/includes/expandPathVariable.h \
+ ../../modules/fileio/includes/FileExist.h \
+ ../../modules/fileio/includes/mclose.h \
+ ../../modules/core/includes/warningmode.h \
+ ../../modules/core/includes/machine.h \
+ ../../modules/string/includes/pcre_private.h \
+ ../../modules/string/includes/dynlib_string.h \
+ ../../modules/output_stream/includes/sciprint.h src/c/splitLine.h \
+ ../../modules/string/includes/strsubst.h src/c/csvDefault.h
+
+/usr/include/stdc-predef.h:
+
+/usr/include/string.h:
+
+/usr/include/features.h:
+
+/usr/include/x86_64-linux-gnu/sys/cdefs.h:
+
+/usr/include/x86_64-linux-gnu/bits/wordsize.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:
+
+/usr/include/xlocale.h:
+
+/usr/include/x86_64-linux-gnu/bits/string.h:
+
+/usr/include/x86_64-linux-gnu/bits/string2.h:
+
+/usr/include/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap.h:
+
+/usr/include/x86_64-linux-gnu/bits/types.h:
+
+/usr/include/x86_64-linux-gnu/bits/typesizes.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
+
+/usr/include/stdlib.h:
+
+/usr/include/x86_64-linux-gnu/bits/string3.h:
+
+/usr/include/stdio.h:
+
+/usr/include/libio.h:
+
+/usr/include/_G_config.h:
+
+/usr/include/wchar.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
+
+/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio2.h:
+
+src/c/csvRead.h:
+
+../../modules/core/includes/MALLOC.h:
+
+../../modules/core/includes/sci_mem_alloc.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitflags.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
+
+/usr/include/x86_64-linux-gnu/sys/types.h:
+
+/usr/include/time.h:
+
+/usr/include/x86_64-linux-gnu/sys/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/sigset.h:
+
+/usr/include/x86_64-linux-gnu/bits/time.h:
+
+/usr/include/x86_64-linux-gnu/bits/select2.h:
+
+/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
+
+/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
+
+/usr/include/alloca.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib.h:
+
+../../modules/core/includes/freeArrayOfString.h:
+
+/usr/include/x86_64-linux-gnu/bits/wchar.h:
+
+/usr/include/x86_64-linux-gnu/bits/wchar2.h:
+
+../../modules/core/includes/BOOL.h:
+
+../../modules/fileio/includes/mopen.h:
+
+../../modules/fileio/includes/dynlib_fileio.h:
+
+../../modules/core/includes/machine.h:
+
+../../modules/fileio/includes/mgetl.h:
+
+../../modules/localization/includes/charEncoding.h:
+
+/usr/include/x86_64-linux-gnu/sys/stat.h:
+
+/usr/include/x86_64-linux-gnu/bits/stat.h:
+
+../../modules/core/includes/BOOL.h:
+
+../../modules/localization/includes/localization.h:
+
+/usr/include/libintl.h:
+
+/usr/include/locale.h:
+
+/usr/include/x86_64-linux-gnu/bits/locale.h:
+
+../../modules/fileio/includes/expandPathVariable.h:
+
+../../modules/fileio/includes/FileExist.h:
+
+../../modules/fileio/includes/mclose.h:
+
+../../modules/core/includes/warningmode.h:
+
+../../modules/core/includes/machine.h:
+
+../../modules/string/includes/pcre_private.h:
+
+../../modules/string/includes/dynlib_string.h:
+
+../../modules/output_stream/includes/sciprint.h:
+
+src/c/splitLine.h:
+
+../../modules/string/includes/strsubst.h:
+
+src/c/csvDefault.h:
diff --git a/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-csvWrite.Plo b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-csvWrite.Plo
new file mode 100755
index 000000000..b28a9098a
--- /dev/null
+++ b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-csvWrite.Plo
@@ -0,0 +1,244 @@
+src/c/libscispreadsheet_algo_la-csvWrite.lo: src/c/csvWrite.c \
+ /usr/include/stdc-predef.h /usr/include/stdio.h /usr/include/features.h \
+ /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \
+ /usr/include/_G_config.h /usr/include/wchar.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
+ /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio2.h /usr/include/string.h \
+ /usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \
+ /usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/stdlib.h \
+ /usr/include/x86_64-linux-gnu/bits/string3.h \
+ ../../modules/string/includes/stringToDouble.h \
+ ../../modules/string/includes/dynlib_string.h \
+ ../../modules/core/includes/BOOL.h src/c/csvWrite.h \
+ ../../modules/fileio/includes/mopen.h \
+ ../../modules/fileio/includes/dynlib_fileio.h \
+ ../../modules/core/includes/machine.h \
+ ../../modules/fileio/includes/mgetl.h \
+ ../../modules/localization/includes/charEncoding.h \
+ /usr/include/x86_64-linux-gnu/bits/wchar.h \
+ /usr/include/x86_64-linux-gnu/bits/wchar2.h \
+ /usr/include/x86_64-linux-gnu/sys/stat.h /usr/include/time.h \
+ /usr/include/x86_64-linux-gnu/bits/stat.h \
+ /usr/include/x86_64-linux-gnu/sys/types.h \
+ /usr/include/x86_64-linux-gnu/sys/select.h \
+ /usr/include/x86_64-linux-gnu/bits/select.h \
+ /usr/include/x86_64-linux-gnu/bits/sigset.h \
+ /usr/include/x86_64-linux-gnu/bits/time.h \
+ /usr/include/x86_64-linux-gnu/bits/select2.h \
+ /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
+ /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
+ ../../modules/core/includes/MALLOC.h \
+ ../../modules/core/includes/sci_mem_alloc.h \
+ /usr/include/x86_64-linux-gnu/bits/waitflags.h \
+ /usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/alloca.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib.h \
+ ../../modules/fileio/includes/expandPathVariable.h \
+ ../../modules/fileio/includes/FileExist.h \
+ ../../modules/fileio/includes/mclose.h \
+ ../../modules/core/includes/core_math.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h \
+ /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \
+ /usr/include/x86_64-linux-gnu/bits/local_lim.h \
+ /usr/include/linux/limits.h \
+ /usr/include/x86_64-linux-gnu/bits/posix2_lim.h \
+ /usr/include/x86_64-linux-gnu/bits/xopen_lim.h /usr/include/math.h \
+ /usr/include/x86_64-linux-gnu/bits/math-vector.h \
+ /usr/include/x86_64-linux-gnu/bits/libm-simd-decl-stubs.h \
+ /usr/include/x86_64-linux-gnu/bits/huge_val.h \
+ /usr/include/x86_64-linux-gnu/bits/huge_valf.h \
+ /usr/include/x86_64-linux-gnu/bits/huge_vall.h \
+ /usr/include/x86_64-linux-gnu/bits/inf.h \
+ /usr/include/x86_64-linux-gnu/bits/nan.h \
+ /usr/include/x86_64-linux-gnu/bits/mathdef.h \
+ /usr/include/x86_64-linux-gnu/bits/mathcalls.h \
+ /usr/include/x86_64-linux-gnu/bits/mathinline.h /usr/include/values.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/float.h \
+ ../../modules/string/includes/strsubst.h src/c/csvDefault.h \
+ src/c/utftolatin.h
+
+/usr/include/stdc-predef.h:
+
+/usr/include/stdio.h:
+
+/usr/include/features.h:
+
+/usr/include/x86_64-linux-gnu/sys/cdefs.h:
+
+/usr/include/x86_64-linux-gnu/bits/wordsize.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:
+
+/usr/include/x86_64-linux-gnu/bits/types.h:
+
+/usr/include/x86_64-linux-gnu/bits/typesizes.h:
+
+/usr/include/libio.h:
+
+/usr/include/_G_config.h:
+
+/usr/include/wchar.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
+
+/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio2.h:
+
+/usr/include/string.h:
+
+/usr/include/xlocale.h:
+
+/usr/include/x86_64-linux-gnu/bits/string.h:
+
+/usr/include/x86_64-linux-gnu/bits/string2.h:
+
+/usr/include/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
+
+/usr/include/stdlib.h:
+
+/usr/include/x86_64-linux-gnu/bits/string3.h:
+
+../../modules/string/includes/stringToDouble.h:
+
+../../modules/string/includes/dynlib_string.h:
+
+../../modules/core/includes/BOOL.h:
+
+src/c/csvWrite.h:
+
+../../modules/fileio/includes/mopen.h:
+
+../../modules/fileio/includes/dynlib_fileio.h:
+
+../../modules/core/includes/machine.h:
+
+../../modules/fileio/includes/mgetl.h:
+
+../../modules/localization/includes/charEncoding.h:
+
+/usr/include/x86_64-linux-gnu/bits/wchar.h:
+
+/usr/include/x86_64-linux-gnu/bits/wchar2.h:
+
+/usr/include/x86_64-linux-gnu/sys/stat.h:
+
+/usr/include/time.h:
+
+/usr/include/x86_64-linux-gnu/bits/stat.h:
+
+/usr/include/x86_64-linux-gnu/sys/types.h:
+
+/usr/include/x86_64-linux-gnu/sys/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/sigset.h:
+
+/usr/include/x86_64-linux-gnu/bits/time.h:
+
+/usr/include/x86_64-linux-gnu/bits/select2.h:
+
+/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
+
+/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
+
+../../modules/core/includes/MALLOC.h:
+
+../../modules/core/includes/sci_mem_alloc.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitflags.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
+
+/usr/include/alloca.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib.h:
+
+../../modules/fileio/includes/expandPathVariable.h:
+
+../../modules/fileio/includes/FileExist.h:
+
+../../modules/fileio/includes/mclose.h:
+
+../../modules/core/includes/core_math.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h:
+
+/usr/include/limits.h:
+
+/usr/include/x86_64-linux-gnu/bits/posix1_lim.h:
+
+/usr/include/x86_64-linux-gnu/bits/local_lim.h:
+
+/usr/include/linux/limits.h:
+
+/usr/include/x86_64-linux-gnu/bits/posix2_lim.h:
+
+/usr/include/x86_64-linux-gnu/bits/xopen_lim.h:
+
+/usr/include/math.h:
+
+/usr/include/x86_64-linux-gnu/bits/math-vector.h:
+
+/usr/include/x86_64-linux-gnu/bits/libm-simd-decl-stubs.h:
+
+/usr/include/x86_64-linux-gnu/bits/huge_val.h:
+
+/usr/include/x86_64-linux-gnu/bits/huge_valf.h:
+
+/usr/include/x86_64-linux-gnu/bits/huge_vall.h:
+
+/usr/include/x86_64-linux-gnu/bits/inf.h:
+
+/usr/include/x86_64-linux-gnu/bits/nan.h:
+
+/usr/include/x86_64-linux-gnu/bits/mathdef.h:
+
+/usr/include/x86_64-linux-gnu/bits/mathcalls.h:
+
+/usr/include/x86_64-linux-gnu/bits/mathinline.h:
+
+/usr/include/values.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/float.h:
+
+../../modules/string/includes/strsubst.h:
+
+src/c/csvDefault.h:
+
+src/c/utftolatin.h:
diff --git a/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-getRange.Plo b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-getRange.Plo
new file mode 100755
index 000000000..621e3a34f
--- /dev/null
+++ b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-getRange.Plo
@@ -0,0 +1,113 @@
+src/c/libscispreadsheet_algo_la-getRange.lo: src/c/getRange.c \
+ /usr/include/stdc-predef.h /usr/include/string.h /usr/include/features.h \
+ /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \
+ /usr/include/x86_64-linux-gnu/bits/string.h \
+ /usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/stdlib.h \
+ /usr/include/x86_64-linux-gnu/bits/string3.h \
+ ../../modules/core/includes/MALLOC.h \
+ ../../modules/core/includes/sci_mem_alloc.h \
+ /usr/include/x86_64-linux-gnu/bits/waitflags.h \
+ /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
+ /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
+ /usr/include/x86_64-linux-gnu/sys/select.h \
+ /usr/include/x86_64-linux-gnu/bits/select.h \
+ /usr/include/x86_64-linux-gnu/bits/sigset.h \
+ /usr/include/x86_64-linux-gnu/bits/time.h \
+ /usr/include/x86_64-linux-gnu/bits/select2.h \
+ /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
+ /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib.h src/c/getRange.h \
+ ../../modules/core/includes/doublecomplex.h \
+ ../../modules/string/includes/complex_array.h \
+ ../../modules/string/includes/dynlib_string.h
+
+/usr/include/stdc-predef.h:
+
+/usr/include/string.h:
+
+/usr/include/features.h:
+
+/usr/include/x86_64-linux-gnu/sys/cdefs.h:
+
+/usr/include/x86_64-linux-gnu/bits/wordsize.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:
+
+/usr/include/xlocale.h:
+
+/usr/include/x86_64-linux-gnu/bits/string.h:
+
+/usr/include/x86_64-linux-gnu/bits/string2.h:
+
+/usr/include/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap.h:
+
+/usr/include/x86_64-linux-gnu/bits/types.h:
+
+/usr/include/x86_64-linux-gnu/bits/typesizes.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
+
+/usr/include/stdlib.h:
+
+/usr/include/x86_64-linux-gnu/bits/string3.h:
+
+../../modules/core/includes/MALLOC.h:
+
+../../modules/core/includes/sci_mem_alloc.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitflags.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
+
+/usr/include/x86_64-linux-gnu/sys/types.h:
+
+/usr/include/time.h:
+
+/usr/include/x86_64-linux-gnu/sys/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/sigset.h:
+
+/usr/include/x86_64-linux-gnu/bits/time.h:
+
+/usr/include/x86_64-linux-gnu/bits/select2.h:
+
+/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
+
+/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
+
+/usr/include/alloca.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib.h:
+
+src/c/getRange.h:
+
+../../modules/core/includes/doublecomplex.h:
+
+../../modules/string/includes/complex_array.h:
+
+../../modules/string/includes/dynlib_string.h:
diff --git a/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-splitLine.Plo b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-splitLine.Plo
new file mode 100755
index 000000000..98ddb15ce
--- /dev/null
+++ b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-splitLine.Plo
@@ -0,0 +1,146 @@
+src/c/libscispreadsheet_algo_la-splitLine.lo: src/c/splitLine.c \
+ /usr/include/stdc-predef.h /usr/include/string.h /usr/include/features.h \
+ /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \
+ /usr/include/x86_64-linux-gnu/bits/string.h \
+ /usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/stdlib.h \
+ /usr/include/x86_64-linux-gnu/bits/string3.h /usr/include/stdio.h \
+ /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
+ /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio2.h src/c/splitLine.h \
+ ../../modules/string/includes/strsubst.h \
+ ../../modules/string/includes/dynlib_string.h \
+ ../../modules/core/includes/MALLOC.h \
+ ../../modules/core/includes/sci_mem_alloc.h \
+ /usr/include/x86_64-linux-gnu/bits/waitflags.h \
+ /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
+ /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
+ /usr/include/x86_64-linux-gnu/sys/select.h \
+ /usr/include/x86_64-linux-gnu/bits/select.h \
+ /usr/include/x86_64-linux-gnu/bits/sigset.h \
+ /usr/include/x86_64-linux-gnu/bits/time.h \
+ /usr/include/x86_64-linux-gnu/bits/select2.h \
+ /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
+ /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib.h \
+ ../../modules/core/includes/freeArrayOfString.h \
+ /usr/include/x86_64-linux-gnu/bits/wchar.h \
+ /usr/include/x86_64-linux-gnu/bits/wchar2.h \
+ ../../modules/core/includes/BOOL.h
+
+/usr/include/stdc-predef.h:
+
+/usr/include/string.h:
+
+/usr/include/features.h:
+
+/usr/include/x86_64-linux-gnu/sys/cdefs.h:
+
+/usr/include/x86_64-linux-gnu/bits/wordsize.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:
+
+/usr/include/xlocale.h:
+
+/usr/include/x86_64-linux-gnu/bits/string.h:
+
+/usr/include/x86_64-linux-gnu/bits/string2.h:
+
+/usr/include/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap.h:
+
+/usr/include/x86_64-linux-gnu/bits/types.h:
+
+/usr/include/x86_64-linux-gnu/bits/typesizes.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
+
+/usr/include/stdlib.h:
+
+/usr/include/x86_64-linux-gnu/bits/string3.h:
+
+/usr/include/stdio.h:
+
+/usr/include/libio.h:
+
+/usr/include/_G_config.h:
+
+/usr/include/wchar.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
+
+/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio2.h:
+
+src/c/splitLine.h:
+
+../../modules/string/includes/strsubst.h:
+
+../../modules/string/includes/dynlib_string.h:
+
+../../modules/core/includes/MALLOC.h:
+
+../../modules/core/includes/sci_mem_alloc.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitflags.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
+
+/usr/include/x86_64-linux-gnu/sys/types.h:
+
+/usr/include/time.h:
+
+/usr/include/x86_64-linux-gnu/sys/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/sigset.h:
+
+/usr/include/x86_64-linux-gnu/bits/time.h:
+
+/usr/include/x86_64-linux-gnu/bits/select2.h:
+
+/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
+
+/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
+
+/usr/include/alloca.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib.h:
+
+../../modules/core/includes/freeArrayOfString.h:
+
+/usr/include/x86_64-linux-gnu/bits/wchar.h:
+
+/usr/include/x86_64-linux-gnu/bits/wchar2.h:
+
+../../modules/core/includes/BOOL.h:
diff --git a/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-utftolatin.Plo b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-utftolatin.Plo
new file mode 100755
index 000000000..5c430d99c
--- /dev/null
+++ b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-utftolatin.Plo
@@ -0,0 +1,104 @@
+src/c/libscispreadsheet_algo_la-utftolatin.lo: src/c/utftolatin.c \
+ /usr/include/stdc-predef.h /usr/include/string.h /usr/include/features.h \
+ /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \
+ /usr/include/x86_64-linux-gnu/bits/string.h \
+ /usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/stdlib.h \
+ /usr/include/x86_64-linux-gnu/bits/string3.h src/c/utftolatin.h \
+ ../../modules/core/includes/MALLOC.h \
+ ../../modules/core/includes/sci_mem_alloc.h \
+ /usr/include/x86_64-linux-gnu/bits/waitflags.h \
+ /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
+ /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
+ /usr/include/x86_64-linux-gnu/sys/select.h \
+ /usr/include/x86_64-linux-gnu/bits/select.h \
+ /usr/include/x86_64-linux-gnu/bits/sigset.h \
+ /usr/include/x86_64-linux-gnu/bits/time.h \
+ /usr/include/x86_64-linux-gnu/bits/select2.h \
+ /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
+ /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib.h
+
+/usr/include/stdc-predef.h:
+
+/usr/include/string.h:
+
+/usr/include/features.h:
+
+/usr/include/x86_64-linux-gnu/sys/cdefs.h:
+
+/usr/include/x86_64-linux-gnu/bits/wordsize.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:
+
+/usr/include/xlocale.h:
+
+/usr/include/x86_64-linux-gnu/bits/string.h:
+
+/usr/include/x86_64-linux-gnu/bits/string2.h:
+
+/usr/include/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap.h:
+
+/usr/include/x86_64-linux-gnu/bits/types.h:
+
+/usr/include/x86_64-linux-gnu/bits/typesizes.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
+
+/usr/include/stdlib.h:
+
+/usr/include/x86_64-linux-gnu/bits/string3.h:
+
+src/c/utftolatin.h:
+
+../../modules/core/includes/MALLOC.h:
+
+../../modules/core/includes/sci_mem_alloc.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitflags.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
+
+/usr/include/x86_64-linux-gnu/sys/types.h:
+
+/usr/include/time.h:
+
+/usr/include/x86_64-linux-gnu/sys/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/sigset.h:
+
+/usr/include/x86_64-linux-gnu/bits/time.h:
+
+/usr/include/x86_64-linux-gnu/bits/select2.h:
+
+/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
+
+/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
+
+/usr/include/alloca.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib.h:
diff --git a/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-xls.Plo b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-xls.Plo
new file mode 100755
index 000000000..df47355a6
--- /dev/null
+++ b/modules/spreadsheet/src/c/.deps/libscispreadsheet_algo_la-xls.Plo
@@ -0,0 +1,210 @@
+src/c/libscispreadsheet_algo_la-xls.lo: src/c/xls.c \
+ /usr/include/stdc-predef.h /usr/include/stdlib.h /usr/include/features.h \
+ /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
+ /usr/include/x86_64-linux-gnu/bits/waitflags.h \
+ /usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
+ /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
+ /usr/include/x86_64-linux-gnu/sys/select.h \
+ /usr/include/x86_64-linux-gnu/bits/select.h \
+ /usr/include/x86_64-linux-gnu/bits/sigset.h \
+ /usr/include/x86_64-linux-gnu/bits/time.h \
+ /usr/include/x86_64-linux-gnu/bits/select2.h \
+ /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
+ /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/stdio.h \
+ /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
+ /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio2.h /usr/include/string.h \
+ /usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \
+ /usr/include/x86_64-linux-gnu/bits/string2.h \
+ /usr/include/x86_64-linux-gnu/bits/string3.h \
+ ../../modules/core/includes/core_math.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h \
+ /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \
+ /usr/include/x86_64-linux-gnu/bits/local_lim.h \
+ /usr/include/linux/limits.h \
+ /usr/include/x86_64-linux-gnu/bits/posix2_lim.h /usr/include/math.h \
+ /usr/include/x86_64-linux-gnu/bits/math-vector.h \
+ /usr/include/x86_64-linux-gnu/bits/libm-simd-decl-stubs.h \
+ /usr/include/x86_64-linux-gnu/bits/huge_val.h \
+ /usr/include/x86_64-linux-gnu/bits/huge_valf.h \
+ /usr/include/x86_64-linux-gnu/bits/huge_vall.h \
+ /usr/include/x86_64-linux-gnu/bits/inf.h \
+ /usr/include/x86_64-linux-gnu/bits/nan.h \
+ /usr/include/x86_64-linux-gnu/bits/mathdef.h \
+ /usr/include/x86_64-linux-gnu/bits/mathcalls.h \
+ /usr/include/x86_64-linux-gnu/bits/mathinline.h \
+ ../../modules/core/includes/MALLOC.h \
+ ../../modules/core/includes/sci_mem_alloc.h \
+ ../../modules/output_stream/includes/sciprint.h \
+ ../../modules/core/includes/BOOL.h \
+ ../../modules/core/includes/returnanan.h \
+ ../../modules/core/includes/machine.h src/c/xls.h \
+ ../../modules/fileio/includes/mseek.h \
+ ../../modules/fileio/includes/dynlib_fileio.h \
+ ../../modules/core/includes/machine.h \
+ ../../modules/fileio/includes/mtell.h \
+ ../../modules/fileio/includes/mget.h
+
+/usr/include/stdc-predef.h:
+
+/usr/include/stdlib.h:
+
+/usr/include/features.h:
+
+/usr/include/x86_64-linux-gnu/sys/cdefs.h:
+
+/usr/include/x86_64-linux-gnu/bits/wordsize.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitflags.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
+
+/usr/include/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap.h:
+
+/usr/include/x86_64-linux-gnu/bits/types.h:
+
+/usr/include/x86_64-linux-gnu/bits/typesizes.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
+
+/usr/include/x86_64-linux-gnu/sys/types.h:
+
+/usr/include/time.h:
+
+/usr/include/x86_64-linux-gnu/sys/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/sigset.h:
+
+/usr/include/x86_64-linux-gnu/bits/time.h:
+
+/usr/include/x86_64-linux-gnu/bits/select2.h:
+
+/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
+
+/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
+
+/usr/include/alloca.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib.h:
+
+/usr/include/stdio.h:
+
+/usr/include/libio.h:
+
+/usr/include/_G_config.h:
+
+/usr/include/wchar.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
+
+/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio2.h:
+
+/usr/include/string.h:
+
+/usr/include/xlocale.h:
+
+/usr/include/x86_64-linux-gnu/bits/string.h:
+
+/usr/include/x86_64-linux-gnu/bits/string2.h:
+
+/usr/include/x86_64-linux-gnu/bits/string3.h:
+
+../../modules/core/includes/core_math.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h:
+
+/usr/include/limits.h:
+
+/usr/include/x86_64-linux-gnu/bits/posix1_lim.h:
+
+/usr/include/x86_64-linux-gnu/bits/local_lim.h:
+
+/usr/include/linux/limits.h:
+
+/usr/include/x86_64-linux-gnu/bits/posix2_lim.h:
+
+/usr/include/math.h:
+
+/usr/include/x86_64-linux-gnu/bits/math-vector.h:
+
+/usr/include/x86_64-linux-gnu/bits/libm-simd-decl-stubs.h:
+
+/usr/include/x86_64-linux-gnu/bits/huge_val.h:
+
+/usr/include/x86_64-linux-gnu/bits/huge_valf.h:
+
+/usr/include/x86_64-linux-gnu/bits/huge_vall.h:
+
+/usr/include/x86_64-linux-gnu/bits/inf.h:
+
+/usr/include/x86_64-linux-gnu/bits/nan.h:
+
+/usr/include/x86_64-linux-gnu/bits/mathdef.h:
+
+/usr/include/x86_64-linux-gnu/bits/mathcalls.h:
+
+/usr/include/x86_64-linux-gnu/bits/mathinline.h:
+
+../../modules/core/includes/MALLOC.h:
+
+../../modules/core/includes/sci_mem_alloc.h:
+
+../../modules/output_stream/includes/sciprint.h:
+
+../../modules/core/includes/BOOL.h:
+
+../../modules/core/includes/returnanan.h:
+
+../../modules/core/includes/machine.h:
+
+src/c/xls.h:
+
+../../modules/fileio/includes/mseek.h:
+
+../../modules/fileio/includes/dynlib_fileio.h:
+
+../../modules/core/includes/machine.h:
+
+../../modules/fileio/includes/mtell.h:
+
+../../modules/fileio/includes/mget.h:
diff --git a/modules/spreadsheet/src/c/.dirstamp b/modules/spreadsheet/src/c/.dirstamp
new file mode 100755
index 000000000..e69de29bb
--- /dev/null
+++ b/modules/spreadsheet/src/c/.dirstamp
diff --git a/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-checkCsvWriteFormat.o b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-checkCsvWriteFormat.o
new file mode 100755
index 000000000..4a7d4c817
--- /dev/null
+++ b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-checkCsvWriteFormat.o
Binary files differ
diff --git a/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-csvDefault.o b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-csvDefault.o
new file mode 100755
index 000000000..a8a212d90
--- /dev/null
+++ b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-csvDefault.o
Binary files differ
diff --git a/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-csvRead.o b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-csvRead.o
new file mode 100755
index 000000000..852a1fd25
--- /dev/null
+++ b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-csvRead.o
Binary files differ
diff --git a/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-csvWrite.o b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-csvWrite.o
new file mode 100755
index 000000000..f9e0d338f
--- /dev/null
+++ b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-csvWrite.o
Binary files differ
diff --git a/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-getRange.o b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-getRange.o
new file mode 100755
index 000000000..ac5a5ef31
--- /dev/null
+++ b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-getRange.o
Binary files differ
diff --git a/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-splitLine.o b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-splitLine.o
new file mode 100755
index 000000000..a2e96c293
--- /dev/null
+++ b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-splitLine.o
Binary files differ
diff --git a/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-utftolatin.o b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-utftolatin.o
new file mode 100755
index 000000000..776ed2520
--- /dev/null
+++ b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-utftolatin.o
Binary files differ
diff --git a/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-xls.o b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-xls.o
new file mode 100755
index 000000000..585e80904
--- /dev/null
+++ b/modules/spreadsheet/src/c/.libs/libscispreadsheet_algo_la-xls.o
Binary files differ
diff --git a/modules/spreadsheet/src/c/DllmainSpreadsheet.c b/modules/spreadsheet/src/c/DllmainSpreadsheet.c
new file mode 100755
index 000000000..29f2a419b
--- /dev/null
+++ b/modules/spreadsheet/src/c/DllmainSpreadsheet.c
@@ -0,0 +1,33 @@
+
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2007-2008 - INRIA - Allan CORNET <allan.cornet@inria.fr>
+ *
+ * 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.1-en.txt
+ *
+ */
+
+#include <windows.h>
+/*--------------------------------------------------------------------------*/
+#pragma comment(lib,"../../bin/libintl.lib")
+/*--------------------------------------------------------------------------*/
+int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
+{
+ switch (reason)
+ {
+ case DLL_PROCESS_ATTACH:
+ break;
+ case DLL_PROCESS_DETACH:
+ break;
+ case DLL_THREAD_ATTACH:
+ break;
+ case DLL_THREAD_DETACH:
+ break;
+ }
+ return 1;
+}
+/*--------------------------------------------------------------------------*/
diff --git a/modules/spreadsheet/src/c/checkCsvWriteFormat.c b/modules/spreadsheet/src/c/checkCsvWriteFormat.c
new file mode 100755
index 000000000..005984092
--- /dev/null
+++ b/modules/spreadsheet/src/c/checkCsvWriteFormat.c
@@ -0,0 +1,99 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010-2011 - 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.1-en.txt
+ *
+ */
+#include <string.h>
+#include <ctype.h>
+#include "csvDefault.h"
+#include "MALLOC.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
+#include "checkCsvWriteFormat.h"
+// =============================================================================
+#define NB_FORMAT_SUPPORTED 7
+static const char *supportedFormat[NB_FORMAT_SUPPORTED] =
+{"lf", "lg", "d", "i", "e", "f", "g"};
+// =============================================================================
+static char *replaceInFormat(const char *format);
+static char *getCleanedFormat(const char *format);
+// =============================================================================
+int checkCsvWriteFormat(const char *format)
+{
+ if (format)
+ {
+ char *tokenPercent1 = strchr((char*)format, '%');
+ char *tokenPercent2 = strrchr((char*)format, '%');
+ if ((tokenPercent2 && tokenPercent1) && (tokenPercent1 == tokenPercent2))
+ {
+ char *cleanedFormat = getCleanedFormat(format);
+ if (cleanedFormat)
+ {
+ FREE(cleanedFormat);
+ cleanedFormat = NULL;
+ return 0;
+ }
+ }
+ }
+ return 1;
+}
+// =============================================================================
+static char *replaceInFormat(const char *format)
+{
+ if (format)
+ {
+ char *cleanedFormat = getCleanedFormat(format);
+ if (cleanedFormat)
+ {
+ FREE(cleanedFormat);
+ cleanedFormat = NULL;
+ return strdup("%s");
+ }
+ }
+
+ return NULL;
+}
+// =============================================================================
+static char *getCleanedFormat(const char *format)
+{
+ char *cleanedFormat = NULL;
+ if (format)
+ {
+ char *percent = strchr((char*)format, '%');
+ if (percent)
+ {
+ int i = 0;
+ for (i = 0; i < NB_FORMAT_SUPPORTED; i++)
+ {
+ char *token = strstr(percent, supportedFormat[i]);
+ if (token)
+ {
+ size_t nbcharacters = strlen(percent) - strlen(token);
+ cleanedFormat = strdup(percent);
+ cleanedFormat[nbcharacters] = 0;
+ if ( ((nbcharacters - 1 > 0) && (isdigit(cleanedFormat[nbcharacters - 1])) ||
+ (cleanedFormat[nbcharacters - 1]) == '.') ||
+ (cleanedFormat[nbcharacters - 1]) == '%')
+ {
+ strcat(cleanedFormat, supportedFormat[i]);
+ return cleanedFormat;
+ }
+ else
+ {
+ FREE(cleanedFormat);
+ cleanedFormat = NULL;
+ }
+ }
+ }
+ }
+ }
+ return cleanedFormat;
+}
+// =============================================================================
diff --git a/modules/spreadsheet/src/c/checkCsvWriteFormat.h b/modules/spreadsheet/src/c/checkCsvWriteFormat.h
new file mode 100755
index 000000000..6f02d7e92
--- /dev/null
+++ b/modules/spreadsheet/src/c/checkCsvWriteFormat.h
@@ -0,0 +1,27 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010-2011 - 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.1-en.txt
+ *
+ */
+#ifndef __CHECKCSVWRITEFORMAT_H__
+#define __CHECKCSVWRITEFORMAT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ int checkCsvWriteFormat(const char *format);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __CHECKCSVWRITEFORMAT_H__ */
+// =============================================================================
diff --git a/modules/spreadsheet/src/c/csvDefault.c b/modules/spreadsheet/src/c/csvDefault.c
new file mode 100755
index 000000000..5e86b9d71
--- /dev/null
+++ b/modules/spreadsheet/src/c/csvDefault.c
@@ -0,0 +1,439 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010-2011 - 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.1-en.txt
+ *
+ */
+#include <string.h>
+#include "csvDefault.h"
+#include "MALLOC.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
+#include "checkCsvWriteFormat.h"
+// =============================================================================
+#define DEFAULT_CSV_SEPARATOR ","
+#define DEFAULT_CSV_DECIMAL "."
+#define DEFAULT_CSV_PRECISION "%.17lg"
+#define DEFAULT_CSV_COMMENTS_REGEXP ""
+#ifdef _MSC_VER
+#define DEFAULT_CSV_EOL "\r\n"
+#else
+#define DEFAULT_CSV_EOL "\n"
+#endif
+#define CSV_DECIMAL_MODE_1 DEFAULT_CSV_DECIMAL
+#define CSV_DECIMAL_MODE_2 ","
+#define DEFAULT_CSV_CONVERSION "double"
+#define CSV_CONVERSION_MODE_1 DEFAULT_CSV_CONVERSION
+#define CSV_CONVERSION_MODE_2 "string"
+#define DEFAULT_CSV_ENCODING "utf-8"
+#define DEFAULT_CSV_ENCODING_MODE1 "utf-8"
+#define DEFAULT_CSV_ENCODING_MODE2 "iso-latin"
+#define CSV_IGNORE_BLANK_LINE_MODE_1 "off"
+#define CSV_IGNORE_BLANK_LINE_MODE_2 "on"
+#define DEFAULT_IGNORE_BLANK_LINE CSV_IGNORE_BLANK_LINE_MODE_2
+// =============================================================================
+static char *defaultCsvSeparator = NULL;
+static char *defaultCsvDecimal = NULL;
+static char *defaultCsvConversion = NULL;
+static char *defaultCsvPrecision = NULL;
+static char *defaultCsvCommentsRegExp = NULL;
+static char *defaultCsvEOL = NULL;
+static char *defaultCsvEncoding = NULL;
+static char *defaultCsvIgnoreBlankLine = NULL;
+// =============================================================================
+static int initializeCsvDefaultValues(void);
+// =============================================================================
+const char *getCsvDefaultSeparator(void)
+{
+ initializeCsvDefaultValues();
+ return defaultCsvSeparator;
+}
+// =============================================================================
+const char *getCsvDefaultDecimal(void)
+{
+ initializeCsvDefaultValues();
+ return defaultCsvDecimal;
+}
+// =============================================================================
+const char *getCsvDefaultConversion(void)
+{
+ initializeCsvDefaultValues();
+ return defaultCsvConversion;
+}
+// =============================================================================
+const char *getCsvDefaultPrecision(void)
+{
+ initializeCsvDefaultValues();
+ return defaultCsvPrecision;
+}
+// =============================================================================
+const char *getCsvDefaultCommentsRegExp(void)
+{
+ initializeCsvDefaultValues();
+ return defaultCsvCommentsRegExp;
+}
+// =============================================================================
+const char *getCsvDefaultEOL(void)
+{
+ initializeCsvDefaultValues();
+ return defaultCsvEOL;
+}
+// =============================================================================
+const char *getCsvDefaultEncoding(void)
+{
+ initializeCsvDefaultValues();
+ return defaultCsvEncoding;
+}
+// =============================================================================
+const char *getCsvDefaultCsvIgnoreBlankLine(void)
+{
+ initializeCsvDefaultValues();
+ return defaultCsvIgnoreBlankLine;
+}
+// =============================================================================
+int setCsvDefaultSeparator(const char *separator)
+{
+ if (initializeCsvDefaultValues())
+ {
+ return 1;
+ }
+ if (separator == NULL)
+ {
+ return 1;
+ }
+
+ if (strcmp(separator, getCsvDefaultDecimal()) == 0)
+ {
+ return 1;
+ }
+
+ if (defaultCsvSeparator)
+ {
+ FREE(defaultCsvSeparator);
+ }
+ defaultCsvSeparator = strdup(separator);
+ if (defaultCsvSeparator == NULL)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+// =============================================================================
+int setCsvDefaultDecimal(const char *decimal)
+{
+ if (initializeCsvDefaultValues())
+ {
+ return 1;
+ }
+ if (decimal == NULL)
+ {
+ return 1;
+ }
+
+ /* decimal separator supported . and , */
+ if ((strcmp(decimal, CSV_DECIMAL_MODE_1) == 0) ||
+ (strcmp(decimal, CSV_DECIMAL_MODE_2) == 0))
+ {
+ if (defaultCsvDecimal)
+ {
+ FREE(defaultCsvDecimal);
+ }
+ defaultCsvDecimal = strdup(decimal);
+ if (defaultCsvDecimal)
+ {
+ return 0;
+ }
+ }
+ return 1;
+}
+// =============================================================================
+int setCsvDefaultConversion(const char *conversion)
+{
+ if (initializeCsvDefaultValues())
+ {
+ return 1;
+ }
+ if (conversion == NULL)
+ {
+ return 1;
+ }
+
+ if ((strcmp(conversion, CSV_CONVERSION_MODE_1) == 0) ||
+ (strcmp(conversion, CSV_CONVERSION_MODE_2) == 0))
+ {
+ if (defaultCsvConversion)
+ {
+ FREE(defaultCsvConversion);
+ }
+ defaultCsvConversion = strdup(conversion);
+ if (defaultCsvConversion)
+ {
+ return 0;
+ }
+ }
+
+ return 1;
+}
+// =============================================================================
+int setCsvDefaultPrecision(const char *precision)
+{
+ if (initializeCsvDefaultValues())
+ {
+ return 1;
+ }
+ if (precision == NULL)
+ {
+ return 1;
+ }
+ if (checkCsvWriteFormat(precision) == 0)
+ {
+ if (defaultCsvPrecision)
+ {
+ FREE(defaultCsvPrecision);
+ }
+ defaultCsvPrecision = strdup(precision);
+ if (defaultCsvPrecision)
+ {
+ return 0;
+ }
+ }
+ return 1;
+}
+// =============================================================================
+int setCsvDefaultCsvIgnoreBlankLine(const char *blankMode)
+{
+ if (initializeCsvDefaultValues())
+ {
+ return 1;
+ }
+ if (blankMode == NULL)
+ {
+ return 1;
+ }
+ if ((strcmp(blankMode, CSV_IGNORE_BLANK_LINE_MODE_1) == 0) ||
+ (strcmp(blankMode, CSV_IGNORE_BLANK_LINE_MODE_2) == 0))
+ {
+ if (defaultCsvIgnoreBlankLine)
+ {
+ FREE(defaultCsvIgnoreBlankLine);
+ }
+ defaultCsvIgnoreBlankLine = strdup(blankMode);
+ if (defaultCsvIgnoreBlankLine)
+ {
+ return 0;
+ }
+ }
+ return 1;
+}
+// =============================================================================
+static int initializeCsvDefaultValues(void)
+{
+ if (defaultCsvSeparator == NULL)
+ {
+ defaultCsvSeparator = strdup(DEFAULT_CSV_SEPARATOR);
+ }
+
+ if (defaultCsvDecimal == NULL)
+ {
+ defaultCsvDecimal = strdup(DEFAULT_CSV_DECIMAL);
+ }
+
+ if (defaultCsvConversion == NULL)
+ {
+ defaultCsvConversion = strdup(DEFAULT_CSV_CONVERSION);
+ }
+
+ if (defaultCsvPrecision == NULL)
+ {
+ defaultCsvPrecision = strdup(DEFAULT_CSV_PRECISION);
+ }
+
+ if (defaultCsvCommentsRegExp == NULL)
+ {
+ defaultCsvCommentsRegExp = strdup(DEFAULT_CSV_COMMENTS_REGEXP);
+ }
+
+ if (defaultCsvEOL == NULL)
+ {
+ defaultCsvEOL = strdup(DEFAULT_CSV_EOL);
+ }
+
+ if (defaultCsvEncoding == NULL)
+ {
+ defaultCsvEncoding = strdup(DEFAULT_CSV_ENCODING);
+ }
+
+ if (defaultCsvIgnoreBlankLine == NULL)
+ {
+ defaultCsvIgnoreBlankLine = strdup(DEFAULT_IGNORE_BLANK_LINE);
+ }
+
+ if ((defaultCsvSeparator == NULL) ||
+ (defaultCsvDecimal == NULL) ||
+ (defaultCsvConversion == NULL) ||
+ (defaultCsvPrecision == NULL) ||
+ (defaultCsvCommentsRegExp == NULL) ||
+ (defaultCsvEOL == NULL) ||
+ (defaultCsvEncoding == NULL) ||
+ (defaultCsvIgnoreBlankLine == NULL))
+ {
+ return 1;
+ }
+
+ return 0;
+}
+// =============================================================================
+int setCsvDefaultReset(void)
+{
+ if (defaultCsvSeparator)
+ {
+ FREE(defaultCsvSeparator);
+ defaultCsvSeparator = NULL;
+ }
+ if (defaultCsvDecimal)
+ {
+ FREE(defaultCsvDecimal);
+ defaultCsvDecimal = NULL;
+ }
+ if (defaultCsvConversion)
+ {
+ FREE(defaultCsvConversion);
+ defaultCsvConversion = NULL;
+ }
+ if (defaultCsvPrecision)
+ {
+ FREE(defaultCsvPrecision);
+ defaultCsvPrecision = NULL;
+ }
+ if (defaultCsvCommentsRegExp)
+ {
+ FREE(defaultCsvCommentsRegExp);
+ defaultCsvCommentsRegExp = NULL;
+ }
+ if (defaultCsvEOL)
+ {
+ FREE(defaultCsvEOL);
+ defaultCsvEOL = NULL;
+ }
+ if (defaultCsvEncoding)
+ {
+ FREE(defaultCsvEncoding);
+ defaultCsvEncoding = NULL;
+ }
+ if (defaultCsvIgnoreBlankLine)
+ {
+ FREE(defaultCsvIgnoreBlankLine);
+ defaultCsvIgnoreBlankLine = NULL;
+ }
+ return initializeCsvDefaultValues();
+}
+// =============================================================================
+int setCsvDefaultCommentsRegExp(const char *commentsRegExp)
+{
+ if (initializeCsvDefaultValues())
+ {
+ return 1;
+ }
+ if (commentsRegExp == NULL)
+ {
+ return 1;
+ }
+
+ if (strcmp(commentsRegExp, getCsvDefaultCommentsRegExp()) == 0)
+ {
+ return 1;
+ }
+
+ if (defaultCsvCommentsRegExp)
+ {
+ FREE(defaultCsvCommentsRegExp);
+ defaultCsvCommentsRegExp = NULL;
+ }
+
+ defaultCsvCommentsRegExp = strdup(commentsRegExp);
+
+ if (defaultCsvDecimal == NULL)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+// =============================================================================
+int setCsvDefaultEOL(const char *eol)
+{
+ if (initializeCsvDefaultValues())
+ {
+ return 1;
+ }
+ if (eol == NULL)
+ {
+ return 1;
+ }
+
+ if (strcmp(eol, getCsvDefaultEOL()) == 0)
+ {
+ return 0;
+ }
+
+ if (defaultCsvEOL)
+ {
+ FREE(defaultCsvEOL);
+ defaultCsvEOL = NULL;
+ }
+
+ defaultCsvEOL = strdup(eol);
+
+ if (defaultCsvEOL == NULL)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+// =============================================================================
+int setCsvDefaultEncoding(const char *encoding)
+{
+ if (initializeCsvDefaultValues())
+ {
+ return 1;
+ }
+ if (encoding == NULL)
+ {
+ return 1;
+ }
+
+ if (strcmp(encoding, getCsvDefaultEncoding()) == 0)
+ {
+ return 1;
+ }
+
+ if ((strcmp(encoding, DEFAULT_CSV_ENCODING_MODE1) != 0) &&
+ (strcmp(encoding, DEFAULT_CSV_ENCODING_MODE2) != 0))
+ {
+ return 1;
+ }
+
+ if (defaultCsvEncoding)
+ {
+ FREE(defaultCsvEncoding);
+ defaultCsvEncoding = NULL;
+ }
+
+ defaultCsvEncoding = strdup(encoding);
+
+ if (defaultCsvEncoding == NULL)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+// =============================================================================
diff --git a/modules/spreadsheet/src/c/csvDefault.h b/modules/spreadsheet/src/c/csvDefault.h
new file mode 100755
index 000000000..2fc78531e
--- /dev/null
+++ b/modules/spreadsheet/src/c/csvDefault.h
@@ -0,0 +1,45 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010-2011 - 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.1-en.txt
+ *
+ */
+#ifndef __CSV_DEFAULT_H__
+#define __CSV_DEFAULT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ const char *getCsvDefaultSeparator(void);
+ const char *getCsvDefaultDecimal(void);
+ const char *getCsvDefaultConversion(void);
+ const char *getCsvDefaultPrecision(void);
+ const char *getCsvDefaultCommentsRegExp(void);
+ const char *getCsvDefaultEOL(void);
+ const char *getCsvDefaultEncoding(void);
+ const char *getCsvDefaultCsvIgnoreBlankLine(void);
+
+ int setCsvDefaultSeparator(const char *separator);
+ int setCsvDefaultDecimal(const char *decimal);
+ int setCsvDefaultConversion(const char *conversion);
+ int setCsvDefaultPrecision(const char *precision);
+ int setCsvDefaultCommentsRegExp(const char *commentsRegExp);
+ int setCsvDefaultEOL(const char *eol);
+ int setCsvDefaultEncoding(const char *encoding);
+ int setCsvDefaultCsvIgnoreBlankLine(const char *blankMode);
+
+ int setCsvDefaultReset(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __CSV_DEFAULT_H__ */
+// =============================================================================
diff --git a/modules/spreadsheet/src/c/csvRead.c b/modules/spreadsheet/src/c/csvRead.c
new file mode 100755
index 000000000..fb967c10d
--- /dev/null
+++ b/modules/spreadsheet/src/c/csvRead.c
@@ -0,0 +1,723 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010-2011 - 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.1-en.txt
+ *
+ */
+#include <string.h>
+#include <stdio.h>
+#include "csvRead.h"
+#include "MALLOC.h"
+#include "freeArrayOfString.h"
+#include "mopen.h"
+#include "mgetl.h"
+#include "localization.h"
+#include "expandPathVariable.h"
+#include "FileExist.h"
+#include "mclose.h"
+#include "warningmode.h"
+#include "pcre_private.h"
+#include "sciprint.h"
+#include "splitLine.h"
+#include "strsubst.h"
+#if _MSC_VER
+#include "strdup_windows.h"
+#endif
+#include "csvDefault.h"
+// =============================================================================
+#if _MSC_VER
+#define READ_ONLY_TEXT_MODE "rt"
+#else
+#define READ_ONLY_TEXT_MODE "r"
+#endif
+// =============================================================================
+static int getNumbersOfColumnsInLines(const char **lines, int sizelines,
+ const char *separator);
+static int getNumbersOfColumnsInLine(const char *line, const char *separator);
+static char **getStringsFromLines(const char **lines, int sizelines,
+ const char *separator, const char *decimal,
+ int m, int n);
+static char **removeEmptyLinesAtTheEnd(const char **lines, int *sizelines);
+static char *stripCharacters(const char *line);
+static char **replaceStrings(const char **lines, int nbLines, const char **toreplace, int sizetoreplace);
+static char **extractComments(const char **lines, int nbLines, const char *regexpcomments, int *nbcomments, int *iErr);
+static char **removeComments(const char **lines, int nbLines, const char *regexpcomments, int *nbNewLine, int *iErr);
+static char **removeAllBlankLines(const char **lines, int *sizelines);
+// =============================================================================
+csvResult* csvRead(const char *filename, const char *separator, const char *decimal, const char **toreplace, int sizetoreplace, const char *regexpcomments, int header)
+{
+ char *expandedFilename = NULL;
+ csvResult *result = NULL;
+ int fd = 0;
+ int f_swap = 0;
+ double res = 0.0;
+ int errMOPEN = MOPEN_INVALID_STATUS;
+ int errMGETL = MGETL_ERROR;
+ double dErrClose = 0.;
+ char **lines = NULL;
+ int nblines = 0;
+ char **replacedInLines = NULL;
+ char **pComments = NULL;
+ int nbComments = 0;
+
+ if ((filename == NULL) || (separator == NULL) || (decimal == NULL))
+ {
+ return NULL;
+ }
+
+ expandedFilename = expandPathVariable((char*)filename);
+ if (!FileExist(expandedFilename))
+ {
+ result = (csvResult*)(MALLOC(sizeof(csvResult)));
+ if (result)
+ {
+ result->err = CSV_READ_FILE_NOT_EXIST;
+ result->m = 0;
+ result->n = 0;
+ result->pstrValues = NULL;
+ result->pstrComments = NULL;
+ result->nbComments = 0;
+ }
+
+ FREE(expandedFilename);
+ return result;
+ }
+
+ C2F(mopen)(&fd, expandedFilename, (char*)READ_ONLY_TEXT_MODE, &f_swap, &res, &errMOPEN);
+ FREE(expandedFilename);
+
+ if (errMOPEN != MOPEN_NO_ERROR)
+ {
+ result = (csvResult*)(MALLOC(sizeof(csvResult)));
+ if (result)
+ {
+ result->err = CSV_READ_MOPEN_ERROR;
+ result->m = 0;
+ result->n = 0;
+ result->pstrValues = NULL;
+ result->pstrComments = NULL;
+ result->nbComments = 0;
+
+ }
+ return result;
+ }
+
+ if (header != 0)
+ {
+ mgetl(fd, header, &nblines, &errMGETL);
+ }
+ lines = mgetl(fd, -1, &nblines, &errMGETL);
+
+ C2F(mclose)(&fd, &dErrClose);
+
+ if (errMGETL != MGETL_NO_ERROR)
+ {
+ if (lines)
+ {
+ freeArrayOfString(lines, nblines);
+ lines = NULL;
+ }
+
+ result = (csvResult*)(MALLOC(sizeof(csvResult)));
+ if (result)
+ {
+ result->err = CSV_READ_READLINES_ERROR;
+ result->m = 0;
+ result->n = 0;
+ result->pstrValues = NULL;
+ result->pstrComments = NULL;
+ result->nbComments = 0;
+ }
+ return result;
+ }
+
+ if (regexpcomments)
+ {
+ int iErr = 0;
+
+ pComments = extractComments((const char**)lines, nblines, (const char*)regexpcomments, &nbComments, &iErr);
+
+ if ((iErr == CAN_NOT_COMPILE_PATTERN) || (iErr == DELIMITER_NOT_ALPHANUMERIC))
+ {
+ result = (csvResult*)(MALLOC(sizeof(csvResult)));
+ if (result)
+ {
+ if ((iErr == CAN_NOT_COMPILE_PATTERN) || (iErr == DELIMITER_NOT_ALPHANUMERIC))
+ {
+ iErr = CSV_READ_REGEXP_ERROR;
+ }
+ result->err = (csvReadError)iErr;
+ result->m = 0;
+ result->n = 0;
+ result->pstrValues = NULL;
+ result->pstrComments = NULL;
+ result->nbComments = 0;
+ }
+ return result;
+ }
+
+ if (pComments)
+ {
+ char **pCleanedLines = NULL;
+ int nbCleanedLines = 0;
+ int i = 0;
+
+ pCleanedLines = removeComments((const char**)lines, nblines, (const char*)regexpcomments, &nbCleanedLines, &iErr);
+ if (pCleanedLines)
+ {
+ FREE(lines);
+ lines = pCleanedLines;
+ nblines = nbCleanedLines;
+ }
+
+ }
+ }
+
+ if (toreplace && (sizetoreplace > 0))
+ {
+ replacedInLines = replaceStrings((const char**)lines, nblines, toreplace, sizetoreplace);
+ if (replacedInLines)
+ {
+ freeArrayOfString(lines, nblines);
+ lines = replacedInLines;
+ }
+ }
+
+ result = csvTextScan((const char**)lines, nblines, (const char*)separator, (const char*)decimal);
+ freeArrayOfString(lines, nblines);
+
+ if (result)
+ {
+ result->pstrComments = pComments;
+ result->nbComments = nbComments;
+ }
+ else
+ {
+ freeArrayOfString(pComments, nbComments);
+ }
+
+
+ return result;
+}
+// =============================================================================
+csvResult* csvTextScan(const char **lines, int numberOfLines, const char *separator, const char *decimal)
+{
+ csvResult *result = NULL;
+ int nbRows = 0;
+ int nbColumns = 0;
+ char **cellsStrings = NULL;
+ char **cleanedLines = NULL;
+ int nbLines = numberOfLines;
+
+ if (strcmp(separator, decimal) == 0)
+ {
+ result = (csvResult*)(MALLOC(sizeof(csvResult)));
+ if (result)
+ {
+ result->err = CSV_READ_SEPARATOR_DECIMAL_EQUAL;
+ result->m = 0;
+ result->n = 0;
+ result->pstrValues = NULL;
+ result->pstrComments = NULL;
+ result->nbComments = 0;
+ }
+ return result;
+ }
+
+ // ticket 472
+ {
+ const char *blankMode = getCsvDefaultCsvIgnoreBlankLine();
+ if (strcmp(blankMode, "on") == 0)
+ {
+ char **tmpLines = removeAllBlankLines(lines, &nbLines);
+ if (tmpLines)
+ {
+ freeArrayOfString(cleanedLines, nbLines);
+ cleanedLines = tmpLines;
+ }
+ }
+ else
+ {
+ /* remove last lines empty (bug 7003 in scilab)*/
+ cleanedLines = removeEmptyLinesAtTheEnd(lines, &nbLines);
+ }
+ }
+
+ nbColumns = getNumbersOfColumnsInLines((const char **)cleanedLines, nbLines, separator);
+ if (nbColumns == 0)
+ {
+ result = (csvResult*)(MALLOC(sizeof(csvResult)));
+ if (result)
+ {
+ result->err = CSV_READ_COLUMNS_ERROR;
+ result->m = 0;
+ result->n = 0;
+ result->pstrValues = NULL;
+ result->pstrComments = NULL;
+ result->nbComments = 0;
+ }
+ FREE(cleanedLines);
+ return result;
+ }
+ else
+ {
+ nbRows = nbLines;
+ }
+
+ cellsStrings = getStringsFromLines((const char **)cleanedLines, nbLines, separator, decimal, nbColumns, nbRows);
+ if (cleanedLines)
+ {
+ freeArrayOfString(cleanedLines, nbLines);
+ cleanedLines = NULL;
+ }
+
+ if (cellsStrings)
+ {
+ result = (csvResult*)(MALLOC(sizeof(csvResult)));
+ if (result)
+ {
+ result->err = CSV_READ_NO_ERROR;
+ result->m = nbRows;
+ result->n = nbColumns;
+ result->pstrValues = cellsStrings;
+ result->pstrComments = NULL;
+ result->nbComments = 0;
+ }
+ else
+ {
+ FREE(cellsStrings);
+ }
+ }
+ else
+ {
+ result = (csvResult*)(MALLOC(sizeof(csvResult)));
+ if (result)
+ {
+ result->err = CSV_READ_COLUMNS_ERROR;
+ result->m = 0;
+ result->n = 0;
+ result->pstrValues = NULL;
+ result->pstrComments = NULL;
+ result->nbComments = 0;
+ }
+ }
+ return result;
+}
+// =============================================================================
+void freeCsvResult(csvResult *result)
+{
+ if (result)
+ {
+ if (result->pstrValues)
+ {
+ freeArrayOfString(result->pstrValues, result->m * result->n);
+ result->pstrValues = NULL;
+ }
+ result->m = 0;
+ result->n = 0;
+
+ if (result->pstrComments)
+ {
+ freeArrayOfString(result->pstrComments, result->nbComments);
+ result->pstrComments = NULL;
+ }
+ result->err = CSV_READ_ERROR;
+ FREE(result);
+ result = NULL;
+ }
+}
+// =============================================================================
+static int getNumbersOfColumnsInLines(const char **lines, int sizelines,
+ const char *separator)
+{
+ int previousNbColumns = 0;
+ int NbColumns = 0;
+ BOOL firstLine = TRUE;
+ if (lines)
+ {
+ int i = 0;
+ for (i = 0; i < sizelines; i++)
+ {
+ NbColumns = getNumbersOfColumnsInLine(lines[i], separator);
+ if (firstLine)
+ {
+ previousNbColumns = NbColumns;
+ firstLine = FALSE;
+ }
+ else
+ {
+ if (previousNbColumns != NbColumns)
+ {
+ if (getWarningMode())
+ {
+ sciprint(_("%s: Inconsistency found in the columns. At line %d, found %d columns while the previous had %d.\n"), _("Warning"), i + 1, NbColumns, previousNbColumns);
+ }
+
+ return 0;
+ }
+ }
+ }
+ }
+ return NbColumns;
+}
+// =============================================================================
+static int getNumbersOfColumnsInLine(const char *line, const char *separator)
+{
+ if (line && separator)
+ {
+ int i = 0;
+ int nbTokens = 0;
+ char **splittedStr = splitLineCSV(line, separator, &nbTokens);
+ if (splittedStr)
+ {
+ freeArrayOfString(splittedStr, nbTokens);
+ return nbTokens;
+ }
+ else
+ {
+ int len = (int)strlen(line);
+ if (len > 0)
+ {
+ nbTokens = 1;
+ return nbTokens;
+ }
+ }
+ }
+ return 0;
+}
+// =============================================================================
+static char **getStringsFromLines(const char **lines, int sizelines,
+ const char *separator,
+ const char *decimal,
+ int m, int n)
+{
+ char **results = NULL;
+
+ if (lines == NULL)
+ {
+ return NULL;
+ }
+ if (separator == NULL)
+ {
+ return NULL;
+ }
+ if (m == 0 || n == 0)
+ {
+ return NULL;
+ }
+
+ results = (char**) MALLOC(sizeof(char*) * (m * n));
+ if (results)
+ {
+ int i = 0;
+ for (i = 0; i < sizelines; i++)
+ {
+ int nbTokens = 0;
+ char **lineStrings = splitLineCSV(lines[i], separator, &nbTokens);
+ int j = 0;
+
+ if (lineStrings == NULL)
+ {
+ lineStrings = (char**)MALLOC(sizeof(char*) * 1);
+ lineStrings[0] = strdup(lines[i]);
+ nbTokens = 1;
+ }
+
+ if (m != nbTokens)
+ {
+ freeArrayOfString(results, nbTokens * n);
+ FREE(lineStrings);
+ return NULL;
+ }
+
+ for (j = 0; j < m; j++)
+ {
+
+ if (!decimal)
+ {
+ results[i + n * j] = strdup(lineStrings[j]);
+ }
+ else
+ {
+ /* Proceed to the remplacement of the provided decimal to the default on
+ * usually, it converts "," => "." */
+ results[i + n * j] = strsub(lineStrings[j], decimal, getCsvDefaultDecimal());
+ }
+
+ if (lineStrings[j])
+ {
+ FREE(lineStrings[j]);
+ lineStrings[j] = NULL;
+ }
+ }
+ FREE(lineStrings);
+ }
+ }
+ return results;
+}
+// =============================================================================
+static char **removeEmptyLinesAtTheEnd(const char **lines, int *sizelines)
+{
+ char **returnedLines = NULL;
+ int nbLinesToRemove = 0;
+
+ if (lines)
+ {
+ int i = 0;
+ if (*sizelines >= 1)
+ {
+ for (i = *sizelines - 1; i >= 0; i--)
+ {
+ char *cleanedLine = stripCharacters(lines[i]);
+ if (cleanedLine)
+ {
+ int len = (int) strlen(cleanedLine);
+ FREE(cleanedLine);
+ cleanedLine = NULL;
+ if (len == 0)
+ {
+ nbLinesToRemove++;
+ FREE((char*)lines[i]);
+ lines[i] = NULL;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+
+ if (nbLinesToRemove > 0)
+ {
+ *sizelines = *sizelines - nbLinesToRemove;
+ }
+ returnedLines = (char **)MALLOC(sizeof(char *) * (*sizelines));
+ if (returnedLines)
+ {
+ for (i = 0; i < *sizelines; i++)
+ {
+ returnedLines[i] = strdup(lines[i]);
+ }
+ }
+ }
+ }
+
+ return returnedLines;
+}
+// =============================================================================
+static char **removeAllBlankLines(const char **lines, int *sizelines)
+{
+ char **returnedLines = NULL;
+ int nbLines = 0;
+ if (lines)
+ {
+ int i = 0;
+ for (i = 0; i < *sizelines; i++)
+ {
+ char *cleanedLine = stripCharacters(lines[i]);
+ if (cleanedLine)
+ {
+ int len = (int) strlen(cleanedLine);
+ FREE(cleanedLine);
+ cleanedLine = NULL;
+ if (len != 0)
+ {
+ if (nbLines == 0)
+ {
+ nbLines++;
+ returnedLines = (char**)MALLOC(sizeof(char*) * nbLines);
+ }
+ else
+ {
+ nbLines++;
+ returnedLines = (char**)REALLOC(returnedLines, sizeof(char*) * nbLines);
+ }
+
+ if (returnedLines)
+ {
+ returnedLines[nbLines - 1] = strdup(lines[i]);
+ }
+ else
+ {
+ *sizelines = 0;
+ return NULL;
+ }
+ }
+ }
+ }
+ *sizelines = nbLines;
+ }
+ return returnedLines;
+}
+// =============================================================================
+static char *stripCharacters(const char *line)
+{
+ char *returnedLine = NULL;
+ if (line)
+ {
+ char *tmpLineWithoutTab = strsub((char*)line, "\t", "");
+ if (tmpLineWithoutTab)
+ {
+ char *tmpLineWithoutLF = strsub(tmpLineWithoutTab, "\r", "");
+ if (tmpLineWithoutLF)
+ {
+ char *tmpLineWithoutCR = strsub(tmpLineWithoutTab, "\n", "");
+ if (tmpLineWithoutCR)
+ {
+ returnedLine = strsub(tmpLineWithoutCR, " ", "");
+ FREE(tmpLineWithoutCR);
+ }
+ else
+ {
+ returnedLine = strdup(line);
+ }
+ FREE(tmpLineWithoutLF);
+ tmpLineWithoutLF = NULL;
+ }
+ else
+ {
+ returnedLine = strdup(line);
+ }
+ FREE(tmpLineWithoutTab);
+ tmpLineWithoutTab = NULL;
+ }
+ else
+ {
+ returnedLine = strdup(line);
+ }
+ }
+
+ return returnedLine;
+}
+// =============================================================================
+static char **replaceStrings(const char **lines, int nbLines, const char **toreplace, int sizetoreplace)
+{
+ char **replacedStrings = NULL;
+ int nr = 0;
+
+ nr = sizetoreplace / 2;
+
+ if (lines)
+ {
+ int i = 0;
+
+ replacedStrings = (char**)MALLOC(sizeof(char*) * nbLines);
+ if (replacedStrings)
+ {
+ // Copy the source lines to the target replacedStrings.
+ int j = 0;
+ for (j = 0; j < nbLines; j++)
+ {
+ replacedStrings[j] = strdup(lines[j]);
+ }
+ // Make replacements within the target replacedStrings.
+ for (i = 0; i < nr; i++)
+ {
+ for (j = 0; j < nbLines; j++)
+ {
+ replacedStrings[j] = strsub(replacedStrings[j], toreplace[i], toreplace[nr + i]);
+ }
+ }
+ }
+ }
+ return replacedStrings;
+}
+// =============================================================================
+static char **extractComments(const char **lines, int nbLines,
+ const char *regexpcomments, int *nbcomments, int *iErr)
+{
+ char **pComments = NULL;
+ int i = 0;
+
+ for (i = 0; i < nbLines; i++)
+ {
+ int Output_Start = 0;
+ int Output_End = 0;
+ pcre_error_code answer = pcre_private((char*)lines[i], (char*)regexpcomments, &Output_Start, &Output_End, NULL, NULL);
+
+ if ( (answer == CAN_NOT_COMPILE_PATTERN) || (answer == DELIMITER_NOT_ALPHANUMERIC))
+ {
+ if (pComments)
+ {
+ freeArrayOfString(pComments, *nbcomments);
+ }
+
+ *nbcomments = 0;
+
+ *iErr = answer;
+ return NULL;
+ }
+
+ if ( answer == PCRE_FINISHED_OK )
+ {
+ (*nbcomments)++;
+ if (pComments == NULL)
+ {
+ pComments = (char **)MALLOC(sizeof(char*) * (*nbcomments));
+ }
+ else
+ {
+ pComments = (char **)REALLOC(pComments, sizeof(char*) * (*nbcomments));
+ }
+
+ if (pComments == NULL)
+ {
+ *nbcomments = 0;
+ *iErr = 1;
+ return NULL;
+ }
+ pComments[(*nbcomments) - 1] = strdup(lines[i]);
+ }
+ }
+
+ return pComments;
+}
+// =============================================================================
+static char **removeComments(const char **lines, int nbLines,
+ const char *regexpcomments, int *newNbLines, int *iErr)
+{
+ char **pLinesCleaned = NULL;
+
+ int i = 0;
+ *newNbLines = 0;
+
+ for (i = 0; i < nbLines; i++)
+ {
+ int Output_Start = 0;
+ int Output_End = 0;
+ pcre_error_code answer = pcre_private((char*)lines[i], (char*)regexpcomments, &Output_Start, &Output_End, NULL, NULL);
+ if ( answer == PCRE_FINISHED_OK )
+ {
+ FREE((char*)lines[i]);
+ lines[i] = NULL;
+ }
+ else
+ {
+ (*newNbLines)++;
+ if (pLinesCleaned == NULL)
+ {
+ pLinesCleaned = (char **)MALLOC(sizeof(char*) * (*newNbLines));
+ }
+ else
+ {
+ pLinesCleaned = (char **)REALLOC(pLinesCleaned, sizeof(char*) * (*newNbLines));
+ }
+
+ if (pLinesCleaned == NULL)
+ {
+ *newNbLines = 0;
+ *iErr = 1;
+ return NULL;
+ }
+
+ pLinesCleaned[(*newNbLines) - 1] = (char*)lines[i];
+ }
+ }
+ return pLinesCleaned;
+}
+// =============================================================================
diff --git a/modules/spreadsheet/src/c/csvRead.h b/modules/spreadsheet/src/c/csvRead.h
new file mode 100755
index 000000000..0d3b70372
--- /dev/null
+++ b/modules/spreadsheet/src/c/csvRead.h
@@ -0,0 +1,55 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010-2011 - 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.1-en.txt
+ *
+ */
+#ifndef __CSV_READ_H__
+#define __CSV_READ_H__
+
+typedef enum
+{
+ CSV_READ_NO_ERROR = 0,
+ CSV_READ_MOPEN_ERROR = 1,
+ CSV_READ_FILE_NOT_EXIST = 2,
+ CSV_READ_MEMORY_ALLOCATION = 3,
+ CSV_READ_READLINES_ERROR = 4,
+ CSV_READ_COLUMNS_ERROR = 5,
+ CSV_READ_ERROR = 6,
+ CSV_READ_SEPARATOR_DECIMAL_EQUAL = 7,
+ CSV_READ_REGEXP_ERROR = 8
+} csvReadError;
+
+typedef struct
+{
+ char **pstrValues;
+ int m;
+ int n;
+ char **pstrComments;
+ int nbComments;
+ csvReadError err;
+} csvResult;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ csvResult* csvRead(const char *filename, const char *separator, const char *decimal,
+ const char **toreplace, int sizetoreplace, const char *regexpcomments, int header);
+
+ csvResult* csvTextScan(const char **lines, int numberOfLines, const char *separator, const char *decimal);
+
+ void freeCsvResult(csvResult *result);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __CSV_READ_H__ */
+
diff --git a/modules/spreadsheet/src/c/csvWrite.c b/modules/spreadsheet/src/c/csvWrite.c
new file mode 100755
index 000000000..9a48f80ef
--- /dev/null
+++ b/modules/spreadsheet/src/c/csvWrite.c
@@ -0,0 +1,557 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010-2011 - 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.1-en.txt
+ *
+ */
+#if defined(__linux__)
+#define _GNU_SOURCE /* Bug 5673 fix: avoid dependency on GLIBC_2.7 */
+#endif
+// =============================================================================
+#include <stdio.h>
+#include <string.h>
+#include "stringToDouble.h"
+#include "csvWrite.h"
+#include "mopen.h"
+#include "mgetl.h"
+#include "expandPathVariable.h"
+#include "FileExist.h"
+#include "mclose.h"
+#include "MALLOC.h"
+#include "core_math.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
+#include "strsubst.h"
+#include "csvDefault.h"
+#include "utftolatin.h"
+// =============================================================================
+#define DEFAULT_CSV_WRITE_STRING_FORMAT "%s"
+#define DEFAULT_CSV_WRITE_DOUBLE_FORMAT "%.lg"
+#define PlusStr "+"
+#define LessStr "-"
+#define ComplexStr "i"
+#define EMPTY_STRING ""
+#if _MSC_VER
+#define MODEWFD "wb"
+#else
+#define MODEWFD "w"
+#endif
+#if _MSC_VER
+#define snprintf _snprintf
+#endif
+// =============================================================================
+#ifndef signbit
+static int signbit(double x)
+{
+ union
+ {
+ double d;
+ short s[4];
+ int i[2];
+ } u;
+
+ u.d = x;
+#if SIZEOF_INT == 4
+ return u.i[1] < 0;
+#else
+ return u.s[3] < 0;
+#endif
+}
+#endif /* signbit */
+// =============================================================================
+static int doConvertToLatin(void)
+{
+ const char *encoding = getCsvDefaultEncoding();
+ if (encoding)
+ {
+ return (strcmp(encoding, "iso-latin") == 0) ? 1 : 0;
+ }
+ return 0;
+}
+// =============================================================================
+csvWriteError csvWrite_double(const char *filename,
+ const double *pdValues, int m, int n,
+ const char *separator,
+ const char *decimal,
+ const char *precisionFormat,
+ const char **headersLines,
+ int nbHeadersLines)
+{
+ FILE *fd = NULL;
+ int i = 0, j = 0;
+ char *expandedFilename = NULL;
+ int isIsoLatin = 0;
+
+ if (filename == NULL)
+ {
+ return CSV_WRITE_ERROR;
+ }
+ if (pdValues == NULL)
+ {
+ return CSV_WRITE_ERROR;
+ }
+ if (m < 0 || n < 0)
+ {
+ return CSV_WRITE_ERROR;
+ }
+ if (separator == NULL)
+ {
+ return CSV_WRITE_ERROR;
+ }
+ if (decimal == NULL)
+ {
+ return CSV_WRITE_ERROR;
+ }
+ if (precisionFormat == NULL)
+ {
+ return CSV_WRITE_ERROR;
+ }
+
+ if (strcmp(separator, decimal) == 0)
+ {
+ return CSV_WRITE_SEPARATOR_DECIMAL_EQUAL;
+ }
+
+ expandedFilename = expandPathVariable((char*)filename);
+ wcfopen(fd , filename, MODEWFD);
+ if (expandedFilename)
+ {
+ FREE(expandedFilename);
+ expandedFilename = NULL;
+ }
+ if ( fd == (FILE *)NULL )
+ {
+ return CSV_WRITE_FOPEN_ERROR;
+ }
+
+ isIsoLatin = doConvertToLatin();
+
+ if ((headersLines) && (nbHeadersLines > 0))
+ {
+ for (i = 0; i < nbHeadersLines; i++)
+ {
+ if (isIsoLatin)
+ {
+ char *converted = utftolatin((char*)headersLines[i]);
+ if (converted)
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, converted);
+ FREE(converted);
+ }
+ else
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, headersLines[i]);
+ }
+ }
+ else
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, headersLines[i]);
+ }
+ fprintf(fd, "%s", getCsvDefaultEOL());
+ }
+ }
+
+ for (i = 0; i < m; i++)
+ {
+ for (j = 0; j < n; j++)
+ {
+ if (ISNAN(pdValues[i + m * j]))
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, NanString);
+ }
+ else if (finite(pdValues[i + m * j]))
+ {
+ char buffer[65535];
+ char *result = NULL;
+ sprintf(buffer, precisionFormat, pdValues[i + m * j]);
+ result = strsub(buffer, getCsvDefaultDecimal(), decimal);
+ if (result)
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, result);
+ FREE(result);
+ result = NULL;
+ }
+ else
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_DOUBLE_FORMAT, pdValues[i + m * j]);
+ }
+ }
+ else
+ {
+ if ( signbit(pdValues[i + m * j]) )
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, NegInfString);
+ }
+ else
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, InfString);
+ }
+ }
+ if (j + 1 < n)
+ {
+ fprintf(fd, "%s", separator);
+ }
+ }
+ fprintf(fd, "%s", getCsvDefaultEOL());
+ }
+
+ fclose(fd);
+ return CSV_WRITE_NO_ERROR;
+}
+// =============================================================================
+csvWriteError csvWrite_complex(const char *filename,
+ const double *pdValuesReal,
+ const double *pdValuesImag,
+ int m, int n,
+ const char *separator,
+ const char *decimal,
+ const char *precisionFormat,
+ const char **headersLines,
+ int nbHeadersLines)
+{
+ FILE *fd = NULL;
+ int i = 0, j = 0;
+ char *expandedFilename = NULL;
+ int isIsoLatin = 0;
+
+ if (filename == NULL)
+ {
+ return CSV_WRITE_ERROR;
+ }
+ if (pdValuesReal == NULL)
+ {
+ return CSV_WRITE_ERROR;
+ }
+ if (pdValuesImag == NULL)
+ {
+ return CSV_WRITE_ERROR;
+ }
+ if (m < 0 || n < 0)
+ {
+ return CSV_WRITE_ERROR;
+ }
+ if (separator == NULL)
+ {
+ return CSV_WRITE_ERROR;
+ }
+ if (decimal == NULL)
+ {
+ return CSV_WRITE_ERROR;
+ }
+ if (precisionFormat == NULL)
+ {
+ return CSV_WRITE_ERROR;
+ }
+
+ if (strcmp(separator, decimal) == 0)
+ {
+ return CSV_WRITE_SEPARATOR_DECIMAL_EQUAL;
+ }
+
+ expandedFilename = expandPathVariable((char*)filename);
+ wcfopen(fd , filename, MODEWFD);
+ if (expandedFilename)
+ {
+ FREE(expandedFilename);
+ expandedFilename = NULL;
+ }
+ if ( fd == (FILE *)NULL )
+ {
+ return CSV_WRITE_FOPEN_ERROR;
+ }
+
+ isIsoLatin = doConvertToLatin();
+
+ if ((headersLines) && (nbHeadersLines > 0))
+ {
+ for (i = 0; i < nbHeadersLines; i++)
+ {
+ if (isIsoLatin)
+ {
+ const char *converted = utftolatin((char*)headersLines[i]);
+ if (converted)
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, converted);
+ FREE((char*)converted);
+ converted = NULL;
+ }
+ else
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, headersLines[i]);
+ }
+ }
+ else
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, headersLines[i]);
+ }
+ fprintf(fd, "%s", getCsvDefaultEOL());
+ }
+ }
+
+ for (i = 0; i < m; i++)
+ {
+ for (j = 0; j < n; j++)
+ {
+ char StringValue[65535];
+
+ double realValue = pdValuesReal[i + m * j];
+ double imagValue = pdValuesImag[i + m * j];
+ int hasReal = 0;
+
+ if (ISNAN(realValue))
+ {
+ strcpy(StringValue, NanString);
+ hasReal = 1;
+ }
+ else if (finite(realValue))
+ {
+ if ((realValue != 0) || (finite(imagValue) && (imagValue == 0)))
+ {
+ char buffer[65535];
+ char *result = NULL;
+
+ sprintf(buffer, precisionFormat, pdValuesReal[i + m * j]);
+ result = strsub(buffer, getCsvDefaultDecimal(), decimal);
+ if (result)
+ {
+ strncpy(StringValue, result, sizeof(StringValue) - 1);
+ FREE(result);
+ }
+ else
+ {
+ sprintf(StringValue, DEFAULT_CSV_WRITE_DOUBLE_FORMAT, pdValuesReal[i + m * j]);
+ }
+ hasReal = 1;
+ }
+ }
+ else
+ {
+ if (signbit(realValue))
+ {
+ strcpy(StringValue, NegInfString);
+ }
+ else
+ {
+ strcpy(StringValue, InfString);
+ }
+ hasReal = 1;
+ }
+
+ if (ISNAN(imagValue))
+ {
+ if (hasReal)
+ {
+ strcat(StringValue, PlusStr);
+ strcat(StringValue, NanString);
+ }
+ else
+ {
+ strcpy(StringValue, NanString);
+ }
+ strcat(StringValue, ComplexStr);
+ }
+ else if (finite(imagValue))
+ {
+ if (imagValue != 0)
+ {
+ char buffer[65535];
+ char *result = NULL;
+
+ if (hasReal && (imagValue > 0))
+ {
+ strcat(StringValue, PlusStr);
+ }
+ else if (imagValue < 0)
+ {
+ if (hasReal)
+ {
+ strcat(StringValue, LessStr);
+ }
+ else
+ {
+ strcpy(StringValue, LessStr);
+ }
+ }
+
+ sprintf(buffer, precisionFormat, fabs(imagValue));
+ result = strsub(buffer, getCsvDefaultDecimal(), decimal);
+ if (result)
+ {
+ if ((hasReal) || (imagValue < 0))
+ {
+ strncat(StringValue, result, sizeof(StringValue) - strlen(StringValue) - 1);
+ StringValue[sizeof(StringValue) - 1] = '\0';
+ }
+ else
+ {
+ strncpy(StringValue, result, sizeof(StringValue) - 1);
+ }
+ FREE(result);
+ }
+ else
+ {
+ sprintf(StringValue, DEFAULT_CSV_WRITE_DOUBLE_FORMAT, imagValue);
+ }
+ strcat(StringValue, ComplexStr);
+ }
+ }
+ else
+ {
+ if (hasReal && (signbit(imagValue) == 0))
+ {
+ strcat(StringValue, PlusStr);
+ }
+ else if (signbit(realValue) > 0)
+ {
+ if (hasReal)
+ {
+ strcat(StringValue, LessStr);
+ }
+ else
+ {
+ strcpy(StringValue, LessStr);
+ }
+ }
+ strcat(StringValue, InfString);
+ strcat(StringValue, ComplexStr);
+ }
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, StringValue);
+ if (j + 1 < n)
+ {
+ fprintf(fd, "%s", separator);
+ }
+ }
+ fprintf(fd, "%s", getCsvDefaultEOL());
+ }
+
+ fclose(fd);
+ return CSV_WRITE_NO_ERROR;
+}
+// =============================================================================
+csvWriteError csvWrite_string(const char *filename,
+ const char **pStrValues, int m, int n,
+ const char *separator,
+ const char *decimal,
+ const char **headersLines,
+ int nbHeadersLines)
+{
+ FILE *fd = NULL;
+ int i = 0, j = 0;
+ char *expandedFilename = NULL;
+ int isIsoLatin = 0;
+
+ if (filename == NULL)
+ {
+ return CSV_WRITE_ERROR;
+ }
+ if (pStrValues == NULL)
+ {
+ return CSV_WRITE_ERROR;
+ }
+ if (m < 0 || n < 0)
+ {
+ return CSV_WRITE_ERROR;
+ }
+ if (separator == NULL)
+ {
+ return CSV_WRITE_ERROR;
+ }
+
+ if (strcmp(separator, decimal) == 0)
+ {
+ return CSV_WRITE_SEPARATOR_DECIMAL_EQUAL;
+ }
+
+ expandedFilename = expandPathVariable((char*)filename);
+ wcfopen(fd , filename, MODEWFD);
+ if (expandedFilename)
+ {
+ FREE(expandedFilename);
+ expandedFilename = NULL;
+ }
+ if ( fd == (FILE *)NULL )
+ {
+ return CSV_WRITE_FOPEN_ERROR;
+ }
+
+ isIsoLatin = doConvertToLatin();
+
+ if ((headersLines) && (nbHeadersLines > 0))
+ {
+ for (i = 0; i < nbHeadersLines; i++)
+ {
+ if (isIsoLatin)
+ {
+ const char *converted = utftolatin((char*)headersLines[i]);
+ if (converted)
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, converted);
+ FREE((char*)converted);
+ converted = NULL;
+ }
+ else
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, headersLines[i]);
+ }
+ }
+ else
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, headersLines[i]);
+ }
+ fprintf(fd, "%s", getCsvDefaultEOL());
+ }
+ }
+
+ for (i = 0 ; i < m ; i++ )
+ {
+ for ( j = 0 ; j < n ; j++)
+ {
+ char *result = NULL;
+ result = strsub((char*)(pStrValues[i + m * j]), getCsvDefaultDecimal(), decimal);
+ if (result)
+ {
+ if (isIsoLatin)
+ {
+ char *converted = utftolatin(result);
+ if (converted)
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, converted);
+ FREE(converted);
+ converted = NULL;
+ }
+ else
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, result);
+ }
+ }
+ else
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, result);
+ }
+ FREE(result);
+ result = NULL;
+ }
+ else
+ {
+ fprintf(fd, DEFAULT_CSV_WRITE_STRING_FORMAT, pStrValues[i + m * j]);
+ }
+
+ if (j + 1 < n)
+ {
+ fprintf(fd, "%s", separator);
+ }
+ }
+ fprintf(fd, "%s", getCsvDefaultEOL());
+ }
+
+ fclose(fd);
+ return CSV_WRITE_NO_ERROR;
+}
+// =============================================================================
+
diff --git a/modules/spreadsheet/src/c/csvWrite.h b/modules/spreadsheet/src/c/csvWrite.h
new file mode 100755
index 000000000..0735f246b
--- /dev/null
+++ b/modules/spreadsheet/src/c/csvWrite.h
@@ -0,0 +1,60 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010-2011 - 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.1-en.txt
+ *
+ */
+
+#ifndef __CSV_WRITE_H__
+#define __CSV_WRITE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef enum {
+ CSV_WRITE_NO_ERROR = 0,
+ CSV_WRITE_FOPEN_ERROR = 1,
+ CSV_WRITE_ERROR = 2,
+ CSV_WRITE_SEPARATOR_DECIMAL_EQUAL = 3
+ }
+ csvWriteError;
+
+
+ csvWriteError csvWrite_double(const char *filename,
+ const double *pdValues, int m, int n,
+ const char *separator,
+ const char *decimal,
+ const char *precisionFormat,
+ const char **headersLines,
+ int nbHeadersLines);
+
+ csvWriteError csvWrite_complex(const char *filename,
+ const double *pdValuesReal,
+ const double *pdValuesImag,
+ int m, int n,
+ const char *separator,
+ const char *decimal,
+ const char *precisionFormat,
+ const char **headersLines,
+ int nbHeadersLines);
+
+ csvWriteError csvWrite_string(const char *filename,
+ const char **pStrValues, int m, int n,
+ const char *separator,
+ const char *decimal,
+ const char **headersLines,
+ int nbHeadersLines);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CSV_WRITE_H__ */
+// =============================================================================
+
diff --git a/modules/spreadsheet/src/c/getRange.c b/modules/spreadsheet/src/c/getRange.c
new file mode 100755
index 000000000..d96b61b9d
--- /dev/null
+++ b/modules/spreadsheet/src/c/getRange.c
@@ -0,0 +1,181 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010-2011 - 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.1-en.txt
+ *
+ */
+#include <string.h>
+#include "MALLOC.h"
+#include "getRange.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
+// =============================================================================
+#define SIZE_ARRAY_RANGE 4
+// =============================================================================
+static int getRangeSize(int *lowCoord, int *highCoord, int maxCoord);
+// =============================================================================
+void getSubIndices(const int *iRange, int * R1, int * R2, int * C1, int * C2 )
+{
+ *R1 = iRange[0];
+ *C1 = iRange[1];
+ *R2 = iRange[2];
+ *C2 = iRange[3];
+
+ return;
+}
+// =============================================================================
+int isValidRange(const int *iRange, int sizeArray)
+{
+ int i = 0;
+ int R1 = 0, C1 = 0, R2 = 0, C2 = 0;
+
+ if (iRange == NULL)
+ {
+ return 0;
+ }
+
+ getSubIndices(iRange, &R1, &R2, &C1, &C2 );
+
+ if (sizeArray != SIZE_ARRAY_RANGE)
+ {
+ return 0;
+ }
+
+ if (R1 <= 0)
+ {
+ return 0;
+ }
+ if (R2 <= 0)
+ {
+ return 0;
+ }
+ if (C1 <= 0)
+ {
+ return 0;
+ }
+ if (C2 <= 0)
+ {
+ return 0;
+ }
+ if (R1 > R2)
+ {
+ return 0;
+ }
+ if (C1 > C2)
+ {
+ return 0;
+ }
+
+ return 1;
+}
+// =============================================================================
+char **getRangeAsString(const char **pStrsValues,
+ int nbRows, int nbCols,
+ const int *iRange,
+ int *returnedNbRows, int *returnedNbCols)
+{
+ if (isValidRange(iRange, SIZE_ARRAY_RANGE))
+ {
+ int R1, C1, R2, C2;
+ int rangeSize;
+
+ getSubIndices(iRange, &R1, &R2, &C1, &C2);
+
+ *returnedNbRows = getRangeSize(&R1, &R2, nbRows);
+ *returnedNbCols = getRangeSize(&C1, &C2, nbCols);
+
+ rangeSize = (*returnedNbRows) * (*returnedNbCols);
+ if (rangeSize > 0)
+ {
+ char **newStrArray = (char**)MALLOC(sizeof(char*) * rangeSize);
+ if (newStrArray != NULL)
+ {
+ int i = 0;
+ int j = 0;
+ int k = 0;
+
+ for (j = C1 - 1 ; j < C2 ; j++)
+ {
+ for (i = R1 - 1 ; i < R2 ; i++ )
+ {
+ newStrArray[k] = strdup(pStrsValues[i + nbRows * j]);
+ k++;
+ }
+ }
+ }
+ return newStrArray;
+ }
+ // range is empty, calling function should raise an out of bound error
+ }
+ return NULL;
+}
+// =============================================================================
+complexArray *getRangeAsComplexArray(const complexArray *pComplex,
+ int nbRows, int nbCols,
+ const int *iRange,
+ int *returnedNbRows, int *returnedNbCols)
+{
+ if (isValidRange(iRange, SIZE_ARRAY_RANGE))
+ {
+ int R1, C1, R2, C2;
+ int rangeSize;
+
+ getSubIndices(iRange, &R1, &R2, &C1, &C2 );
+
+ *returnedNbRows = getRangeSize(&R1, &R2, nbRows);
+ *returnedNbCols = getRangeSize(&C1, &C2, nbCols);
+
+ rangeSize = (*returnedNbRows) * (*returnedNbCols);
+ if (rangeSize > 0)
+ {
+ complexArray *newComplexArray =
+ createComplexArrayEmpty(rangeSize);
+ if (newComplexArray != NULL)
+ {
+ int i = 0;
+ int j = 0;
+ int k = 0;
+
+ newComplexArray->isComplex = pComplex->isComplex;
+
+ for (j = C1 - 1 ; j < C2 ; j++)
+ {
+ for (i = R1 - 1 ; i < R2 ; i++)
+ {
+ newComplexArray->realPart[k] = pComplex->realPart[i + (nbRows * j)];
+ if (pComplex->isComplex)
+ {
+ newComplexArray->imagPart[k] = pComplex->imagPart[i + (nbRows * j)];
+ }
+ k++;
+ }
+ }
+ }
+ return newComplexArray;
+ }
+ // range is empty, calling function should raise an out of bound error
+ }
+ return NULL;
+}
+// =============================================================================
+static int getRangeSize(int *lowCoord, int *highCoord, int maxCoord)
+{
+ // IsValidRange has done all checks of range, except on right bound
+ if (*lowCoord <= maxCoord)
+ {
+ if (*highCoord > maxCoord)
+ {
+ *highCoord = maxCoord;
+ }
+ return *highCoord - *lowCoord + 1;
+ }
+ // lower coord is out of bound
+ return 0;
+}
+// =============================================================================
diff --git a/modules/spreadsheet/src/c/getRange.h b/modules/spreadsheet/src/c/getRange.h
new file mode 100755
index 000000000..25a4efe57
--- /dev/null
+++ b/modules/spreadsheet/src/c/getRange.h
@@ -0,0 +1,47 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010-2011 - 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.1-en.txt
+ *
+ */
+#ifndef __GETRANGE_H__
+#define __GETRANGE_H__
+
+#include "doublecomplex.h"
+#include "complex_array.h"
+
+#define SIZE_RANGE_SUPPORTED 4
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ // Extract the strings in pStrsValues which are in the range.
+ char **getRangeAsString(const char **pStrsValues,
+ int nbRows, int nbCols,
+ const int *iRange,
+ int *returnedNbRows, int *returnedNbCols);
+
+
+ // Extract the double complexes in pComplex which are in the range.
+ complexArray *getRangeAsComplexArray(const complexArray *pComplex,
+ int nbRows, int nbCols,
+ const int *iRange,
+ int *returnedNbRows, int *returnedNbCols);
+
+
+ // Returns 1 if the range is valid, returns 0 if not.
+ int isValidRange(const int *range, int sizeArray);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __GETRANGE_H__ */
+// =============================================================================
diff --git a/modules/spreadsheet/src/c/libscispreadsheet_algo_la-checkCsvWriteFormat.lo b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-checkCsvWriteFormat.lo
new file mode 100755
index 000000000..7d1bf7fd6
--- /dev/null
+++ b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-checkCsvWriteFormat.lo
@@ -0,0 +1,12 @@
+# src/c/libscispreadsheet_algo_la-checkCsvWriteFormat.lo - a libtool object file
+# Generated by libtool (GNU libtool) 2.4.2
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/libscispreadsheet_algo_la-checkCsvWriteFormat.o'
+
+# Name of the non-PIC object
+non_pic_object=none
+
diff --git a/modules/spreadsheet/src/c/libscispreadsheet_algo_la-csvDefault.lo b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-csvDefault.lo
new file mode 100755
index 000000000..4732ce50d
--- /dev/null
+++ b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-csvDefault.lo
@@ -0,0 +1,12 @@
+# src/c/libscispreadsheet_algo_la-csvDefault.lo - a libtool object file
+# Generated by libtool (GNU libtool) 2.4.2
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/libscispreadsheet_algo_la-csvDefault.o'
+
+# Name of the non-PIC object
+non_pic_object=none
+
diff --git a/modules/spreadsheet/src/c/libscispreadsheet_algo_la-csvRead.lo b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-csvRead.lo
new file mode 100755
index 000000000..227177c0c
--- /dev/null
+++ b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-csvRead.lo
@@ -0,0 +1,12 @@
+# src/c/libscispreadsheet_algo_la-csvRead.lo - a libtool object file
+# Generated by libtool (GNU libtool) 2.4.2
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/libscispreadsheet_algo_la-csvRead.o'
+
+# Name of the non-PIC object
+non_pic_object=none
+
diff --git a/modules/spreadsheet/src/c/libscispreadsheet_algo_la-csvWrite.lo b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-csvWrite.lo
new file mode 100755
index 000000000..9f4a083be
--- /dev/null
+++ b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-csvWrite.lo
@@ -0,0 +1,12 @@
+# src/c/libscispreadsheet_algo_la-csvWrite.lo - a libtool object file
+# Generated by libtool (GNU libtool) 2.4.2
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/libscispreadsheet_algo_la-csvWrite.o'
+
+# Name of the non-PIC object
+non_pic_object=none
+
diff --git a/modules/spreadsheet/src/c/libscispreadsheet_algo_la-getRange.lo b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-getRange.lo
new file mode 100755
index 000000000..9fa24ec17
--- /dev/null
+++ b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-getRange.lo
@@ -0,0 +1,12 @@
+# src/c/libscispreadsheet_algo_la-getRange.lo - a libtool object file
+# Generated by libtool (GNU libtool) 2.4.2
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/libscispreadsheet_algo_la-getRange.o'
+
+# Name of the non-PIC object
+non_pic_object=none
+
diff --git a/modules/spreadsheet/src/c/libscispreadsheet_algo_la-splitLine.lo b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-splitLine.lo
new file mode 100755
index 000000000..8a190d6da
--- /dev/null
+++ b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-splitLine.lo
@@ -0,0 +1,12 @@
+# src/c/libscispreadsheet_algo_la-splitLine.lo - a libtool object file
+# Generated by libtool (GNU libtool) 2.4.2
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/libscispreadsheet_algo_la-splitLine.o'
+
+# Name of the non-PIC object
+non_pic_object=none
+
diff --git a/modules/spreadsheet/src/c/libscispreadsheet_algo_la-utftolatin.lo b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-utftolatin.lo
new file mode 100755
index 000000000..eae1eed66
--- /dev/null
+++ b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-utftolatin.lo
@@ -0,0 +1,12 @@
+# src/c/libscispreadsheet_algo_la-utftolatin.lo - a libtool object file
+# Generated by libtool (GNU libtool) 2.4.2
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/libscispreadsheet_algo_la-utftolatin.o'
+
+# Name of the non-PIC object
+non_pic_object=none
+
diff --git a/modules/spreadsheet/src/c/libscispreadsheet_algo_la-xls.lo b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-xls.lo
new file mode 100755
index 000000000..d3c479af4
--- /dev/null
+++ b/modules/spreadsheet/src/c/libscispreadsheet_algo_la-xls.lo
@@ -0,0 +1,12 @@
+# src/c/libscispreadsheet_algo_la-xls.lo - a libtool object file
+# Generated by libtool (GNU libtool) 2.4.2
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/libscispreadsheet_algo_la-xls.o'
+
+# Name of the non-PIC object
+non_pic_object=none
+
diff --git a/modules/spreadsheet/src/c/ripole/.deps/.dirstamp b/modules/spreadsheet/src/c/ripole/.deps/.dirstamp
new file mode 100755
index 000000000..e69de29bb
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.deps/.dirstamp
diff --git a/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-bt-int.Plo b/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-bt-int.Plo
new file mode 100755
index 000000000..d75e17ea0
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-bt-int.Plo
@@ -0,0 +1,115 @@
+src/c/ripole/libscispreadsheet_algo_la-bt-int.lo: src/c/ripole/bt-int.c \
+ /usr/include/stdc-predef.h /usr/include/stdio.h /usr/include/features.h \
+ /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \
+ /usr/include/_G_config.h /usr/include/wchar.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
+ /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio2.h /usr/include/stdlib.h \
+ /usr/include/x86_64-linux-gnu/bits/waitflags.h \
+ /usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
+ /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
+ /usr/include/x86_64-linux-gnu/sys/select.h \
+ /usr/include/x86_64-linux-gnu/bits/select.h \
+ /usr/include/x86_64-linux-gnu/bits/sigset.h \
+ /usr/include/x86_64-linux-gnu/bits/time.h \
+ /usr/include/x86_64-linux-gnu/bits/select2.h \
+ /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
+ /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib.h \
+ ../../modules/core/includes/MALLOC.h \
+ ../../modules/core/includes/sci_mem_alloc.h src/c/ripole/bt-int.h
+
+/usr/include/stdc-predef.h:
+
+/usr/include/stdio.h:
+
+/usr/include/features.h:
+
+/usr/include/x86_64-linux-gnu/sys/cdefs.h:
+
+/usr/include/x86_64-linux-gnu/bits/wordsize.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:
+
+/usr/include/x86_64-linux-gnu/bits/types.h:
+
+/usr/include/x86_64-linux-gnu/bits/typesizes.h:
+
+/usr/include/libio.h:
+
+/usr/include/_G_config.h:
+
+/usr/include/wchar.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
+
+/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio2.h:
+
+/usr/include/stdlib.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitflags.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
+
+/usr/include/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
+
+/usr/include/x86_64-linux-gnu/sys/types.h:
+
+/usr/include/time.h:
+
+/usr/include/x86_64-linux-gnu/sys/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/sigset.h:
+
+/usr/include/x86_64-linux-gnu/bits/time.h:
+
+/usr/include/x86_64-linux-gnu/bits/select2.h:
+
+/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
+
+/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
+
+/usr/include/alloca.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib.h:
+
+../../modules/core/includes/MALLOC.h:
+
+../../modules/core/includes/sci_mem_alloc.h:
+
+src/c/ripole/bt-int.h:
diff --git a/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-bytedecoders.Plo b/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-bytedecoders.Plo
new file mode 100755
index 000000000..3bf68bb7c
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-bytedecoders.Plo
@@ -0,0 +1,54 @@
+src/c/ripole/libscispreadsheet_algo_la-bytedecoders.lo: \
+ src/c/ripole/bytedecoders.c /usr/include/stdc-predef.h \
+ /usr/include/stdio.h /usr/include/features.h \
+ /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \
+ /usr/include/_G_config.h /usr/include/wchar.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
+ /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio2.h src/c/ripole/bytedecoders.h
+
+/usr/include/stdc-predef.h:
+
+/usr/include/stdio.h:
+
+/usr/include/features.h:
+
+/usr/include/x86_64-linux-gnu/sys/cdefs.h:
+
+/usr/include/x86_64-linux-gnu/bits/wordsize.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:
+
+/usr/include/x86_64-linux-gnu/bits/types.h:
+
+/usr/include/x86_64-linux-gnu/bits/typesizes.h:
+
+/usr/include/libio.h:
+
+/usr/include/_G_config.h:
+
+/usr/include/wchar.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
+
+/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio2.h:
+
+src/c/ripole/bytedecoders.h:
diff --git a/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-logger.Plo b/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-logger.Plo
new file mode 100755
index 000000000..ddb319ba8
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-logger.Plo
@@ -0,0 +1,187 @@
+src/c/ripole/libscispreadsheet_algo_la-logger.lo: src/c/ripole/logger.c \
+ /usr/include/stdc-predef.h /usr/include/stdio.h /usr/include/features.h \
+ /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \
+ /usr/include/_G_config.h /usr/include/wchar.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
+ /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio2.h /usr/include/stdlib.h \
+ /usr/include/x86_64-linux-gnu/bits/waitflags.h \
+ /usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
+ /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
+ /usr/include/x86_64-linux-gnu/sys/select.h \
+ /usr/include/x86_64-linux-gnu/bits/select.h \
+ /usr/include/x86_64-linux-gnu/bits/sigset.h \
+ /usr/include/x86_64-linux-gnu/bits/time.h \
+ /usr/include/x86_64-linux-gnu/bits/select2.h \
+ /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
+ /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/string.h \
+ /usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \
+ /usr/include/x86_64-linux-gnu/bits/string2.h \
+ /usr/include/x86_64-linux-gnu/bits/string3.h /usr/include/syslog.h \
+ /usr/include/x86_64-linux-gnu/sys/syslog.h \
+ /usr/include/x86_64-linux-gnu/bits/syslog-path.h \
+ /usr/include/x86_64-linux-gnu/bits/syslog.h /usr/include/errno.h \
+ /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
+ /usr/include/x86_64-linux-gnu/asm/errno.h \
+ /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/ctype.h ../../modules/localization/includes/localization.h \
+ ../../modules/core/includes/machine.h /usr/include/libintl.h \
+ /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \
+ src/c/ripole/logger.h ../../modules/core/includes/MALLOC.h \
+ ../../modules/core/includes/sci_mem_alloc.h \
+ ../../modules/localization/includes/charEncoding.h \
+ /usr/include/x86_64-linux-gnu/bits/wchar.h \
+ /usr/include/x86_64-linux-gnu/bits/wchar2.h \
+ /usr/include/x86_64-linux-gnu/sys/stat.h \
+ /usr/include/x86_64-linux-gnu/bits/stat.h \
+ ../../modules/core/includes/BOOL.h
+
+/usr/include/stdc-predef.h:
+
+/usr/include/stdio.h:
+
+/usr/include/features.h:
+
+/usr/include/x86_64-linux-gnu/sys/cdefs.h:
+
+/usr/include/x86_64-linux-gnu/bits/wordsize.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:
+
+/usr/include/x86_64-linux-gnu/bits/types.h:
+
+/usr/include/x86_64-linux-gnu/bits/typesizes.h:
+
+/usr/include/libio.h:
+
+/usr/include/_G_config.h:
+
+/usr/include/wchar.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
+
+/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio2.h:
+
+/usr/include/stdlib.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitflags.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
+
+/usr/include/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
+
+/usr/include/x86_64-linux-gnu/sys/types.h:
+
+/usr/include/time.h:
+
+/usr/include/x86_64-linux-gnu/sys/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/sigset.h:
+
+/usr/include/x86_64-linux-gnu/bits/time.h:
+
+/usr/include/x86_64-linux-gnu/bits/select2.h:
+
+/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
+
+/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
+
+/usr/include/alloca.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib.h:
+
+/usr/include/string.h:
+
+/usr/include/xlocale.h:
+
+/usr/include/x86_64-linux-gnu/bits/string.h:
+
+/usr/include/x86_64-linux-gnu/bits/string2.h:
+
+/usr/include/x86_64-linux-gnu/bits/string3.h:
+
+/usr/include/syslog.h:
+
+/usr/include/x86_64-linux-gnu/sys/syslog.h:
+
+/usr/include/x86_64-linux-gnu/bits/syslog-path.h:
+
+/usr/include/x86_64-linux-gnu/bits/syslog.h:
+
+/usr/include/errno.h:
+
+/usr/include/x86_64-linux-gnu/bits/errno.h:
+
+/usr/include/linux/errno.h:
+
+/usr/include/x86_64-linux-gnu/asm/errno.h:
+
+/usr/include/asm-generic/errno.h:
+
+/usr/include/asm-generic/errno-base.h:
+
+/usr/include/ctype.h:
+
+../../modules/localization/includes/localization.h:
+
+../../modules/core/includes/machine.h:
+
+/usr/include/libintl.h:
+
+/usr/include/locale.h:
+
+/usr/include/x86_64-linux-gnu/bits/locale.h:
+
+src/c/ripole/logger.h:
+
+../../modules/core/includes/MALLOC.h:
+
+../../modules/core/includes/sci_mem_alloc.h:
+
+../../modules/localization/includes/charEncoding.h:
+
+/usr/include/x86_64-linux-gnu/bits/wchar.h:
+
+/usr/include/x86_64-linux-gnu/bits/wchar2.h:
+
+/usr/include/x86_64-linux-gnu/sys/stat.h:
+
+/usr/include/x86_64-linux-gnu/bits/stat.h:
+
+../../modules/core/includes/BOOL.h:
diff --git a/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-ole.Plo b/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-ole.Plo
new file mode 100755
index 000000000..6058126cd
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-ole.Plo
@@ -0,0 +1,195 @@
+src/c/ripole/libscispreadsheet_algo_la-ole.lo: src/c/ripole/ole.c \
+ /usr/include/stdc-predef.h /usr/include/stdio.h /usr/include/features.h \
+ /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \
+ /usr/include/_G_config.h /usr/include/wchar.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
+ /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio2.h /usr/include/stdlib.h \
+ /usr/include/x86_64-linux-gnu/bits/waitflags.h \
+ /usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
+ /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
+ /usr/include/x86_64-linux-gnu/sys/select.h \
+ /usr/include/x86_64-linux-gnu/bits/select.h \
+ /usr/include/x86_64-linux-gnu/bits/sigset.h \
+ /usr/include/x86_64-linux-gnu/bits/time.h \
+ /usr/include/x86_64-linux-gnu/bits/select2.h \
+ /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
+ /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/ctype.h \
+ /usr/include/xlocale.h /usr/include/string.h \
+ /usr/include/x86_64-linux-gnu/bits/string.h \
+ /usr/include/x86_64-linux-gnu/bits/string2.h \
+ /usr/include/x86_64-linux-gnu/bits/string3.h /usr/include/errno.h \
+ /usr/include/x86_64-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
+ /usr/include/x86_64-linux-gnu/asm/errno.h \
+ /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ src/c/ripole/logger.h src/c/ripole/pldstr.h src/c/ripole/bt-int.h \
+ src/c/ripole/bytedecoders.h src/c/ripole/olestream-unwrap.h \
+ src/c/ripole/ole.h ../../modules/localization/includes/localization.h \
+ ../../modules/core/includes/machine.h /usr/include/libintl.h \
+ /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \
+ ../../modules/localization/includes/charEncoding.h \
+ /usr/include/x86_64-linux-gnu/bits/wchar.h \
+ /usr/include/x86_64-linux-gnu/bits/wchar2.h \
+ /usr/include/x86_64-linux-gnu/sys/stat.h \
+ /usr/include/x86_64-linux-gnu/bits/stat.h \
+ ../../modules/core/includes/MALLOC.h \
+ ../../modules/core/includes/sci_mem_alloc.h \
+ ../../modules/core/includes/BOOL.h \
+ ../../modules/fileio/includes/createdirectory.h \
+ ../../modules/fileio/includes/dynlib_fileio.h
+
+/usr/include/stdc-predef.h:
+
+/usr/include/stdio.h:
+
+/usr/include/features.h:
+
+/usr/include/x86_64-linux-gnu/sys/cdefs.h:
+
+/usr/include/x86_64-linux-gnu/bits/wordsize.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:
+
+/usr/include/x86_64-linux-gnu/bits/types.h:
+
+/usr/include/x86_64-linux-gnu/bits/typesizes.h:
+
+/usr/include/libio.h:
+
+/usr/include/_G_config.h:
+
+/usr/include/wchar.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
+
+/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio2.h:
+
+/usr/include/stdlib.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitflags.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
+
+/usr/include/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
+
+/usr/include/x86_64-linux-gnu/sys/types.h:
+
+/usr/include/time.h:
+
+/usr/include/x86_64-linux-gnu/sys/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/sigset.h:
+
+/usr/include/x86_64-linux-gnu/bits/time.h:
+
+/usr/include/x86_64-linux-gnu/bits/select2.h:
+
+/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
+
+/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
+
+/usr/include/alloca.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib.h:
+
+/usr/include/ctype.h:
+
+/usr/include/xlocale.h:
+
+/usr/include/string.h:
+
+/usr/include/x86_64-linux-gnu/bits/string.h:
+
+/usr/include/x86_64-linux-gnu/bits/string2.h:
+
+/usr/include/x86_64-linux-gnu/bits/string3.h:
+
+/usr/include/errno.h:
+
+/usr/include/x86_64-linux-gnu/bits/errno.h:
+
+/usr/include/linux/errno.h:
+
+/usr/include/x86_64-linux-gnu/asm/errno.h:
+
+/usr/include/asm-generic/errno.h:
+
+/usr/include/asm-generic/errno-base.h:
+
+src/c/ripole/logger.h:
+
+src/c/ripole/pldstr.h:
+
+src/c/ripole/bt-int.h:
+
+src/c/ripole/bytedecoders.h:
+
+src/c/ripole/olestream-unwrap.h:
+
+src/c/ripole/ole.h:
+
+../../modules/localization/includes/localization.h:
+
+../../modules/core/includes/machine.h:
+
+/usr/include/libintl.h:
+
+/usr/include/locale.h:
+
+/usr/include/x86_64-linux-gnu/bits/locale.h:
+
+../../modules/localization/includes/charEncoding.h:
+
+/usr/include/x86_64-linux-gnu/bits/wchar.h:
+
+/usr/include/x86_64-linux-gnu/bits/wchar2.h:
+
+/usr/include/x86_64-linux-gnu/sys/stat.h:
+
+/usr/include/x86_64-linux-gnu/bits/stat.h:
+
+../../modules/core/includes/MALLOC.h:
+
+../../modules/core/includes/sci_mem_alloc.h:
+
+../../modules/core/includes/BOOL.h:
+
+../../modules/fileio/includes/createdirectory.h:
+
+../../modules/fileio/includes/dynlib_fileio.h:
diff --git a/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-olestream-unwrap.Plo b/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-olestream-unwrap.Plo
new file mode 100755
index 000000000..6958cfb9e
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-olestream-unwrap.Plo
@@ -0,0 +1,185 @@
+src/c/ripole/libscispreadsheet_algo_la-olestream-unwrap.lo: \
+ src/c/ripole/olestream-unwrap.c /usr/include/stdc-predef.h \
+ /usr/include/stdio.h /usr/include/features.h \
+ /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \
+ /usr/include/_G_config.h /usr/include/wchar.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
+ /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio2.h /usr/include/stdlib.h \
+ /usr/include/x86_64-linux-gnu/bits/waitflags.h \
+ /usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
+ /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
+ /usr/include/x86_64-linux-gnu/sys/select.h \
+ /usr/include/x86_64-linux-gnu/bits/select.h \
+ /usr/include/x86_64-linux-gnu/bits/sigset.h \
+ /usr/include/x86_64-linux-gnu/bits/time.h \
+ /usr/include/x86_64-linux-gnu/bits/select2.h \
+ /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
+ /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/string.h \
+ /usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \
+ /usr/include/x86_64-linux-gnu/bits/string2.h \
+ /usr/include/x86_64-linux-gnu/bits/string3.h /usr/include/ctype.h \
+ /usr/include/errno.h /usr/include/x86_64-linux-gnu/bits/errno.h \
+ /usr/include/linux/errno.h /usr/include/x86_64-linux-gnu/asm/errno.h \
+ /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ src/c/ripole/logger.h src/c/ripole/pldstr.h src/c/ripole/bytedecoders.h \
+ src/c/ripole/olestream-unwrap.h \
+ ../../modules/localization/includes/localization.h \
+ ../../modules/core/includes/machine.h /usr/include/libintl.h \
+ /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \
+ ../../modules/core/includes/MALLOC.h \
+ ../../modules/core/includes/sci_mem_alloc.h \
+ ../../modules/localization/includes/charEncoding.h \
+ /usr/include/x86_64-linux-gnu/bits/wchar.h \
+ /usr/include/x86_64-linux-gnu/bits/wchar2.h \
+ /usr/include/x86_64-linux-gnu/sys/stat.h \
+ /usr/include/x86_64-linux-gnu/bits/stat.h \
+ ../../modules/core/includes/BOOL.h
+
+/usr/include/stdc-predef.h:
+
+/usr/include/stdio.h:
+
+/usr/include/features.h:
+
+/usr/include/x86_64-linux-gnu/sys/cdefs.h:
+
+/usr/include/x86_64-linux-gnu/bits/wordsize.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:
+
+/usr/include/x86_64-linux-gnu/bits/types.h:
+
+/usr/include/x86_64-linux-gnu/bits/typesizes.h:
+
+/usr/include/libio.h:
+
+/usr/include/_G_config.h:
+
+/usr/include/wchar.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
+
+/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio2.h:
+
+/usr/include/stdlib.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitflags.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
+
+/usr/include/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
+
+/usr/include/x86_64-linux-gnu/sys/types.h:
+
+/usr/include/time.h:
+
+/usr/include/x86_64-linux-gnu/sys/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/sigset.h:
+
+/usr/include/x86_64-linux-gnu/bits/time.h:
+
+/usr/include/x86_64-linux-gnu/bits/select2.h:
+
+/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
+
+/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
+
+/usr/include/alloca.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib.h:
+
+/usr/include/string.h:
+
+/usr/include/xlocale.h:
+
+/usr/include/x86_64-linux-gnu/bits/string.h:
+
+/usr/include/x86_64-linux-gnu/bits/string2.h:
+
+/usr/include/x86_64-linux-gnu/bits/string3.h:
+
+/usr/include/ctype.h:
+
+/usr/include/errno.h:
+
+/usr/include/x86_64-linux-gnu/bits/errno.h:
+
+/usr/include/linux/errno.h:
+
+/usr/include/x86_64-linux-gnu/asm/errno.h:
+
+/usr/include/asm-generic/errno.h:
+
+/usr/include/asm-generic/errno-base.h:
+
+src/c/ripole/logger.h:
+
+src/c/ripole/pldstr.h:
+
+src/c/ripole/bytedecoders.h:
+
+src/c/ripole/olestream-unwrap.h:
+
+../../modules/localization/includes/localization.h:
+
+../../modules/core/includes/machine.h:
+
+/usr/include/libintl.h:
+
+/usr/include/locale.h:
+
+/usr/include/x86_64-linux-gnu/bits/locale.h:
+
+../../modules/core/includes/MALLOC.h:
+
+../../modules/core/includes/sci_mem_alloc.h:
+
+../../modules/localization/includes/charEncoding.h:
+
+/usr/include/x86_64-linux-gnu/bits/wchar.h:
+
+/usr/include/x86_64-linux-gnu/bits/wchar2.h:
+
+/usr/include/x86_64-linux-gnu/sys/stat.h:
+
+/usr/include/x86_64-linux-gnu/bits/stat.h:
+
+../../modules/core/includes/BOOL.h:
diff --git a/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-pldstr.Plo b/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-pldstr.Plo
new file mode 100755
index 000000000..0f8349e91
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-pldstr.Plo
@@ -0,0 +1,146 @@
+src/c/ripole/libscispreadsheet_algo_la-pldstr.lo: src/c/ripole/pldstr.c \
+ /usr/include/stdc-predef.h /usr/include/stdio.h /usr/include/features.h \
+ /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \
+ /usr/include/_G_config.h /usr/include/wchar.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
+ /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio2.h /usr/include/string.h \
+ /usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \
+ /usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/stdlib.h \
+ /usr/include/x86_64-linux-gnu/bits/string3.h \
+ /usr/include/x86_64-linux-gnu/bits/waitflags.h \
+ /usr/include/x86_64-linux-gnu/bits/waitstatus.h \
+ /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
+ /usr/include/x86_64-linux-gnu/sys/select.h \
+ /usr/include/x86_64-linux-gnu/bits/select.h \
+ /usr/include/x86_64-linux-gnu/bits/sigset.h \
+ /usr/include/x86_64-linux-gnu/bits/time.h \
+ /usr/include/x86_64-linux-gnu/bits/select2.h \
+ /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
+ /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/ctype.h \
+ src/c/ripole/logger.h src/c/ripole/pldstr.h \
+ ../../modules/core/includes/MALLOC.h \
+ ../../modules/core/includes/sci_mem_alloc.h \
+ ../../modules/localization/includes/localization.h \
+ ../../modules/core/includes/machine.h /usr/include/libintl.h \
+ /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h
+
+/usr/include/stdc-predef.h:
+
+/usr/include/stdio.h:
+
+/usr/include/features.h:
+
+/usr/include/x86_64-linux-gnu/sys/cdefs.h:
+
+/usr/include/x86_64-linux-gnu/bits/wordsize.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:
+
+/usr/include/x86_64-linux-gnu/bits/types.h:
+
+/usr/include/x86_64-linux-gnu/bits/typesizes.h:
+
+/usr/include/libio.h:
+
+/usr/include/_G_config.h:
+
+/usr/include/wchar.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
+
+/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio2.h:
+
+/usr/include/string.h:
+
+/usr/include/xlocale.h:
+
+/usr/include/x86_64-linux-gnu/bits/string.h:
+
+/usr/include/x86_64-linux-gnu/bits/string2.h:
+
+/usr/include/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
+
+/usr/include/stdlib.h:
+
+/usr/include/x86_64-linux-gnu/bits/string3.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitflags.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
+
+/usr/include/x86_64-linux-gnu/sys/types.h:
+
+/usr/include/time.h:
+
+/usr/include/x86_64-linux-gnu/sys/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/sigset.h:
+
+/usr/include/x86_64-linux-gnu/bits/time.h:
+
+/usr/include/x86_64-linux-gnu/bits/select2.h:
+
+/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
+
+/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
+
+/usr/include/alloca.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib.h:
+
+/usr/include/ctype.h:
+
+src/c/ripole/logger.h:
+
+src/c/ripole/pldstr.h:
+
+../../modules/core/includes/MALLOC.h:
+
+../../modules/core/includes/sci_mem_alloc.h:
+
+../../modules/localization/includes/localization.h:
+
+../../modules/core/includes/machine.h:
+
+/usr/include/libintl.h:
+
+/usr/include/locale.h:
+
+/usr/include/x86_64-linux-gnu/bits/locale.h:
diff --git a/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-ripole.Plo b/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-ripole.Plo
new file mode 100755
index 000000000..90f6fc7d7
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.deps/libscispreadsheet_algo_la-ripole.Plo
@@ -0,0 +1,150 @@
+src/c/ripole/libscispreadsheet_algo_la-ripole.lo: src/c/ripole/ripole.c \
+ /usr/include/stdc-predef.h /usr/include/stdio.h /usr/include/features.h \
+ /usr/include/x86_64-linux-gnu/sys/cdefs.h \
+ /usr/include/x86_64-linux-gnu/bits/wordsize.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs.h \
+ /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
+ /usr/include/x86_64-linux-gnu/bits/types.h \
+ /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \
+ /usr/include/_G_config.h /usr/include/wchar.h \
+ /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
+ /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio.h \
+ /usr/include/x86_64-linux-gnu/bits/stdio2.h /usr/include/stdlib.h \
+ /usr/include/x86_64-linux-gnu/bits/waitflags.h \
+ /usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/endian.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap.h \
+ /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
+ /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \
+ /usr/include/x86_64-linux-gnu/sys/select.h \
+ /usr/include/x86_64-linux-gnu/bits/select.h \
+ /usr/include/x86_64-linux-gnu/bits/sigset.h \
+ /usr/include/x86_64-linux-gnu/bits/time.h \
+ /usr/include/x86_64-linux-gnu/bits/select2.h \
+ /usr/include/x86_64-linux-gnu/sys/sysmacros.h \
+ /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
+ /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/string.h \
+ /usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \
+ /usr/include/x86_64-linux-gnu/bits/string2.h \
+ /usr/include/x86_64-linux-gnu/bits/string3.h /usr/include/ctype.h \
+ src/c/ripole/logger.h src/c/ripole/pldstr.h src/c/ripole/ole.h \
+ src/c/ripole/ripole.h ../../modules/localization/includes/localization.h \
+ ../../modules/core/includes/machine.h /usr/include/libintl.h \
+ /usr/include/locale.h /usr/include/x86_64-linux-gnu/bits/locale.h \
+ ../../modules/core/includes/MALLOC.h \
+ ../../modules/core/includes/sci_mem_alloc.h
+
+/usr/include/stdc-predef.h:
+
+/usr/include/stdio.h:
+
+/usr/include/features.h:
+
+/usr/include/x86_64-linux-gnu/sys/cdefs.h:
+
+/usr/include/x86_64-linux-gnu/bits/wordsize.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs.h:
+
+/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h:
+
+/usr/include/x86_64-linux-gnu/bits/types.h:
+
+/usr/include/x86_64-linux-gnu/bits/typesizes.h:
+
+/usr/include/libio.h:
+
+/usr/include/_G_config.h:
+
+/usr/include/wchar.h:
+
+/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
+
+/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdio2.h:
+
+/usr/include/stdlib.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitflags.h:
+
+/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
+
+/usr/include/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/endian.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap.h:
+
+/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
+
+/usr/include/x86_64-linux-gnu/sys/types.h:
+
+/usr/include/time.h:
+
+/usr/include/x86_64-linux-gnu/sys/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/select.h:
+
+/usr/include/x86_64-linux-gnu/bits/sigset.h:
+
+/usr/include/x86_64-linux-gnu/bits/time.h:
+
+/usr/include/x86_64-linux-gnu/bits/select2.h:
+
+/usr/include/x86_64-linux-gnu/sys/sysmacros.h:
+
+/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
+
+/usr/include/alloca.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
+
+/usr/include/x86_64-linux-gnu/bits/stdlib.h:
+
+/usr/include/string.h:
+
+/usr/include/xlocale.h:
+
+/usr/include/x86_64-linux-gnu/bits/string.h:
+
+/usr/include/x86_64-linux-gnu/bits/string2.h:
+
+/usr/include/x86_64-linux-gnu/bits/string3.h:
+
+/usr/include/ctype.h:
+
+src/c/ripole/logger.h:
+
+src/c/ripole/pldstr.h:
+
+src/c/ripole/ole.h:
+
+src/c/ripole/ripole.h:
+
+../../modules/localization/includes/localization.h:
+
+../../modules/core/includes/machine.h:
+
+/usr/include/libintl.h:
+
+/usr/include/locale.h:
+
+/usr/include/x86_64-linux-gnu/bits/locale.h:
+
+../../modules/core/includes/MALLOC.h:
+
+../../modules/core/includes/sci_mem_alloc.h:
diff --git a/modules/spreadsheet/src/c/ripole/.dirstamp b/modules/spreadsheet/src/c/ripole/.dirstamp
new file mode 100755
index 000000000..e69de29bb
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.dirstamp
diff --git a/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-bt-int.o b/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-bt-int.o
new file mode 100755
index 000000000..9ba2120cc
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-bt-int.o
Binary files differ
diff --git a/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-bytedecoders.o b/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-bytedecoders.o
new file mode 100755
index 000000000..88acbd579
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-bytedecoders.o
Binary files differ
diff --git a/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-logger.o b/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-logger.o
new file mode 100755
index 000000000..a80052c19
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-logger.o
Binary files differ
diff --git a/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-ole.o b/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-ole.o
new file mode 100755
index 000000000..9c45581d3
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-ole.o
Binary files differ
diff --git a/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-olestream-unwrap.o b/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-olestream-unwrap.o
new file mode 100755
index 000000000..0f3bbc33c
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-olestream-unwrap.o
Binary files differ
diff --git a/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-pldstr.o b/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-pldstr.o
new file mode 100755
index 000000000..d0cec33d9
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-pldstr.o
Binary files differ
diff --git a/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-ripole.o b/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-ripole.o
new file mode 100755
index 000000000..07358d81c
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/.libs/libscispreadsheet_algo_la-ripole.o
Binary files differ
diff --git a/modules/spreadsheet/src/c/ripole/LICENSE.ripole b/modules/spreadsheet/src/c/ripole/LICENSE.ripole
new file mode 100755
index 000000000..1f85bfb46
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/LICENSE.ripole
@@ -0,0 +1,33 @@
+Copyright (c) 2003, PLD
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the
+following conditions are met:
+
+* Redistributions of source code must retain the above
+copyright notice, this list of conditions and the following
+disclaimer.
+
+* Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following
+disclaimer in the documentation and/or other materials provided
+with the distribution.
+
+* Neither the name of the PLD nor the names of its contributors
+may be used to endorse or promote products derived from this software
+without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
diff --git a/modules/spreadsheet/src/c/ripole/bt-int.c b/modules/spreadsheet/src/c/ripole/bt-int.c
new file mode 100755
index 000000000..fc01f3132
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/bt-int.c
@@ -0,0 +1,130 @@
+/*--------------------------------------------------------------------------*/
+#include <stdio.h>
+#include <stdlib.h>
+/*--------------------------------------------------------------------------*/
+#include "MALLOC.h"
+#include "bt-int.h"
+/*--------------------------------------------------------------------------*/
+int BTI_init( struct bti_node **n )
+{
+ *n = NULL;
+ return 0;
+}
+/*--------------------------------------------------------------------------*/
+int BTI_add( struct bti_node **n, int value )
+{
+ int collision = 0;
+ int dir = 0;
+ struct bti_node *p = NULL, *node = *n;
+
+ /* fprintf(stdout,"Adding %d to %p\n", value, *n);*/
+ while (node != NULL)
+ {
+ if (value > node->data)
+ {
+ p = node;
+ dir = 1;
+ node = node->r;
+ }
+ else if (value < node->data)
+ {
+ p = node;
+ dir = -1;
+ node = node->l;
+ }
+ else if (value == node->data)
+ {
+ collision = 1;
+ break;
+ }
+ }
+
+ if (collision == 0)
+ {
+ struct bti_node *leaf = NULL;
+
+ leaf = MALLOC(sizeof(struct bti_node));
+ if (leaf == NULL)
+ {
+ return -1;
+ }
+
+ leaf->data = value;
+ leaf->l = leaf->r = NULL;
+
+ if (p != NULL)
+ {
+ switch (dir)
+ {
+ case 1:
+ p->r = leaf;
+ break;
+ case -1:
+ p->l = leaf;
+ break;
+ }
+ }
+ else
+ {
+ *n = leaf;
+ }
+ }
+
+ return collision;
+}
+/*--------------------------------------------------------------------------*/
+int BTI_dump( struct bti_node **n )
+{
+ struct bti_node *node = NULL;
+
+ node = *n;
+
+ if (node->l)
+ {
+ BTI_dump(&(node->l));
+ }
+ if (*n)
+ {
+ fprintf(stdout, "%d, ", node->data);
+ }
+ if (node->r)
+ {
+ BTI_dump(&(node->r));
+ }
+
+ return 0;
+
+}
+/*--------------------------------------------------------------------------*/
+int BTI_done( struct bti_node **n )
+{
+ struct bti_node *node = NULL ;
+
+ if (n == NULL)
+ {
+ return 0;
+ }
+ if (*n == NULL)
+ {
+ return 0;
+ }
+
+ node = *n;
+
+ if (node->l)
+ {
+ BTI_done(&(node->l));
+ }
+ if (node->r)
+ {
+ BTI_done(&(node->r));
+ }
+ if (*n)
+ {
+ FREE(*n);
+ *n = NULL;
+ }
+
+ return 0;
+}
+/*--------------------------------------------------------------------------*/
diff --git a/modules/spreadsheet/src/c/ripole/bt-int.h b/modules/spreadsheet/src/c/ripole/bt-int.h
new file mode 100755
index 000000000..202d93820
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/bt-int.h
@@ -0,0 +1,15 @@
+#ifndef __BT_INT__
+#define __BT_INT__
+
+struct bti_node
+{
+ int data;
+ struct bti_node *l, *r;
+};
+
+int BTI_init( struct bti_node **n );
+int BTI_add( struct bti_node **n, int value );
+int BTI_dump( struct bti_node **n );
+int BTI_done( struct bti_node **n );
+
+#endif
diff --git a/modules/spreadsheet/src/c/ripole/bytedecoders.c b/modules/spreadsheet/src/c/ripole/bytedecoders.c
new file mode 100755
index 000000000..24865c064
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/bytedecoders.c
@@ -0,0 +1,77 @@
+#include <stdio.h>
+#include "bytedecoders.h"
+
+/*-----------------------------------------------------------------\
+ Function Name : int
+ Returns Type : unsigned
+ ----Parameter List
+ 1. get_byte_value( unsigned char *start ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+--------------------------------------------------------------------
+ Comments:
+
+--------------------------------------------------------------------
+ Changes:
+
+\------------------------------------------------------------------*/
+int get_1byte_value( unsigned char *start )
+{
+ return (int) * start;
+}
+
+/*-----------------------------------------------------------------\
+ Function Name : int
+ Returns Type : unsigned
+ ----Parameter List
+ 1. get_ushort_value( unsigned char *start ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+--------------------------------------------------------------------
+ Comments:
+
+--------------------------------------------------------------------
+ Changes:
+
+\------------------------------------------------------------------*/
+int get_2byte_value( unsigned char *start )
+{
+ int value = 0;
+
+ value = *start | ((*(start + 1)) << 8);
+
+ return value;
+}
+
+/*-----------------------------------------------------------------\
+ Function Name : int
+ Returns Type : unsigned
+ ----Parameter List
+ 1. get_ulong_value( unsigned char *start ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+--------------------------------------------------------------------
+ Comments:
+
+--------------------------------------------------------------------
+ Changes:
+
+\------------------------------------------------------------------*/
+int get_4byte_value(unsigned char *start )
+{
+ int value = 0;
+
+ value = (*start)
+ | ((*(start + 1)) << 8)
+ | ((*(start + 2)) << 16)
+ | ((*(start + 3)) << 24);
+
+ /* printf("String=0x%x %x %x %x:%u = %d\n", *start, *(start +1), *(start +2), *(start +3), *(start +3), value);*/
+
+ return value;
+}
+
+
diff --git a/modules/spreadsheet/src/c/ripole/bytedecoders.h b/modules/spreadsheet/src/c/ripole/bytedecoders.h
new file mode 100755
index 000000000..3a53e951f
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/bytedecoders.h
@@ -0,0 +1,26 @@
+/*
+** -*- C -*-
+**
+** bytedecoders.h
+** Made by Bruno JOFRET <bruno.jofret@inria.fr>
+**
+** Started on Wed Oct 17 13:54:15 2007 bruno
+** Last update Wed Oct 17 16:51:47 2007 bruno
+**
+** Copyright INRIA 2007
+*/
+
+#ifndef __BYTEDECODERS_H__
+#define __BYTEDECODERS_H__
+
+/** @TODO : Comments ?? */
+int get_1byte_value(unsigned char *start );
+
+/** @TODO : Comments ?? */
+int get_2byte_value(unsigned char *start );
+
+/** @TODO : Comments ?? */
+int get_4byte_value(unsigned char *start );
+
+
+#endif /* __BYTEDECODERS_H__ */
diff --git a/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-bt-int.lo b/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-bt-int.lo
new file mode 100755
index 000000000..16c272b25
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-bt-int.lo
@@ -0,0 +1,12 @@
+# src/c/ripole/libscispreadsheet_algo_la-bt-int.lo - a libtool object file
+# Generated by libtool (GNU libtool) 2.4.2
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/libscispreadsheet_algo_la-bt-int.o'
+
+# Name of the non-PIC object
+non_pic_object=none
+
diff --git a/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-bytedecoders.lo b/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-bytedecoders.lo
new file mode 100755
index 000000000..8d788052e
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-bytedecoders.lo
@@ -0,0 +1,12 @@
+# src/c/ripole/libscispreadsheet_algo_la-bytedecoders.lo - a libtool object file
+# Generated by libtool (GNU libtool) 2.4.2
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/libscispreadsheet_algo_la-bytedecoders.o'
+
+# Name of the non-PIC object
+non_pic_object=none
+
diff --git a/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-logger.lo b/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-logger.lo
new file mode 100755
index 000000000..fced0d284
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-logger.lo
@@ -0,0 +1,12 @@
+# src/c/ripole/libscispreadsheet_algo_la-logger.lo - a libtool object file
+# Generated by libtool (GNU libtool) 2.4.2
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/libscispreadsheet_algo_la-logger.o'
+
+# Name of the non-PIC object
+non_pic_object=none
+
diff --git a/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-ole.lo b/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-ole.lo
new file mode 100755
index 000000000..7e1db6854
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-ole.lo
@@ -0,0 +1,12 @@
+# src/c/ripole/libscispreadsheet_algo_la-ole.lo - a libtool object file
+# Generated by libtool (GNU libtool) 2.4.2
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/libscispreadsheet_algo_la-ole.o'
+
+# Name of the non-PIC object
+non_pic_object=none
+
diff --git a/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-olestream-unwrap.lo b/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-olestream-unwrap.lo
new file mode 100755
index 000000000..50c1fa4e0
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-olestream-unwrap.lo
@@ -0,0 +1,12 @@
+# src/c/ripole/libscispreadsheet_algo_la-olestream-unwrap.lo - a libtool object file
+# Generated by libtool (GNU libtool) 2.4.2
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/libscispreadsheet_algo_la-olestream-unwrap.o'
+
+# Name of the non-PIC object
+non_pic_object=none
+
diff --git a/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-pldstr.lo b/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-pldstr.lo
new file mode 100755
index 000000000..d74c2e337
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-pldstr.lo
@@ -0,0 +1,12 @@
+# src/c/ripole/libscispreadsheet_algo_la-pldstr.lo - a libtool object file
+# Generated by libtool (GNU libtool) 2.4.2
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/libscispreadsheet_algo_la-pldstr.o'
+
+# Name of the non-PIC object
+non_pic_object=none
+
diff --git a/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-ripole.lo b/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-ripole.lo
new file mode 100755
index 000000000..8b731029f
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/libscispreadsheet_algo_la-ripole.lo
@@ -0,0 +1,12 @@
+# src/c/ripole/libscispreadsheet_algo_la-ripole.lo - a libtool object file
+# Generated by libtool (GNU libtool) 2.4.2
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/libscispreadsheet_algo_la-ripole.o'
+
+# Name of the non-PIC object
+non_pic_object=none
+
diff --git a/modules/spreadsheet/src/c/ripole/logger.c b/modules/spreadsheet/src/c/ripole/logger.c
new file mode 100755
index 000000000..31ad2896b
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/logger.c
@@ -0,0 +1,379 @@
+
+/* Abstract logging system used to facilitate multiple modes*/
+/* of logging*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifndef _MSC_VER
+#include <syslog.h>
+#endif
+#include <errno.h>
+#include <stdarg.h>
+#include <ctype.h>
+
+#include "localization.h"
+#include "logger.h"
+#include "MALLOC.h"
+#include "charEncoding.h"
+
+//#define SYSLOG_ENABLE 1
+
+#ifndef _MSC_VER
+static int _LOGGER_mode = _LOGGER_SYSLOG;
+static int _LOGGER_syslog_mode = LOG_MAIL | LOG_INFO;
+#else
+static int _LOGGER_mode = _LOGGER_STDERR;
+static int _LOGGER_syslog_mode = 0;
+#endif
+
+static FILE *_LOGGER_outf;
+
+struct LOGGER_globals
+{
+ int wrap;
+ int wraplength;
+};
+
+/* Create and Initialise the global structure for LOGGER,*/
+/* we init it to have NO wrapping.*/
+
+static struct LOGGER_globals LOGGER_glb = { 0, 0 };
+
+#ifdef _MSC_VER
+#define vsnprintf _vsnprintf
+#endif
+
+/*------------------------------------------------------------------------
+Procedure: LOGGER_get_file ID:1
+Purpose: Returns the pointer to the file being used to output logs to
+Input:
+Output:
+Errors:
+------------------------------------------------------------------------*/
+FILE *LOGGER_get_file( void )
+{
+ return _LOGGER_outf;
+}
+
+
+/*------------------------------------------------------------------------
+Procedure: LOGGER_set_output_mode ID:1
+Purpose: Sets the message/log output method, ie, stderr, stdout
+or syslog
+Input:
+Output:
+Errors:
+------------------------------------------------------------------------*/
+int LOGGER_set_output_mode( int modechoice )
+{
+ _LOGGER_mode = modechoice;
+ return 0;
+}
+
+/*------------------------------------------------------------------------
+Procedure: LOGGER_set_output_file ID:1
+Purpose: Sets the output file for when _LOGGER_mode is set to
+_LOGGER_file
+Input:
+Output:
+Errors:
+------------------------------------------------------------------------*/
+int LOGGER_set_output_file( FILE *f )
+{
+ _LOGGER_outf = f;
+ return 0;
+}
+
+/*------------------------------------------------------------------------
+Procedure: LOGGER_set_syslog_mode ID:1
+Purpose: Sets the mode that messaging to the syslog daemon will
+be sent as (ie, LOG_MAIL|LOG_INFO)
+Input:
+Output:
+Errors:
+------------------------------------------------------------------------*/
+int LOGGER_set_syslog_mode( int syslogmode )
+{
+ _LOGGER_syslog_mode = syslogmode;
+ return 0;
+}
+
+
+
+
+/*------------------------------------------------------------------------
+Procedure: LOGGER_set_logfile ID:1
+Purpose: Opens and setups the internal Log file file pointer with the
+log file as given by lfname
+Input:
+Output:
+Errors:
+------------------------------------------------------------------------*/
+int LOGGER_set_logfile( char *lfname )
+{
+ int result = 0;
+
+ wcfopen(_LOGGER_outf, lfname, "a");
+ if (!_LOGGER_outf)
+ {
+#if !defined(_MSC_VER) && defined(SYSLOG_ENABLE)
+ syslog(1, _("LOGGER_set_logfile: ERROR - Cannot open logfile '%s' (%s)"), lfname, strerror(errno));
+#else
+ fprintf(stderr, _("LOGGER_set_logfile: ERROR - Cannot open logfile '%s' (%s)\n"), lfname, strerror(errno));
+#endif
+ result = -1;
+ }
+
+ return result;
+}
+
+
+
+/*------------------------------------------------------------------------
+Procedure: LOGGER_set_wraplength ID:1
+Purpose: Sets the character count at which LOGGER will break a line
+Input: int length: Positive int indicating number of chracters at which to wrap at
+Output:
+Errors:
+------------------------------------------------------------------------*/
+int LOGGER_set_wraplength( int length )
+{
+ if ( length >= 0 )
+ {
+ LOGGER_glb.wraplength = length;
+ }
+
+ return LOGGER_glb.wraplength;
+}
+
+/*------------------------------------------------------------------------
+Procedure: LOGGER_set_wrap ID:1
+Purpose: Set log output wrapping to on or off
+Input: int level: 0 = no wrap, > 0 = wrap.
+Output:
+Errors:
+------------------------------------------------------------------------*/
+int LOGGER_set_wrap( int level )
+{
+ if ( level >= 0 )
+ {
+ LOGGER_glb.wrap = level;
+ }
+
+ return LOGGER_glb.wrap;
+}
+
+
+
+/*------------------------------------------------------------------------
+Procedure: LOGGER_close_logfile ID:1
+Purpose: Closes the modules log file pointer.
+Input:
+Output:
+Errors:
+------------------------------------------------------------------------*/
+int LOGGER_close_logfile( void )
+{
+ int result = 0;
+
+ if (_LOGGER_outf)
+ {
+ fclose(_LOGGER_outf);
+ }
+
+ return result;
+}
+
+
+
+/*------------------------------------------------------------------------
+Procedure: LOGGER_clean_output ID:1
+Purpose: Checks through the output string for any characters which could cause
+potential 'isssues' with the data writing calls, items such as stray non-escaped
+% characters can cause havoc.
+Input: char *string: Raw string
+int maxsize: Maximum available buffer size for this string to expand to
+Output:
+Errors:
+------------------------------------------------------------------------*/
+int LOGGER_clean_output( char *string, char **buffer )
+{
+ char *newstr;
+ char *p, *q;
+ char *next_space;
+
+ int pc;
+ int slen = (int)strlen( string );
+ int line_size;
+ int maxsize = slen * 2;
+
+ /* First up, allocate maxsize bytes for a temporary new string.*/
+ newstr = MALLOC(slen * 2 + 1);
+ if ( newstr == NULL )
+ {
+ /* FIXME - Report an error here ... to -somewhere-*/
+ return -1;
+ }
+
+ p = newstr;
+ q = string;
+ pc = 0;
+ line_size = 0;
+
+ while (slen--)
+ {
+
+ /* Do we need to apply any wrapping to the output? If so then we*/
+ /* shall embark on a journey of strange space and distance*/
+ /* evaluations to determine if we should wrap now or later*/
+
+ if ( LOGGER_glb.wrap > 0 )
+ {
+ if (isspace((int)*q))
+ {
+ next_space = strpbrk( (q + 1), "\t\n\v " );
+ if (next_space != NULL)
+ {
+ if ((line_size + (next_space - q)) >= LOGGER_glb.wraplength)
+ {
+ *p = '\n';
+ p++;
+ pc++;
+ line_size = 0;
+ }
+ }
+ }
+
+ if ( line_size >= LOGGER_glb.wraplength )
+ {
+ *p = '\n';
+ p++;
+ pc++;
+ line_size = 0;
+ }
+ }
+
+ /* If the string has a % in it, then we need to encode it as*/
+ /* a DOUBLE % symbol.*/
+
+ if (*q == '%')
+ {
+ /* if (strchr("fdlsxXn",*(q+1)))*/
+ /* {*/
+ *p = '%';
+ p++;
+ pc++;
+ /* }*/
+ }
+
+ /* Copy the character of the string in*/
+ *p = *q;
+
+ /* Move everything along.*/
+ q++;
+ p++;
+ pc++;
+ line_size++;
+
+ if ( pc > (maxsize - 1) )
+ {
+ break;
+ }
+ }
+
+ *p = '\0';
+
+ /* This will have to be deallocated later!*/
+ if (newstr)
+ {
+ *buffer = newstr;
+ }
+
+ return 0;
+}
+
+/*------------------------------------------------------------------------
+Procedure: LOGGER_log ID:1
+Purpose: Logs the params as supplied to the required
+output as defined by LOGGER_set_output
+Input:
+Output:
+Errors:
+------------------------------------------------------------------------*/
+int LOGGER_log( char *format, ...)
+{
+ va_list ptr;
+ char tmpoutput[10240];
+ char linebreak[] = "\n";
+ char nolinebreak[] = "";
+ char *lineend;
+ char *output;
+
+
+ /* get our variable arguments*/
+ va_start(ptr, format);
+
+ /* produce output, and spit to the log file*/
+#ifdef NO_SNPRINTF
+ vsprintf(tmpoutput, format, ptr);
+#else
+ vsnprintf(tmpoutput, 10240, format, ptr);
+#endif
+
+ LOGGER_clean_output( tmpoutput, &output );
+
+ if ( output[strlen(output) - 1] == '\n' )
+ {
+ lineend = nolinebreak;
+ }
+ else
+ {
+ lineend = linebreak;
+ }
+
+ if ( output[strlen(output) - 1] == '\n' )
+ {
+ lineend = nolinebreak;
+ }
+ else
+ {
+ lineend = linebreak;
+ }
+
+ /* Send the output to the appropriate output destination*/
+ switch (_LOGGER_mode)
+ {
+ case _LOGGER_SYSLOG:
+#if !defined(_MSC_VER) && defined(SYSLOG_ENABLE)
+ syslog(_LOGGER_syslog_mode, "%s", output);
+ break;
+#endif
+ case _LOGGER_STDERR:
+ fprintf(stderr, "%s%s", output, lineend );
+ break;
+
+ case _LOGGER_STDOUT:
+ fprintf(stdout, "%s%s", output, lineend);
+ fflush(stdout);
+ break;
+ case _LOGGER_FILE:
+ fprintf(_LOGGER_outf, "%s%s", output, lineend);
+ fflush(_LOGGER_outf);
+ break;
+ default:
+ fprintf(stdout, _("LOGGER-Default: %s%s"), output, lineend);
+ }
+
+
+ if (output)
+ {
+ FREE(output);
+ }
+
+ return 0;
+}
+
+
+
+
diff --git a/modules/spreadsheet/src/c/ripole/logger.h b/modules/spreadsheet/src/c/ripole/logger.h
new file mode 100755
index 000000000..96e98c608
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/logger.h
@@ -0,0 +1,29 @@
+
+#ifndef __LOGGER__
+#define __LOGGER__
+/* LOGGER.h */
+
+#define _LOGGER_STDERR 1
+#define _LOGGER_STDOUT 2
+#define _LOGGER_FILE 3
+/* #ifndef _MSC_VER */
+#define _LOGGER_SYSLOG 4
+/* #endif */
+
+#ifndef FL
+#define FL __FILE__,__LINE__
+#endif
+
+int LOGGER_log( char *format, ...);
+int LOGGER_set_output_mode( int modechoice );
+int LOGGER_set_output_file( FILE *f );
+int LOGGER_set_syslog_mode( int syslogmode );
+int LOGGER_set_logfile( char *lfname );
+int LOGGER_set_wraplength( int length );
+int LOGGER_set_wrap( int level );
+
+int LOGGER_close_logfile( void );
+FILE *LOGGER_get_file( void );
+
+int LOGGER_clean_output( char *string, char **buffer );
+#endif
diff --git a/modules/spreadsheet/src/c/ripole/ole.c b/modules/spreadsheet/src/c/ripole/ole.c
new file mode 100755
index 000000000..03e85349d
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/ole.c
@@ -0,0 +1,2136 @@
+#ifdef _MSC_VER
+#include <Windows.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+
+#include "logger.h"
+#include "pldstr.h"
+#include "bt-int.h"
+#include "bytedecoders.h"
+#include "olestream-unwrap.h"
+#include "ole.h"
+#include "localization.h"
+#include "charEncoding.h"
+#include "createdirectory.h"
+/** Sector ID values (predefined) **/
+#define OLE_SECTORID_FREE -1 /** Unallocated sector **/
+#define OLE_SECTORID_ENDOFCHAIN -2 /** Sector marks the end of the a sector-ID chain **/
+#define OLE_SECTORID_SAT -3 /** Sector used by sector allocation Table **/
+#define OLE_SECTORID_MSAT -4 /** Sector used by master sector allocation Table **/
+
+#include "MALLOC.h" /* MALLOC */
+
+/* Main header accessors*/
+#define header_id(x) ((x) +0)
+#define header_clid(x) ((x) +0x08)
+#define header_minor_version(x) ((x) +0x18)
+#define header_dll_version(x) ((x) +0x1a)
+#define header_byte_order(x) ((x) +0x1c)
+#define header_sector_shift(x) ((x) +0x1e)
+#define header_mini_sector_shift(x) ((x) +0x20)
+#define header_fat_sector_count(x) ((x) +0x2c)
+#define header_directory_stream_start_sector(x) ((x) +0x30)
+#define header_mini_cutoff_size(x) ((x) +0x38)
+#define header_mini_fat_start(x) ((x) +0x3c)
+#define header_mini_fat_sector_count(x) ((x) +0x40)
+#define header_dif_start_sector(x) ((x) +0x44)
+#define header_dif_sector_count(x) ((x) +0x48)
+#define header_fat_sectors(x) ((x) +0x4c)
+
+/*Property Storage accessor macros*/
+#define pps_rawname(x) ((x) +0)
+#define pps_sizeofname(x) ((x) +0x40)
+#define pps_type(x) ((x) +0x42)
+#define pps_previouspps(x) ((x) +0x44)
+#define pps_nextpps(x) ((x) +0x48)
+#define pps_directorypps(x) ((x) +0x4c)
+#define pps_time1seconds(x) ((x) +0x64)
+#define pps_time1days(x) ((x) +0x68)
+#define pps_time2seconds(x) ((x) +0x6c)
+#define pps_time2days(x) ((x) +0x70)
+#define pps_propertystart(x) ((x) +0x74)
+#define pps_sizeofproperty(x) ((x) +0x78)
+
+/* Type lengths*/
+#define LEN_BYTE 1
+#define LEN_USHORT 2
+#define LEN_ULONG 4
+
+/* Directory types*/
+#define STGTY_INVALID 0
+#define STGTY_STORAGE 1
+#define STGTY_STREAM 2
+#define STGTY_LOCKBYTES 3
+#define STGTY_PROPERTY 4
+#define STGTY_ROOT 5
+
+/* Directory tag colours*/
+#define DE_RED 0
+#define DE_BLACK 1
+
+#define DOLE if (OLE_DNORMAL(ole->debug))
+#define VOLE if (ole->verbose)
+
+unsigned char OLE_id_v2[] = { 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1 };
+unsigned char OLE_id_v1[] = { 0x0e, 0x11, 0xfc, 0x0d, 0xd0, 0xcf, 0x11, 0xe0 };
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_version
+Returns Type : int
+----Parameter List
+1. void ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_version(void)
+{
+ fprintf(stderr, _("ripOLE: %s\n"), LIBOLE_VERSION);
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_init
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+20041127-2029:PLD: Added file_size initialization
+\------------------------------------------------------------------*/
+int OLE_init(struct OLE_object *ole)
+{
+ ole->debug = 0;
+ ole->verbose = 0;
+ ole->quiet = 0;
+ ole->filename_report_fn = NULL;
+ ole->f = NULL;
+ ole->file_size = 0;
+
+ ole->FAT = NULL;
+ ole->FAT_limit = NULL;
+ ole->miniFAT = NULL;
+ ole->miniFAT_limit = NULL;
+
+ ole->header_block[0] = '\0';
+ ole->ministream = NULL;
+ ole->properties = NULL;
+
+ ole->header.sector_shift = 0;
+ ole->header.mini_sector_shift = 0;
+
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_dir_init
+Returns Type : int
+----Parameter List
+1. struct OLE_directory_entry *dir ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_dir_init(struct OLE_directory_entry *dir)
+{
+ memset(dir->element_name, '\0', OLE_DIRECTORY_ELEMENT_NAME_SIZE);
+ dir->element_name_byte_count = 0;
+
+ dir->element_type = 0;
+ dir->element_colour = 0;
+
+ dir->left_child = 0;
+ dir->right_child = 0;
+ dir->root = 0;
+
+ dir->class[0] = '\0';
+ dir->userflags = 0;
+ dir->timestamps[0] = '\0';
+ dir->start_sector = 0;
+ dir->stream_size = 0;
+
+ return 0;
+};
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_set_verbose
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole,
+2. int level ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_set_verbose(struct OLE_object *ole, int level)
+{
+ ole->verbose = level;
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_set_quiet
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole,
+2. int level ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_set_quiet(struct OLE_object *ole, int level)
+{
+ ole->quiet = level;
+ ole->verbose = 0;
+ ole->debug = 0;
+
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_set_debug
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole,
+2. int level ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_set_debug(struct OLE_object *ole, int level)
+{
+ ole->debug = level;
+ if (ole->debug > 0)
+ {
+ LOGGER_log(_("%s:%d:OLE_set_debug: Debug level set to %d"), FL, ole->debug);
+ }
+
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_set_save_unknown_streams
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole,
+2. int level ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_set_save_unknown_streams(struct OLE_object *ole, int level)
+{
+ ole->save_unknown_streams = level;
+
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_sectorpos
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole,
+2. int SID ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+Given a sector ID, this function will return the file position
+offset.
+
+Assumes that the offset for the file starts at 512 bytes (which
+is the size of the OLE header)
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_sectorpos(struct OLE_object *ole, int SID)
+{
+ int pos = 0;
+
+ pos = 512 + (SID * ole->header.sector_size);
+
+ return pos;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_get_block
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole,
+2. int block_index, Block indexes / Sector ID's are signed ints.
+3. unsigned char *block_buffer ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_get_block(struct OLE_object *ole, int block_index, unsigned char *block_buffer)
+{
+ if (block_buffer == NULL)
+ {
+ LOGGER_log(_("%s:%d:OLE_get_block:ERROR: Block buffer is NULL"), FL);
+ return -1;
+ }
+
+ if (ole->f != NULL)
+ {
+ int read_count = 0;
+ int fseek_result = 0;
+ size_t offset = 0;
+ unsigned char *bb = NULL;
+
+ bb = MALLOC(sizeof(unsigned char) * ole->header.sector_size);
+ if (bb == NULL)
+ {
+ LOGGER_log(_("%s:%d:OLE_get_block:ERROR: Cannot allocate %d bytes for OLE block"), FL, ole->header.sector_size);
+ return -1;
+ }
+
+ DOLE LOGGER_log("%s:%d:OLE_get_block:DEBUG: BlockIndex=%d, Buffer=0x%x", FL, block_index, block_buffer);
+
+ /*20051211-2343:PLD: offset = (block_index +1) << ole->header.sector_shift; */
+ offset = OLE_sectorpos(ole, block_index);
+
+ DOLE LOGGER_log("%s:%d:OLE_get_block:DEBUG: Read offset in file = 0x%x size to read= 0x%x", FL, offset, ole->header.sector_size);
+
+ fseek_result = fseek(ole->f, (long)offset, SEEK_SET);
+ if (fseek_result != 0)
+ {
+ if (bb != NULL)
+ {
+ FREE(bb);
+ bb = NULL;
+ }
+ LOGGER_log(_("%s:%d:OLE_get_block:ERROR: Seek failure (block=%d:%d)"), FL, block_index, offset, strerror(errno));
+ return OLEER_GET_BLOCK_SEEK;
+ }
+
+ /*read_count = fread(block_buffer, sizeof(unsigned char), ole->header.sector_size, ole->f); */
+ read_count = (int)fread(bb, sizeof(unsigned char), ole->header.sector_size, ole->f);
+ DOLE LOGGER_log("%s:%d:OLE_get_block:DEBUG: Read %d byte of data", FL, read_count);
+
+ if (read_count != (int)ole->header.sector_size)
+ {
+ if (bb != NULL)
+ {
+ FREE(bb);
+ bb = NULL;
+ }
+ VOLE LOGGER_log(_("%s:%d:Mismatch in bytes read. Requested %d, got %d\n"), FL, ole->header.sector_size, read_count);
+
+ return OLEER_GET_BLOCK_READ;
+ }
+
+ DOLE LOGGER_log("%s:%d:OLE_get_block:DEBUG: Copying over memory read from file", FL);
+
+ memcpy(block_buffer, bb, ole->header.sector_size);
+
+ DOLE LOGGER_log("%s:%d:OLE_get_block:DEBUG: memory block copied to block_buffer", FL);
+
+ /* We're now done with BB, dispose of it */
+ if (bb)
+ {
+ FREE(bb);
+ bb = NULL;
+ }
+
+ DOLE LOGGER_log("%s:%d:OLE_get_block:DEBUG: Disposed of temporary bb block", FL);
+
+ }
+ else
+ {
+ LOGGER_log(_("%s:%d:OLE_get_block:ERROR: OLE file is closed\n"), FL);
+ return -1;
+ }
+
+ DOLE LOGGER_log("%s:%d:OLE_get_block:DEBUG: Done", FL);
+
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_get_miniblock
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole,
+2. unsigned int block_index,
+3. unsigned char *block_buffer ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_get_miniblock(struct OLE_object *ole, int block_index, unsigned char *block_buffer)
+{
+ /* This code may refer memory outside of the allocated one for ole->ministream *
+ * in case of VBA Streams Serge Steer 26/01/2007 */
+ if (ole->ministream)
+ {
+ int offset = block_index << ole->header.mini_sector_shift;
+
+ memcpy(block_buffer, ole->ministream + offset, ole->header.mini_sector_size);
+ }
+
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_dbstosbs
+Returns Type : int
+----Parameter List
+1. char *raw_string,
+2. size_t char_count,
+3. char *clean_string ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_dbstosbs(char *raw_string, size_t byte_count, char *clean_string, int clean_string_len)
+{
+ char *limit = raw_string + byte_count - 1;
+
+ clean_string_len--;
+
+ while ((raw_string < limit) && (byte_count > 0) && (byte_count--) && (clean_string_len--))
+ {
+ int v = (char) * raw_string;
+
+ if (isprint(v))
+ {
+ *clean_string = (char)v;
+ clean_string++;
+ }
+
+ raw_string += 2;
+ }
+ *clean_string = '\0';
+
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_print_string
+Returns Type : int
+----Parameter List
+1. char *string,
+2. size_t length ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_print_string(char *string, size_t char_count)
+{
+ while (char_count--)
+ {
+ printf("%c", *string);
+ string += 2;
+ }
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_print_sector
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole,
+2. unsigned char *sector ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+static int OLE_print_sector(struct OLE_object *ole, unsigned char *sector, unsigned int bytes)
+{
+ int current_byte;
+ int ubytes = bytes;
+
+ printf("\n");
+ for (current_byte = 0; current_byte < ubytes; current_byte++)
+ {
+ printf("%02X ", *(sector + current_byte));
+ if (((current_byte + 1) % 32) == 0)
+ {
+ int j;
+
+ for (j = current_byte - 31; j <= current_byte; j++)
+ {
+ if (isalnum(*(sector + j)))
+ {
+ printf("%c", *(sector + j));
+ }
+ else
+ {
+ printf(".");
+ }
+ }
+ printf("\n");
+ }
+ }
+ printf("\n");
+
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_is_OLE_file
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_is_file_OLE(struct OLE_object *ole)
+{
+
+ if (memcmp(OLE_id_v1, ole->header_block, sizeof(OLE_id_v1)) == 0)
+ {
+ return 1;
+ }
+ if (memcmp(OLE_id_v2, ole->header_block, sizeof(OLE_id_v2)) == 0)
+ {
+ return 1;
+ }
+
+ return 0;
+
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_get_header
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_get_header(struct OLE_object *ole)
+{
+ int result = 0;
+
+ ole->header.sector_size = OLE_HEADER_BLOCK_SIZE;
+ result = OLE_get_block(ole, -1, ole->header_block);
+
+ if (OLE_is_file_OLE(ole) == 0)
+ {
+ return OLEER_NOT_OLE_FILE;
+ }
+
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_convert_header
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_convert_header(struct OLE_object *ole)
+{
+ struct OLE_header *h;
+ unsigned char *hb; /** pointer to the header block **/
+ unsigned char *fat_start;
+ unsigned int i;
+
+ h = &(ole->header);
+ hb = ole->header_block;
+
+ /** Note that the header_*(hb) calls are actually macros which are
+ ** defined in the ole.h file. These macros basically take the
+ ** hb value and add the required offset, they don't affect the
+ ** value of hb (or they certainly SHOULD NOT! )
+ **/
+
+ h->minor_version = get_2byte_value(header_minor_version(hb));
+ h->dll_version = get_2byte_value(header_dll_version(hb));
+ h->byte_order = get_2byte_value(header_byte_order(hb)); /** 0xFEFF = Little endian, 0xFFFE = big endian **/
+ h->sector_shift = get_2byte_value(header_sector_shift(hb));
+ h->sector_size = 1 << h->sector_shift;
+
+ h->mini_sector_shift = get_2byte_value(header_mini_sector_shift(hb));
+ h->mini_sector_size = 1 << h->mini_sector_shift;
+
+ h->fat_sector_count = get_4byte_value(header_fat_sector_count(hb)); /** Total number of sectors use for the SAT **/
+ h->directory_stream_start_sector = get_4byte_value(header_directory_stream_start_sector(hb)); /** Start sector-ID for the DIRECTORY STREAM **/
+ h->mini_cutoff_size = get_4byte_value(header_mini_cutoff_size(hb));
+ h->mini_fat_start = get_4byte_value(header_mini_fat_start(hb));
+ h->mini_fat_sector_count = get_4byte_value(header_mini_fat_sector_count(hb));
+ h->dif_start_sector = get_4byte_value(header_dif_start_sector(hb));
+ h->dif_sector_count = get_4byte_value(header_dif_sector_count(hb));
+
+ /** Compute the maximum possible sector number by taking our OLE filesize
+ ** and dividing it by the size of our sector size. While this isn't
+ ** absolutely accurate it is at least useful in providing us with an
+ ** upper-bound of what is an acceptable sector ID **/
+ ole->last_sector = (int)(ole->file_size >> h->sector_shift);
+
+ /** Decode our first 109 sector-ID's into the master sector allocation table (MSAT/FAT) **/
+ fat_start = header_fat_sectors(hb);
+ for (i = 0; i < h->fat_sector_count; i++)
+ {
+ if (i >= OLE_HEADER_FAT_SECTOR_COUNT_LIMIT)
+ {
+ break;
+ }
+ h->FAT[i] = get_4byte_value(fat_start + (LEN_ULONG * i));
+ }
+
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_header_sanity_check
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+Determines the degree of insanity in the header, returning it
+as an integer, 1 per degree of insanity.
+
+--------------------------------------------------------------------
+Changes:
+20041127-2027:PLD: Initial version
+
+\------------------------------------------------------------------*/
+static int OLE_header_sanity_check(struct OLE_object *ole)
+{
+ int insanity = 0;
+ int max_sectors;
+ struct OLE_header *h;
+
+ h = &(ole->header);
+
+ max_sectors = (int)(ole->file_size / h->sector_size);
+
+ if (h->sector_shift > 20)
+ {
+ insanity++;
+ }
+ if (h->mini_sector_shift > 10)
+ {
+ insanity++;
+ }
+ if ((int)h->fat_sector_count < 0)
+ {
+ insanity++;
+ }
+ if (h->fat_sector_count > (unsigned int)max_sectors)
+ {
+ insanity++;
+ }
+ if (h->directory_stream_start_sector > (unsigned int)max_sectors)
+ {
+ insanity++;
+ }
+
+ return insanity;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_print_header
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_print_header(struct OLE_object *ole)
+{
+ unsigned int i;
+ struct OLE_header *h;
+
+ h = &(ole->header);
+
+ printf("Minor version = %d\n"
+ "DLL version = %d\n"
+ "Byte order = %d\n\n"
+ "Sector shift = %d\n"
+ "Sector size = %d\n"
+ "Mini Sector shift = %d\n"
+ "Mini sector size = %d\n\n"
+ "FAT sector count = %d\n"
+ "First FAT sector = %d\n\n"
+ "Maximum ministream size = %d\n\n"
+ "First MiniFAT sector = %d\n"
+ "MiniFAT sector count = %d\n\n"
+ "First DIF sector = %d\n"
+ "DIF sector count = %d\n"
+ "--------------------------------\n", h->minor_version, h->dll_version, h->byte_order, h->sector_shift, h->sector_size,
+ h->mini_sector_shift, h->mini_sector_size, h->fat_sector_count, h->directory_stream_start_sector, h->mini_cutoff_size, h->mini_fat_start,
+ h->mini_fat_sector_count, h->dif_start_sector, h->dif_sector_count);
+
+ /* Print out the FAT chain */
+ for (i = 0; i < h->fat_sector_count; i++)
+ {
+ if (i >= OLE_HEADER_FAT_SECTOR_COUNT_LIMIT)
+ {
+ break; /* We can't read beyond the 109th sector location */
+ }
+ printf("FAT[%d] = %d\n", i, h->FAT[i]);
+ }
+
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_convert_directory
+Returns Type : int
+----Parameter List
+1. unsigned char *buf,
+2. struct OLE_directory_entry *dir ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_convert_directory(struct OLE_object *ole, unsigned char *buf, struct OLE_directory_entry *dir)
+{
+ /** Converts a raw block of 128 bytes from the file to a
+ ** struct OLE_directory_entry data structure
+ **/
+
+ /** Flush the element name **/
+ memset(dir->element_name, '\0', OLE_DIRECTORY_ELEMENT_NAME_SIZE);
+
+ /** The first 64 bytes of the structure are the element's name
+ ** in 16-bite UNICODE, meaning a maximum of 31 characters when
+ ** we account for the trailing zero byte
+ **/
+
+ /** Copy the first 64 bytes of our *buf parameter into the element name **/
+ memcpy(dir->element_name, buf, OLE_DIRECTORY_ELEMENT_NAME_SIZE);
+
+ /** how many bytes of the above 64 bytes are used for the name (NOT CHARACTERS!), **
+ ** example, for a 8 character string with a trailing zero we use **
+ ** (8+1)*2 = 18 bytes
+ **/
+ dir->element_name_byte_count = get_2byte_value(buf + 0x40);
+
+ /** Element type is of the following:
+ ** 0x00 - empty
+ ** 0x01 - user storage
+ ** 0x02 - user stream
+ ** 0x03 - lock bytes (we don't know what this is for)
+ ** 0x04 - property (again, we don't know)
+ ** 0x05 - root storage
+ **/
+ dir->element_type = (char)get_1byte_value(buf + 0x42);
+
+ /** Element colour for the red-black tree:
+ ** 0x00 - Red
+ ** 0x01 - Black
+ **/
+ dir->element_colour = (char)get_1byte_value(buf + 0x43);
+
+ /** Directory ID (DID) of the left child, -1 if no sibling **/
+ dir->left_child = get_4byte_value(buf + 0x44);
+
+ /** Directory ID (DID) of the right child, -1 if no sibling **/
+ dir->right_child = get_4byte_value(buf + 0x48);
+
+ /** Directory ID (DID) of the root node entry of the RB tree of all
+ ** storage members (if this entry is a storage), else -1.
+ **/
+ dir->root = get_4byte_value(buf + 0x4c);
+
+ memcpy(dir->class, buf + 0x50, 16);
+ dir->userflags = get_4byte_value(buf + 0x60);
+ memcpy(dir->timestamps, buf + 0x64, 16); /** Actually consists of 2 8 byte stamps **/
+
+ /** Sector ID of the first sector or short-sector **/
+ dir->start_sector = get_4byte_value(buf + 0x74);
+
+ /** Size of this stream **/
+ DOLE LOGGER_log("%s:%d:OLE_directory_entry:DEBUG: stream size = 0x%x %x %x %x", FL, *(buf + 0x78), *(buf + 0x79), *(buf + 0x7A), *(buf + 0x7B));
+
+ dir->stream_size = get_4byte_value(buf + 0x78);
+
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_print_directory
+Returns Type : int
+----Parameter List
+1. struct OLE *ole,
+2. struct OLE_directory_entry *dir ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_print_directory(struct OLE_object *ole, struct OLE_directory_entry *dir)
+{
+ char element[64];
+
+ OLE_dbstosbs(dir->element_name, dir->element_name_byte_count, element, sizeof(element));
+
+ printf("Element Name = %s\n"
+ "Element type = %d\n"
+ "Element colour = %d\n"
+ "Left Child = %d\n"
+ "Right Child = %d\n"
+ "Root = %d\n"
+ "User flags = %d\n"
+ "Start sector = %d\n"
+ "Stream Size = %d\n", element, dir->element_type, dir->element_colour, dir->left_child, dir->right_child, dir->root, dir->userflags,
+ dir->start_sector, dir->stream_size);
+
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_load_FAT
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_load_FAT(struct OLE_object *ole)
+{
+ unsigned int FAT_size;
+
+ FAT_size = ole->header.fat_sector_count << ole->header.sector_shift;
+ DOLE LOGGER_log("%s:%d:OLE_load_FAT:DEBUG:Allocating for %d sectors (%d bytes)\n", FL, ole->header.fat_sector_count, FAT_size);
+
+ ole->FAT = MALLOC(FAT_size * sizeof(unsigned char));
+ ole->FAT_limit = ole->FAT + FAT_size;
+ if (ole->FAT != NULL)
+ {
+ unsigned int i;
+ unsigned char *fat_position = ole->FAT;
+ unsigned int sector_count = ole->header.fat_sector_count;
+
+ if (sector_count > OLE_HEADER_FAT_SECTOR_COUNT_LIMIT)
+ {
+ sector_count = OLE_HEADER_FAT_SECTOR_COUNT_LIMIT;
+ DOLE LOGGER_log("%s:%d:OLE_load_FAT:DEBUG: sector count greater than limit; set to %d", FL, sector_count);
+ }
+
+ /* Load in all our primary-FAT sectors from the OLE file */
+ for (i = 0; i < sector_count; i++)
+ {
+ int getblock_result = 0;
+
+ DOLE LOGGER_log("%s:%d:OLE_load_FAT:DEBUG: Loading sector %d", FL, i);
+
+ getblock_result = OLE_get_block(ole, ole->header.FAT[i], fat_position);
+ if (getblock_result != 0)
+ {
+ /* if the get block fails, return the error - but keep the FAT */
+ /* pointer alive - so that we can facilitate debugging */
+ /* otherwise the caller is always going to get a NULL pointer */
+ /* and have no idea to what extent the data was read. */
+ /**/
+ /* This behavior may be changed later - but for now (beta development) */
+ /* it'll be okay to leave it here - just make sure we know to */
+ /* free the FAT block later. */
+ return getblock_result;
+ }
+
+ fat_position += ole->header.sector_size;
+ if (fat_position > ole->FAT_limit)
+ {
+ LOGGER_log("%s:%d:OLE_load_FAT:DEBUG: FAT boundary limit exceeded %p > %p", FL, fat_position, ole->FAT_limit);
+ return -1;
+ }
+ }
+
+ /* If our DIF count is > 0, this means we have a pretty big */
+ /* file on hand (> 7Mb) and thus we now have to do some */
+ /* fancy double-dereferenced sector request - enough to */
+ /* twist your brain if you're not alert, you have been */
+ /* warned. */
+
+ if (ole->header.dif_sector_count > 0)
+ {
+ unsigned char *fat_block;
+ unsigned char *fat_block_end;
+ unsigned int current_sector = ole->header.dif_start_sector;
+
+ DOLE LOGGER_log("%s:%d:OLE_load_FAT:DEBUG: Allocating %d bytes to fat_block\n", FL, ole->header.sector_size);
+
+ fat_block = MALLOC(ole->header.sector_size);
+
+ if (fat_block == NULL)
+ {
+ LOGGER_log(_("%s:%d:OLE_load_FAT:ERROR: Unable to allocate %d bytes\n"), FL, ole->header.sector_size);
+ return -1;
+ /* exit(1); */
+ }
+
+ /* We need to know where the end of this block is - because it's */
+ /* used to show us where the NEXT FAT block is going to come from */
+ /* NOTE - this only occurs if we do have another block, else */
+ /* we'll simply have to just realise that we don't need any more */
+ /* blocks and stop with this one. */
+
+ fat_block_end = fat_block + ole->header.sector_size - LEN_ULONG;
+
+ /* We know we've got 'dif_sector_count' blocks to read, each of */
+ /* these blocks hold no more than 127 sector addresses which */
+ /* contain the actual FAT data we're after (this is the double */
+ /* dereference bit that twists your brain ) */
+
+ DOLE LOGGER_log("%s:%d:OLE_load_FAT:DEBUG: Loading DIF sectors (count = %d)", FL, ole->header.dif_sector_count);
+
+ for (i = 0; i < ole->header.dif_sector_count; i++)
+ {
+ int import_sector;
+ unsigned char *DIF = fat_block;
+ int tick = 0;
+ int getblock_result;
+
+ DOLE LOGGER_log("%s:%d:OLE_load_FAT:DEBUG: Reading DIF/XBAT index-data[%d] from sector 0x%x", FL, i, current_sector);
+
+ getblock_result = OLE_get_block(ole, current_sector, fat_block);
+ if (getblock_result != OLE_OK)
+ {
+ if (fat_block)
+ {
+ FREE(fat_block);
+ }
+ return getblock_result;
+ }
+
+ if (OLE_DPEDANTIC(ole->debug))
+ {
+ OLE_print_sector(ole, fat_block, ole->header.sector_size);
+ }
+
+ /* Now, traverse this block until we hit a < 0 */
+ /* If we get what is a non-valid sector value */
+ /* we know we've reached the end of the valid */
+ /* sectors from which to read more extended FAT */
+ /* data. */
+
+ do
+ {
+ import_sector = get_4byte_value(DIF);
+ DOLE LOGGER_log("%s:%d:OLE_load_FAT:DEBUG: import sector = 0x%x", FL, import_sector);
+
+ if (import_sector >= 0)
+ {
+ if (fat_position + ole->header.sector_size <= ole->FAT_limit)
+ {
+ DOLE LOGGER_log("%s:%d:OLE_load_FAT:DEBUG: Reading DIF/XBAT-data[%d] from sector 0x%x", FL, tick, import_sector);
+
+ getblock_result = OLE_get_block(ole, import_sector, fat_position);
+ if (getblock_result != OLE_OK)
+ {
+ LOGGER_log(_("%s:%d:OLE_load_FAT:ERROR: Not able to load block, import sector = 0x%x, fat position = 0x%x"), FL,
+ import_sector, fat_position);
+ if (fat_block)
+ {
+ FREE(fat_block);
+ }
+ return getblock_result;
+ }
+
+ fat_position += ole->header.sector_size;
+ DOLE LOGGER_log("%s:%d:OLE_load_FAT:DEBUG: FAT position = 0x%x (start = 0x%x, end = 0x%x)", FL, fat_position, fat_block,
+ ole->FAT_limit);
+
+ /*if (fat_position +ole->header.sector_size > ole->FAT_limit) */
+ if (fat_position > ole->FAT_limit)
+ {
+ DOLE LOGGER_log(_("%s:%d:OLE_load_FAT:ERROR: FAT memory boundary limit exceeded %p >= %p"), FL, fat_position,
+ ole->FAT_limit);
+ if (fat_block)
+ {
+ FREE(fat_block);
+ }
+ return OLEER_MEMORY_OVERFLOW;
+ }
+ tick++;
+ DIF += LEN_ULONG;
+ }
+ else
+ {
+ LOGGER_log(_("%s:%d:OLE_load_FAT:ERROR: FAT memory boundary limit exceeded %p >= %p"), FL, fat_position, ole->FAT_limit);
+ if (fat_block)
+ {
+ FREE(fat_block);
+ }
+ return OLEER_MEMORY_OVERFLOW;
+ }
+ }
+ else
+ {
+ VOLE LOGGER_log(_("%s:%d:OLE_load_FAT:ERROR: sector request was negative (%d)"), FL, import_sector);
+ }
+
+ DOLE LOGGER_log("%s:%d:OLE_load_FAT:DEBUG: DIF = 0x%x", FL, DIF);
+ }
+ while ((import_sector >= 0) && (DIF < fat_block_end));
+
+ /* Get the next sector of DIF/XBAT data ... */
+ /**/
+ /* If we still have more sectors full of extended FAT */
+ /* sectors that we have to read, then we neet to */
+ /* obtain the address of the next FAT-sector filled */
+ /* sector */
+ if (i < ole->header.dif_sector_count - 1)
+ {
+ current_sector = get_4byte_value(fat_block_end);
+ DOLE LOGGER_log("%s:%d:OLE_load_FAT:DEBUG: Next DIF/XBAT index sector located at 0x%x", FL, current_sector);
+
+ if ((int)current_sector < 0)
+ {
+ break;
+ }
+ }
+ } /* For every DIF/XBAT sector we're supposed to read */
+
+ if (fat_block)
+ {
+ FREE(fat_block);
+ }
+ } /* If we have DIF/XBAT sectors to read into the FAT */
+
+ } /* If we managed to allocate memory for our FAT table */
+
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_follow_chain
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole,
+2. int FAT_sector_start ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_follow_chain(struct OLE_object *ole, int FAT_sector_start)
+{
+ int current_sector = FAT_sector_start;
+ int chain_length = 0;
+ int last_sector_of_file = ole->last_sector;
+ int break_out = 0;
+ struct bti_node *n;
+
+ BTI_init(&n);
+
+ if (FAT_sector_start < 0)
+ {
+ return 0;
+ }
+
+ DOLE LOGGER_log("%s:%d:OLE_follow_chain:DEBUG: Starting chain follow at sector %d", FL, FAT_sector_start);
+
+ do
+ {
+ int next_sector;
+ unsigned char *next_sector_location;
+
+ next_sector_location = ole->FAT + (LEN_ULONG * current_sector);
+ if (next_sector_location > (ole->FAT_limit - 4))
+ {
+ DOLE LOGGER_log("%s:%d:OLE_follow_chain:DEBUG: ERROR: Next sector was outside of the limits of this file (%ld > %ld)", FL,
+ next_sector_location, ole->FAT_limit);
+ break;
+ }
+
+ /*next_sector = get_4byte_value( ole->FAT +(LEN_ULONG *current_sector)); */
+ next_sector = get_4byte_value(next_sector_location);
+
+ if (BTI_add(&n, next_sector) != 0)
+ {
+ DOLE LOGGER_log("%s:%d:OLE_follow_chain:DEBUG: Sector collision, terminating chain traversal", FL);
+
+ chain_length = -1;
+
+ break;
+ }
+
+ DOLE LOGGER_log("%s:%d:OLE_follow_chain:DEBUG: 0x%0X:%d)->(0x%0X:%d)\n", FL, current_sector, current_sector, next_sector, next_sector);
+
+ /* 20040729-10H37 Added this to prevent endless loop which sometimes occurs at sector 0 */
+
+ if (next_sector == current_sector)
+ {
+ break;
+ }
+
+ /* fflush(stdout); */
+ current_sector = next_sector;
+ chain_length++;
+
+ /** Test to see if we should terminate this chain traversal **/
+ switch (current_sector)
+ {
+ case OLE_SECTORID_MSAT:
+ case OLE_SECTORID_SAT:
+ case OLE_SECTORID_ENDOFCHAIN:
+ case OLE_SECTORID_FREE:
+ break_out = 1;
+ break;
+ default:
+ break_out = 0;
+ };
+
+ if (current_sector < 0)
+ {
+ break_out = 1;
+ }
+
+ }
+ while ((break_out == 0) && (current_sector < last_sector_of_file));
+
+ BTI_done(&n);
+
+ return chain_length;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_follow_minichain
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole,
+2. int FAT_sector_start ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_follow_minichain(struct OLE_object *ole, int miniFAT_sector_start)
+{
+ /*unsigned int current_sector = miniFAT_sector_start; */
+ int current_sector = miniFAT_sector_start;
+ int chain_length = 0;
+ int break_out = 0;
+
+ DOLE LOGGER_log("%s:%d:OLE_follow_minichain:DEBUG: Starting at sector %d", FL, miniFAT_sector_start);
+
+ if (miniFAT_sector_start < 0)
+ {
+ return 0;
+ }
+
+ do
+ {
+ /*unsigned int next_sector; */
+ int next_sector;
+
+ DOLE LOGGER_log("%s:%d:OLE_follow_minichain:DEBUG: Requesting 4-byte value at '%d'", FL, ole->miniFAT + (LEN_ULONG * current_sector));
+
+ /* next text commented out because ole->miniFAT_limit is set to null ans vever change
+ * if (ole->miniFAT +(LEN_ULONG *current_sector) > ole->miniFAT_limit) {
+ * DOLE LOGGER_log("%s:%d:OLE_follow_minichain:DEBUG: Requested location is out of bounds\n",FL);
+ * return 0;
+ * }
+ */
+
+ next_sector = get_4byte_value(ole->miniFAT + (LEN_ULONG * current_sector));
+
+ DOLE LOGGER_log("%s:%d:OLE_follow_minichain:DEBUG: Current Msector(0x%0X:%d)->next(0x%0X:%d)\n", FL, current_sector, current_sector,
+ next_sector, next_sector);
+
+ /** Check for conditions that indicate we should stop traversing this chain **/
+
+ /** 1. We cannot point to ourselves **/
+ if (current_sector == next_sector)
+ {
+ break;
+ }
+
+ chain_length++;
+ current_sector = next_sector;
+
+ /** Test for non-positive type sector ID's **/
+ switch (current_sector)
+ {
+ case OLE_SECTORID_MSAT:
+ case OLE_SECTORID_SAT:
+ case OLE_SECTORID_ENDOFCHAIN:
+ case OLE_SECTORID_FREE:
+ break_out = 1;
+ break;
+ default:
+ break_out = 0;
+ };
+
+ DOLE LOGGER_log("%s:%d:OLE_follow_minichain:DEBUG: current sector = %d", FL, current_sector);
+
+ /* Test changed Serge Steer Scilab */
+ /* } while ((break_out==0) &&(current_sector <= ole->last_sector)); */
+ }
+ while (break_out == 0);
+ DOLE LOGGER_log("%s:%d:OLE_follow_minichain:DEBUG: Done. Chainlength=%d", FL, chain_length);
+
+ return chain_length;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : char
+Returns Type : unsigned
+----Parameter List
+1. *OLE_load_minichain( struct OLE_object *ole,
+2. int FAT_sector_start ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+PLD:2003-Aug-28: Added sanity checking on the miniFAT_sector_start
+value so that we didn't try to load up a miniFAT starting on a
+negative value
+
+\------------------------------------------------------------------*/
+unsigned char *OLE_load_minichain(struct OLE_object *ole, int miniFAT_sector_start)
+{
+
+ int chain_length = 0;
+ int current_sector = miniFAT_sector_start;
+ unsigned char *buffer;
+ unsigned char *bp;
+ int break_out = 0;
+
+ DOLE LOGGER_log("%s:%d:OLE_load_minichain:DEBUG: Loading minichain starting at %d", FL, miniFAT_sector_start);
+
+ /* Added this sanity checking 2003 Aug 28 */
+ if (miniFAT_sector_start < 0)
+ {
+ return NULL;
+ }
+
+ chain_length = OLE_follow_minichain(ole, miniFAT_sector_start);
+ DOLE LOGGER_log("%s:%d:OLE_load_minichain:DEBUG: Found %d mini-sectors to load (%d bytes)\n", FL, chain_length,
+ chain_length * ole->header.mini_sector_size);
+
+ /* 20040911-21H59 */
+ /* If our chain is 0 length, then there's nothing to return */
+ if (chain_length == 0)
+ {
+ return NULL;
+ }
+
+ bp = buffer = MALLOC(chain_length * ole->header.mini_sector_size * sizeof(unsigned char));
+ if (buffer != NULL)
+ {
+ do
+ {
+ int next_sector;
+
+ DOLE LOGGER_log("%s:%d:OLE_load_minichain:DEBUG: Loading sector %d", FL, current_sector);
+
+ OLE_get_miniblock(ole, current_sector, bp);
+ bp += ole->header.mini_sector_size;
+
+ next_sector = get_4byte_value(ole->miniFAT + (LEN_ULONG * current_sector));
+ current_sector = next_sector;
+ /* NEXT LINES ADDED TO BE COHERENT WITH OLE_follow_minichain ABOVE Serge Steer Scilab */
+ switch (current_sector)
+ {
+ case OLE_SECTORID_MSAT:
+ case OLE_SECTORID_SAT:
+ case OLE_SECTORID_ENDOFCHAIN:
+ case OLE_SECTORID_FREE:
+ break_out = 1;
+ break;
+ default:
+ break_out = 0;
+ };
+ /* Test changed Serge Steer Scilab */
+ /* } while ((current_sector != OLE_SECTORID_ENDOFCHAIN)&&(current_sector >= 0)&&(current_sector <= ole->last_sector)); */
+
+ }
+ while (break_out == 0);
+
+ }
+ else
+ {
+ LOGGER_log(_("%s:%d:OLE_get_miniblock:ERROR: Failed to allocate enough memory for miniChain"), FL);
+ }
+
+ DOLE LOGGER_log("%s:%d:OLE_load_minichain:DEBUG: Done. buffer=%p", FL, buffer);
+
+ return buffer;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : char
+Returns Type : unsigned
+----Parameter List
+1. *OLE_load_chain( struct OLE_object *ole,
+2. int FAT_sector_start ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+Make the loading aware of negative-value sectors so that it can
+make more intelligent exit strategies.
+
+\------------------------------------------------------------------*/
+unsigned char *OLE_load_chain(struct OLE_object *ole, int FAT_sector_start)
+{
+
+ int chain_length = 0;
+ int current_sector = FAT_sector_start;
+ unsigned char *buffer = NULL;
+ unsigned char *bp = NULL;
+
+ ole->last_chain_size = 0;
+
+ if (FAT_sector_start < 0)
+ {
+ return NULL;
+ }
+
+ DOLE LOGGER_log("%s:%d:OLE_load_chain:DEBUG: Loading chain, starting at sector %d", FL, FAT_sector_start);
+
+ chain_length = OLE_follow_chain(ole, FAT_sector_start);
+ DOLE LOGGER_log("%s:%d:OLE_load_chain:DEBUG: %d sectors need to be loaded", FL, chain_length);
+
+ if (chain_length > 0)
+ {
+ size_t offset;
+
+ offset = ole->last_chain_size = chain_length << ole->header.sector_shift;
+ bp = buffer = MALLOC((offset) * sizeof(unsigned char));
+ if (buffer == NULL)
+ {
+ LOGGER_log("%s:%d:OLE_load_chain:ERROR: Cannot allocate %d bytes for OLE chain", FL, offset);
+ return NULL;
+ }
+
+ if (buffer != NULL)
+ {
+ int tick = 0;
+ unsigned char *bp_limit;
+
+ bp_limit = bp + offset;
+
+ do
+ {
+ int next_sector;
+
+ DOLE LOGGER_log("%s:%d:OLE_load_chain:DEBUG: Loading sector[%d] %d", FL, tick, current_sector);
+
+ ole->error = OLE_get_block(ole, current_sector, bp);
+ if (ole->error != OLE_OK)
+ {
+ /*FREE5 if (bp != NULL) FREE(bp); */
+ return NULL;
+ }
+
+ bp += ole->header.sector_size;
+ if (bp > bp_limit)
+ {
+ if (buffer != NULL)
+ {
+ FREE(buffer);
+ bp = buffer = NULL;
+ }
+ VOLE LOGGER_log(_("%s:%d:OLE_load_chain:ERROR: Load-chain went over memory boundary"), FL);
+
+ return NULL;
+ };
+
+ next_sector = get_4byte_value(ole->FAT + (LEN_ULONG * current_sector));
+ current_sector = next_sector;
+ tick++;
+ }
+ while ((current_sector >= 0) && (current_sector <= ole->last_sector));
+ }
+ }
+ DOLE LOGGER_log("%s:%d:OLE_load_chain:DEBUG: Done loading chain", FL);
+
+ return buffer;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_open_file
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole,
+2. char *fullpath ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+20041127-2033:PLD: Added ole->file_size setting so that we
+can use this in the sanity checking to see if the
+requested sectors are outside of the possible valid
+filesize range.
+
+\------------------------------------------------------------------*/
+int OLE_open_file(struct OLE_object *ole, char *fullpath)
+{
+#ifdef _MSC_VER
+ struct _stat st;
+#else
+ struct stat st;
+#endif
+ int stat_result;
+ FILE *f;
+
+#ifdef _MSC_VER
+ stat_result = wcstat(fullpath, &st);
+#else
+ stat_result = stat(fullpath, &st);
+#endif
+ if (stat_result != 0)
+ {
+ DOLE LOGGER_log(_("%s:%d:OLE_open_file:ERROR: Cannot locate file '%s' for opening (%s)"), FL, fullpath, strerror(errno));
+
+ return OLEER_BAD_INPUT_FILE;
+ }
+
+ DOLE LOGGER_log("%s:%d:OLE_open_file:DEBUG: File size of %s = %ld", FL, fullpath, st.st_size);
+
+ if ((stat_result == 0) && (st.st_size < 512))
+ {
+ return OLEER_NOT_OLE_FILE;
+ }
+
+ ole->file_size = st.st_size;
+
+ wcfopen(f, fullpath, "rb");
+
+ if (f == NULL)
+ {
+ ole->f = NULL;
+ if (ole->quiet == 0)
+ {
+ LOGGER_log(_("%s:%d:OLE_open_file:ERROR:Cannot open %s for reading (%s)\n"), FL, fullpath, strerror(errno));
+ }
+ return -1;
+ }
+ else
+ {
+ ole->f = f;
+ ole->file_size = st.st_size;
+ ole->last_sector = -1;
+ }
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_open_directory
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole,
+2. char *directory ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_open_directory(struct OLE_object *ole, char *directory)
+{
+ int result = 0;
+
+#ifndef _MSC_VER
+ result = mkdir(directory, S_IRWXU);
+#else
+ {
+ wchar_t *wdirectory = to_wide_string(directory);
+
+ result = createdirectoryW(wdirectory);
+ FREE(wdirectory);
+ }
+ /* If the function succeeds, the return value is nonzero.
+ * If the function fails, the return value is zero. */
+ if (result)
+ {
+ result = 0;
+ }
+#endif
+ if ((result != 0) && (errno != EEXIST))
+ {
+ LOGGER_log(_("%s:%d:OLE_open_directory:ERROR: %s"), FL, strerror(errno));
+ }
+ else
+ {
+ result = OLE_OK;
+ }
+
+ return result;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_set_filename_report_fn
+Returns Type : int
+----Parameter List
+1. int (*ptr_to_fn)(char *) ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+This is merely a passthrough function to the OLEUW one, we do
+this in order to avoid having to force the calling parent from
+having to #include the OLEUW headers as well
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_set_filename_report_fn(struct OLE_object *ole, int (*ptr_to_fn) (char *))
+{
+ ole->filename_report_fn = ptr_to_fn;
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_store_stream
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole,
+2. char *stream_name,
+3. char *directory,
+4. unsigned char *stream ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_store_stream(struct OLE_object *ole, char *stream_name, char *directory, char *stream, size_t stream_size)
+{
+ char *full_path = NULL;
+
+ full_path = PLD_dprintf("%s/%s", directory, stream_name);
+ if (full_path == NULL)
+ {
+ LOGGER_log(_("%s:%d:OLE_store_stream:ERROR: Cannot compose full filename string from '%s' and '%s'"), FL, directory, stream_name);
+ return -1;
+ }
+ else
+ {
+ FILE *f;
+
+ wcfopen(f, full_path, "wb");
+
+ if (f == NULL)
+ {
+ LOGGER_log(_("%s:%d:OLE_store_stream:ERROR: Cannot open %s for writing (%s)"), FL, full_path, strerror(errno));
+ if (full_path)
+ {
+ FREE(full_path);
+ }
+ return -1;
+ }
+ else
+ {
+ size_t written_bytes;
+
+ written_bytes = fwrite(stream, 1, stream_size, f);
+ if (written_bytes != stream_size)
+ {
+ LOGGER_log(_("%s:%d:OLE_store_stream:WARNING: Only wrote %d of %d bytes to file %s"), FL, written_bytes, stream_size, full_path);
+ }
+ fclose(f);
+
+ if ((OLE_VNORMAL(ole->verbose)) && (ole->filename_report_fn != NULL))
+ {
+ ole->filename_report_fn(stream_name);
+ }
+ } /* if file is valid */
+ } /* if full_path is valid */
+
+ if (full_path)
+ {
+ FREE(full_path);
+ }
+
+ return OLE_OK;
+}
+
+/*-----------------------------------------------------------------\
+ Function Name : OLE_decode_file_done
+ Returns Type : int
+ ----Parameter List
+ 1. struct OLE_object *ole ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+ --------------------------------------------------------------------
+ Comments:
+
+ --------------------------------------------------------------------
+ Changes:
+
+ \------------------------------------------------------------------*/
+int OLE_decode_file_done(struct OLE_object *ole)
+{
+ if (ole->f)
+ {
+ fclose(ole->f);
+ }
+ /** Why weren't these active? (they were commented out ) **/
+ if (ole->FAT)
+ {
+ FREE(ole->FAT);
+ }
+ if (ole->miniFAT)
+ {
+ FREE(ole->miniFAT);
+ }
+ if (ole->ministream)
+ {
+ FREE(ole->ministream);
+ }
+ if (ole->properties)
+ {
+ FREE(ole->properties);
+ }
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_terminate_and_return
+Returns Type : int
+----Parameter List
+1. struct OLE_object *ole,
+2. int result ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_terminate_and_return(struct OLE_object *ole, int result)
+{
+ OLE_decode_file_done(ole);
+ return result;
+}
+
+#ifdef RIPOLE_WALK_TREE
+int OLE_walk_tree(struct OLE_object *ole, char *fname, char *decode_path, int depth)
+{
+
+ /** Sanity check **/
+
+ if (depth > 100)
+ {
+ return 0;
+ }
+ if (ole->total_file_count > 10000)
+ {
+ return 0;
+ }
+ if (element_type < 0)
+ {
+ return 0;
+ }
+
+ switch (element_type)
+ {
+
+ case STGTY_ROOT:
+ /** ROOT DIRECTORY ENTRY **/
+ /** ROOT DIRECTORY ENTRY **/
+ /** ROOT DIRECTORY ENTRY **/
+ DOLE LOGGER_log("%s:%d:OLE_walk_tree:DEBUG: Loading ministream/SmallBlockArray", FL);
+ ole->ministream = OLE_load_chain(ole, adir->start_sector);
+ if (ole->ministream == NULL)
+ {
+ return OLEER_MINISTREAM_READ_FAIL;
+ }
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: ministream done", FL);
+ }
+
+}
+
+else if (adir->element_type == STGTY_STORAGE)
+{
+ /** STORAGE ELEMENT **/
+ /** STORAGE ELEMENT **/
+ /** STORAGE ELEMENT **/
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: Item is directory, start child is at index %d\n", FL, i);
+
+ ole->ministream = OLE_load_chain(ole, adir->start_sector);
+ if (ole->ministream == NULL)
+ {
+ return OLEER_MINISTREAM_READ_FAIL;
+ }
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: DIRECTORY ministream done", FL);
+
+}
+#endif
+
+int OLE_decode_stream(struct OLE_object *ole, struct OLE_directory_entry *adir, char *decode_path)
+{
+ char *stream_data;
+ struct OLEUNWRAP_object oleuw;
+ int decode_result = OLEUW_STREAM_NOT_DECODED;
+ char element_name[64];
+ int result = 0;
+
+ memset(element_name, '\0', 64);
+ OLE_dbstosbs(adir->element_name, adir->element_name_byte_count, element_name, 64);
+
+ DOLE LOGGER_log("%s:%d:OLE_decode_stream:DEBUG: Decoding stream '%s'", FL, element_name);
+
+ DOLE LOGGER_log("%s:%d:OLE_decode_stream:DEBUG: Initializing stream unwrapper", FL);
+
+ OLEUNWRAP_init(&oleuw);
+ OLEUNWRAP_set_debug(&oleuw, ole->debug);
+ OLEUNWRAP_set_verbose(&oleuw, ole->verbose);
+ OLEUNWRAP_set_filename_report_fn(&oleuw, ole->filename_report_fn);
+ OLEUNWRAP_set_save_unknown_streams(&oleuw, ole->save_unknown_streams);
+ DOLE LOGGER_log("%s:%d:OLE_decode_stream:DEBUG: Unwrap engine set.", FL);
+
+ if (adir->stream_size >= ole->header.mini_cutoff_size)
+ {
+ /** Standard size sector stored stream **/
+ /** Standard size sector stored stream **/
+ /** Standard size sector stored stream **/
+ DOLE LOGGER_log("%s:%d:OLE_decode_stream:DEBUG: Loading normal sized chain starting at sector %d", FL, adir->start_sector);
+
+ stream_data = (char *)OLE_load_chain(ole, adir->start_sector);
+ if (stream_data == NULL)
+ {
+ DOLE LOGGER_log("%s:%d:OLE_decode_stream:DEBUG: Terminating from stream data being NULL ", FL);
+
+ /*OLE_decode_file_done(ole); */
+ return OLEER_MINISTREAM_STREAM_READ_FAIL;
+ }
+ DOLE LOGGER_log("%s:%d:OLE_decode_stream:DEBUG: Normal decode START. element name ='%s' stream size = '%ld'", FL, element_name,
+ adir->stream_size);
+ decode_result = OLEUNWRAP_decodestream(&oleuw, element_name, stream_data, adir->stream_size, decode_path);
+ DOLE LOGGER_log("%s:%d:OLE_decode_stream:DEBUG: Normal decode done.", FL);
+ }
+ else
+ {
+
+ /** Minichain/Minisector stored stream **/
+ /** Minichain/Minisector stored stream **/
+ /** Minichain/Minisector stored stream **/
+ DOLE LOGGER_log("%s:%d:OLE_decode_stream:DEBUG: Minichain loader, starting at sector %d", FL, adir->start_sector);
+
+ stream_data = (char *)OLE_load_minichain(ole, adir->start_sector);
+ if (stream_data == NULL)
+ {
+ DOLE LOGGER_log("%s:%d:OLE_decode_stream:DEBUG: Ministream was non-existant, terminating", FL);
+
+ /*OLE_decode_file_done(ole); */
+ return OLEER_NORMALSTREAM_STREAM_READ_FAIL;
+ }
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: Mini decode START.", FL);
+
+ decode_result = OLEUNWRAP_decodestream(&oleuw, element_name, stream_data, adir->stream_size, decode_path);
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: Mini decode done.", FL);
+ }
+
+ /* Added for Scilab */
+ if ((stream_data != NULL) && (decode_result == OLEUW_STREAM_NOT_DECODED) &&
+ (ole->save_unknown_streams == 2) && ((strcmp(element_name, "Workbook") == 0) || (strcmp(element_name, "Book") == 0)))
+ {
+ strcpy(element_name, "Workbook");
+ OLE_store_stream(ole, element_name, decode_path, stream_data, adir->stream_size);
+
+ } /* If we needed to save an unknown stream */
+
+ else /* end Scilab addition */ if ((stream_data != NULL) && (decode_result == OLEUW_STREAM_NOT_DECODED) && (ole->save_unknown_streams))
+ {
+ char *lfname;
+
+ lfname = PLD_dprintf("ole-stream.%d", adir->start_sector);
+ if (lfname != NULL)
+ {
+ DOLE LOGGER_log("%s:%d:OLE_decode_stream:DEBUG: Saving stream to %s", FL, lfname);
+
+ OLE_store_stream(ole, lfname, decode_path, stream_data, adir->stream_size);
+ FREE(lfname);
+ }
+ } /* If we needed to save an unknown stream */
+
+ /* Clean up an stream_data which we may have */
+ /* read in from the chain-loader. */
+ if (stream_data)
+ {
+ FREE(stream_data);
+ }
+
+ return result;
+}
+
+/*-----------------------------------------------------------------\
+Function Name : OLE_decode_file
+Returns Type : int
+----Parameter List
+1. char *fname,
+2. char *decode_path ,
+------------------
+Exit Codes :
+Side Effects :
+--------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int OLE_decode_file(struct OLE_object *ole, char *fname, char *decode_path)
+{
+ unsigned char *current_property, *property_limit;
+ int result = 0;
+ int i;
+
+ /* Reject any bad paramters. */
+ if (ole == NULL)
+ {
+ return OLEER_DECODE_NULL_OBJECT;
+ }
+ if (fname == NULL)
+ {
+ return OLEER_DECODE_NULL_FILENAME;
+ }
+ if (decode_path == NULL)
+ {
+ return OLEER_DECODE_NULL_PATH;
+ }
+
+ /* We need to gain access to the OLE2 data file, without */
+ /* this pretty much everything is pointless. */
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: opening %s", FL, fname);
+
+ result = OLE_open_file(ole, fname);
+ if (result != 0)
+ {
+ return result;
+ }
+
+ /* Try create the output directory which we're using */
+ /* to write the decoded files out to. */
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: opening output directory %s", FL, decode_path);
+
+ result = OLE_open_directory(ole, decode_path);
+ if (result != 0)
+ {
+ return result;
+ }
+
+ /* In order to successfully decode an OLE2 stream, we have to read */
+ /* and understand the first 512 bytes of the file, this is the */
+ /* OLE2 header. */
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: Getting main header", FL);
+
+ result = OLE_get_header(ole);
+ if (result != 0)
+ {
+ return result;
+ }
+
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: Converting main header", FL);
+
+ result = OLE_convert_header(ole);
+ if (result != 0)
+ {
+ return result;
+ }
+
+ result = OLE_header_sanity_check(ole);
+ if (result > 0)
+ {
+ return OLEER_INSANE_OLE_FILE;
+ }
+
+ DOLE OLE_print_header(ole);
+
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: Loading FAT", FL);
+
+ result = OLE_load_FAT(ole);
+ if (result != 0)
+ {
+ return result;
+ }
+
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: Loading miniFAT chain", FL);
+
+ ole->miniFAT = OLE_load_chain(ole, ole->header.mini_fat_start);
+ /* commented out by Serge Steer for Scilab */
+ /* if (ole->miniFAT == NULL) return OLEER_MINIFAT_READ_FAIL; */
+
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: Loading Directory stream chain", FL);
+
+ ole->properties = OLE_load_chain(ole, ole->header.directory_stream_start_sector);
+ if (ole->properties == NULL)
+ {
+ return OLEER_PROPERTIES_READ_FAIL;
+ }
+
+ i = 0;
+ current_property = ole->properties;
+ property_limit = current_property + ole->last_chain_size;
+ /* while(1) */
+ while (current_property < property_limit)
+ {
+ struct OLE_directory_entry a_dir_object, *adir;
+ int property_value = 0;
+
+ adir = &a_dir_object;
+
+ OLE_dir_init(adir);
+
+ property_value = get_1byte_value(current_property);
+ if (property_value < 1)
+ {
+ break;
+ }
+
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG:--------- DIRECTORY INDEX: %d", FL, i);
+
+ OLE_convert_directory(ole, current_property, adir);
+
+ DOLE
+ {
+ LOGGER_log("%s:%d:OLE_decode_file:DEBUG: Printing directory details...", FL);
+ OLE_print_directory(ole, adir);
+ LOGGER_log("%s:%d:OLE_decode_file:DEBUG: End of directory details", FL);
+ }
+
+ if (adir->element_colour > 1)
+ {
+ break;
+ }
+
+ if ((adir->element_type == STGTY_INVALID) || (adir->element_type > STGTY_ROOT))
+ {
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: breaking out due to element type %d", FL, adir->element_type);
+
+ break;
+
+ }
+ else if (adir->element_type == STGTY_ROOT)
+ {
+ /** ROOT DIRECTORY ENTRY **/
+ /** ROOT DIRECTORY ENTRY **/
+ /** ROOT DIRECTORY ENTRY **/
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: Loading ministream/SmallBlockArray", FL);
+
+ ole->ministream = OLE_load_chain(ole, adir->start_sector);
+ /* commented out by Serge Steer for Scilab */
+ /*if (ole->ministream == NULL) return OLEER_MINISTREAM_READ_FAIL; */
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: ministream done", FL);
+
+ }
+ else if (adir->element_type == STGTY_STORAGE)
+ {
+ /** STORAGE ELEMENT **/
+ /** STORAGE ELEMENT **/
+ /** STORAGE ELEMENT **/
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: Item is directory, start child is at index %d\n", FL, i);
+
+ ole->ministream = OLE_load_chain(ole, adir->start_sector);
+ /* commented out by Serge Steer for Scilab */
+ /*if (ole->ministream == NULL) return OLEER_MINISTREAM_READ_FAIL; */
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: DIRECTORY ministream done", FL);
+
+ }
+ else if (adir->element_type == STGTY_STREAM)
+ {
+ /** STREAM ELEMENT **/
+ /** STREAM ELEMENT **/
+ /** STREAM ELEMENT **/
+ /* due to ole.c bugs we restrict here steams to decode to Workbooks (Excel) */
+ char element_name[64];
+
+ memset(element_name, '\0', 64);
+ OLE_dbstosbs(adir->element_name, adir->element_name_byte_count, element_name, 64);
+
+ if ((strcmp(element_name, "Workbook") == 0) || (strcmp(element_name, "Book") == 0))
+ {
+ OLE_decode_stream(ole, adir, decode_path);
+ }
+ /*end of replacment code */
+ /* Original code */
+ /* OLE_decode_stream( ole, adir, decode_path ); */
+ }
+ else
+ {
+ /** If the element isn't of the above types then it's possibly
+ ** an empty element or just one used for the MSAT/SAT
+ ** either way we just step over it and carry on **/
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: Element type %d does not need to be handled", FL, adir->element_type);
+ }
+
+ /* Jump to the next property record, which */
+ /* is always 128 bytes ahead. */
+ current_property += 128;
+ i++;
+
+ } /* While there are still more directory entries to read in. */
+
+ DOLE LOGGER_log("%s:%d:OLE_decode_file:DEBUG: Finished", FL);
+
+ /*
+ * if (ole->f) fclose(ole->f);
+ * fclose(ole->f);
+ * if (ole->FAT) FREE(ole->FAT);
+ * if (ole->miniFAT) FREE(ole->miniFAT);
+ * if (ole->ministream) FREE(ole->ministream);
+ * if (ole->properties) FREE(ole->properties);
+ */
+
+ return OLE_OK;
+}
diff --git a/modules/spreadsheet/src/c/ripole/ole.h b/modules/spreadsheet/src/c/ripole/ole.h
new file mode 100755
index 000000000..c52e85a9b
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/ole.h
@@ -0,0 +1,173 @@
+
+#ifndef LIBOLE
+#define LIBOLE
+
+#define LIBOLE_VERSION "200512112226"
+
+#define OLE_OK 0
+#define OLEER_NO_INPUT_FILE 100
+#define OLEER_BAD_INPUT_FILE 101
+#define OLEER_NOT_OLE_FILE 102
+#define OLEER_INSANE_OLE_FILE 103
+
+#define OLEER_DECODE_NULL_OBJECT 10
+#define OLEER_DECODE_NULL_FILENAME 11
+#define OLEER_DECODE_NULL_PATH 12
+
+#define OLEER_LOADFAT_BAD_BOUNDARY 20
+
+#define OLEER_MINIFAT_READ_FAIL 30
+#define OLEER_PROPERTIES_READ_FAIL 31
+#define OLEER_MINISTREAM_READ_FAIL 32
+#define OLEER_MINISTREAM_STREAM_READ_FAIL 33
+#define OLEER_NORMALSTREAM_STREAM_READ_FAIL 34
+
+#define OLEER_GET_BLOCK_SEEK 41
+#define OLEER_GET_BLOCK_READ 42
+
+#define OLEER_MEMORY_OVERFLOW 50
+
+#define OLE_VERBOSE_NORMAL 1
+#define OLE_VERBOSE_FATREAD 2
+#define OLE_VERBOSE_DIRREAD 4
+#define OLE_VERBOSE_STREAMREAD 8
+#define OLE_VERBOSE_STREAMDECODE 16
+
+#define OLE_VNORMAL(x) ((x) && OLE_VERBOSE_NORMAL == OLE_VERBOSE_NORMAL )
+
+#define OLE_DEBUG_NORMAL 1
+#define OLE_DEBUG_PEDANTIC 2
+
+#define OLE_DNORMAL(x) ((x) && OLE_DEBUG_NORMAL == OLE_DEBUG_NORMAL)
+#define OLE_DPEDANTIC(x) ((x) && OLE_DEBUG_PEDANTIC == OLE_DEBUG_PEDANTIC)
+
+
+#define OLE_HEADER_FAT_SECTOR_COUNT_LIMIT 109
+struct OLE_header
+{
+ unsigned int minor_version;
+ unsigned int dll_version;
+ unsigned int byte_order;
+ unsigned int sector_shift;
+ unsigned int sector_size;
+ unsigned int mini_sector_shift;
+ unsigned int mini_sector_size;
+ unsigned int fat_sector_count;
+ unsigned int directory_stream_start_sector;
+ unsigned int mini_cutoff_size;
+ unsigned int mini_fat_start;
+ unsigned int mini_fat_sector_count;
+ unsigned int dif_start_sector;
+ unsigned int dif_sector_count;
+ unsigned int FAT[OLE_HEADER_FAT_SECTOR_COUNT_LIMIT];
+};
+
+#define OLE_DIRECTORY_ELEMENT_NAME_SIZE 64
+#define OLE_DIRECTORY_CLASS_SIZE 16
+#define OLE_DIRECTORY_TIMESTAMPS_SIZE 16
+struct OLE_directory_entry
+{
+ char element_name[OLE_DIRECTORY_ELEMENT_NAME_SIZE];
+ int element_name_byte_count;
+
+ char element_type;
+ char element_colour;
+
+ unsigned int left_child;
+ unsigned int right_child;
+ unsigned int root;
+
+ unsigned char class[OLE_DIRECTORY_CLASS_SIZE];
+ unsigned int userflags;
+ unsigned char timestamps[OLE_DIRECTORY_TIMESTAMPS_SIZE];
+ unsigned int start_sector;
+ unsigned int stream_size;
+};
+
+
+
+#define OLE_HEADER_BLOCK_SIZE 512
+struct OLE_object
+{
+
+ int error;
+ size_t file_size;
+ int last_sector;
+ size_t last_chain_size;
+
+ FILE *f;
+ unsigned char *FAT;
+ unsigned char *FAT_limit; /** Added to prevent segment violations **/
+ unsigned char *miniFAT;
+ unsigned char *miniFAT_limit; /** Added to prevent segment violations **/
+ unsigned char header_block[OLE_HEADER_BLOCK_SIZE];
+ unsigned char *ministream;
+ unsigned char *properties;
+
+ struct OLE_header header;
+
+ /* End user configurable parameters:*/
+ int debug;
+ int verbose;
+ int quiet;
+ int save_unknown_streams;
+
+ int save_streams;
+ int save_mini_streams;
+ int save_normal_streams;
+
+ int decode_streams;
+ int decode_mini_streams;
+ int decode_normal_streams;
+
+ int (*filename_report_fn)(char *);
+
+};
+
+
+
+/* Prototypes*/
+
+int OLE_version( void );
+
+int OLE_init( struct OLE_object *ole );
+int OLE_set_verbose( struct OLE_object *ole, int level );
+int OLE_set_debug( struct OLE_object *ole, int level );
+int OLE_set_quiet( struct OLE_object *ole, int level );
+int OLE_set_save_unknown_streams( struct OLE_object *ole, int level );
+
+int OLE_get_block( struct OLE_object *ole, int block_index, unsigned char *block_buffer );
+int OLE_get_miniblock( struct OLE_object *ole, int block_index, unsigned char *block_buffer );
+int OLE_dbstosbs( char *raw_string, size_t char_count, char *clean_string, int clean_string_len );
+int OLE_print_string( char *string, size_t char_count);
+/**
+ ** Bruno : Removed, is now static in ole.c !!
+ ** int OLE_print_sector( struct OLE_object *ole, char *sector, unsigned int bytes);
+ **/
+int OLE_get_header( struct OLE_object *ole );
+int OLE_convert_header( struct OLE_object *ole );
+int OLE_print_header( struct OLE_object *ole );
+int OLE_convert_directory(struct OLE_object *ole, unsigned char *buf, struct OLE_directory_entry *dir );
+int OLE_print_directory( struct OLE_object *ole, struct OLE_directory_entry *dir );
+int OLE_load_FAT( struct OLE_object *ole );
+int OLE_follow_chain( struct OLE_object *ole, int FAT_sector_start );
+int OLE_follow_minichain( struct OLE_object *ole, int miniFAT_sector_start );
+unsigned char *OLE_load_minichain( struct OLE_object *ole, int miniFAT_sector_start );
+unsigned char *OLE_load_chain( struct OLE_object *ole, int FAT_sector_start );
+int OLE_open_file( struct OLE_object *ole, char *fullpath );
+int OLE_decode_file( struct OLE_object *ole, char *fname, char *decode_path );
+int OLE_decode_file_done( struct OLE_object *ole );
+
+int OLE_dir_init(struct OLE_directory_entry *dir );
+int OLE_sectorpos( struct OLE_object *ole, int SID );
+int OLE_is_file_OLE( struct OLE_object *ole );
+int OLE_open_directory( struct OLE_object *ole, char *directory );
+int OLE_store_stream( struct OLE_object *ole, char *stream_name, char *directory, char *stream, size_t stream_size );
+int OLE_terminate_and_return( struct OLE_object *ole, int result );
+int OLE_decode_stream( struct OLE_object *ole, struct OLE_directory_entry *adir, char *decode_path );
+
+
+/* Our callbacks.*/
+int OLE_set_filename_report_fn( struct OLE_object *ole, int (*ptr_to_fn)(char *) );
+
+#endif
diff --git a/modules/spreadsheet/src/c/ripole/olestream-unwrap.c b/modules/spreadsheet/src/c/ripole/olestream-unwrap.c
new file mode 100755
index 000000000..a34f3d728
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/olestream-unwrap.c
@@ -0,0 +1,400 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+
+#include "logger.h"
+#include "pldstr.h"
+#include "bytedecoders.h"
+#include "olestream-unwrap.h"
+#include "localization.h"
+#include "MALLOC.h"
+#include "charEncoding.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
+
+
+#define DUW if (oleuw->debug)
+
+struct OLE10_header
+{
+ unsigned char data[6];
+ char *attach_name;
+ unsigned char data2[8];
+ char *fname_1;
+ char *fname_2;
+ size_t attach_size;
+ size_t attach_size_1;
+ size_t attach_start_offset;
+};
+
+
+/*-----------------------------------------------------------------\
+ Function Name : OLEUNWRAP_init
+ Returns Type : int
+ ----Parameter List
+ 1. struct OLEUNWRAP_object *oleuw ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+--------------------------------------------------------------------
+ Comments:
+
+--------------------------------------------------------------------
+ Changes:
+
+\------------------------------------------------------------------*/
+int OLEUNWRAP_init( struct OLEUNWRAP_object *oleuw )
+{
+ oleuw->debug = 0;
+ oleuw->verbose = 0;
+ oleuw->filename_report_fn = NULL;
+
+ return OLEUW_OK;
+}
+
+/*-----------------------------------------------------------------\
+ Function Name : OLEUNWRAP_set_debug
+ Returns Type : int
+ ----Parameter List
+ 1. struct OLEUNWRAP_object *oleuw,
+ 2. int level ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+--------------------------------------------------------------------
+ Comments:
+
+--------------------------------------------------------------------
+ Changes:
+
+\------------------------------------------------------------------*/
+int OLEUNWRAP_set_debug( struct OLEUNWRAP_object *oleuw, int level )
+{
+ oleuw->debug = level;
+ return OLEUW_OK;
+}
+
+/*-----------------------------------------------------------------\
+ Function Name : OLEUNWRAP_set_verbose
+ Returns Type : int
+ ----Parameter List
+ 1. struct OLEUNWRAP_object *oleuw,
+ 2. int level ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+--------------------------------------------------------------------
+ Comments:
+
+--------------------------------------------------------------------
+ Changes:
+
+\------------------------------------------------------------------*/
+int OLEUNWRAP_set_verbose( struct OLEUNWRAP_object *oleuw, int level )
+{
+ oleuw->verbose = level;
+ return OLEUW_OK;
+}
+
+/*-----------------------------------------------------------------\
+ Function Name : OLEUNWRAP_set_save_unknown_streams
+ Returns Type : int
+ ----Parameter List
+ 1. struct OLEUNWRAP_object *oleuw,
+ 2. int level ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+--------------------------------------------------------------------
+ Comments:
+
+--------------------------------------------------------------------
+ Changes:
+
+\------------------------------------------------------------------*/
+int OLEUNWRAP_set_save_unknown_streams( struct OLEUNWRAP_object *oleuw, int level )
+{
+ oleuw->save_unknown_streams = level;
+ return OLEUW_OK;
+}
+
+
+/*-----------------------------------------------------------------\
+ Function Name : OLEUNWRAP_save_stream
+ Returns Type : int
+ ----Parameter List
+ 1. char *fname,
+ 2. char *stream,
+ 3. size_t bytes ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+--------------------------------------------------------------------
+ Comments:
+
+--------------------------------------------------------------------
+ Changes:
+
+\------------------------------------------------------------------*/
+int OLEUNWRAP_save_stream( struct OLEUNWRAP_object *oleuw, char *fname, char *decode_path, char *stream, size_t bytes )
+{
+ char *full_name;
+ FILE *f;
+ int result = 0;
+
+ DUW LOGGER_log("%s:%d:OLEUNWRAP_save_stream:DEBUG: fname=%s, decodepath=%s, size=%ld"
+ , FL
+ , fname
+ , decode_path
+ , bytes
+ );
+
+ full_name = PLD_dprintf("%s/%s", decode_path, fname );
+ if (full_name == NULL)
+ {
+ LOGGER_log(_("%s:%d:OLEUNWRAP_save_stream:ERROR: Unable to create filename string from '%s' and '%s'"), FL, fname, decode_path);
+ return -1;
+ }
+
+ wcfopen(f, full_name, "wb");
+ if (f != NULL)
+ {
+ size_t write_count;
+
+ write_count = fwrite( stream, 1, bytes, f );
+ if (write_count != bytes)
+ {
+ LOGGER_log(_("%s:%d:OLEUNWRAP_save_stream:WARNING: Only wrote %d of %d bytes to file %s\n"), FL, write_count, bytes, full_name );
+ }
+
+ fclose(f);
+
+
+ }
+ else
+ {
+ LOGGER_log(_("%s:%d:OLEUNWRAP_save_stream:ERROR: Unable to open %s for writing (%s)\n"), FL, full_name, strerror(errno));
+ result = -1;
+ }
+
+ if (full_name)
+ {
+ FREE(full_name);
+ }
+
+ DUW LOGGER_log("%s:%d:OLEUNWRAP_save_stream:DEBUG: Done saving '%s'", FL, fname);
+
+ return result;
+}
+
+/*-----------------------------------------------------------------\
+ Function Name : OLEUNWRAP_sanitize_filename
+ Returns Type : int
+ ----Parameter List
+ 1. char *fname ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+--------------------------------------------------------------------
+ Comments:
+
+--------------------------------------------------------------------
+ Changes:
+
+\------------------------------------------------------------------*/
+int OLEUNWRAP_sanitize_filename( char *fname )
+{
+ while (*fname)
+ {
+ if ( !isalnum((int)*fname) && (*fname != '.') )
+ {
+ *fname = '_';
+ }
+ if ( (*fname < ' ') || (*fname > '~') )
+ {
+ *fname = '_';
+ }
+ fname++;
+ }
+ return 0;
+}
+
+/*-----------------------------------------------------------------\
+ Function Name : OLEUNWRAP_decode_attachment
+ Returns Type : int
+ ----Parameter List
+ 1. char *stream ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+--------------------------------------------------------------------
+ Comments:
+
+--------------------------------------------------------------------
+ Changes:
+
+\------------------------------------------------------------------*/
+int OLEUNWRAP_decode_attachment( struct OLEUNWRAP_object *oleuw, char *stream, size_t stream_size, char *decode_path )
+{
+ struct OLE10_header oh;
+ char *sp = stream;
+ char *data_start_point = stream;
+ int result = OLEUW_OK;
+
+ /* Get the data size*/
+ oh.attach_size_1 = (size_t)get_4byte_value( (unsigned char *) sp );
+ sp += 4;
+
+ DUW LOGGER_log("%s:%d:OLEUNWRAP_decode_attachment:DEBUG: attachsize = %d, stream length = %d\n", FL, oh.attach_size_1, stream_size );
+
+ oh.attach_start_offset = (stream_size - oh.attach_size_1);
+ data_start_point = stream + oh.attach_start_offset;
+
+ /*if (oh.attach_start_offset == 4)*/
+ if (oh.attach_start_offset < 4)
+ {
+ /* If we only had the stream byte-length in our header*/
+ /* then we know we don't have a complex header.*/
+ oh.attach_name = PLD_dprintf("unknown-%ld", oh.attach_size_1);
+ oh.attach_size = oh.attach_size_1;
+ }
+ else
+ {
+
+ DUW LOGGER_log("%s:%d:OLEUNWRAP_decode_attachment:DEBUG: Decoding file information header", FL);
+ /* Unknown memory segment*/
+ memcpy( oh.data, sp, 2 );
+ sp += 2;
+
+ /* Full attachment string*/
+ oh.attach_name = strdup( sp );
+ sp = sp + strlen(oh.attach_name) + 1;
+
+ /* Attachment full path*/
+ oh.fname_1 = strdup( sp );
+ sp += strlen(oh.fname_1) + 1;
+
+ /* Unknown memory segment*/
+ memcpy( oh.data2, sp, 8 );
+ sp = sp + 8;
+
+ /* Attachment full path*/
+ oh.fname_2 = strdup( sp );
+ sp += strlen(oh.fname_2) + 1;
+
+ oh.attach_size = (size_t)get_4byte_value( (unsigned char*) sp );
+ sp += 4;
+
+ if (oh.attach_size > stream_size)
+ {
+ oh.attach_size = stream_size;
+ }
+
+ data_start_point = sp;
+ }
+
+ DUW LOGGER_log(_("%s:%d:OLEUNWRAP_decode_attachment:DEBUG: Attachment %s:%s:%s size = %d\n"), FL, oh.attach_name, oh.fname_1, oh.fname_2, oh.attach_size );
+
+
+ /** 20050119:2053:PLD - Added to sanitize 8-bit filenames **/
+ /** Sanitize the output filename **/
+ OLEUNWRAP_sanitize_filename(oh.attach_name);
+ OLEUNWRAP_sanitize_filename(oh.fname_1);
+ OLEUNWRAP_sanitize_filename(oh.fname_2);
+
+ result = OLEUNWRAP_save_stream( oleuw, oh.attach_name, decode_path, data_start_point, oh.attach_size );
+ if (result == OLEUW_OK)
+ {
+ if (oleuw->debug > 0)
+ {
+ LOGGER_log(_("%s:%d:OLEUNWRAP_decode_attachment:DEBUG: Calling reporter for the filename"), FL);
+ }
+ if ((oleuw->verbose > 0) && (oleuw->filename_report_fn != NULL))
+ {
+ oleuw->filename_report_fn(oh.attach_name);
+ }
+ /* Do call back to reporting function*/
+ }
+
+ /* Clean up our previously allocated data*/
+ if (oh.fname_1 != NULL)
+ {
+ FREE(oh.fname_1);
+ }
+ if (oh.attach_name != NULL)
+ {
+ FREE(oh.attach_name);
+ }
+ if (oh.fname_2 != NULL)
+ {
+ FREE(oh.fname_2);
+ }
+
+ return OLEUW_OK;
+}
+
+/*-----------------------------------------------------------------\
+ Function Name : OLEUNWRAP_decodestream
+ Returns Type : int
+ ----Parameter List
+ 1. char *element_string,
+ 2. char *stream ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+--------------------------------------------------------------------
+ Comments:
+
+--------------------------------------------------------------------
+ Changes:
+
+\------------------------------------------------------------------*/
+int OLEUNWRAP_decodestream( struct OLEUNWRAP_object *oleuw, char *element_string, char *stream, size_t stream_size, char *decode_path )
+{
+ int result = OLEUW_OK;
+
+ if (strstr(element_string, OLEUW_ELEMENT_10NATIVE_STRING) != NULL)
+ {
+ OLEUNWRAP_decode_attachment( oleuw, stream, stream_size, decode_path );
+
+ }
+ else
+ {
+ if (oleuw->debug)
+ {
+ LOGGER_log(_("Unable to decode stream with element string '%s'\n"), element_string);
+ }
+ result = OLEUW_STREAM_NOT_DECODED;
+ }
+
+ return result;
+}
+
+
+/*-----------------------------------------------------------------\
+ Function Name : OLEUNWRAP_set_filename_report_fn
+ Returns Type : int
+ ----Parameter List
+ 1. struct OLEUNWRAP_object *oleuw,
+ 2. int (*ptr_to_fn)(char *) ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+--------------------------------------------------------------------
+ Comments:
+
+--------------------------------------------------------------------
+ Changes:
+
+\------------------------------------------------------------------*/
+int OLEUNWRAP_set_filename_report_fn( struct OLEUNWRAP_object *oleuw, int (*ptr_to_fn)(char *) )
+{
+
+ oleuw->filename_report_fn = ptr_to_fn;
+
+ return 0;
+}
+
diff --git a/modules/spreadsheet/src/c/ripole/olestream-unwrap.h b/modules/spreadsheet/src/c/ripole/olestream-unwrap.h
new file mode 100755
index 000000000..fc8492cfb
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/olestream-unwrap.h
@@ -0,0 +1,28 @@
+
+#define OLEUW_ELEMENT_10NATIVE 10
+#define OLEUW_ELEMENT_10NATIVE_STRING "Ole10Native"
+
+#define OLEUW_OK 0
+#define OLEUW_STREAM_NOT_DECODED 100
+
+struct OLEUNWRAP_object
+{
+ int (*filename_report_fn)(char *);
+ int debug;
+ int verbose;
+ int save_unknown_streams;
+};
+
+
+int OLEUNWRAP_init( struct OLEUNWRAP_object *oleuw );
+int OLEUNWRAP_set_debug( struct OLEUNWRAP_object *oleuw, int level );
+int OLEUNWRAP_set_verbose( struct OLEUNWRAP_object *oleuw, int level );
+int OLEUNWRAP_set_save_unknown_streams( struct OLEUNWRAP_object *oleuw, int level );
+
+int OLEUNWRAP_save_stream( struct OLEUNWRAP_object *oleuw, char *fname, char *decode_path, char *stream, size_t bytes );
+int OLEUNWRAP_decode_attachment( struct OLEUNWRAP_object *oleuw, char *stream, size_t stream_size, char *decode_path );
+int OLEUNWRAP_decodestream( struct OLEUNWRAP_object *oleuw, char *element_string, char *stream, size_t stream_size, char *decode_path );
+
+int OLEUNWRAP_set_filename_report_fn( struct OLEUNWRAP_object *oleuw, int (*ptr_to_fn)(char *) );
+
+int OLEUNWRAP_sanitize_filename(char *fname);
diff --git a/modules/spreadsheet/src/c/ripole/pldstr.c b/modules/spreadsheet/src/c/ripole/pldstr.c
new file mode 100755
index 000000000..659ef56bf
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/pldstr.c
@@ -0,0 +1,908 @@
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "logger.h"
+#include "pldstr.h"
+#include "MALLOC.h"
+#include "localization.h"
+
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#define vsnprintf _vsnprintf
+#endif
+
+/*-----------------------------------------------------------------\
+ Function Name : *PLD_strstr
+ Returns Type : char
+ ----Parameter List
+ 1. char *haystack,
+ 2. char *needle,
+ 3. int insensitive,
+ ------------------
+ Exit Codes :
+ Side Effects :
+--------------------------------------------------------------------
+ Comments:
+
+--------------------------------------------------------------------
+ Changes:
+
+\------------------------------------------------------------------*/
+char *PLD_strstr(char *haystack, char *needle, int insensitive)
+{
+ char *hs;
+ char *ne;
+ char *result;
+
+ /* LOGGER_log("%s:%d:\nHS=%s\nNE=%s\nIS=%d\n",FL, haystack, needle, insensitive );*/
+
+ if (insensitive > 0)
+ {
+ hs = strdup(haystack);
+ PLD_strlower((unsigned char*) hs);
+ ne = strdup(needle);
+ PLD_strlower((unsigned char*) ne);
+ }
+ else
+ {
+ hs = haystack;
+ ne = needle;
+ }
+
+ result = strstr(hs, ne);
+ /* if (result) LOGGER_log("%s:%d:HIT: %s",FL, result);*/
+ /* else LOGGER_log("%s:%d:MISS (looking for %s|%s)",FL, needle,ne);*/
+
+ if ((result != NULL) && (insensitive > 0))
+ {
+ result = result - hs + haystack;
+ FREE(hs);
+ FREE(ne);
+
+ /* LOGGER_log("%s:%d:HIT - %s",FL, result );*/
+ }
+
+ return result;
+}
+
+/*------------------------------------------------------------------------
+Procedure: PLD_strncpy ID:1
+Purpose: Copy characters from 'src' to 'dst', writing not more than 'len'
+characters to the destination, including the terminating \0.
+Thus, for any effective copying, len must be > 1.
+Input: char *dst: Destination string
+char *src: Source string
+size_t len: length of string
+Output: Returns a pointer to the destination string.
+Errors:
+------------------------------------------------------------------------*/
+char *PLD_strncpy (char *dst, const char *src, size_t len)
+{
+
+ /* Thanks go to 'defrost' of #c for providing the replacement*/
+ /* code which you now see here. It covers the errors better*/
+ /* than my own previous code.*/
+
+ /* If we have no buffer space, then it's futile attempting*/
+ /* to copy anything, just return NULL*/
+ if (len == 0)
+ {
+ return NULL;
+ }
+
+ /* Providing our destination pointer isn't NULL, we can*/
+ /* commence copying data across*/
+
+ if (dst)
+ {
+ char *dp = dst;
+
+ /* If our source string exists, start moving it to the*/
+ /* destination string character at a time.*/
+ if (src)
+ {
+ char *sp = (char *)src;
+ while ((--len) && (*sp))
+ {
+ *dp = *sp;
+ dp++;
+ sp++;
+ }
+ }
+
+ *dp = '\0';
+ }
+
+ return dst;
+}
+
+
+
+/*------------------------------------------------------------------------
+Procedure: PLD_strncat ID:1
+Purpose: Buffer size limited string concat function for two strings.
+Input: char *dst: Destination string
+char *src: Source string
+size_t len: Destination string buffer size - total string size cannot exceed this
+Output:
+Errors: If the length of both strings in total is greater than the available buffer space
+in *dst, we copy the maximum possible amount of chars from *src such that
+buffer does not overflow. A suffixed '\0' will always be appended.
+------------------------------------------------------------------------*/
+char *PLD_strncat( char *dst, const char *src, size_t len )
+{
+ char *dp = dst;
+ const char *sp = src;
+ size_t cc;
+
+ if (len == 0)
+ {
+ return dst;
+ }
+
+ len--;
+
+ /* Locate the end of the current string.*/
+ cc = 0;
+ while ((*dp) && (cc < len))
+ {
+ dp++;
+ cc++;
+ }
+
+ /* If we have no more buffer space, then return the destination*/
+
+ if (cc >= len)
+ {
+ return dst;
+ }
+
+ /* While we have more source, and there's more char space left in the buffer*/
+
+ while ((*sp) && (cc < len))
+ {
+ cc++;
+ *dp = *sp;
+ dp++;
+ sp++;
+ }
+
+ /* Terminate dst, as a gaurantee of string ending.*/
+
+ *dp = '\0';
+
+ return dst;
+}
+
+
+/*------------------------------------------------------------------------
+Procedure: PLD_strncate ID:1
+Purpose: Catencates a source string to the destination string starting from a given
+endpoint. This allows for faster catencation of strings by avoiding the
+computation required to locate the endpoint of the destination string.
+Input: char *dst: Destination string
+char *src: Source string
+size_t len: Destination buffer size
+char *endpoint: Endpoint of destination string, location from where new
+string will be appended
+Output:
+Errors:
+------------------------------------------------------------------------*/
+char *PLD_strncate( char *dst, const char *src, size_t len, char *endpoint )
+{
+ char *dp = dst;
+ const char *sp = src;
+ size_t cc = 0;
+
+ if (len == 0)
+ {
+ return dst;
+ }
+
+ len--;
+
+ /* If endpoint does not relate correctly, then force manual detection*/
+ /* of the endpoint.*/
+
+ if ((!endpoint) || (endpoint == dst) || ((endpoint - dst + 1) > (int)len))
+ {
+ /* Locate the end of the current string.*/
+ cc = 0;
+ while ((*dp != '\0') && (cc < len))
+ {
+ dp++;
+ cc++;
+ }
+ }
+ else
+ {
+ cc = endpoint - dst + 1;
+ dp = endpoint;
+ }
+
+ /* If we have no more buffer space, then return the destination*/
+
+ if (cc >= len)
+ {
+ return dst;
+ }
+
+ /* While we have more source, and there's more char space left in the buffer*/
+
+ while ((*sp) && (cc < len))
+ {
+ cc++;
+ *dp = *sp;
+ dp++;
+ sp++;
+ }
+
+ /* Terminate dst, as a gaurantee of string ending.*/
+
+ *dp = '\0';
+
+ return dst;
+}
+
+
+
+
+
+/*------------------------------------------------------------------------
+Procedure: XAM_strncasecmp ID:1
+Purpose: Portable version of strncasecmp(), this may be removed in later
+versions as the strncase* type functions are more widely
+implemented
+Input:
+Output:
+Errors:
+------------------------------------------------------------------------*/
+int PLD_strncasecmp( char *s1, char *s2, int n )
+{
+ char *ds1 = s1, *ds2 = s2;
+ char c1, c2;
+ int result = 0;
+
+ while (n > 0)
+ {
+ c1 = (char)tolower(*ds1);
+ c2 = (char)tolower(*ds2);
+
+ if (c1 == c2)
+ {
+ n--;
+ ds1++;
+ ds2++;
+ }
+ else
+ {
+ result = c2 - c1;
+ n = 0;
+ }
+
+ }
+
+ return result;
+
+}
+
+
+
+
+
+/*------------------------------------------------------------------------
+Procedure: XAM_strtok ID:1
+Purpose: A thread safe version of strtok()
+Input:
+Output:
+Errors:
+------------------------------------------------------------------------*/
+char *PLD_strtok( struct PLD_strtok *st, char *line, char *delimeters )
+{
+ char *stop;
+ char *dc;
+ char *result = NULL;
+
+ if ( line )
+ {
+ st->start = line;
+ }
+
+ /*Strip off any leading delimeters*/
+
+ dc = delimeters;
+ while ((st->start) && (*dc != '\0'))
+ {
+ if (*dc == *(st->start))
+ {
+ st->start++;
+ dc = delimeters;
+ }
+ else
+ {
+ dc++;
+ }
+ }
+
+ /* Where we are left, is the start of our token.*/
+
+ result = st->start;
+
+ if ((st->start) && (st->start != '\0'))
+ {
+ stop = strpbrk( st->start, delimeters ); /* locate our next delimeter */
+
+ /* If we found a delimeter, then that is good. We must now break the string here*/
+ /* and don't forget to store the character which we stopped on. Very useful bit*/
+ /* of information for programs which process expressions.*/
+
+ if (stop)
+ {
+
+ /* Store our delimeter.*/
+
+ st->delimeter = *stop;
+
+ /* Terminate our token.*/
+
+ *stop = '\0';
+
+
+ /* Because we're emulating strtok() behaviour here, we have to*/
+ /* absorb all the concurrent delimeters, that is, unless we*/
+ /* reach the end of the string, we cannot return a string with*/
+ /* no chars.*/
+
+ stop++;
+ dc = delimeters;
+ while (*dc != '\0')
+ {
+ if (*dc == *stop)
+ {
+ stop++;
+ dc = delimeters;
+ }
+ else
+ {
+ dc++;
+ }
+ } /* While*/
+
+ if (*stop == '\0')
+ {
+ st->start = NULL;
+ }
+ else
+ {
+ st->start = stop;
+ }
+
+ }
+ else
+ {
+ st->start = NULL;
+ st->delimeter = '\0';
+ }
+ }
+ else
+ {
+ st->start = NULL;
+ result = NULL;
+ }
+
+
+ return result;
+}
+
+
+
+/*------------------------------------------------------------------------
+Procedure: PLD_strlower ID:1
+Purpose: Converts a string to lowercase
+Input: char *convertme : string to convert
+Output:
+Errors:
+------------------------------------------------------------------------*/
+int PLD_strlower( unsigned char *convertme )
+{
+
+ /* Updates:*/
+ /* 09-11-2002 - changed from 'char *' to 'unsigned char *' to deal with*/
+ /* non-ASCII characters ( ie, french ). Pointed out by Emmanuel Collignon*/
+
+ unsigned char *c = convertme;
+
+ while ( *c != '\0')
+ {
+ *c = (unsigned char)tolower((int) * c);
+ c++;
+ }
+
+ return 0;
+}
+
+
+/*-----------------------------------------------------------------\
+ Function Name : *PLD_strreplace
+ Returns Type : char
+ ----Parameter List
+ 1. char *source, Original buffer, \0 terminated
+ 2. char *searchfor, String sequence to search for
+ 3. char *replacewith, String sequence to replace 'searchfor' with
+ 4. int replacenumber , How many times to replace 'searchfor', 0 == unlimited
+ ------------------
+ Exit Codes : Returns a pointer to the new buffer space. The original
+ buffer will still remain intact - ensure that the calling
+ program FREE()'s the original buffer if it's no longer
+ needed
+ Side Effects :
+ --------------------------------------------------------------------
+Comments:
+Start out with static text matching - upgrade to regex later.
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+char *PLD_strreplace_general( struct PLD_strreplace *replace_details )
+{
+ char *new_buffer = NULL;
+ char *source_end;
+ char *segment_start, *segment_end, *segment_p;
+ char *new_p;
+ char *preexist_location = NULL;
+ char *postexist_location = NULL;
+ int replace_count = 0;
+ int size_required;
+ int size_difference;
+ int source_length;
+ int searchfor_length;
+ int replacewith_length;
+ int segment_ok;
+
+ if (replace_details->source == NULL)
+ {
+ return NULL;
+ }
+
+ source_length = (int)strlen( replace_details->source );
+ source_end = replace_details->source + source_length;
+ searchfor_length = (int)strlen(replace_details->searchfor);
+ replacewith_length = (int)strlen(replace_details->replacewith);
+ size_difference = replacewith_length - searchfor_length;
+ size_required = source_length;
+ replace_count = replace_details->replacenumber;
+
+ if ((replace_details->preexist != NULL) && (strlen(replace_details->preexist) < 1))
+ {
+ replace_details->preexist = NULL;
+ }
+ if ((replace_details->postexist != NULL) && (strlen(replace_details->postexist) < 1))
+ {
+ replace_details->postexist = NULL;
+ }
+
+ /* If we have a 'pre-exist' request, then we need to check this out first*/
+ /* because if the pre-exist string cannot be found, then there's very*/
+ /* little point us continuing on in our search ( because without the*/
+ /* preexist string existing, we are thus not qualified to replace anything )*/
+ if (replace_details->preexist != NULL)
+ {
+ preexist_location = PLD_strstr(replace_details->source, replace_details->preexist, replace_details->insensitive);
+ if (preexist_location == NULL)
+ {
+ return replace_details->source;
+ }
+ }
+
+ /* Determine if initial POSTexist tests will pass, if we don't pick up*/
+ /* anything here, then there's no point in continuing either*/
+ if (replace_details->postexist != NULL)
+ {
+ char *p = replace_details->source;
+ postexist_location = NULL;
+ do
+ {
+ p = PLD_strstr(p, replace_details->postexist, replace_details->insensitive);
+ if (p != NULL)
+ {
+ postexist_location = p;
+ p = p + strlen(replace_details->postexist);
+ }
+ }
+ while (p != NULL);
+
+ if (postexist_location == NULL)
+ {
+ return replace_details->source;
+ }
+ }
+
+
+ /* Step 1 - determine the MAXIMUM number of times we might have to replace this string ( or the limit*/
+ /* set by replacenumber*/
+ /**/
+ /* Note - we only need this number if the string we're going to be inserting into the */
+ /* source is larger than the one we're replacing - this is so that we can ensure that*/
+ /* we have sufficient memory available in the buffer.*/
+ if (size_difference > 0)
+ {
+ if (replace_count == 0)
+ {
+ char *p, *q;
+
+ p = replace_details->source;
+ q = PLD_strstr(p, replace_details->searchfor, replace_details->insensitive);
+ while (q != NULL)
+ {
+ replace_count++;
+ /*size_required += size_difference;*/
+ p = q + searchfor_length;
+ q = PLD_strstr(p, replace_details->searchfor, replace_details->insensitive);
+ }
+
+ }
+ size_required = source_length + (size_difference * replace_count) + 1;
+ }
+ else
+ {
+ size_required = source_length + 1;
+ }
+
+
+ /* Allocate the memory required to hold the new string [at least], check to see that*/
+ /* all went well, if not, then return an error*/
+ new_buffer = MALLOC( sizeof(char) * size_required);
+ if (new_buffer == NULL)
+ {
+ LOGGER_log(_("%s:%d:PLD_strreplace:ERROR: Cannot allocate %d bytes of memory to perform replacement operation"), FL, size_required);
+ return replace_details->source;
+ }
+
+ /* Our segment must always start at the beginning of the source, */
+ /* on the other hand, the segment_end can be anything from the*/
+ /* next byte to NULL ( which is specially treated to mean to */
+ /* the end of the source )*/
+ segment_start = replace_details->source;
+
+
+ /* Locate the first segment */
+ segment_ok = 0;
+ segment_end = PLD_strstr(replace_details->source, replace_details->searchfor, replace_details->insensitive);
+
+ /* Determine if the first segment is valid in the presence of the */
+ /* pre-exist and post-exist requirements*/
+ while ((segment_end != NULL) && (segment_ok == 0)\
+ && ((replace_details->preexist != NULL) || (replace_details->postexist != NULL)))
+ {
+ int pre_ok = 0;
+ int post_ok = 0;
+
+ /* The PREexist test assumes a couple of factors - please ensure these are*/
+ /* relevant if you change any code prior to this point.*/
+ /* */
+ /* 1. preexist_location has already been computed and is not NULL*/
+ /**/
+ /* 2. By relative position, the first preexist_location will be a valid location*/
+ /* on which to validate for ALL replacements beyond that point, thus, we*/
+ /* never actually have to recompute preexist_location again.*/
+ /**/
+ /* 3. Conversely, the last computed postexist_location is valid for all */
+ /* matches before it*/
+ /**/
+ if (preexist_location == NULL)
+ {
+ pre_ok = 1;
+ }
+ else if (preexist_location < segment_end)
+ {
+ pre_ok = 1;
+ }
+
+ if (postexist_location == NULL)
+ {
+ post_ok = 1;
+ }
+ else if (postexist_location > segment_end)
+ {
+ post_ok = 1;
+ }
+
+ if ((pre_ok == 0) || (post_ok == 0))
+ {
+ segment_end = PLD_strstr(segment_end + searchfor_length, replace_details->searchfor, replace_details->insensitive);
+ }
+ else
+ {
+ segment_ok = 1;
+ }
+ }
+
+ segment_p = segment_start;
+ new_p = new_buffer;
+ while (segment_start != NULL)
+ {
+ int replacewith_count;
+ char *replacewith_p;
+
+ if (segment_end == NULL)
+ {
+ segment_end = source_end;
+ }
+
+ replace_count--;
+
+ /* Perform the segment copy*/
+ segment_p = segment_start;
+ while ((segment_p < segment_end) && (size_required > 0))
+ {
+ *new_p = *segment_p;
+ new_p++;
+ segment_p++;
+ size_required--;
+ }
+
+ /* Perform the string replacement*/
+ if (segment_end < source_end)
+ {
+ replacewith_count = replacewith_length;
+ replacewith_p = replace_details->replacewith;
+ while ((replacewith_count--) && (size_required > 0))
+ {
+ *new_p = *replacewith_p;
+ new_p++;
+ replacewith_p++;
+ size_required--;
+ }
+ }
+
+ if (size_required < 1 )
+ {
+ LOGGER_log(_("%s:%d:PLD_strreplace_general: Allocated memory ran out while replacing '%s' with '%s'"), FL, replace_details->searchfor, replace_details->replacewith);
+ *new_p = '\0';
+ break;
+ }
+
+ /* Find the next segment*/
+ segment_start = segment_end + searchfor_length;
+
+ /* If we've reached the end of the number of replacements we're supposed*/
+ /* to do, then we prepare the termination of the while loop by setting*/
+ /* our segment end to the end of the source.*/
+ /**/
+ /* NOTE: Remember that the replace_count is pre-decremented at the start*/
+ /* of the while loop, so, if the caller requested '0' replacements*/
+ /* this will now be -1, thus, it won't get terminated from this == 0*/
+ /* match. Just thought you'd like to be reminded of that incase you*/
+ /* were wondering "Huh? this would terminate an unlimited replacement"*/
+ if (replace_count == 0)
+ {
+ segment_end = NULL;
+ }
+ else
+ {
+ /* If our new segment to copy starts after the*/
+ /* end of the source, then we actually have */
+ /* nothing else to copy, thus, we prepare the*/
+ /* segment_start varible to cause the while loop */
+ /* to terminate.*/
+ /**/
+ /* Otherwise, we try and locate the next segment*/
+ /* ending point, and set the starting point to*/
+ /* be on the 'other side' of the 'searchfor' string*/
+ /* which we found in the last search.*/
+ /**/
+ if (segment_start > source_end)
+ {
+ segment_start = NULL;
+ }
+ else
+ {
+
+ /* Try find the next segment*/
+ segment_ok = 0;
+ segment_end = PLD_strstr(segment_end + searchfor_length, replace_details->searchfor, replace_details->insensitive);
+
+ /* If we have a pre/post-exist requirement, then enter into this*/
+ /* series of tests. NOTE - at least one of the pre or post tests*/
+ /* must fire to give an meaningful result - else we'll end up with */
+ /* a loop which simply goes to the end of the searchspace buffer*/
+ while ((segment_end != NULL) && (segment_ok == 0)\
+ && ((replace_details->preexist != NULL) || (replace_details->postexist != NULL)))
+ {
+ int pre_ok = 0;
+ int post_ok = 0;
+
+ /* The PREexist test assumes a couple of factors - please ensure these are*/
+ /* relevant if you change any code prior to this point.*/
+ /* */
+ /* 1. preexist_location has already been computed and is not NULL*/
+ /**/
+ /* 2. By relative position, the first preexist_location will be a valid location*/
+ /* on which to validate for ALL replacements beyond that point, thus, we*/
+ /* never actually have to recompute preexist_location again.*/
+ /**/
+ /* 3. Conversely, the last computed postexist_location is valid for all */
+ /* matches before it*/
+ /**/
+ if (preexist_location == NULL)
+ {
+ pre_ok = 1;
+ }
+ else if (preexist_location < segment_end)
+ {
+ pre_ok = 1;
+ }
+
+ if (postexist_location == NULL)
+ {
+ post_ok = 1;
+ }
+ else if (postexist_location > segment_end)
+ {
+ post_ok = 1;
+ }
+
+ if ((pre_ok == 0) || (post_ok == 0))
+ {
+ segment_end = PLD_strstr(segment_end + searchfor_length, replace_details->searchfor, replace_details->insensitive);
+ }
+ else
+ {
+ segment_ok = 1;
+ }
+ }
+
+ } /* If-else segment_start > source_end*/
+
+ }
+
+ }
+
+ *new_p = '\0';
+
+ if (replace_details->source != NULL)
+ {
+ FREE (replace_details->source);
+ }
+ replace_details->source = new_buffer;
+ return new_buffer;
+}
+
+/*-----------------------------------------------------------------\
+ Function Name : *PLD_strreplace
+ Returns Type : char
+ ----Parameter List
+ 1. char **source,
+ 2. char *searchfor,
+ 3. char *replacewith,
+ 4. int replacenumber ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+ --------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+char *PLD_strreplace( char **source, char *searchfor, char *replacewith, int replacenumber )
+{
+ struct PLD_strreplace replace_details;
+ char *tmp_source;
+
+ replace_details.source = *source;
+ replace_details.searchfor = searchfor;
+ replace_details.replacewith = replacewith;
+ replace_details.replacenumber = replacenumber;
+ replace_details.preexist = NULL;
+ replace_details.postexist = NULL;
+ replace_details.insensitive = 0;
+
+ tmp_source = PLD_strreplace_general( &replace_details );
+
+ if (tmp_source != *source)
+ {
+ *source = tmp_source;
+ }
+
+ return *source;
+}
+
+
+/*-----------------------------------------------------------------\
+ Function Name : *PLD_dprintf
+ Returns Type : char
+ ----Parameter List
+ 1. const char *format,
+ 2. ...,
+ ------------------
+ Exit Codes :
+ Side Effects :
+--------------------------------------------------------------------
+ Comments:
+ This is a dynamic string allocation function, not as fast as some
+ other methods, but it works across the board with both glibc 2.0
+ and 2.1 series.
+
+--------------------------------------------------------------------
+ Changes:
+
+\------------------------------------------------------------------*/
+char *PLD_dprintf(const char *format, ...)
+{
+ int n, size = 1024; /* Assume we don't need more than 1K to start with*/
+ char *p;
+ va_list ap;
+
+ /* Attempt to allocate and then check */
+ p = MALLOC(size * sizeof(char));
+ if (p == NULL)
+ {
+ return NULL;
+ }
+
+ while (1)
+ {
+ /* Attempt to print out string out into the allocated space*/
+ va_start(ap, format);
+
+ n = vsnprintf (p, size, format, ap);
+ va_end(ap);
+
+ /* If things went well, then return the new string*/
+ if ((n > -1) && (n < size))
+ {
+ return p;
+ }
+
+ /* If things didn't go well, then we have to allocate more space*/
+ /* based on which glibc we're using ( fortunately, the return codes*/
+ /* tell us which glibc is being used! *phew**/
+ /**/
+ /* If n > -1, then we're being told precisely how much space we need*/
+ /* else (older glibc) we have to just guess again ...*/
+
+ if (n > -1)
+ {
+ size = n + 1; /* Allocate precisely what is needed*/
+ }
+ else
+ {
+ size *= 2; /* Double the amount allocated, note, we could just increase by 1K, but if we have a long string, we'd end up using a lot of realloc's*/
+ }
+
+ /* We could just realloc 'blind', but that'd be wrong and potentially cause a DoS, so*/
+ /* instead, we'll be good and first attempt to realloc to a temp variable then, if all*/
+ /* is well, we go ahead and update*/
+ if (1)
+ {
+ char *tmp_p;
+
+ tmp_p = REALLOC(p, size);
+ if (tmp_p == NULL)
+ {
+ if (p != NULL)
+ {
+ FREE(p);
+ }
+ return NULL;
+ }
+ else
+ {
+ p = tmp_p;
+ }
+ }
+ }
+
+}
+
+
+/*-----------------END.*/
diff --git a/modules/spreadsheet/src/c/ripole/pldstr.h b/modules/spreadsheet/src/c/ripole/pldstr.h
new file mode 100755
index 000000000..6763e2483
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/pldstr.h
@@ -0,0 +1,40 @@
+#ifndef __PLDSTR__
+#define __PLDSTR__
+
+#ifndef FL
+#define FL __FILE__,__LINE__
+#endif
+
+struct PLD_strtok
+{
+ char *start;
+ char delimeter;
+};
+
+struct PLD_strreplace
+{
+ char *source;
+ char *searchfor;
+ char *replacewith;
+
+ char *preexist;
+ char *postexist;
+
+ int replacenumber;
+
+ int insensitive;
+};
+
+char *PLD_strstr(char *haystack, char *needle, int insensitive);
+char *PLD_strncpy( char *dst, const char *src, size_t len );
+char *PLD_strncat( char *dst, const char *src, size_t len );
+char *PLD_strncate( char *dst, const char *src, size_t len, char *endpoint );
+char *PLD_strtok( struct PLD_strtok *st, char *line, char *delimeters );
+int PLD_strncasecmp( char *s1, char *s2, int n );
+int PLD_strlower( unsigned char *convertme );
+
+char *PLD_strreplace_general( struct PLD_strreplace *replace_details );
+char *PLD_strreplace( char **source, char *searchfor, char *replacewith, int replacenumber );
+char *PLD_dprintf(const char *fmt, ...);
+
+#endif
diff --git a/modules/spreadsheet/src/c/ripole/ripole.c b/modules/spreadsheet/src/c/ripole/ripole.c
new file mode 100755
index 000000000..867b69d67
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/ripole.c
@@ -0,0 +1,201 @@
+
+/* Microsoft OLE2 stream parser.*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "logger.h"
+#include "pldstr.h"
+#include "ole.h"
+#include "ripole.h"
+#include "localization.h"
+
+#undef WITHMAIN
+
+#include "MALLOC.h"
+
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
+
+#define ROLE_VERSION "0.2.0"
+
+static char defaultdir[] = ".";
+/*static char version[] = "0.2.0 - 12-December-2005 (C) PLDaniels http:/*www.pldaniels.com/ripole";
+static char help[] = "ripOLE -i <OLE2 file> [ -d <directory> ] [--save-unknown-streams] [--version|-V] [--verbose|-v] [--debug] [--help|-h]";
+*/
+/*-----------------------------------------------------------------\
+ Function Name : set_defaults
+ Returns Type : int
+ ----Parameter List
+ 1. struct ripOLE_object *role ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+ --------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int ROLE_set_defaults(struct ripOLE_object *role)
+{
+ role->outputdir = defaultdir;
+ role->debug = 0;
+ role->verbose = 0;
+ role->save_unknown_streams = 0;
+ role->inputfile = NULL;
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------\
+ Function Name : ripOLE_report_filename_decoded
+ Returns Type : int
+ ----Parameter List
+ 1. char *filename,
+ ------------------
+ Exit Codes :
+ Side Effects :
+ --------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int ROLE_report_filename_decoded(char *filename)
+{
+ LOGGER_log(_("Decoding filename=%s"), filename);
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------\
+ Function Name : ROLE_init
+ Returns Type : int
+ ----Parameter List
+ 1. struct ripOLE_object *role,
+ ------------------
+ Exit Codes :
+ Side Effects :
+ --------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int ROLE_init(struct ripOLE_object *role)
+{
+ role->debug = 0;
+ role->verbose = 0;
+ role->save_unknown_streams = 0;
+
+ role->inputfile = NULL;
+ role->outputdir = NULL;
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------\
+ Function Name : ROLE_done
+ Returns Type : int
+ ----Parameter List
+ 1. struct ripOLE_object *role,
+ ------------------
+ Exit Codes :
+ Side Effects :
+ --------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int ROLE_done(struct ripOLE_object *role)
+{
+ if (role->inputfile != NULL)
+ {
+ FREE(role->inputfile);
+ }
+ if (role->outputdir != NULL)
+ {
+ FREE(role->outputdir);
+ }
+
+ return 0;
+}
+
+/*-----------------------------------------------------------------\
+ Function Name : ROLE_validate
+ Returns Type : int
+ ----Parameter List
+ 1. struct ripOLE_object *role ,
+ ------------------
+ Exit Codes :
+ Side Effects :
+ --------------------------------------------------------------------
+Comments:
+
+--------------------------------------------------------------------
+Changes:
+
+\------------------------------------------------------------------*/
+int ROLE_validate(struct ripOLE_object *role)
+{
+ int result = 0;
+
+ if (role->inputfile == NULL)
+ {
+ fprintf(stderr, _("ripOLE requires an input file to decode.\n"));
+ return -1;
+ }
+
+ return result;
+}
+
+int ripole(char *inputfile, char *outputdir, int debug, int verbose)
+{
+ /*struct OLE_object *ole = NULL; */
+ struct OLE_object ole;
+ int result = 0;
+
+ /*ole = MALLOC(sizeof(struct OLE_object));
+ * if (ole == NULL)
+ * {
+ * LOGGER_log(_("ripOLE: Cannot allocate memory for OLE object"));
+ * return 1;
+ * } */
+
+ LOGGER_set_output_mode(_LOGGER_STDOUT);
+
+ OLE_init(&ole);
+ if (debug == 1)
+ {
+ OLE_set_debug(&ole, OLE_DEBUG_NORMAL);
+ }
+ if (verbose == 1)
+ {
+ OLE_set_verbose(&ole, OLE_VERBOSE_NORMAL);
+ }
+ /*ole->save_unknown_streams==2 added for Scilab to extract onlyspreadsheet streams
+ * see OLE_decode_stream in ole.c file */
+ OLE_set_save_unknown_streams(&ole, 2); /* get only spreadsheet streams */
+
+ OLE_set_filename_report_fn(&ole, ROLE_report_filename_decoded);
+
+ result = OLE_decode_file(&ole, inputfile, outputdir);
+ OLE_decode_file_done(&ole);
+
+ if ((result != 0) && (verbose == 1))
+ {
+ LOGGER_log(_("ripOLE: decoding of %s resulted in error %d.\n"), inputfile, result);
+ }
+
+ /*if (ole != NULL) FREE(ole); */
+ return result;
+}
diff --git a/modules/spreadsheet/src/c/ripole/ripole.h b/modules/spreadsheet/src/c/ripole/ripole.h
new file mode 100755
index 000000000..402a6fda5
--- /dev/null
+++ b/modules/spreadsheet/src/c/ripole/ripole.h
@@ -0,0 +1,37 @@
+
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2007-2008 - INRIA - Sylvestre LEDRU <sylvestre.ledru@inria.fr>
+ *
+ * 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.1-en.txt
+ *
+ */
+
+#ifndef __RIPOLE_H__
+#define __RIPOLE_H__
+
+struct ripOLE_object
+{
+ int debug;
+ int verbose;
+ int save_unknown_streams;
+
+ char *inputfile;
+ char *outputdir;
+
+};
+
+int ROLE_set_defaults( struct ripOLE_object *role );
+int ROLE_parse_parameters( struct ripOLE_object *role, int argc, char **argv );
+int ROLE_set_parameters( struct ripOLE_object *role, struct OLE_object *ole );
+int ROLE_report_filename_decoded(char *filename);
+int ROLE_init(struct ripOLE_object *role);
+int ROLE_done(struct ripOLE_object *role);
+int ROLE_validate(struct ripOLE_object *role );
+int ripole(char *inputfile, char *outputdir, int debug, int verbose);
+
+#endif /* #define __RIPOLE_H__ */
diff --git a/modules/spreadsheet/src/c/splitLine.c b/modules/spreadsheet/src/c/splitLine.c
new file mode 100755
index 000000000..dc7313ec6
--- /dev/null
+++ b/modules/spreadsheet/src/c/splitLine.c
@@ -0,0 +1,241 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010-2011 - 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.1-en.txt
+ *
+ */
+#include <string.h>
+#include <stdio.h>
+#include "splitLine.h"
+#include "strsubst.h"
+#include "MALLOC.h"
+#include "freeArrayOfString.h"
+
+#define EMPTYFIELD "__EMPTY_FIELD_CSV__"
+#define DOUBLE_QUOTE '"'
+
+// Add the token (string) to the array of tokens,
+// and applies post processing (escape double quotes,...)
+static int addToken(char **tokens, int *tokenIdx, const char* tokenValue, int tokenLen)
+{
+ char *token = (char *) MALLOC((sizeof(char) * tokenLen) + 1);
+
+ if (token)
+ {
+ char *token2;
+ const char *c, *c_end;
+ char *c2;
+
+ memcpy(token, tokenValue, tokenLen);
+ token[tokenLen] = 0;
+
+ if (strcmp(token, EMPTYFIELD) == 0)
+ {
+ strcpy(token, "");
+ }
+
+ // Escape double quotes, and remove simple quotes
+ token2 = (char *) MALLOC((sizeof(char) * tokenLen) + 1);
+ c = token;
+ c_end = c + tokenLen;
+ c2 = token2;
+ while (c < c_end)
+ {
+ if (*c == DOUBLE_QUOTE)
+ {
+ c++;
+ if (*c == DOUBLE_QUOTE)
+ {
+ *c2 = DOUBLE_QUOTE;
+ c++;
+ c2++;
+ }
+ }
+ else
+ {
+ *c2 = *c;
+ c++;
+ c2++;
+ }
+ }
+ *c2 = 0;
+
+ // Add token
+ tokens[*tokenIdx] = token2;
+ (*tokenIdx)++;
+
+ FREE(token);
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/* ==================================================================== */
+char **splitLineCSV(const char *str, const char *sep, int *toks)
+{
+ char **retstr = NULL;
+ const char *idx = NULL;
+ const char *end = NULL;
+ const char *sep_end = NULL;
+ const char *sep_idx = NULL;
+ int len = 0;
+ int curr_str = 0;
+ int inDoubleQuote = 0;
+
+ /* Usually, it should be ,, or ;; */
+ char tokenstring_to_search[64] = "";
+ /* Previous item will be replaced by ;__EMPTY_FIELD_CSV__; */
+ char tokenreplacement_string[64] = "";
+ char *substitutedstring = NULL;
+
+ sprintf(tokenstring_to_search, "%s%s", sep, sep);
+ sprintf(tokenreplacement_string, "%s%s%s", sep, EMPTYFIELD, sep);
+ substitutedstring = strsub(str, tokenstring_to_search, tokenreplacement_string);
+ /* in a string like foo;bar;;;, replace all the ;;, not only the first and last one */
+ while (strstr(substitutedstring, tokenstring_to_search) != NULL)
+ {
+ substitutedstring = strsub(substitutedstring, tokenstring_to_search, tokenreplacement_string);
+ }
+
+ if (strncmp(substitutedstring, sep, strlen(sep)) == 0)
+ {
+ char *tmp = NULL;
+ size_t l = strlen(substitutedstring) + strlen(EMPTYFIELD) + strlen(sep) + 1;
+ tmp = (char*)MALLOC(sizeof(char) * l);
+ sprintf(tmp, "%s%s%s", EMPTYFIELD, sep, &substitutedstring[1]);
+ FREE(substitutedstring);
+ substitutedstring = tmp;
+ }
+
+ if (substitutedstring[strlen(substitutedstring) - 1] == sep[0])
+ {
+ char *tmp = NULL;
+ size_t l = strlen(substitutedstring) + strlen(EMPTYFIELD) + 1;
+ tmp = (char*)MALLOC(sizeof(char) * l);
+ sprintf(tmp, "%s%s", substitutedstring, EMPTYFIELD);
+ FREE(substitutedstring);
+ substitutedstring = tmp;
+ }
+
+ sep_end = sep + strlen(sep);
+ end = substitutedstring + strlen(substitutedstring);
+
+ idx = substitutedstring;
+
+ if (strstr(substitutedstring, sep) == NULL)
+ {
+ *toks = 0;
+ FREE(substitutedstring);
+ return NULL;
+ }
+
+ retstr = (char **) MALLOC((sizeof(char *) * (int)strlen(substitutedstring)));
+ if (retstr == NULL)
+ {
+ *toks = 0;
+ FREE(substitutedstring);
+ return NULL;
+ }
+
+ while (idx < end)
+ {
+ // If we are in a double quoted field, we do not plit on separators
+ if (!inDoubleQuote)
+ {
+ sep_idx = sep;
+ while (sep_idx < sep_end)
+ {
+ if ((*idx == *sep_idx))
+ {
+ if (len > 0)
+ {
+ if (curr_str < (int)strlen(substitutedstring))
+ {
+ // New token (= field)
+ if (addToken(retstr, &curr_str, (char*)(idx - len), len))
+ {
+ // Reset for next field
+ len = 0;
+ idx++;
+ }
+ else
+ {
+ *toks = 0;
+ freeArrayOfString(retstr, strlen(substitutedstring));
+ FREE(substitutedstring);
+ return NULL;
+ }
+ }
+
+ if (curr_str >= (int)strlen(substitutedstring))
+ {
+ *toks = curr_str + 1;
+ FREE(substitutedstring);
+ return retstr;
+ }
+ }
+ else
+ {
+ idx++;
+ len = 0;
+ }
+ }
+ else
+ {
+ sep_idx++;
+ }
+ }
+ }
+
+ if (*idx == '"')
+ {
+ // Count number of consecutive double quotes
+ int nbDoubleQuotes = 0;
+ const char *idxTmp = idx;
+
+ while (*idxTmp == '"')
+ {
+ idxTmp++;
+ }
+ nbDoubleQuotes = idxTmp - idx;
+
+ // if it is odd, we enter or leave a double quoted field
+ if (nbDoubleQuotes % 2 == 1)
+ {
+ inDoubleQuote = (inDoubleQuote == 0) ? 1 : 0;
+ }
+ len += nbDoubleQuotes;
+ idx += nbDoubleQuotes;
+ }
+ else
+ {
+ len++;
+ idx++;
+ }
+ }
+
+ if (len > 0)
+ {
+ // New token (= field)
+ if (!addToken(retstr, &curr_str, (char*)(idx - len), len))
+ {
+ *toks = 0;
+ freeArrayOfString(retstr, strlen(substitutedstring));
+ FREE(substitutedstring);
+ return NULL;
+ }
+ }
+
+ *toks = curr_str;
+
+ FREE(substitutedstring);
+
+ return retstr;
+}
+/* ==================================================================== */
diff --git a/modules/spreadsheet/src/c/splitLine.h b/modules/spreadsheet/src/c/splitLine.h
new file mode 100755
index 000000000..7a7ee6b3e
--- /dev/null
+++ b/modules/spreadsheet/src/c/splitLine.h
@@ -0,0 +1,30 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010-2011 - 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.1-en.txt
+ *
+ */
+#ifndef __SPLITLINE_H__
+#define __SPLITLINE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /**
+ * split a line by separator
+ */
+ char **splitLineCSV(const char *str, const char *sep, int *toks);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __SPLITLINE_H__ */
+/* ==================================================================== */
diff --git a/modules/spreadsheet/src/c/spreadsheet.rc b/modules/spreadsheet/src/c/spreadsheet.rc
new file mode 100755
index 000000000..e6eda1fa6
--- /dev/null
+++ b/modules/spreadsheet/src/c/spreadsheet.rc
@@ -0,0 +1,97 @@
+// Microsoft Visual C++ generated resource script.
+//
+
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+//#include "afxres.h"
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// French (France) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
+#ifdef _WIN32
+LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 5,5,2,0
+ PRODUCTVERSION 5,5,2,0
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x0L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040c04b0"
+ BEGIN
+ VALUE "CompanyName", "Scilab"
+ VALUE "FileDescription", "spreadsheet module"
+ VALUE "FileVersion", "5, 5, 2, 0"
+ VALUE "InternalName", "spreadsheet"
+ VALUE "LegalCopyright", "Copyright (C) 2017"
+ VALUE "OriginalFilename", "spreadsheet.dll"
+ VALUE "ProductName", " spreadsheet"
+ VALUE "ProductVersion", "5, 5, 2, 0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x40c, 1200
+ END
+END
+
+#endif // French (France) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/modules/spreadsheet/src/c/utftolatin.c b/modules/spreadsheet/src/c/utftolatin.c
new file mode 100755
index 000000000..00ea10b90
--- /dev/null
+++ b/modules/spreadsheet/src/c/utftolatin.c
@@ -0,0 +1,223 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010-2011 - 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.1-en.txt
+ *
+ */
+#include <string.h>
+#include "utftolatin.h"
+#include "MALLOC.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
+// =============================================================================
+char *utftolatin(char *utfString)
+{
+ char *latinString = NULL;
+ if (utfString)
+ {
+ size_t lenUtfString = strlen(utfString) + 1;
+ latinString = (char*) CALLOC(lenUtfString, sizeof(char));
+
+ if (latinString)
+ {
+ unsigned long ucs4 = 0;
+ int c = 0, state = 0, octets = 0;
+ char *t = NULL;
+
+ ucs4 = 0;
+ state = 0;
+ octets = 0;
+
+ t = latinString;
+ *t = 0;
+
+ while ((c = *(utfString++)) != 0)
+ {
+ switch (state)
+ {
+ case 0: /* start of utf8 char */
+ if ((c & 0xfe) == 0xfc)
+ {
+ /* 6 octets */
+ ucs4 = (c & 0x01) << 30;
+ octets = 6;
+ state = 5;
+ /* look for 5 more */
+ }
+ else if ((c & 0xfc) == 0xf8)
+ {
+ /* 5 octets */
+ ucs4 = (c & 0x03) << 24;
+ octets = 5;
+ state = 4;
+ }
+ else if ((c & 0xf8) == 0xf0)
+ {
+ /* 4 octets */
+ ucs4 = (c & 0x07) << 18;
+ octets = 4;
+ state = 3;
+ }
+ else if ((c & 0xf0) == 0xe0)
+ {
+ /* 3 octets */
+ ucs4 = (c & 0x0f) << 12;
+ octets = 3;
+ state = 2;
+ }
+ else if ((c & 0xe0) == 0xc0)
+ {
+ /* 2 octets */
+ ucs4 = (c & 0x1f) << 6;
+ octets = 2;
+ state = 1;
+ /* look for 1 more */
+ }
+ else if ((c & 0x80) == 0x00)
+ {
+ /* 1 octet */
+ ucs4 = (c & 0x7f);
+ octets = 1;
+ state = 0;
+ /* we have a result */
+ }
+ else
+ {
+ /* error */
+ FREE(latinString);
+ return strdup(utfString);
+ }
+ break;
+ case 1:
+ if ((c & 0xc0) == 0x80)
+ {
+ ucs4 = ucs4 | (c & 0x3f);
+ if (ucs4 < 0x80 || ucs4 > 0x7ff)
+ {
+ ucs4 = 0xffffffff;
+ }
+ }
+ else
+ {
+ ucs4 = 0xffffffff;
+ }
+ state = 0; /* we're done and have a result */
+ break;
+ case 2:
+ if ((c & 0xc0) == 0x80)
+ {
+ ucs4 = ucs4 | ((c & 0x3f) << 6);
+ state = 1;
+ }
+ else
+ {
+ ucs4 = 0xffffffff;
+ state = 0;
+ }
+ break;
+ case 3:
+ if ((c & 0xc0) == 0x80)
+ {
+ ucs4 = ucs4 | ((c & 0x3f) << 12);
+ state = 2;
+ }
+ else
+ {
+ ucs4 = 0xffffffff;
+ state = 0;
+ }
+ break;
+ case 4:
+ if ((c & 0xc0) == 0x80)
+ {
+ ucs4 = ucs4 | ((c & 0x3f) << 18);
+ state = 3;
+ }
+ else
+ {
+ ucs4 = 0xffffffff;
+ state = 0;
+ }
+ break;
+ case 5:
+ if ((c & 0xc0) == 0x80)
+ {
+ ucs4 = ucs4 | ((c & 0x3f) << 24);
+ state = 4;
+ }
+ else
+ {
+ ucs4 = 0xffffffff;
+ state = 0;
+ }
+ break;
+ default: /* error, can't happen */
+ {
+ ucs4 = 0xffffffff;
+ state = 0;
+ break;
+ }
+ }
+ if (state == 0)
+ {
+ switch (octets)
+ {
+ case 1:
+ if (ucs4 > 0x7f)
+ {
+ ucs4 = 0xffffffff;
+ }
+ break;
+ case 2:
+ if (ucs4 < 0x80 || ucs4 > 0x7ff)
+ {
+ ucs4 = 0xffffffff;
+ }
+ break;
+ case 3:
+ if (ucs4 < 0x800 || ucs4 > 0xffff)
+ {
+ ucs4 = 0xffffffff;
+ }
+ break;
+ case 4:
+ if (ucs4 < 0x10000 || ucs4 > 0x1fffff)
+ {
+ ucs4 = 0xffffffff;
+ }
+ break;
+ case 5:
+ if (ucs4 < 0x200000 || ucs4 > 0x3ffffff)
+ {
+ ucs4 = 0xffffffff;
+ }
+ break;
+ case 6:
+ if (ucs4 < 0x4000000 || ucs4 > 0x7fffffff)
+ {
+ ucs4 = 0xffffffff;
+ }
+ break;
+ default:
+ ucs4 = 0xffffffff;
+ break;
+ }
+
+ if (ucs4 != 0xffffffff)
+ {
+ *(t++) = (char)ucs4;
+ }
+ }
+ }
+ *t = 0;
+ }
+ }
+ return latinString;
+}
+// =============================================================================
diff --git a/modules/spreadsheet/src/c/utftolatin.h b/modules/spreadsheet/src/c/utftolatin.h
new file mode 100755
index 000000000..cf1059909
--- /dev/null
+++ b/modules/spreadsheet/src/c/utftolatin.h
@@ -0,0 +1,27 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010-2011 - 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.1-en.txt
+ *
+ */
+#ifndef __UTFTOLATIN_H__
+#define __UTFTOLATIN_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ char *utftolatin(char *utfString);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __UTFTOLATIN_H__ */
+// =============================================================================
diff --git a/modules/spreadsheet/src/c/xls.c b/modules/spreadsheet/src/c/xls.c
new file mode 100755
index 000000000..4a8b7384b
--- /dev/null
+++ b/modules/spreadsheet/src/c/xls.c
@@ -0,0 +1,1131 @@
+
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2005-2008 - INRIA - Serge STEER <serge.steer@inria.fr>
+ * Copyright (C) 2005-2008 - INRIA - Pierrick MODE
+ *
+ * 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.1-en.txt
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "core_math.h"
+#include "MALLOC.h" /* MALLOC */
+#include "sciprint.h"
+#include "returnanan.h"
+#include "xls.h"
+#include "mseek.h"
+#include "mtell.h"
+#include "mget.h"
+/*------------------------------------------------------------------*/
+#define typ_short "s"
+#define typ_ushort "us"
+#define typ_char "c"
+#define typ_uchar "uc"
+#define typ_double "d"
+#define typ_int "i"
+/*------------------------------------------------------------------*/
+extern int ripole(char *inputfile, char *outputfile, int debug, int verbose);
+/*------------------------------------------------------------------*/
+/*Prototype*/
+static double NumFromRk2(long rk);
+static void getBoundsheets(int * fd, char ***Sheetnames, int** Abspos, int *nsheets, double *cur_pos, int *err);
+static void getSST(int *fd, short Len, int BIFF, int *ns, char ***sst, int *err);
+static void getBOF(int *fd , int* Data, int *err);
+static void getString(int *fd, short *count, short *Len, int flag, char **str, int *err);
+
+/**
+ ** Bruno : Defined but not used ... so what !!!!!!!!
+ static int get_oleheader(int *fd);
+**/
+/*------------------------------------------------------------------*/
+void xls_read(int *fd, int *cur_pos, double **data, int **chainesind, int *N, int *M, int *err)
+{
+ /*---------------Declaration Des Variables*--------------------*/
+ unsigned short Opcode = 0, Len = 0; /*Code Operationnel et Longueur du tag a lire*/
+ double *valeur = NULL; /*Tableau Recapitulatif (Final) des valeurs de la feuille Excel*/
+ double pos = 0;
+
+ int one = 1;
+ int three = 3;
+
+ int i = 0; /*Variables de boucle*/
+ int hauteur = 0, longueur = 0, capacite = 0; /*Hauteur, longueur de la feuille, */
+ /*int taille = 0; Nombre de types de caract�ers a enregistrer*/
+ char *sheetname = NULL; /*Nom de la feuille*/
+ int rkvalue = 0; /*RK value*/
+ /*for RK */
+ unsigned short row = 0, col = 0, xf = 0;/*Index to row, to column, and to XF record*/
+ /*for MULRK */
+ unsigned short ixfe = 0;
+ short colFirst = 0, colLast = 0, ncol = 0; /*Index to rox, to first column (fc)*/
+ /* for LABELSST */
+ short labelsst1[3];
+ int indsst = 0; /*Index to SST record*/
+ /* for DIMENSIONS */
+ int f_row = 0, l_row = 0;
+ unsigned short f_col = 0, l_col = 0, notused = 0;
+ /* for FORMULA */
+ double resultat = 0.;/*Result of the formula*/
+ short optionflag = 0;/*Option flags*/
+ int formula_notused = 0; /*Not used*/
+ double NaN = C2F(returnanan)();
+
+ int BOFData[7]; /*[BIFF Version DataType Identifier Year HistoryFlags LowestXlsVersion]*/
+ /* initialization of pointers corresponding to malloc's */
+ valeur = (double *)NULL;
+ sheetname = (char *)NULL;
+ *chainesind = (int *) NULL;
+ *err = 0;
+
+ pos = (double)(*cur_pos);
+ C2F(mseek) (fd, &pos, "set", err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+
+ /* first record should be a BOF */
+ getBOF(fd , BOFData, err);
+
+ if (*err > 0)
+ {
+ return;
+ }
+ if (BOFData[0] < 0) /* not a BOF */
+ {
+ *err = 2;
+ return;
+ }
+ if (BOFData[0] != 8) /* not a BIFF8 */
+ {
+ *err = 3;
+ return;
+ }
+
+ C2F(mtell) (fd, &pos, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+
+ while (1)
+ {
+ C2F(mseek) (fd, &pos, "set", err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ /*Enregistrement de l'Opcode et de la Len du tag*/
+ C2F(mgetnc) (fd, &Opcode, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, &Len, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ switch (Opcode)
+ {
+ case 10:/*EOF */
+ *N = hauteur;
+ *M = longueur;
+ *data = valeur;
+ *cur_pos = (int)pos;
+ *cur_pos = *cur_pos + 4 + Len;
+ return;
+ case 638: /*RK*/
+ C2F(mgetnc) (fd, (void*)&row, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*)&col, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ // Check col and row are in bounds
+ if ((col >= longueur) || (row >= hauteur))
+ {
+ *err = 2;
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*)&xf , &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*) &rkvalue , &one, typ_int, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ valeur[col * (hauteur) + row] = NumFromRk2(rkvalue);
+ break;
+ case 515: /*Number*/
+ C2F(mgetnc) (fd, (void*)&row, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*)&col, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ // Check col and row are in bounds
+ if ((col >= longueur) || (row >= hauteur))
+ {
+ *err = 2;
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*)&xf , &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*) &resultat , &one, typ_double, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ valeur[col * (hauteur) + row] = resultat ;
+ break;
+
+ case 189: /*MULRK*/
+ C2F(mgetnc) (fd, (void*)&row, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*)&colFirst, &one, typ_short, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ // Check col and row are in bounds
+ if ((colFirst >= longueur) || (row >= hauteur))
+ {
+ *err = 2;
+ goto ErrL;
+ }
+ /*List of nc=lc-fc+1 XF/RK structures*/
+ ncol = (Len - 6) / 6;
+ for (i = 0; i < ncol; i++)
+ {
+ C2F(mgetnc) (fd, (void*) &ixfe, &one, typ_short, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*) &rkvalue, &one, typ_int, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ valeur[row + (colFirst + i)*hauteur] = NumFromRk2(rkvalue);
+ }
+
+ /*Index of last column*/
+ C2F(mgetnc) (fd, (void*) &colLast, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ break;
+
+ case 253:/*LABELSST*/
+ C2F(mgetnc) (fd, (void*) labelsst1, &three, typ_short, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*) &indsst , &one, typ_int, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ /*Allocation dans le tableau final*/
+ col = labelsst1[1];
+ row = labelsst1[0];
+ // Check col and row are in bounds
+ if ((col >= longueur) || (row >= hauteur))
+ {
+ *err = 2;
+ goto ErrL;
+ }
+ (*chainesind)[col * (hauteur) + row] = indsst + 1;
+ break;
+ case 512:/* DIMENSIONS*/
+ C2F(mgetnc) (fd, (void*) &f_row, &one, typ_int, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*) &l_row, &one, typ_int, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*) &f_col, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*) &l_col, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*) &notused, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+
+ /*Calcul de longueur, hauteur et capacite de la feuille*/
+ hauteur = l_row; /*-f_row;*/
+ longueur = l_col; /*-f_col;*/
+ capacite = hauteur * longueur;
+
+ /*Declaration des tableaux de synthese*/
+ if ((valeur = (void*) MALLOC((capacite + 1) * sizeof(double))) == NULL)
+ {
+ goto ErrL;
+ }
+ if ((*chainesind = (int *) MALLOC((capacite + 1) * sizeof(int))) == NULL)
+ {
+ goto ErrL;
+ }
+ for (i = 0; i <= capacite; i++)
+ {
+ (*chainesind)[i] = 0;
+ valeur[i] = NaN;
+ }
+ break;
+ case 6:/* FORMULA*/
+ C2F(mgetnc) (fd, (void*) &row, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*) &col, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ // Check col and row are in bounds
+ if ((col >= longueur) || (row >= hauteur))
+ {
+ *err = 2;
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*) &xf, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+
+ C2F(mgetnc) (fd, (void*) &resultat, &one, typ_double, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+
+ valeur[(col * hauteur + row)] = resultat;
+
+ C2F(mgetnc) (fd, (void*)&optionflag, &one, typ_short, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+
+ C2F(mgetnc) (fd, (void*) &formula_notused, &one, typ_int, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+
+ /*Formuled data*/
+
+ /*taille=Len-2-2-2-8-2-4;
+ char formuladata[taille];
+ C2F(mgetnc) (fd, (void*) formuladata, &taille, typ_char, err);
+ if (*err > 0) goto ErrL;*/
+
+ break;
+ }
+
+ pos = pos + 4 + Len;
+ }
+
+ *cur_pos = (int)pos;
+ return;
+ErrL:
+ {
+ FREE(sheetname);
+ FREE(valeur);
+ FREE(*chainesind);
+ if (*err == 0)
+ {
+ *err = 1; /* malloc problem */
+ }
+ else
+ {
+ *err = 2; /* read problem */
+ }
+ return;
+ }
+}
+
+
+void xls_open(int *err, int *fd, char ***sst, int *ns, char ***Sheetnames, int** Abspos, int *nsheets)
+{
+ /* if opt==1 it is supposed that the current file position is at the beginning of oleheader
+ * if opt==0 it is supposed that the current file position is at the beginning of workbook stream
+ */
+
+ /* we suppose that the ole file as a simple structure:
+ * Workbook stream should follows immediately the header
+ * and is strored in sequential sections
+ */
+
+ /*return *err:
+ 0 = OK
+ 1 = not an OLE file
+ 2 = no Workbook included
+ 3 = memory allocation problem
+ 4 = incorrect file
+ 5 = not a BIFF8 xls file
+ */
+ /*---------------D�claration Des Variables*--------------------*/
+ int k, one = 1;
+ double cur_pos, init_pos;
+ unsigned short Opcode, Len;
+ /*BOF data*/
+ int BOFData[7]; /*[BIFF Version DataType Identifier Year HistoryFlags LowestXlsVersion]*/
+ *nsheets = 0;
+ *err = 0;
+ /*---------------D�claration Des Variables*--------------------*/
+
+ /* if (get_oleheader(fd)) {
+ *err=1;
+ return;
+ }*/
+ C2F(mtell) (fd, &cur_pos, err);
+ init_pos = cur_pos;
+
+ /* first record should be a BOF */
+ getBOF(fd , BOFData, err);
+ if (*err > 0)
+ {
+ return;
+ }
+
+ if (BOFData[0] < 0) /* not a BOF */
+ {
+ *err = 4;
+ return;
+ }
+ if (BOFData[0] != 8) /* not a BIFF8 */
+ {
+ *err = 5;
+ return;
+ }
+
+ C2F(mtell) (fd, &cur_pos, err);
+ if (*err > 0)
+ {
+ goto Err2;
+ }
+
+ /* loops on records till an EOF is found */
+ while (1)
+ {
+ C2F(mseek) (fd, &cur_pos, "set", err);
+ if (*err > 0)
+ {
+ goto Err2;
+ }
+ /*Enregistrement de l'Opcode et de la Len du tag*/
+ C2F(mgetnc) (fd, &Opcode, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto Err2;
+ }
+ C2F(mgetnc) (fd, &Len, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto Err2;
+ }
+
+ switch (Opcode)
+ {
+ case 10: /*EOF*/
+ cur_pos = cur_pos + 4 + Len;
+ return ;
+ case 133: /* Boundsheets */
+ getBoundsheets(fd, Sheetnames, Abspos, nsheets, &cur_pos, err);
+ for (k = 0; k < *nsheets; k++)
+ {
+ (*Abspos)[k] += init_pos;
+ }
+ if (*err > 0)
+ {
+ return;
+ }
+ break;
+ case 252: /* SST= Shared String table*/
+ getSST(fd, Len, BOFData[0], ns, sst, err);
+ if (*err > 0)
+ {
+ return;
+ }
+ cur_pos = cur_pos + 4 + Len;
+ break;
+ default:
+ cur_pos = cur_pos + 4 + Len;
+ }
+ }
+
+Err2:
+ *err = 4; /* read problem */
+ return;
+
+}
+
+static double NumFromRk2(long rk)
+{
+ double num;
+ if (rk & 0x02)
+ {
+ /* int*/
+ num = (double) (rk >> 2);
+ }
+ else
+ {
+ /* hi words of IEEE num*/
+ *((int *)&num + 1) = rk & 0xfffffffc;
+ *((int *)&num) = 0;
+ }
+ if (rk & 0x01)
+ /* divide by 100*/
+ {
+ num /= 100;
+ }
+ return num;
+}
+
+static void getBOF(int *fd , int* Data, int *err)
+{
+ /* return Data a vector [BIFF Version DataType Identifier Year HistoryFlags LowestXlsVersion]
+ * works for BIFF2 to BIFF8 records */
+ int BIFF;
+ short Version;
+ short DataType;
+ short Identifier = 0;
+ short Year = 0;
+ int HistoryFlags = 0;
+ int LowestXlsVersion = 0;
+
+ unsigned short Opcode;
+ unsigned short Len;
+ int one = 1;
+
+ C2F(mgetnc) (fd, (void*)&Opcode, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ return;
+ }
+ C2F(mgetnc) (fd, (void*)&Len, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ return;
+ }
+
+ switch (Opcode)
+ {
+ case 2057: /*Begin of file, BOF for BIFF5 BIFF7 BIFF8 BIFF8X*/
+ C2F(mgetnc) (fd, (void*)&Version, &one, typ_short, err);
+ if (*err > 0)
+ {
+ return;
+ }
+ C2F(mgetnc) (fd, (void*)&DataType, &one, typ_short, err);
+ if (*err > 0)
+ {
+ return;
+ }
+ C2F(mgetnc) (fd, (void*)&Identifier, &one, typ_short, err);
+ if (*err > 0)
+ {
+ return;
+ }
+ C2F(mgetnc) (fd, (void*)&Year, &one, typ_short, err);
+ if (*err > 0)
+ {
+ return;
+ }
+ if (Len == 16)
+ {
+ C2F(mgetnc) (fd, (void*)&HistoryFlags, &one, typ_int, err);
+ if (*err > 0)
+ {
+ return;
+ }
+ C2F(mgetnc) (fd, (void*)&LowestXlsVersion, &one, typ_int, err);
+ if (*err > 0)
+ {
+ return;
+ }
+ BIFF = 8;
+ if (Version != 1536)
+ {
+ return;
+ }
+ }
+ else
+ {
+ BIFF = 7;
+ }
+ break;
+ case 1033 : /*Interpr�tation du BIFF4 0409 H*/
+ C2F(mgetnc) (fd, (void*)&Version, &one, typ_short, err);
+ if (*err > 0)
+ {
+ return;
+ }
+ C2F(mgetnc) (fd, (void*)&DataType, &one, typ_short, err);
+ if (*err > 0)
+ {
+ return;
+ }
+ BIFF = 4;
+ break;
+ case 521 : /*Interpr�tation du BIFF3 0209 H*/
+ C2F(mgetnc) (fd, (void*)&Version, &one, typ_short, err);
+ if (*err > 0)
+ {
+ return;
+ }
+ C2F(mgetnc) (fd, (void*)&DataType, &one, typ_short, err);
+ if (*err > 0)
+ {
+ return;
+ }
+ BIFF = 3;
+ break;
+ case 9 : /*Interpr�tation du BIFF2 0009 H*/
+ C2F(mgetnc) (fd, (void*)&Version, &one, typ_short, err);
+ if (*err > 0)
+ {
+ return;
+ }
+ C2F(mgetnc) (fd, (void*)&DataType, &one, typ_short, err);
+ if (*err > 0)
+ {
+ return;
+ }
+ BIFF = 2;
+ break;
+ default:
+ BIFF = -1; /* not a BOF record */
+ Version = 0;
+ DataType = 0;
+ }
+ Data[0] = BIFF;
+ Data[1] = Version;
+ Data[2] = DataType;
+ Data[3] = Identifier;
+ Data[4] = Year;
+ Data[5] = HistoryFlags;
+ Data[6] = LowestXlsVersion;
+
+}
+
+static void getSST(int *fd, short Len, int BIFF, int *ns, char ***sst, int *err)
+{
+ int i = 0, one = 1;
+ /* SST data */
+ int ntot = 0; /*total number of strings */
+ int nm = 0;/*Number of following strings*/
+ short count = 0;
+
+ *ns = 0;
+ *sst = NULL;
+
+ if (BIFF == 8)
+ {
+ /*Total number of strings in the workbook*/
+ C2F(mgetnc) (fd, (void*)&ntot, &one, typ_int, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*)&nm, &one, typ_int, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ *ns = nm;
+ count += 8;
+ if (nm != 0)
+ {
+ if ( (*sst = (char **)MALLOC(nm * sizeof(char*))) == NULL)
+ {
+ goto ErrL;
+ }
+ for (i = 0; i < nm; i++)
+ {
+ (*sst)[i] = NULL;
+ }
+ for (i = 0; i < nm; i++) /* LOOP ON STRINGS */
+ {
+ *err = i; /*for debug*/
+ getString(fd, &count, &Len, 1, &((*sst)[i]), err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ /*printf("i=%d, %s\n",i,(*sst)[i]);*/
+ }
+ }
+ }
+ return;
+ErrL:
+ if (*sst != NULL)
+ {
+ for (i = 0; i < nm; i++)
+ if ( (*sst)[i] != NULL )
+ {
+ FREE((*sst)[i]);
+ }
+ FREE(*sst);
+ }
+
+ if (*err == 0)
+ {
+ *err = 3; /* malloc problem */
+ }
+ else
+ {
+ *err = 4; /* read problem */
+ }
+}
+
+static void getString(int *fd, short *PosInRecord, short *RecordLen, int flag, char **str, int *err)
+{
+ short ln = 0;
+ short Opcode = 0;/* to store tag information */
+ int BytesToBeRead = 0, one = 1, strindex = 0;
+ char OptionFlag = 0;
+ int sz = 0; /* for extended string data */
+ short rt = 0;/* for rich string data */
+ int UTFEncoding = 0, extendedString = 0, richString = 0;
+ int j = 0, l1 = 0;
+
+ *str = (char *)NULL;
+ *err = 0;
+ ln = 0;
+
+ /*check for continue tag */
+ if (flag && (*PosInRecord == *RecordLen)) /* data limit encountered */
+ {
+ /*check for continue tag */
+ /*lecture de l'Opcode et de la RecordLen du tag*/
+ C2F(mgetnc) (fd, &Opcode, &one, typ_ushort, err);
+ if ((*err > 0) || (Opcode != 60))
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, RecordLen, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ *PosInRecord = 0;
+ }
+
+ /* get the number of characters included in the string (number of bytes or number of couple of bytes) */
+ if (flag) /* getString called by getSST */
+ {
+ C2F(mgetnc) (fd, (void*)&ln, &one, typ_short, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ *PosInRecord += 2;
+ }
+ else /* getString called by getBoundsheets */
+ {
+ C2F(mgetnc) (fd, (void*)&ln, &one, typ_char, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ *PosInRecord += 1;
+ }
+
+ /*get the encoding options */
+ C2F(mgetnc) (fd, (void*)&OptionFlag, &one, typ_char, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ *PosInRecord += 1;
+
+ UTFEncoding = (OptionFlag & 0x01) == 1;
+ extendedString = (OptionFlag & 0x04) != 0;
+ richString = (OptionFlag & 0x08) != 0;
+
+ if (richString) /*richString*/
+ {
+ C2F(mgetnc) (fd, (void*)&rt, &one, typ_short, err);
+ *PosInRecord += 2;
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ }
+
+ if (extendedString) /* extendedString */
+ {
+ C2F(mgetnc) (fd, (void*)&sz, &one, typ_int, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ *PosInRecord += 4;
+ }
+
+ /* number of bytes to be read */
+ BytesToBeRead = (UTFEncoding) ? ln * 2 : ln;
+
+
+ if ((*str = (char*) MALLOC((BytesToBeRead + 1) * sizeof(char))) == NULL)
+ {
+ goto ErrL;
+ }
+ /* read the bytes */
+
+ if (!flag || (*PosInRecord + BytesToBeRead <= *RecordLen))
+ {
+ /* all bytes are in the same record */
+ C2F(mgetnc) (fd, (void*)*str, &BytesToBeRead, typ_char, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ *PosInRecord += (short)BytesToBeRead;
+ }
+ else /* char stream contains at least one "continue" */
+ {
+ int bytesRead = *RecordLen - *PosInRecord; /* number of bytes before continue */
+ strindex = 0; /*current position in str*/
+ /* read bytes before the "continue" */
+ /* according to documentation bytesRead should be strictly positive */
+ C2F(mgetnc) (fd, (void*)(*str + strindex), &bytesRead, typ_char, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ strindex += bytesRead;
+ *PosInRecord += (short)bytesRead;
+ while (BytesToBeRead - bytesRead > 0)
+ {
+ /*"continue" tag assumed, verify */
+ C2F(mgetnc) (fd, &Opcode, &one, typ_ushort, err);
+ if ((*err > 0) || (Opcode != 60))
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, RecordLen, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ *PosInRecord = 0;
+ /* encoding option may change !!!! */
+ C2F(mgetnc) (fd, (void*)&OptionFlag, &one, typ_char, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ *PosInRecord += 1;
+
+ if ((!UTFEncoding && (OptionFlag == 0)) || (UTFEncoding && (OptionFlag != 0)))
+ {
+ /*string encoding does not change */
+ l1 = Min(BytesToBeRead - bytesRead, *RecordLen - *PosInRecord);
+ C2F(mgetnc) (fd, (void*)(*str + strindex), &l1, typ_char, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ bytesRead += l1;
+ strindex += l1;
+ *PosInRecord += (short)l1;
+ }
+ else if (UTFEncoding && (OptionFlag == 0))
+ {
+ /* character encoding changes from twobytes to a single byte*/
+ /* may this happen ???? */
+ l1 = Min(BytesToBeRead - bytesRead, *RecordLen - *PosInRecord);
+ for (j = 0; j < l1; j++)
+ {
+ C2F(mgetnc) (fd, (void*)(*str + strindex), &one, typ_char, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ (*str)[strindex + 1] = '\0';
+ strindex += 2;
+ *PosInRecord += 2;
+ UTFEncoding = 0;
+ }
+ }
+ else
+ {
+ /* character encoding changes from a single byte to two bytes */
+ /* first, convert read characters to two bytes*/
+ char *str1 = *str;
+ strindex = 0;
+ str = (char**) MALLOC((2 * BytesToBeRead + 1) * sizeof(char*));
+ if (str == NULL)
+ {
+ goto ErrL;
+ }
+ for (j = 0; j < bytesRead; j++)
+ {
+ (*str)[strindex] = str1[j];
+ (*str)[strindex + 1] = '\0';
+ strindex += 2;
+ }
+ FREE(str1);
+ BytesToBeRead = BytesToBeRead * 2;
+ bytesRead = bytesRead * 2;
+ /* read following two bytes characters */
+ l1 = Min((BytesToBeRead - bytesRead) * 2, *RecordLen - *PosInRecord);
+ C2F(mgetnc) (fd, (void*)(*str + strindex), &l1, typ_char, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ bytesRead += l1;
+ strindex += l1;
+ *PosInRecord += (short)l1;
+ UTFEncoding = 1;
+ }
+
+ }
+
+ } /*all character read */
+
+ /* For extended strings, skip over the extended string data*/
+ /* may continuation records appear here? */
+ l1 = 4 * rt;
+ if (richString)
+ {
+ double dl1 = (double)l1;
+ C2F(mseek) (fd, &dl1, "cur", err);
+ *PosInRecord += (short)l1;
+ }
+ if (extendedString)
+ {
+ double dsz = (double)sz;
+ C2F(mseek) (fd, &dsz, "cur", err);
+ *PosInRecord += (short)sz;
+ }
+
+ /* add string terminaison */
+ if (UTFEncoding)
+ {
+ /* Scilab currently do not support unicode, so we remove the second byte*/
+ strindex = 0;
+ for (j = 0; j < BytesToBeRead; j += 2)
+ {
+ (*str)[strindex] = (*str)[j];
+ strindex++;
+ }
+ BytesToBeRead = BytesToBeRead / 2;
+ }
+ (*str)[BytesToBeRead] = '\0';
+
+
+ return;
+ErrL:
+ if (*err == 0)
+ {
+ FREE(*str);
+ *err = 3; /* malloc problem */
+ }
+ else
+ {
+ *err = 4; /* read problem */
+ }
+}
+
+static void getBoundsheets(int * fd, char ***Sheetnames, int** Abspos, int *nsheets, double *cur_pos, int *err)
+{
+ /* the global workbook contains a sequence of boudsheets this procedure reads all
+ * the sequence and returns a vector o sheetnames, a vector of absolute sheet positions*/
+ int abspos; /* Absolute stream position of BoF*/
+ char visibility, sheettype; /*Visiblity , Sheet type*/
+ double pos;
+ unsigned short Opcode;
+ unsigned short Len;
+ int one = 1;
+ int ns, i;
+
+ *Sheetnames = (char **)NULL;
+ *Abspos = (int *)NULL;
+ *err = 0;
+
+ /* memorize the first boundsheet beginning */
+ pos = *cur_pos;
+ /* Count number of boundsheets */
+ ns = 0;
+ while (1)
+ {
+ C2F(mseek) (fd, cur_pos, "set", err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, &Opcode, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, &Len, &one, typ_ushort, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ if (Opcode == 133)
+ {
+ C2F(mgetnc) (fd, (void*)&abspos, &one, typ_int, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*)&visibility, &one, typ_char, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*)&sheettype, &one, typ_char, err);
+ if (sheettype == 0) /* worksheet */
+ {
+ ns++;
+ }
+ *cur_pos = *cur_pos + 4 + Len;
+ }
+ else
+ {
+ break;
+ }
+
+ }
+
+ *nsheets = ns;
+ /*alloc the Sheetnames ans Abspos arrays */
+ if ( (*Sheetnames = (char **)MALLOC(ns * sizeof(char*))) == NULL)
+ {
+ goto ErrL;
+ }
+ if ( (*Abspos = (int *)MALLOC(ns * sizeof(int))) == NULL)
+ {
+ goto ErrL;
+ }
+
+ /* rescan boundsheet sequence to get the data */
+ *cur_pos = pos;
+ i = -1;
+ while (1)
+ {
+ C2F(mseek) (fd, cur_pos, "set", err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, &Opcode, &one, typ_ushort, err);
+ C2F(mgetnc) (fd, &Len, &one, typ_ushort, err);
+ if (Opcode == 133)
+ {
+ C2F(mgetnc) (fd, (void*)&abspos, &one, typ_int, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*)&visibility, &one, typ_char, err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ C2F(mgetnc) (fd, (void*)&sheettype, &one, typ_char, err);
+ if (sheettype == 0) /* worksheet */
+ {
+ short count = 0;
+ i++;
+ (*Abspos)[i] = abspos;
+ getString(fd, &count, (short *) &Len, 0, &((*Sheetnames)[i]), err);
+ if (*err > 0)
+ {
+ goto ErrL;
+ }
+ }
+ *cur_pos = *cur_pos + 4 + Len;
+ }
+ else
+ {
+ break;
+ }
+
+ }
+ return;
+ErrL:
+ if (*Sheetnames != NULL)
+ {
+ for (i = 0; i < ns; i++)
+ if ( (*Sheetnames)[i] != NULL )
+ {
+ FREE((*Sheetnames)[i]);
+ }
+ FREE(*Sheetnames);
+ }
+ FREE(*Abspos);
+ if (*err == 0)
+ {
+ *err = 3; /* malloc problem */
+ }
+ else
+ {
+ *err = 4; /* read problem */
+ }
+}
+
+/**
+ ** Bruno : Defined but not used... so what !!!!!!!!!
+ **
+ static int get_oleheader(int *fd)
+ {
+ unsigned char MAGIC[8] = { 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1 };
+ unsigned char header[512];
+ int c,ierr;
+
+ C2F(mgetnc) (fd, (void *)header,(c=512,&c), typ_uchar, &ierr);
+ if (ierr !=0) return 1;
+ if (memcmp (header, MAGIC, sizeof (MAGIC)) != 0) return 1;
+ return 0;
+ }
+**/
diff --git a/modules/spreadsheet/src/c/xls.h b/modules/spreadsheet/src/c/xls.h
new file mode 100755
index 000000000..f7e6a08e2
--- /dev/null
+++ b/modules/spreadsheet/src/c/xls.h
@@ -0,0 +1,30 @@
+
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2007-2008 - INRIA
+ *
+ * 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.1-en.txt
+ *
+ */
+
+#ifndef __XLS_H__
+#define __XLS_H__
+
+/**
+* xls_read
+*
+*/
+void xls_read(int *fd, int *cur_pos, double **data, int **chainesind, int *N, int *M, int *err);
+
+/**
+* xls_open
+*
+*/
+void xls_open(int *err, int *fd, char ***sst, int *ns, char ***Sheetnames, int** Abspos, int *nsheets);
+
+#endif /* __XLS_H__ */
+/*--------------------------------------------------------------------------*/
diff --git a/modules/spreadsheet/src/nospreadsheet/nospreadsheet.c b/modules/spreadsheet/src/nospreadsheet/nospreadsheet.c
new file mode 100755
index 000000000..8073805b1
--- /dev/null
+++ b/modules/spreadsheet/src/nospreadsheet/nospreadsheet.c
@@ -0,0 +1,23 @@
+
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2007-2008 - INRIA - Allan CORNET <allan.cornet@inria.fr>
+ *
+ * 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.1-en.txt
+ *
+ */
+
+#include "gw_spreadsheet.h"
+#include "Scierror.h"
+#include "localization.h"
+/*--------------------------------------------------------------------------*/
+int gw_spreadsheet(void)
+{
+ Scierror(999, _("Scilab spreadsheet module not installed.\n"));
+ return 0;
+}
+/*--------------------------------------------------------------------------*/
diff --git a/modules/spreadsheet/src/nospreadsheet/nospreadsheet.rc b/modules/spreadsheet/src/nospreadsheet/nospreadsheet.rc
new file mode 100755
index 000000000..d7ceef095
--- /dev/null
+++ b/modules/spreadsheet/src/nospreadsheet/nospreadsheet.rc
@@ -0,0 +1,97 @@
+// Microsoft Visual C++ generated resource script.
+//
+
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+//#include "afxres.h"
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// French (France) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
+#ifdef _WIN32
+LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 5,5,2,0
+ PRODUCTVERSION 5,5,2,0
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x0L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040c04b0"
+ BEGIN
+ VALUE "FileDescription", "nospreadsheet module"
+ VALUE "FileVersion", "5, 5, 2, 0"
+ VALUE "InternalName", "nospreadsheet module"
+ VALUE "LegalCopyright", "Copyright (C) 2017"
+ VALUE "OriginalFilename", "nospreadsheet.dll"
+ VALUE "ProductName", " nospreadsheet"
+ VALUE "ProductVersion", "5, 5, 2, 0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x40c, 1200
+ END
+END
+
+#endif // French (France) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/modules/spreadsheet/src/nospreadsheet/nospreadsheet.vcxproj b/modules/spreadsheet/src/nospreadsheet/nospreadsheet.vcxproj
new file mode 100755
index 000000000..8345f23b7
--- /dev/null
+++ b/modules/spreadsheet/src/nospreadsheet/nospreadsheet.vcxproj
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{AC43B2A6-601A-4E15-97DF-2B296FFAD4F9}</ProjectGuid>
+ <RootNamespace>nospreadsheet</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)bin\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)bin\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)bin\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)bin\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>../../../core/includes;../../../output_stream/includes;../../../localization/includes;../../../../libs/intl;../../../api_scilab/includes;../../includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;SPREADSHEET_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>../../../../bin/libintl.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary>
+ <TargetMachine>MachineX86</TargetMachine>
+ <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>../../../core/includes;../../../output_stream/includes;../../../localization/includes;../../../../libs/intl;../../../api_scilab/includes;../../includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;SPREADSHEET_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>../../../../bin/libintl.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary>
+ <TargetMachine>MachineX64</TargetMachine>
+ <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ <AdditionalIncludeDirectories>../../../core/includes;../../../output_stream/includes;../../../localization/includes;../../../../libs/intl;../../../api_scilab/includes;../../includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;SPREADSHEET_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>../../../../bin/libintl.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary>
+ <TargetMachine>MachineX86</TargetMachine>
+ <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ <AdditionalIncludeDirectories>../../../core/includes;../../../output_stream/includes;../../../localization/includes;../../../../libs/intl;../../../api_scilab/includes;../../includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;SPREADSHEET_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>../../../../bin/libintl.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>$(SolutionDir)bin\$(ProjectName).dll</OutputFile>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary>
+ <TargetMachine>MachineX64</TargetMachine>
+ <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="nospreadsheet.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="nospreadsheet.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\localization\src\localization.vcxproj">
+ <Project>{ecffeb0c-1eda-45ee-9a10-b18143852e17}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\output_stream\src\c\output_stream.vcxproj">
+ <Project>{a5911cd7-f8e8-440c-a23e-4843a0636f3a}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/modules/spreadsheet/src/nospreadsheet/nospreadsheet.vcxproj.filters b/modules/spreadsheet/src/nospreadsheet/nospreadsheet.vcxproj.filters
new file mode 100755
index 000000000..5dc6c2726
--- /dev/null
+++ b/modules/spreadsheet/src/nospreadsheet/nospreadsheet.vcxproj.filters
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
+ </Filter>
+ <Filter Include="Libraries Dependencies">
+ <UniqueIdentifier>{6f778267-99a5-4901-b33b-520286c5ae08}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="nospreadsheet.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="nospreadsheet.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file