Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Letwory <nathan@letworyinteractive.com>2004-04-16 19:55:16 +0400
committerNathan Letwory <nathan@letworyinteractive.com>2004-04-16 19:55:16 +0400
commit39a8c014c4572f7f5f9ca099482929b67fe4273e (patch)
tree84224067db57aaa5717930d2c5703f7ab70f14f8 /source/blender/blenloader
parent2cc124cf3b1281488c726b71090c1d2640e8078d (diff)
This commit removes the glue from Blender, and with it
the directories decrypt, deflate, encrypt, inflate, readstreamglue, sign, writeblenfile and writestreamglue. Sirdude was so kind to modify the makefiles, so SCons and Make are ready to build with the new Blender. Visual Studio workspaces, solutions and projectfiles still need to be updated (I'll do the .vcprojs and .sln myself after this commit). Runtimes created with the Blender Publisher are not anymore recognised - if you want these available, you'll have to convert them first to .blends with the Publisher.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/BLO_readfile.h20
-rw-r--r--source/blender/blenloader/BLO_sys_types.h102
-rw-r--r--source/blender/blenloader/intern/readblenentry.c12
-rw-r--r--source/blender/blenloader/intern/readfile.c160
-rw-r--r--source/blender/blenloader/intern/writefile.c130
5 files changed, 126 insertions, 298 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 48f9886c61c..66b3729d860 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -215,26 +215,8 @@ int BLO_has_bfile_extension(char *str);
void BLO_library_append(struct SpaceFile *sfile, char *dir, int idcode);
+BlendFileData* blo_read_blendafterruntime(int file, int actualsize, BlendReadError *error_r);
-/* Ick ick ick, why are internal loader functions
- * being exported out of the loader? IMHO readstreamglue
- * should not need to know anything about the loader,
- * but this is a point of contention. - zr
- */
- void*
-blo_readstreamfile_begin(
- void *endControl);
-
- int
-blo_readstreamfile_process(
- void *filedataVoidPtr,
- unsigned char *data,
- unsigned int dataIn);
-
- int
-blo_readstreamfile_end(
- void *filedataVoidPtr);
-
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenloader/BLO_sys_types.h b/source/blender/blenloader/BLO_sys_types.h
new file mode 100644
index 00000000000..38dde20500e
--- /dev/null
+++ b/source/blender/blenloader/BLO_sys_types.h
@@ -0,0 +1,102 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * A platform-independent definition of [u]intXX_t
+ * Plus the accompanying header include for htonl/ntohl
+ *
+ * This file includes <sys/types.h> to define [u]intXX_t types, where
+ * XX can be 8, 16, 32 or 64. Unfortunately, not all systems have this
+ * file.
+ * - Windows uses __intXX compiler-builtin types. These are signed,
+ * so we have to flip the signs.
+ * For these rogue platforms, we make the typedefs ourselves.
+ *
+ */
+
+#ifndef BLO_SYS_TYPES_H
+#define BLO_SYS_TYPES_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef FREE_WINDOWS
+typedef unsigned char uint8_t;
+typedef unsigned int uint32_t;
+#endif
+
+#if defined(_WIN32) && !defined(FREE_WINDOWS)
+
+/* The __intXX are built-in types of the visual complier! So we don't
+ * need to include anything else here. */
+
+typedef signed __int8 int8_t;
+typedef signed __int16 int16_t;
+typedef signed __int32 int32_t;
+typedef signed __int64 int64_t;
+
+typedef unsigned __int8 uint8_t;
+typedef unsigned __int16 uint16_t;
+typedef unsigned __int32 uint32_t;
+typedef unsigned __int64 uint64_t;
+
+#elif defined(__linux__)
+
+ /* Linux-i386, Linux-Alpha, Linux-ppc */
+#include <stdint.h>
+
+#elif defined (__APPLE__)
+
+#include <inttypes.h>
+
+#else
+
+ /* FreeBSD, Irix, Solaris */
+#include <sys/types.h>
+
+#endif /* ifdef platform for types */
+
+#ifdef _WIN32
+#define htonl(x) correctByteOrder(x)
+#define ntohl(x) correctByteOrder(x)
+#elif defined (__FreeBSD__) || defined (__OpenBSD__)
+#include <sys/param.h>
+#elif defined (__APPLE__)
+#include <sys/types.h>
+#else /* irix sun linux */
+#include <netinet/in.h>
+#endif /* ifdef platform for htonl/ntohl */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* eof */
+
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 7797f4468d1..bf4a634e8ed 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -257,12 +257,6 @@ BlendFileData *BLO_read_from_file(char *file, BlendReadError *error_r) {
bfd->type= BLENFILETYPE_RUNTIME;
strcpy(bfd->main->name, file);
}
- } else {
- bfd= BLO_readblenfilename(file, error_r);
- if (bfd) {
- bfd->type= BLENFILETYPE_PUB;
- strcpy(bfd->main->name, file);
- }
}
return bfd;
@@ -280,12 +274,6 @@ BlendFileData *BLO_read_from_memory(void *mem, int memsize, BlendReadError *erro
strcpy(bfd->main->name, "");
}
blo_freefiledata(fd);
- } else {
- bfd= BLO_readblenfilememory(mem, memsize, error_r);
- if (bfd) {
- bfd->type= BLENFILETYPE_PUB;
- strcpy(bfd->main->name, "");
- }
}
return bfd;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index cc8163e5b73..cb241af6c4c 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -128,9 +128,6 @@
#include "mydevice.h"
-
-
-
/*
Remark: still a weak point is the newadress() function, that doesnt solve reading from
multiple files at the same time
@@ -5067,154 +5064,31 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
}
}
-// ****************** STREAM GLUE READER **********************
-
-static int fd_read_from_streambuffer(FileData *filedata, void *buffer, int size)
-{
- int readsize = EOF;
- int type;
-
- if (size <= (filedata->inbuffer - filedata->seek)) {
- memmove(buffer, filedata->buffer + filedata->seek, size);
- filedata->seek += size;
- readsize = size;
- } else {
- // special ENDB handling
- if (((filedata->inbuffer - filedata->seek) == 8) && (size > 8)) {
- memmove(&type, filedata->buffer + filedata->seek, sizeof(type));
+/* reading runtime */
- if (type == ENDB) {
- memmove(buffer, filedata->buffer + filedata->seek, 8);
- readsize = 8;
- }
- }
- }
-
- return (readsize);
-}
-
-void *blo_readstreamfile_begin(void *endControl)
-{
- void **params = endControl;
-
+BlendFileData *blo_read_blendafterruntime(int file, int actualsize, BlendReadError *error_r) {
+ BlendFileData *bfd = NULL;
FileData *fd = filedata_new();
- fd->read = fd_read_from_streambuffer;
- fd->buffersize = 100000;
- fd->buffer = MEM_mallocN(fd->buffersize, "Buffer readstreamfile");
- fd->bfd_r = params[0];
- fd->error_r = params[1];
-
- return fd;
-}
+ fd->filedes = file;
+ fd->buffersize = actualsize;
+ fd->read = fd_read_from_file;
-int blo_readstreamfile_process(void *filedataVoidPtr, unsigned char *data, unsigned int dataIn)
-{
- struct FileData *filedata = filedataVoidPtr;
- int err = 0;
- int size, datasize;
- char *newbuffer;
- BHead8 bhead8;
- BHead4 bhead4;
-
- // copy everything in the buffer
-
- if (((int) dataIn + filedata->inbuffer) > filedata->buffersize) {
- // do we need a bigger buffer ?
- if (((int) dataIn + filedata->inbuffer - filedata->seek) > filedata->buffersize) {
- // copy data and ajust settings
- filedata->buffersize = dataIn + filedata->inbuffer - filedata->seek;
- newbuffer = MEM_mallocN(filedata->buffersize, "readstreamfile newbuffer");
- memmove(newbuffer, filedata->buffer + filedata->seek, filedata->inbuffer - filedata->seek);
- MEM_freeN(filedata->buffer);
- filedata->buffer = newbuffer;
- } else {
- // we just move the existing data to the start
- // of the block
- memmove(filedata->buffer, filedata->buffer + filedata->seek, filedata->inbuffer - filedata->seek);
- }
- // adjust seek and inbuffer accordingly
- filedata->inbuffer -= filedata->seek;
- filedata->seek = 0;
- }
-
- memmove(filedata->buffer + filedata->inbuffer, data, dataIn);
- filedata->inbuffer += dataIn;
-
- // OK, so now we have everything in one buffer. What are we
- // going to do with it...
-
- while (1) {
- datasize = filedata->inbuffer - filedata->seek;
-
- if (filedata->headerdone) {
- if (filedata->flags & FD_FLAGS_FILE_POINTSIZE_IS_4) {
- if (datasize > sizeof(bhead4)) {
- datasize -= sizeof(bhead4);
- memmove(&bhead4, filedata->buffer + filedata->seek, sizeof(bhead4));
- size = bhead4.len;
- } else {
- break;
- }
- } else {
- if (datasize > sizeof(bhead8)) {
- datasize -= sizeof(bhead8);
- memmove(&bhead8, filedata->buffer + filedata->seek, sizeof(bhead8));
- size = bhead8.len;
- } else {
- break;
- }
- }
+ decode_blender_header(fd);
- if (filedata->flags & FD_FLAGS_SWITCH_ENDIAN) {
- SWITCH_INT(size);
- }
-
- // do we have enough left in the buffer to read
- // in a full bhead + data ?
- if (size <= datasize) {
- get_bhead(filedata);
- } else {
- break;
- }
-
- } else {
- if (datasize < SIZEOFBLENDERHEADER) {
- // still need more data to continue..
- break;
- } else {
- decode_blender_header(filedata);
- filedata->headerdone = 1;
- if (! (filedata->flags & FD_FLAGS_FILE_OK)) {
- // not a blender file ... ?
- err = 1;
- break;
- }
- }
+ if (fd->flags & FD_FLAGS_FILE_OK) {
+ if (!read_file_dna(fd)) {
+ blo_freefiledata(fd);
+ fd= NULL;
+ return NULL;
}
- }
-
- return err;
-}
-
-int blo_readstreamfile_end(void *filedataVoidPtr)
-{
- struct FileData *fd = filedataVoidPtr;
- int err = 1;
-
- *fd->bfd_r= NULL;
- if (!(fd->flags & FD_FLAGS_FILE_OK)) {
- *fd->error_r= BRE_NOT_A_BLEND;
- } else if ((fd->inbuffer - fd->seek) != 8) {
- *fd->error_r= BRE_INCOMPLETE;
- } else if (!get_bhead(fd) || !read_file_dna(fd)) {
- // ENDB block !
- *fd->error_r= BRE_INCOMPLETE;
} else {
- *fd->bfd_r= blo_read_file_internal(fd, fd->error_r);
- err = 0;
+ blo_freefiledata(fd);
+ fd= NULL;
+ return NULL;
}
+ bfd= blo_read_file_internal(fd, error_r);
blo_freefiledata(fd);
- return err;
+ return bfd;
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index b7e510834aa..455eed82aaa 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -162,12 +162,6 @@ Important to know is that 'streaming' has been added to files, for Blender Publi
#include "readfile.h"
#include "genfile.h"
-/* ******* MYWRITE ********* */
-
-#include "BLO_writeStreamGlue.h"
-
-/***/
-
typedef struct {
struct SDNA *sdna;
@@ -175,12 +169,9 @@ typedef struct {
unsigned char *buf;
int tot, count, error;
-
- int is_publisher;
- struct writeStreamGlueStruct *streamGlue;
} WriteData;
-static WriteData *writedata_new(int file, int is_publisher)
+static WriteData *writedata_new(int file)
{
extern char DNAstr[]; /* DNA.c */
extern int DNAlen;
@@ -193,7 +184,6 @@ static WriteData *writedata_new(int file, int is_publisher)
wd->sdna= dna_sdna_from_data(DNAstr, DNAlen, 0);
wd->file= file;
- wd->is_publisher= is_publisher;
wd->buf= MEM_mallocN(100000, "wd->buf");
@@ -203,13 +193,8 @@ static WriteData *writedata_new(int file, int is_publisher)
static void writedata_do_write(WriteData *wd, void *mem, int memlen)
{
if (wd->error) return;
-
- if (wd->is_publisher) {
- wd->error = writeStreamGlue(Global_streamGlueControl, &wd->streamGlue, mem, memlen, 0);
- } else {
- if (write(wd->file, mem, memlen) != memlen)
- wd->error= 1;
- }
+ if (write(wd->file, mem, memlen) != memlen)
+ wd->error= 1;
}
static void writedata_free(WriteData *wd)
@@ -222,7 +207,6 @@ static void writedata_free(WriteData *wd)
/***/
-struct streamGlueControlStruct *Global_streamGlueControl;
int mywfile;
/**
@@ -268,25 +252,7 @@ bgnwrite(
int file,
int write_flags)
{
- int is_publisher= (write_flags & (G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN | G_FILE_PUBLISH));
- WriteData *wd= writedata_new(file, is_publisher);
-
- if (is_publisher) {
- mywfile= file;
- wd->streamGlue = NULL;
- Global_streamGlueControl = streamGlueControlConstructor();
- streamGlueControlAppendAction(Global_streamGlueControl, DUMPFROMMEMORY);
- if (write_flags & G_FILE_COMPRESS) {
- streamGlueControlAppendAction(Global_streamGlueControl, DEFLATE);
- }
- if (write_flags & G_FILE_LOCK) {
- streamGlueControlAppendAction(Global_streamGlueControl, ENCRYPT);
- }
- if (write_flags & G_FILE_SIGN) {
- streamGlueControlAppendAction(Global_streamGlueControl, SIGN);
- }
- streamGlueControlAppendAction(Global_streamGlueControl, WRITEBLENFILE);
- }
+ WriteData *wd= writedata_new(file);
return wd;
}
@@ -307,88 +273,6 @@ endwrite(
writedata_do_write(wd, wd->buf, wd->count);
wd->count= 0;
}
- if (wd->is_publisher) {
- writeStreamGlue(Global_streamGlueControl, &wd->streamGlue, NULL, 0, 1);
- streamGlueControlDestructor(Global_streamGlueControl);
- // final writestream error handling goes here
- if (wd->error) {
- int err = wd->error;
- int errFunction = BWS_GETFUNCTION(err);
- int errGeneric = BWS_GETGENERR(err);
- int errSpecific = BWS_GETSPECERR(err);
- char *errFunctionStrings[] = {
- "",
- "The write stream",
- "The deflation",
- "The encryption",
- "The signing",
- "Writing the blendfile"
- };
- char *errGenericStrings[] = {
- "",
- "generated an out of memory error",
- "is not allowed in this version",
- "has problems with your key"
- };
- char *errWriteStreamGlueStrings[] = {
- "",
- "does not know how to proceed"
- };
- char *errDeflateStrings[] = {
- "",
- "bumped on a compress error"
- };
- char *errEncryptStrings[] = {
- "",
- "could not write the key",
- "bumped on an encrypt error"
- };
- char *errSignStrings[] = {
- "",
- "could not write the key",
- "failed"
- };
- char *errWriteBlenFileStrings[] = {
- "",
- "encountered problems writing the filedescription",
- "encountered problems writing the blendfile",
- "encountered problems writing one (or more) parameters"
- };
- char *errFunctionString= errFunctionStrings[errFunction];
- char *errExtraString= "";
-
- if (errGeneric)
- {
- errExtraString= errGenericStrings[errGeneric];
- }
- else if (errSpecific)
- {
- switch (errFunction)
- {
- case BWS_WRITESTREAMGLUE:
- errExtraString= errWriteStreamGlueStrings[errSpecific];
- break;
- case BWS_DEFLATE:
- errExtraString= errDeflateStrings[errSpecific];
- break;
- case BWS_ENCRYPT:
- errExtraString= errEncryptStrings[errSpecific];
- break;
- case BWS_SIGN:
- errExtraString= errSignStrings[errSpecific];
- break;
- case BWS_WRITEBLENFILE:
- errExtraString= errWriteBlenFileStrings[errSpecific];
- break;
- default:
- break;
- }
- }
-
- // call Blender error popup window
- error("%s %s", errFunctionString, errExtraString);
- }
- }
err= wd->error;
writedata_free(wd);
@@ -1739,8 +1623,7 @@ void BLO_write_runtime(char *file, char *exename) {
outfd= open(gamename, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0777);
if (outfd != -1) {
- /* Ensure runtime's are built with Publisher files */
- write_file_handle(outfd, 0, G.fileflags|G_FILE_PUBLISH);
+ write_file_handle(outfd, 0, G.fileflags);
if (write(outfd, " ", 1) != 1) {
cause= "Unable to write to output file";
@@ -1820,8 +1703,7 @@ void BLO_write_runtime(char *file, char *exename) {
datastart= lseek(outfd, 0, SEEK_CUR);
- /* Ensure runtime's are built with Publisher files */
- write_file_handle(outfd, 0, G.fileflags|G_FILE_PUBLISH);
+ write_file_handle(outfd, 0, G.fileflags);
if (!handle_write_msb_int(outfd, datastart) || (write(outfd, "BRUNTIME", 8)!=8)) {
cause= "Unable to write to output file";