Initial revision
This commit is contained in:
11
cole/examples/Makefile.am
Normal file
11
cole/examples/Makefile.am
Normal file
@@ -0,0 +1,11 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
EXTRA_DIST = present.sdd sprsheet.sdc sprsheet.xls text.doc text.sdw \
|
||||
README-examples
|
||||
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
LDADD = $(top_builddir)/libcole.la
|
||||
TESTS = filesystem directory file version
|
||||
|
||||
noinst_PROGRAMS = filesystem directory file demo version
|
||||
|
369
cole/examples/Makefile.in
Normal file
369
cole/examples/Makefile.in
Normal file
@@ -0,0 +1,369 @@
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
AS = @AS@
|
||||
CC = @CC@
|
||||
COLE_MAJOR = @COLE_MAJOR@
|
||||
COLE_MICRO = @COLE_MICRO@
|
||||
COLE_MINOR = @COLE_MINOR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
HOST_ALIAS_NAME = @HOST_ALIAS_NAME@
|
||||
HOST_CANONICAL_NAME = @HOST_CANONICAL_NAME@
|
||||
HOST_CPU = @HOST_CPU@
|
||||
HOST_OS = @HOST_OS@
|
||||
HOST_VENDOR = @HOST_VENDOR@
|
||||
LD = @LD@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
NM = @NM@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
USE_SYMBOL_UNDERSCORE = @USE_SYMBOL_UNDERSCORE@
|
||||
VERSION = @VERSION@
|
||||
VERSION_INFO = @VERSION_INFO@
|
||||
|
||||
EXTRA_DIST = present.sdd sprsheet.sdc sprsheet.xls text.doc text.sdw README-examples
|
||||
|
||||
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
LDADD = $(top_builddir)/libcole.la
|
||||
TESTS = filesystem directory file version
|
||||
|
||||
noinst_PROGRAMS = filesystem directory file demo version
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../config.h
|
||||
CONFIG_CLEAN_FILES = topsrcdir.h
|
||||
PROGRAMS = $(noinst_PROGRAMS)
|
||||
|
||||
|
||||
DEFS = @DEFS@ -I. -I$(srcdir) -I..
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
filesystem_SOURCES = filesystem.c
|
||||
filesystem_OBJECTS = filesystem.o
|
||||
filesystem_LDADD = $(LDADD)
|
||||
filesystem_DEPENDENCIES = $(top_builddir)/libcole.la
|
||||
filesystem_LDFLAGS =
|
||||
directory_SOURCES = directory.c
|
||||
directory_OBJECTS = directory.o
|
||||
directory_LDADD = $(LDADD)
|
||||
directory_DEPENDENCIES = $(top_builddir)/libcole.la
|
||||
directory_LDFLAGS =
|
||||
file_SOURCES = file.c
|
||||
file_OBJECTS = file.o
|
||||
file_LDADD = $(LDADD)
|
||||
file_DEPENDENCIES = $(top_builddir)/libcole.la
|
||||
file_LDFLAGS =
|
||||
demo_SOURCES = demo.c
|
||||
demo_OBJECTS = demo.o
|
||||
demo_LDADD = $(LDADD)
|
||||
demo_DEPENDENCIES = $(top_builddir)/libcole.la
|
||||
demo_LDFLAGS =
|
||||
version_SOURCES = version.c
|
||||
version_OBJECTS = version.o
|
||||
version_LDADD = $(LDADD)
|
||||
version_DEPENDENCIES = $(top_builddir)/libcole.la
|
||||
version_LDFLAGS =
|
||||
CFLAGS = @CFLAGS@
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
DIST_COMMON = Makefile.am Makefile.in topsrcdir.h.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
SOURCES = filesystem.c directory.c file.c demo.c version.c
|
||||
OBJECTS = filesystem.o directory.o file.o demo.o version.o
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .lo .o .s
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps examples/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
topsrcdir.h: $(top_builddir)/config.status topsrcdir.h.in
|
||||
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
mostlyclean-noinstPROGRAMS:
|
||||
|
||||
clean-noinstPROGRAMS:
|
||||
-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
|
||||
|
||||
distclean-noinstPROGRAMS:
|
||||
|
||||
maintainer-clean-noinstPROGRAMS:
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.S.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core *.core
|
||||
|
||||
clean-compile:
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
maintainer-clean-compile:
|
||||
|
||||
.c.lo:
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||
|
||||
.s.lo:
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||
|
||||
.S.lo:
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
|
||||
maintainer-clean-libtool:
|
||||
|
||||
filesystem: $(filesystem_OBJECTS) $(filesystem_DEPENDENCIES)
|
||||
@rm -f filesystem
|
||||
$(LINK) $(filesystem_LDFLAGS) $(filesystem_OBJECTS) $(filesystem_LDADD) $(LIBS)
|
||||
|
||||
directory: $(directory_OBJECTS) $(directory_DEPENDENCIES)
|
||||
@rm -f directory
|
||||
$(LINK) $(directory_LDFLAGS) $(directory_OBJECTS) $(directory_LDADD) $(LIBS)
|
||||
|
||||
file: $(file_OBJECTS) $(file_DEPENDENCIES)
|
||||
@rm -f file
|
||||
$(LINK) $(file_LDFLAGS) $(file_OBJECTS) $(file_LDADD) $(LIBS)
|
||||
|
||||
demo: $(demo_OBJECTS) $(demo_DEPENDENCIES)
|
||||
@rm -f demo
|
||||
$(LINK) $(demo_LDFLAGS) $(demo_OBJECTS) $(demo_LDADD) $(LIBS)
|
||||
|
||||
version: $(version_OBJECTS) $(version_DEPENDENCIES)
|
||||
@rm -f version
|
||||
$(LINK) $(version_LDFLAGS) $(version_OBJECTS) $(version_LDADD) $(LIBS)
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = examples
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
check-TESTS: $(TESTS)
|
||||
@failed=0; all=0; \
|
||||
srcdir=$(srcdir); export srcdir; \
|
||||
for tst in $(TESTS); do \
|
||||
if test -f $$tst; then dir=.; \
|
||||
else dir="$(srcdir)"; fi; \
|
||||
if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \
|
||||
all=`expr $$all + 1`; \
|
||||
echo "PASS: $$tst"; \
|
||||
elif test $$? -ne 77; then \
|
||||
all=`expr $$all + 1`; \
|
||||
failed=`expr $$failed + 1`; \
|
||||
echo "FAIL: $$tst"; \
|
||||
fi; \
|
||||
done; \
|
||||
if test "$$failed" -eq 0; then \
|
||||
banner="All $$all tests passed"; \
|
||||
else \
|
||||
banner="$$failed of $$all tests failed"; \
|
||||
fi; \
|
||||
dashes=`echo "$$banner" | sed s/./=/g`; \
|
||||
echo "$$dashes"; \
|
||||
echo "$$banner"; \
|
||||
echo "$$dashes"; \
|
||||
test "$$failed" -eq 0
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
dvi: dvi-am
|
||||
check-am: all-am
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
|
||||
check: check-am
|
||||
installcheck-am:
|
||||
installcheck: installcheck-am
|
||||
install-exec-am:
|
||||
install-exec: install-exec-am
|
||||
|
||||
install-data-am:
|
||||
install-data: install-data-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-am
|
||||
uninstall-am:
|
||||
uninstall: uninstall-am
|
||||
all-am: Makefile $(PROGRAMS)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs:
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-noinstPROGRAMS mostlyclean-compile \
|
||||
mostlyclean-libtool mostlyclean-tags \
|
||||
mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-noinstPROGRAMS clean-compile clean-libtool clean-tags \
|
||||
clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-noinstPROGRAMS distclean-compile \
|
||||
distclean-libtool distclean-tags distclean-generic \
|
||||
clean-am
|
||||
-rm -f libtool
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-noinstPROGRAMS \
|
||||
maintainer-clean-compile maintainer-clean-libtool \
|
||||
maintainer-clean-tags maintainer-clean-generic \
|
||||
distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
.PHONY: mostlyclean-noinstPROGRAMS distclean-noinstPROGRAMS \
|
||||
clean-noinstPROGRAMS maintainer-clean-noinstPROGRAMS \
|
||||
mostlyclean-compile distclean-compile clean-compile \
|
||||
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
|
||||
clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
|
||||
distclean-tags clean-tags maintainer-clean-tags distdir check-TESTS \
|
||||
info-am info dvi-am dvi check check-am installcheck-am installcheck \
|
||||
install-exec-am install-exec install-data-am install-data install-am \
|
||||
install uninstall-am uninstall all-redirect all-am all installdirs \
|
||||
mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
11
cole/examples/README-examples
Normal file
11
cole/examples/README-examples
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
present.sdd - StarOffice 5.0 presentation.
|
||||
sprsheet.sdc - StarOffice 5.0 spreadsheet.
|
||||
sprsheet.xls - Microsoft Excel 95 spreadsheet.
|
||||
text.sdw - StarOffice 5.0 text.
|
||||
|
||||
All the files above was generated using the free StarOffice 5.0 Personal
|
||||
Edition.
|
||||
|
||||
text.doc - Microsoft Word 97 text with an incrusted image.
|
||||
|
159
cole/examples/demo.c
Normal file
159
cole/examples/demo.c
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
cole - A free C OLE library.
|
||||
cole using sample.
|
||||
Copyright 1998, 1999 Roberto Arturo Tena Sanchez
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/*
|
||||
Arturo Tena <arturo@directmail.org>
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/* To compile this file outside cole source tree,
|
||||
you must include here <cole/cole.h> instead <cole.h> */
|
||||
#include <cole.h>
|
||||
|
||||
|
||||
#define PRGNAME "demo"
|
||||
#define BUFFER_SIZE 128
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
COLEFS * cfs;
|
||||
COLEDIR * cd;
|
||||
COLEDIRENT * cde;
|
||||
COLEFILE * cf;
|
||||
COLERRNO colerrno;
|
||||
char * entry_name;
|
||||
char buffer[BUFFER_SIZE];
|
||||
size_t char_read;
|
||||
size_t char_read_total;
|
||||
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf (stderr, "cole demo. cole is a free C OLE library.\n"
|
||||
"Usage: demo <FILE>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* version info
|
||||
*/
|
||||
printf ("Version info: (%d.%d.%d) (%d.%d.%d) (%s)\n",
|
||||
COLE_MAJOR_VERSION, COLE_MINOR_VERSION, COLE_MICRO_VERSION,
|
||||
cole_major_version, cole_minor_version, cole_micro_version,
|
||||
cole_version);
|
||||
printf ("Host info: (%s)\n", cole_host_info);
|
||||
|
||||
|
||||
cfs = cole_mount (argv[1], &colerrno);
|
||||
if (cfs == NULL) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (cole_print_tree (cfs, &colerrno)) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
cd = cole_opendir_rootdir (cfs, &colerrno);
|
||||
if (cd == NULL) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
for (cde = cole_visiteddirentry (cd); cde != NULL;
|
||||
cde = cole_nextdirentry (cd)) {
|
||||
if (cole_direntry_isdir (cde))
|
||||
printf ("DIR ");
|
||||
else if (cole_direntry_isfile (cde)) {
|
||||
printf ("FILE ");
|
||||
/* open the file using their direntry */
|
||||
cf = cole_fopen_direntry (cde, &colerrno);
|
||||
if (cf == NULL) {
|
||||
cole_perror ("travel", colerrno);
|
||||
cole_closedir (cd, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
if (cole_fclose (cf, &colerrno)) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_closedir (cd, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
} else
|
||||
printf ("???? ");
|
||||
printf ("%7u ", cole_direntry_getsize (cde));
|
||||
entry_name = cole_direntry_getname (cde);
|
||||
printf ("%08lx-%08lx %08lx-%08lx\t",
|
||||
cole_direntry_getdays1 (cde),
|
||||
cole_direntry_getsec1 (cde),
|
||||
cole_direntry_getdays2 (cde),
|
||||
cole_direntry_getsec2 (cde));
|
||||
if (!isprint ((int)entry_name[0]))
|
||||
printf ("'\\x%02x%s'\n", entry_name[0], entry_name+1);
|
||||
else
|
||||
printf ("'%s'\n", entry_name);
|
||||
}
|
||||
if (cole_closedir (cd, &colerrno)) {
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
cf = cole_fopen (cfs, "\005SummaryInformation", &colerrno);
|
||||
if (cf == NULL) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
char_read_total = 0;
|
||||
printf ("Reading: ");
|
||||
while ((char_read = cole_fread (cf, buffer, BUFFER_SIZE, &colerrno))) {
|
||||
printf ("[%d]", char_read);
|
||||
char_read_total += char_read;
|
||||
}
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
printf ("\nRead %d bytes from the stream '\\005SummaryInformation'\n",
|
||||
char_read_total);
|
||||
if (cole_fclose (cf, &colerrno)) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (cole_umount (cfs, &colerrno)) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
121
cole/examples/directory.c
Normal file
121
cole/examples/directory.c
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
cole - A free C OLE library.
|
||||
cole test.
|
||||
Copyright 1998, 1999 Roberto Arturo Tena Sanchez
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/*
|
||||
Arturo Tena <arturo@directmail.org>
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <cole.h>
|
||||
#include <topsrcdir.h>
|
||||
|
||||
|
||||
/*
|
||||
MISSING TO TEST:
|
||||
cole_opendir_direntry
|
||||
cole_dir_getname
|
||||
cole_dir_getsize
|
||||
cole_dir_getdays1
|
||||
cole_dir_getsec1
|
||||
cole_dir_getdays2
|
||||
cole_dir_getsec2
|
||||
*/
|
||||
|
||||
|
||||
#define PRGNAME "directory"
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
COLEFS * cfs;
|
||||
COLEDIR * cd;
|
||||
COLEDIRENT * cde;
|
||||
COLEFILE * cf;
|
||||
char * entry_name;
|
||||
COLERRNO colerrno;
|
||||
|
||||
|
||||
cfs = cole_mount (COLE_TOPSRCDIR"/examples/text.doc", &colerrno);
|
||||
if (cfs == NULL) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
cd = cole_opendir_rootdir (cfs, &colerrno);
|
||||
if (cd == NULL) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
for (cde = cole_visiteddirentry (cd); cde != NULL;
|
||||
cde = cole_nextdirentry (cd)) {
|
||||
if (cole_direntry_isdir (cde))
|
||||
printf ("DIR ");
|
||||
else if (cole_direntry_isfile (cde)) {
|
||||
printf ("FILE");
|
||||
/* open the file using their direntry */
|
||||
cf = cole_fopen_direntry (cde, &colerrno);
|
||||
if (cf == NULL) {
|
||||
cole_perror ("travel", colerrno);
|
||||
cole_closedir (cd, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
/* Here we process cf */
|
||||
if (cole_fclose (cf, &colerrno)) {
|
||||
cole_perror ("travel", colerrno);
|
||||
cole_closedir (cd, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
} else
|
||||
printf ("????");
|
||||
printf (" %7u", cole_direntry_getsize (cde));
|
||||
entry_name = cole_direntry_getname (cde);
|
||||
if (!isprint ((int)entry_name[0]))
|
||||
printf ("' \\x%02x%s'", entry_name[0], entry_name+1);
|
||||
else
|
||||
printf ("'%s'", entry_name);
|
||||
printf ("\t%08lx-%08lx %08lx-%08lx",
|
||||
cole_direntry_getdays1 (cde),
|
||||
cole_direntry_getsec1 (cde),
|
||||
cole_direntry_getdays2 (cde),
|
||||
cole_direntry_getsec2 (cde));
|
||||
printf ("\n");
|
||||
}
|
||||
if (cole_closedir (cd, &colerrno)) {
|
||||
cole_perror ("travel", colerrno);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
if (cole_umount (cfs, &colerrno)) {
|
||||
cole_perror ("travel", colerrno);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
192
cole/examples/file.c
Normal file
192
cole/examples/file.c
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
cole - A free C OLE library.
|
||||
cole test.
|
||||
Copyright 1998, 1999 Roberto Arturo Tena Sanchez
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/*
|
||||
Arturo Tena <arturo@directmail.org>
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cole.h>
|
||||
#include <topsrcdir.h>
|
||||
|
||||
|
||||
/* cole_fopen_direntry is tested in `directory.c' */
|
||||
|
||||
|
||||
#define PRGNAME "file"
|
||||
#define BUFFER_SIZE 128
|
||||
#define FILENAME2_SIZE 108004
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
COLEFS * cfs;
|
||||
COLEFILE * cf;
|
||||
COLERRNO colerrno;
|
||||
char buffer[BUFFER_SIZE];
|
||||
size_t char_read;
|
||||
size_t char_read_total;
|
||||
char *filename2 = "/ObjectPool/_994231763/\001Ole10Native";
|
||||
char *filename2_pretty = "/ObjectPool/_994231763/\\001Ole10Native";
|
||||
|
||||
cfs = cole_mount (COLE_TOPSRCDIR"/examples/text.doc", &colerrno);
|
||||
if (cfs == NULL) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
cf = cole_fopen (cfs, filename2, &colerrno);
|
||||
if (cf == NULL) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
printf ("File size: %d\n", cole_fsize (cf));
|
||||
if (cole_fsize (cf) != FILENAME2_SIZE) {
|
||||
fprintf (stderr, "Test failed\n");
|
||||
cole_fclose (cf, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
printf ("File position: %d\n", cole_ftell (cf));
|
||||
char_read_total = 0;
|
||||
while ((char_read = cole_fread (cf, buffer, BUFFER_SIZE, &colerrno)))
|
||||
char_read_total += char_read;
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
printf ("File position: %d\n", cole_ftell (cf));
|
||||
printf ("Read %d bytes from the stream `%s'\n", char_read_total,
|
||||
filename2_pretty);
|
||||
|
||||
|
||||
if (cole_frewind (cf, &colerrno)) {
|
||||
fprintf (stderr, "Test failed\n");
|
||||
cole_fclose (cf, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
printf ("File position: %d\n", cole_ftell (cf));
|
||||
if (cole_ftell (cf) != 0) {
|
||||
fprintf (stderr, "Test failed\n");
|
||||
cole_fclose (cf, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (cole_fseek (cf, 0, COLE_SEEK_END, &colerrno)) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_fclose (cf, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
printf ("File position: %d\n", cole_ftell (cf));
|
||||
if (cole_ftell (cf) != FILENAME2_SIZE) {
|
||||
fprintf (stderr, "Test failed\n");
|
||||
cole_fclose (cf, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (cole_fseek (cf, 200, COLE_SEEK_END, &colerrno)) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_fclose (cf, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
printf ("File position: %d\n", cole_ftell (cf));
|
||||
if (cole_ftell (cf) != FILENAME2_SIZE - 200) {
|
||||
fprintf (stderr, "Test failed\n");
|
||||
cole_fclose (cf, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (cole_fseek (cf, 100, COLE_SEEK_FORWARD, &colerrno)) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_fclose (cf, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
printf ("File position: %d\n", cole_ftell (cf));
|
||||
if (cole_ftell (cf) != FILENAME2_SIZE - 200 + 100) {
|
||||
fprintf (stderr, "Test failed\n");
|
||||
cole_fclose (cf, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (cole_fseek (cf, 200, COLE_SEEK_BACKWARD, &colerrno)) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_fclose (cf, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
printf ("File position: %d\n", cole_ftell (cf));
|
||||
if (cole_ftell (cf) != FILENAME2_SIZE - 200 + 100 - 200) {
|
||||
fprintf (stderr, "Test failed\n");
|
||||
cole_fclose (cf, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (!cole_fseek (cf, FILENAME2_SIZE + 1, COLE_SEEK_SET, &colerrno)) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_fclose (cf, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
printf ("File position: %d\n", cole_ftell (cf));
|
||||
|
||||
if (cole_fseek (cf, FILENAME2_SIZE, COLE_SEEK_END, &colerrno)) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_fclose (cf, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
if (cole_ftell (cf) != 0) {
|
||||
fprintf (stderr, "Test failed\n");
|
||||
cole_fclose (cf, NULL);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
printf ("File position: %d\n", cole_ftell (cf));
|
||||
|
||||
|
||||
|
||||
if (cole_fclose (cf, &colerrno)) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (cole_umount (cfs, &colerrno)) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
102
cole/examples/filesystem.c
Normal file
102
cole/examples/filesystem.c
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
cole - A free C OLE library.
|
||||
cole test.
|
||||
Copyright 1998, 1999 Roberto Arturo Tena Sanchez
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/*
|
||||
Arturo Tena <arturo@directmail.org>
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cole.h>
|
||||
#include <topsrcdir.h>
|
||||
|
||||
|
||||
#define PRGNAME "filesystem"
|
||||
|
||||
|
||||
/* To test cole_locate_filename() */
|
||||
struct str_info {
|
||||
char *name;
|
||||
size_t size;
|
||||
};
|
||||
COLE_LOCATE_ACTION_FUNC check_size;
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
COLEFS * cfs;
|
||||
COLERRNO colerrno;
|
||||
|
||||
/* To test cole_locate_filename() */
|
||||
#define FILENAME "/ObjectPool/_994231763/\001Ole10Native"
|
||||
struct str_info info = { FILENAME, 108004 };
|
||||
|
||||
|
||||
cfs = cole_mount (COLE_TOPSRCDIR"/examples/text.doc", &colerrno);
|
||||
if (cfs == NULL) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
if (cole_print_tree (cfs, &colerrno)) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
if (cole_locate_filename (cfs, FILENAME, &info, check_size,
|
||||
&colerrno)) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
if (cole_recurse_tree (cfs, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
&colerrno)) {
|
||||
cole_perror (PRGNAME, colerrno);
|
||||
cole_umount (cfs, NULL);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
if (cole_umount (cfs, &colerrno)) {
|
||||
cole_perror ("travel", colerrno);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
|
||||
/* To test cole_locate_filename() */
|
||||
void
|
||||
check_size (COLEDIRENT *cde, void *_info) {
|
||||
struct str_info *info = (struct str_info *)_info;
|
||||
|
||||
if (info->size != cole_direntry_getsize (cde))
|
||||
printf ("SIZE OF `%s' DOESN'T CHECK!\n", info->name);
|
||||
else
|
||||
printf ("Size of `%s' is ok\n", info->name);
|
||||
}
|
||||
|
BIN
cole/examples/present.sdd
Normal file
BIN
cole/examples/present.sdd
Normal file
Binary file not shown.
BIN
cole/examples/sprsheet.sdc
Normal file
BIN
cole/examples/sprsheet.sdc
Normal file
Binary file not shown.
BIN
cole/examples/sprsheet.xls
Normal file
BIN
cole/examples/sprsheet.xls
Normal file
Binary file not shown.
BIN
cole/examples/text.doc
Normal file
BIN
cole/examples/text.doc
Normal file
Binary file not shown.
BIN
cole/examples/text.sdw
Normal file
BIN
cole/examples/text.sdw
Normal file
Binary file not shown.
41
cole/examples/topsrcdir.h.in
Normal file
41
cole/examples/topsrcdir.h.in
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
cole - A free C OLE library.
|
||||
Copyright 1998, 1999 Roberto Arturo Tena Sanchez
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/*
|
||||
Arturo Tena <arturo@directmail.org>
|
||||
*/
|
||||
|
||||
#ifndef COLE_TOPSRCDIR_H
|
||||
#define COLE_TOPSRCDIR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define COLE_TOPSRCDIR "@top_srcdir@"
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* COLE_TOPSRCDIR_H */
|
||||
|
42
cole/examples/version.c
Normal file
42
cole/examples/version.c
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
cole - A free C OLE library.
|
||||
cole test.
|
||||
Copyright 1998, 1999 Roberto Arturo Tena Sanchez
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/*
|
||||
Arturo Tena <arturo@directmail.org>
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cole.h>
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
printf ("cole version (defines): %d.%d.%d\n",
|
||||
COLE_MAJOR_VERSION, COLE_MINOR_VERSION, COLE_MICRO_VERSION);
|
||||
printf ("cole version (variables): %d.%d.%d\n",
|
||||
cole_major_version, cole_minor_version, cole_micro_version);
|
||||
printf ("cole version (cole_version): %s\n", cole_version);
|
||||
printf ("cole host: %s\n", cole_host_info);
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user