sync master with lastest vba changes
[ooovba.git] / msfontextract / msfontextract.patch
blob7532a061985aaa0bd6dac3dd846eafe94c6a8062
1 --- misc/libmspack/mspack/makefile.mk Mon Mar 31 11:34:58 2008
2 +++ misc/build/libmspack/mspack/makefile.mk Mon Mar 31 11:34:31 2008
3 @@ -1 +1,82 @@
4 -dummy
5 +#*************************************************************************
6 +#
7 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 +#
9 +# Copyright 2008 by Sun Microsystems, Inc.
11 +# OpenOffice.org - a multi-platform office productivity suite
13 +# $RCSfile: msfontextract.patch,v $
15 +# $Revision: 1.9 $
17 +# This file is part of OpenOffice.org.
19 +# OpenOffice.org is free software: you can redistribute it and/or modify
20 +# it under the terms of the GNU Lesser General Public License version 3
21 +# only, as published by the Free Software Foundation.
23 +# OpenOffice.org is distributed in the hope that it will be useful,
24 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
25 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 +# GNU Lesser General Public License version 3 for more details
27 +# (a copy is included in the LICENSE file that accompanied this code).
29 +# You should have received a copy of the GNU Lesser General Public License
30 +# version 3 along with OpenOffice.org. If not, see
31 +# <http://www.openoffice.org/license.html>
32 +# for a copy of the LGPLv3 License.
34 +#*************************************************************************
36 +PRJ=..$/..$/..$/..$/..$/
38 +PRJNAME=msfontextract
39 +TARGET=msfontextract
40 +TARGETTYPE=CUI
41 +LIBTARGET=NO
42 +NO_DEFAULT_STL=TRUE
43 +LIBSALCPPRT=
44 +EXTERNAL_WARNINGS_NOT_ERRORS=TRUE
46 +# --- Settings -----------------------------------------------------
49 +.INCLUDE : settings.mk
51 +# --- Files --------------------------------------------------------
53 +CCFILES= \
54 + msfontextract.c
56 +.IF "$(SYSTEM_MSPACK)" != "YES"
57 +CCFILES+= \
58 + system.c \
59 + cabd.c \
60 + lzxd.c \
61 + ministub .c
62 +.ENDIF
64 +OBJFILES= \
65 + $(OBJ)$/msfontextract.obj
67 +.IF "$(SYSTEM_MSPACK)" != "YES"
68 +OBJFILES += \
69 + $(OBJ)$/system.obj \
70 + $(OBJ)$/cabd.obj \
71 + $(OBJ)$/lzxd.obj \
72 + $(OBJ)$/ministub.obj
73 +.ENDIF
75 +APP1TARGET= $(TARGET)
76 +APP1OBJS= $(OBJFILES)
78 +APP1STDLIBS=
80 +.IF "$(SYSTEM_MSPACK)" == "YES"
81 +APP1STDLIBS+= -lmspack
82 +.ENDIF
84 +# --- Targets ------------------------------------------------------
86 +.INCLUDE : target.mk
87 --- misc/libmspack/mspack/ministub.c Mon Mar 31 11:34:58 2008
88 +++ misc/build/libmspack/mspack/ministub.c Mon Mar 31 11:34:02 2008
89 @@ -1 +1,11 @@
90 -dummy
91 +#include <mspack.h>
93 +/* other expansion types not needed */
94 +int mszipd_init() {return MSPACK_ERR_DECRUNCH;}
95 +int mszipd_decompress() {return MSPACK_ERR_DECRUNCH;}
96 +void mszipd_free() {}
98 +int qtmd_init() {return MSPACK_ERR_DECRUNCH;}
99 +int qtmd_decompress() {return MSPACK_ERR_DECRUNCH;}
100 +void qtmd_free() {}
102 --- misc/libmspack/mspack/msfontextract.c Mon Mar 31 11:34:58 2008
103 +++ misc/build/libmspack/mspack/msfontextract.c Mon Mar 31 11:34:02 2008
104 @@ -1 +1,107 @@
105 -dummy
107 +* Portions (almost all!) (C) 2003 Stuart Caie.
108 +* you can redistribute it and/or modify it under
109 +* the terms of the GNU Lesser General Public License (LGPL) version 2.1
112 +#include <ctype.h>
113 +#include <stdio.h>
114 +#include <stdlib.h>
115 +#include <string.h>
116 +#include <unistd.h>
117 +#include <mspack.h>
119 +char *error_msg(int error) {
120 + switch (error) {
121 + case MSPACK_ERR_OK: return "no error";
122 + case MSPACK_ERR_ARGS: return "bad arguments to library function";
123 + case MSPACK_ERR_OPEN: return "error opening file";
124 + case MSPACK_ERR_READ: return "read error";
125 + case MSPACK_ERR_WRITE: return "write error";
126 + case MSPACK_ERR_SEEK: return "seek error";
127 + case MSPACK_ERR_NOMEMORY: return "out of memory";
128 + case MSPACK_ERR_SIGNATURE: return "bad signature";
129 + case MSPACK_ERR_DATAFORMAT: return "error in data format";
130 + case MSPACK_ERR_CHECKSUM: return "checksum error";
131 + case MSPACK_ERR_CRUNCH: return "compression error";
132 + case MSPACK_ERR_DECRUNCH: return "decompression error";
134 + return "unknown error";
138 +/* creates name of output file */
139 +char *create_output_name(const char *fname, char *dir) {
140 + char c, *p, *name;
141 + if (!(name = malloc(strlen(fname) + (dir ? strlen(dir) : 0) + 2))) {
142 + fprintf(stderr, "out of memory!\n");
143 + return NULL;
145 + /* start with blank name */
146 + *name = '\0';
147 + /* add output directory if needed */
148 + if (dir) {
149 + strcpy(name, dir);
150 + strcat(name, "/");
152 + p = &name[strlen(name)];
153 + do {
154 + c = *fname++;
155 + *p++ = tolower((unsigned char) c);
156 + } while (c);
158 + return name;
162 +int
163 +main(int argc, char** argv)
166 + struct mscab_decompressor *cabd;
167 + struct mscabd_cabinet *cab;
168 + struct mscabd_file *file;
169 + char * ename = NULL;
170 + int err;
172 + /* argv[1] is the cabinet to extract */
173 + /* argv[2] is the path to extract to */
174 + if ((!(argv[1])) || (!(argv[2]))) {
175 + fprintf(stderr,"Usage: %s <cabinet> <destpath>\n",argv[0]);
176 + return 1;
179 + /* initialize libmspack and create a CAB decompressor */
180 + MSPACK_SYS_SELFTEST(err);
181 + if (err) {
182 + fprintf(stderr,"Cannot initialize libmspack\n");
183 + return 1;
185 + if (!(cabd = mspack_create_cab_decompressor(NULL))) {
186 + fprintf(stderr, "can't make decompressor: %s\n",
187 + error_msg(cabd->last_error(cabd)));
188 + return 1;
192 + /* look for an embedded cabinet */
193 + if ((cab = cabd->search(cabd, argv[1]))) {
194 + /* for all files in the cabinet */
195 + for (file = cab->files; file; file = file->next) {
196 + if (!(ename = create_output_name(file->filename, argv[2]))) continue;
197 + if ((cabd->extract(cabd, file, ename))) {
198 + fprintf(stderr,"%s: extract error on \"%s\": %s\n",argv[1],
199 + ename, error_msg(cabd->last_error(cabd)));
200 + exit(1);
202 + free(ename);
204 + cabd->close(cabd, cab);
206 + else {
207 + fprintf(stderr, "%s: no embedded cabinet found\n", argv[1] );
209 + mspack_destroy_cab_decompressor(cabd);
210 + return 0;
213 --- misc/libmspack/mspack/mspack.h Fri Dec 12 18:06:15 2003
214 +++ misc/build/libmspack/mspack/mspack.h Mon Mar 31 11:34:02 2008
215 @@ -120,6 +120,11 @@
216 #include <sys/types.h>
217 #include <unistd.h>
219 +/* MS Compiler defines size_t in stddef.h */
220 +#if defined(_MSC_VER) || defined(__MINGW32__)
221 +#include <stddef.h>
222 +#endif
225 * System self-test function, to ensure both library and calling program
226 * can use one another.
227 --- misc/libmspack/mspack/system.h Thu Sep 11 16:06:52 2003
228 +++ misc/build/libmspack/mspack/system.h Mon Mar 31 11:34:02 2008
229 @@ -12,12 +12,16 @@
231 #ifdef DEBUG
232 # include <stdio.h>
233 -# define D(x) do { printf("%s:%d (%s) ",__FILE__, __LINE__, __FUNCTION__); \
234 +# define D(x) do { printf("%s:%d ",__FILE__, __LINE__); \
235 printf x ; fputc('\n', stdout); fflush(stdout);} while (0);
236 #else
237 # define D(x)
238 #endif
240 +/* Brutal hack to make it compile with MS .NET Compiler that doesn't
241 + know what inline means. */
242 +#define inline
244 /* endian-neutral reading of little-endian data */
245 #define __egi32(a,n) ( (((a)[n+3]) << 24) | (((a)[n+2]) << 16) | \
246 (((a)[n+1]) << 8) | ((a)[n+0]) )
247 @@ -39,6 +43,7 @@
248 /* validates a system structure */
249 extern int mspack_valid_system(struct mspack_system *sys);
251 +#if 0
252 /* inline memcmp() */
253 static inline int memcmp(const void *s1, const void *s2, size_t n) {
254 unsigned char *c1 = (unsigned char *) s1;
255 @@ -54,5 +59,6 @@
256 while (*e) e++;
257 return e - s;
259 +#endif
261 #endif