diff options
Diffstat (limited to 'source/blender/writestreamglue')
20 files changed, 1544 insertions, 0 deletions
diff --git a/source/blender/writestreamglue/BLO_getPubKey.h b/source/blender/writestreamglue/BLO_getPubKey.h new file mode 100644 index 00000000000..5dc0d9e0547 --- /dev/null +++ b/source/blender/writestreamglue/BLO_getPubKey.h @@ -0,0 +1,40 @@ +/** + * $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 ***** + * PUBLISHER: get the public key from the .BPkeyfile + * STUB: give back the dataStreamPubKey + */ + + int +getPubKey(byte *dataStreamPubKey, + int dataStreamPubKeyLen, + byte **publisherPubKey, + int *publisherPubKeyLen); + diff --git a/source/blender/writestreamglue/BLO_writeStreamErrors.h b/source/blender/writestreamglue/BLO_writeStreamErrors.h new file mode 100644 index 00000000000..ce8464b75ce --- /dev/null +++ b/source/blender/writestreamglue/BLO_writeStreamErrors.h @@ -0,0 +1,85 @@ +/** + * $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 ***** + * all Blender Write Stream errors + * NOTE: adding stuff here means you also have to update the error + * messages in writefile.c + */ + +#ifndef BLO_WRITESTREAMERRORS_H +#define BLO_WRITESTREAMERRORS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define BWS_SETFUNCTION(x) ( (int)(x) << 1) +#define BWS_GETFUNCTION(x) (( (int)(x) >> 1) & 7) +#define BWS_SETGENERR(x) ( (int)(x) << 4) +#define BWS_GETGENERR(x) (( (int)(x) >> 4) & 7) +#define BWS_SETSPECERR(x) ( (int)(x) << 7) +#define BWS_GETSPECERR(x) (( (int)(x) >> 7) & 7) + +// FUNCTION +#define BWS_WRITESTREAMGLUE 1 +#define BWS_DEFLATE 2 +#define BWS_ENCRYPT 3 +#define BWS_SIGN 4 +#define BWS_WRITEBLENFILE 5 + +// GENeric errors +#define BWS_MALLOC 1 +#define BWS_STUB 2 +#define BWS_RSA 3 + +// WRITESTREAMGLUE specific +#define BWS_UNKNOWN 1 + +// DEFLATE specific +#define BWS_DEFLATEERROR 1 + +// ENCRYPT specific +#define BWS_RSANEWERROR 1 +#define BWS_ENCRYPTERROR 2 + +// SIGN specific +#define BWS_RSANEWERROR 1 +#define BWS_SIGNERROR 2 + +// WRITEBLENFILE specific +#define BWS_FILEDES 1 +#define BWS_WRITE 2 +#define BWS_PARAM 3 + +#ifdef __cplusplus +} +#endif + +#endif /* BLO_WRITESTREAMERRORS_H */ diff --git a/source/blender/writestreamglue/BLO_writeStreamGlue.h b/source/blender/writestreamglue/BLO_writeStreamGlue.h new file mode 100644 index 00000000000..6a160f3b505 --- /dev/null +++ b/source/blender/writestreamglue/BLO_writeStreamGlue.h @@ -0,0 +1,90 @@ +/** + * $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 ***** + * struct/function that connects the data stream processors + */ + +#ifndef BLO_WRITESTREAMGLUE_H +#define BLO_WRITESTREAMGLUE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "BLO_readStreamGlue.h" +#include "BLO_writeStreamErrors.h" + +/******************** start BLO_streamGlueControl.c part *****************/ +struct streamGlueControlStruct { + int actions; + int actionsDone; + unsigned char action[MAXSTREAMLENGTH]; +}; + + struct streamGlueControlStruct * +streamGlueControlConstructor( + void); + + void +streamGlueControlDestructor( + struct streamGlueControlStruct *streamControl); + + int +streamGlueControlAppendAction( + struct streamGlueControlStruct *streamControl, + unsigned char nextAction); + + unsigned char +streamGlueControlGetNextAction( + struct streamGlueControlStruct *streamControl); + +// TODO avoid this global variable +extern struct streamGlueControlStruct *Global_streamGlueControl; +/******************** end BLO_streamGlueControl.c part *****************/ + +struct writeStreamGlueStruct { + int dataProcessorType; + unsigned int streamBufferCount; + unsigned char *streamBuffer; +}; + + int +writeStreamGlue( + struct streamGlueControlStruct *streamGlueControl, + struct writeStreamGlueStruct **streamGlue, + unsigned char *data, + unsigned int dataIn, + int finishUp); + +#ifdef __cplusplus +} +#endif + +#endif /* BLO_WRITESTREAMGLUE_H */ diff --git a/source/blender/writestreamglue/Makefile b/source/blender/writestreamglue/Makefile new file mode 100644 index 00000000000..22f3adb345e --- /dev/null +++ b/source/blender/writestreamglue/Makefile @@ -0,0 +1,38 @@ +# +# $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 ***** +# +# Bounces make to subdirectories. + +SOURCEDIR = source/blender/writestreamglue +DIRS = intern stub +TESTDIRS = test + +include nan_subdirs.mk diff --git a/source/blender/writestreamglue/intern/BLO_dumpFromMemory.c b/source/blender/writestreamglue/intern/BLO_dumpFromMemory.c new file mode 100644 index 00000000000..f132840572a --- /dev/null +++ b/source/blender/writestreamglue/intern/BLO_dumpFromMemory.c @@ -0,0 +1,84 @@ +/** + * $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 ***** + * streamglue loopback adds a streamGlueHeader to start of the write stream + */ + +#include <stdio.h> +#include <stdlib.h> + +#include "GEN_messaging.h" + +#include "zlib.h" + +#include "BLO_writeStreamGlue.h" + +#include "BLO_dumpFromMemory.h" + + int +BLO_dumpFromMemory( + unsigned char *data, + unsigned int dataIn, + struct streamGlueHeaderStruct *streamGlueHeader) +{ + struct writeStreamGlueStruct *streamGlue = NULL; + int err = 0; + +#ifndef NDEBUG + fprintf(GEN_errorstream, + "BLO_dumpFromMemory: %u streamGlueHeader + %u data = %u\n", + STREAMGLUEHEADERSIZE, + dataIn, + STREAMGLUEHEADERSIZE + dataIn); +#endif + + // all data is in. set size in streamGlueHeader and write it out + streamGlueHeader->totalStreamLength = htonl(dataIn); + streamGlueHeader->crc = htonl(crc32(0L, (const Bytef *) streamGlueHeader, + STREAMGLUEHEADERSIZE - 4)); + err = writeStreamGlue( + Global_streamGlueControl, + &streamGlue, + (unsigned char *)streamGlueHeader, + STREAMGLUEHEADERSIZE, + 0); + if (err) return err; + + // write out data + err = writeStreamGlue( + Global_streamGlueControl, + &streamGlue, + data, + dataIn, + 1); + + return err; +} + diff --git a/source/blender/writestreamglue/intern/BLO_dumpFromMemory.h b/source/blender/writestreamglue/intern/BLO_dumpFromMemory.h new file mode 100644 index 00000000000..cb418f67f01 --- /dev/null +++ b/source/blender/writestreamglue/intern/BLO_dumpFromMemory.h @@ -0,0 +1,39 @@ +/** + * $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 ***** + * streamglue loopback adds a streamGlueHeader to start of the write stream + */ + + int +BLO_dumpFromMemory( + unsigned char *data, + unsigned int dataIn, + struct streamGlueHeaderStruct *streamGlueHeader); + diff --git a/source/blender/writestreamglue/intern/BLO_getPubKey.c b/source/blender/writestreamglue/intern/BLO_getPubKey.c new file mode 100644 index 00000000000..d691c0ae2be --- /dev/null +++ b/source/blender/writestreamglue/intern/BLO_getPubKey.c @@ -0,0 +1,72 @@ +/** + * $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 ***** + * Publisher only: get the public key from the .BPkeyfile + */ + +#include <stdlib.h> + +#include "BLO_keyStore.h" +#include "BLO_getPubKey.h" + + int +getPubKey(byte *dataStreamPubKey, + int dataStreamPubKeyLen, + byte **publisherPubKey, + int *publisherPubKeyLen) +{ + int err = 0; + + *publisherPubKeyLen = keyStoreGetPubKey(publisherPubKey); + + if (*publisherPubKeyLen == 0) { + // we're a publisher without .BPkey + *publisherPubKey = NULL; + return 1; + } + + if (dataStreamPubKeyLen != *publisherPubKeyLen) { + // different keys + *publisherPubKeyLen = 0; + *publisherPubKey = NULL; + return 2; + } + + if (memcmp(dataStreamPubKey, *publisherPubKey, *publisherPubKeyLen) + != 0) { + // different keys + *publisherPubKeyLen = 0; + *publisherPubKey = NULL; + return 3; + } + + return err; +} + diff --git a/source/blender/writestreamglue/intern/BLO_streamGlueControl.c b/source/blender/writestreamglue/intern/BLO_streamGlueControl.c new file mode 100644 index 00000000000..fc12738fa35 --- /dev/null +++ b/source/blender/writestreamglue/intern/BLO_streamGlueControl.c @@ -0,0 +1,90 @@ +/** + * $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 ***** + * define what actions a write stream should do + */ + +#include <string.h> +#include <stdlib.h> +#include <assert.h> + +#include "BLO_writeStreamGlue.h" + + struct streamGlueControlStruct * +streamGlueControlConstructor( + void) +{ + struct streamGlueControlStruct *control; + control = malloc(sizeof(struct streamGlueControlStruct)); + assert(control); + // TODO handle malloc errors + control->actions = 0; + control->actionsDone = 0; + memset(control->action, 0, MAXSTREAMLENGTH); + return(control); +} + + void +streamGlueControlDestructor( + struct streamGlueControlStruct *streamControl) +{ + free(streamControl); +} + + int +streamGlueControlAppendAction( + struct streamGlueControlStruct *streamControl, + unsigned char nextAction) +{ + assert(streamControl); + assert(streamControl->actions < MAXSTREAMLENGTH); + streamControl->action[streamControl->actions] = nextAction; + streamControl->actions++; + return(streamControl->actions); +} + + unsigned char +streamGlueControlGetNextAction( + struct streamGlueControlStruct *streamControl) +{ + unsigned char nextAction; + assert(streamControl); + assert(streamControl->actionsDone < streamControl->actions); + if (streamControl->actionsDone >= streamControl->actions) { + // the stream should have been terminated by a data + // processor, but instead streamGlue is called again ... + nextAction = UNKNOWN; // best guess ... + } else { + nextAction = streamControl->action[streamControl->actionsDone]; + streamControl->actionsDone++; + } + return(nextAction); +} + diff --git a/source/blender/writestreamglue/intern/BLO_writeStreamGlue.c b/source/blender/writestreamglue/intern/BLO_writeStreamGlue.c new file mode 100644 index 00000000000..934cbb91004 --- /dev/null +++ b/source/blender/writestreamglue/intern/BLO_writeStreamGlue.c @@ -0,0 +1,170 @@ +/** + * $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 ***** + * connect the data stream processors + */ + +#include <stdio.h> +#include <stdlib.h> +#include <assert.h> + +#include "zlib.h" + +#include "GEN_messaging.h" + +#include "BLO_writeStreamGlue.h" + +#include "BLO_dumpFromMemory.h" + +#include "BLO_writeblenfile.h" +#include "BLO_deflate.h" +#include "BLO_encrypt.h" +#include "BLO_sign.h" + +/** + * streamGlueWrite does not really stream; it buffers all data it gets + * because it needs everything to create the header, which is in front + * of the data (to make reading easier, which occurs much more often + * than writing and is thus more important to optimize for). + * @param streamControl contains a list of Glue actions. Every + * streamGlueWrite constructor eats up the next first action. + */ + int +writeStreamGlue( + struct streamGlueControlStruct *streamGlueControl, + struct writeStreamGlueStruct **streamGlue, + unsigned char *data, + unsigned int dataIn, + int finishUp) +{ + int err = 0; + + if (NULL == *streamGlue) { + /* we are called for the first time; play constructor */ + (*streamGlue) = malloc(sizeof(struct writeStreamGlueStruct)); + + if (!(*streamGlue)) { + err = BWS_SETFUNCTION(BWS_WRITESTREAMGLUE) | + BWS_SETGENERR(BWS_MALLOC); + return err; + } + + (*streamGlue)->dataProcessorType = + streamGlueControlGetNextAction(streamGlueControl); + (*streamGlue)->streamBufferCount = 0; + (*streamGlue)->streamBuffer = NULL; + } + if (dataIn > 0) { + /* simply buffer it */ + (*streamGlue)->streamBuffer = realloc((*streamGlue)->streamBuffer, + dataIn + (*streamGlue)->streamBufferCount); + if (!(*streamGlue)->streamBuffer) { + err = BWS_SETFUNCTION(BWS_WRITESTREAMGLUE) | + BWS_SETGENERR(BWS_MALLOC); + free(*streamGlue); + return err; + } + memcpy((*streamGlue)->streamBuffer + (*streamGlue)->streamBufferCount, + data, dataIn); + (*streamGlue)->streamBufferCount += dataIn; + } + if (finishUp) { + /* all data is in, create header and call data processor */ + + /* first create the streamGlueHeaderStruct */ + struct streamGlueHeaderStruct *streamGlueHeader; + streamGlueHeader = malloc(STREAMGLUEHEADERSIZE); + if (!streamGlueHeader) { + err = BWS_SETFUNCTION(BWS_WRITESTREAMGLUE) | + BWS_SETGENERR(BWS_MALLOC); + free((*streamGlue)->streamBuffer); + free(*streamGlue); + return err; + } + streamGlueHeader->magic = 'A'; + streamGlueHeader->totalStreamLength = 0; // set in the actions _end + streamGlueHeader->dataProcessorType = + htonl((*streamGlue)->dataProcessorType); + streamGlueHeader->crc = 0; // set in in the actions _end + +#ifndef NDEBUG + fprintf(GEN_errorstream, + "streamGlue: write %d gets %u data + %u streamGlueHeader = %u\n", + (*streamGlue)->dataProcessorType, + (*streamGlue)->streamBufferCount, + STREAMGLUEHEADERSIZE, + (*streamGlue)->streamBufferCount + STREAMGLUEHEADERSIZE); +#endif + + /* all data ready, start the right data processor */ + switch ((*streamGlue)->dataProcessorType) { + case DUMPFROMMEMORY: + err = BLO_dumpFromMemory((*streamGlue)->streamBuffer, + (*streamGlue)->streamBufferCount, + streamGlueHeader); + break; + case DEFLATE: + err = BLO_deflate((*streamGlue)->streamBuffer, + (*streamGlue)->streamBufferCount, + streamGlueHeader); + break; + case ENCRYPT: + err = BLO_encrypt((*streamGlue)->streamBuffer, + (*streamGlue)->streamBufferCount, + streamGlueHeader); + break; + case SIGN: + err = BLO_sign((*streamGlue)->streamBuffer, + (*streamGlue)->streamBufferCount, + streamGlueHeader); + break; + case WRITEBLENFILE: + err = BLO_writeblenfile((*streamGlue)->streamBuffer, + (*streamGlue)->streamBufferCount, + streamGlueHeader); + break; + default: +#ifndef NDEBUG + fprintf(GEN_errorstream, + "unknown dataProcessorType %d\n", + (*streamGlue)->dataProcessorType); +#endif + err = BWS_SETFUNCTION(BWS_WRITESTREAMGLUE) | + BWS_SETSPECERR(BWS_UNKNOWN); + break; + } + + free(streamGlueHeader); + free((*streamGlue)->streamBuffer); + free(*streamGlue); + } + return err; +} + diff --git a/source/blender/writestreamglue/intern/Makefile b/source/blender/writestreamglue/intern/Makefile new file mode 100644 index 00000000000..df3f88ea006 --- /dev/null +++ b/source/blender/writestreamglue/intern/Makefile @@ -0,0 +1,71 @@ +# +# $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 ***** +# +# + +LIBNAME = writestreamglue +DIR = $(OCGDIR)/blender/$(LIBNAME) + +include nan_compile.mk + +ifeq ($(OS),$(findstring $(OS), "beos darwin freebsd linux openbsd solaris windows")) + CFLAGS += -funsigned-char +endif + +CFLAGS += $(LEVEL_2_C_WARNINGS) + +# path to our own private header files +CPPFLAGS += -I. + +# path to our own external header files +CPPFLAGS += -I.. + +# path to external modules +CPPFLAGS += -I../../../kernel/gen_messaging + +CPPFLAGS += -I../../readstreamglue + +CPPFLAGS += -I../../writeblenfile +CPPFLAGS += -I../../blenloader + +CPPFLAGS += -I../../deflate +CPPFLAGS += -I../../encrypt +CPPFLAGS += -I../../sign + +CPPFLAGS += -I$(NAN_OPENSSL)/include + +#TODO make keystore this a seperate lib +CPPFLAGS += -I$(NAN_BLENKEY)/include + +ifeq ($(OS),$(findstring $(OS), "solaris windows")) + CPPFLAGS += -I$(NAN_ZLIB)/include +endif + diff --git a/source/blender/writestreamglue/stub/BLO_getPubKeySTUB.c b/source/blender/writestreamglue/stub/BLO_getPubKeySTUB.c new file mode 100644 index 00000000000..86cdfdacd69 --- /dev/null +++ b/source/blender/writestreamglue/stub/BLO_getPubKeySTUB.c @@ -0,0 +1,51 @@ +/** + * $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 ***** + * player/plugin only: 'get' the public key from the datastream + * note really a STUB eh ... + */ + +#include "blenkey.h" // for byte ... duh this needs change ! +#include "BLO_getPubKey.h" + + int +getPubKey(byte *dataStreamPubKey, + int dataStreamPubKeyLen, + byte **publisherPubKey, + int *publisherPubKeyLen) +{ + int err = 0; + + *publisherPubKeyLen = dataStreamPubKeyLen; + *publisherPubKey = dataStreamPubKey; + + return err; +} + diff --git a/source/blender/writestreamglue/stub/BLO_keyStoreSTUB.c b/source/blender/writestreamglue/stub/BLO_keyStoreSTUB.c new file mode 100644 index 00000000000..2cf118d8e5e --- /dev/null +++ b/source/blender/writestreamglue/stub/BLO_keyStoreSTUB.c @@ -0,0 +1,58 @@ +/** + * $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 ***** + * keyStore stubs + */ + +#include <stdio.h> + +#include "BLO_keyStore.h" + + void +keyStoreConstructor( + UserStruct *keyUserStruct, + char *privHexKey, + char *pubHexKey, + byte *ByteChecks, + char *HexPython) +{ + keyUserStruct = NULL; + privHexKey = NULL; + pubHexKey = NULL; + ByteChecks = NULL; + HexPython = NULL; +} + + void +keyStoreDestructor( + void) +{ +} + diff --git a/source/blender/writestreamglue/stub/BLO_streamGlueControlSTUB.c b/source/blender/writestreamglue/stub/BLO_streamGlueControlSTUB.c new file mode 100644 index 00000000000..5c4b5794e76 --- /dev/null +++ b/source/blender/writestreamglue/stub/BLO_streamGlueControlSTUB.c @@ -0,0 +1,87 @@ +/** + * $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 ***** + * + */ + +#include <stdio.h> + +#include "GEN_messaging.h" + +#include "BLO_writeStreamGlue.h" + + struct streamGlueControlStruct * +streamGlueControlConstructor( + void) +{ +#ifdef NDEBUG + fprintf(GEN_errorstream, + "Error streamGlueControlConstructor is a stub\n"); +#endif + return(NULL); +} + + void +streamGlueControlDestructor( + struct streamGlueControlStruct *streamControl) +{ + streamControl = NULL; +#ifdef NDEBUG + fprintf(GEN_errorstream, + "Error streamGlueControlDestructor is a stub\n"); +#endif +} + + int +streamGlueControlAppendAction( + struct streamGlueControlStruct *streamControl, + unsigned char nextAction) +{ + streamControl = NULL; + nextAction = 0; +#ifdef NDEBUG + fprintf(GEN_errorstream, + "Error streamGlueControlAppendAction is a stub\n"); +#endif + return(0); +} + + unsigned char +streamGlueControlGetNextAction( + struct streamGlueControlStruct *streamControl) +{ + streamControl = NULL; +#ifdef NDEBUG + fprintf(GEN_errorstream, + "Error streamGlueControlGetNextAction is a stub\n"); +#endif + return(0); +} + diff --git a/source/blender/writestreamglue/stub/BLO_writeStreamGlueSTUB.c b/source/blender/writestreamglue/stub/BLO_writeStreamGlueSTUB.c new file mode 100644 index 00000000000..9b077efbd59 --- /dev/null +++ b/source/blender/writestreamglue/stub/BLO_writeStreamGlueSTUB.c @@ -0,0 +1,61 @@ +/** + * $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 ***** + * streamGlueRead stubs + */ + +#include <stdio.h> + +#include "GEN_messaging.h" +#include "BLO_writeStreamGlue.h" + + int +writeStreamGlue( + struct streamGlueControlStruct *streamGlueControl, + struct writeStreamGlueStruct **streamGlue, + unsigned char *data, + unsigned int dataIn, + int finishUp) +{ + int err = 0; + streamGlueControl = NULL; + *streamGlue = NULL; + data = NULL; + dataIn = 0; + finishUp = 0; +#ifndef NDEBUG + fprintf(GEN_errorstream, + "Error writeStreamGlue is a stub\n"); +#endif + err = BWS_SETFUNCTION(BWS_WRITESTREAMGLUE) | + BWS_SETGENERR(BWS_STUB); + return err; +} + diff --git a/source/blender/writestreamglue/stub/Makefile b/source/blender/writestreamglue/stub/Makefile new file mode 100644 index 00000000000..54633d289ad --- /dev/null +++ b/source/blender/writestreamglue/stub/Makefile @@ -0,0 +1,58 @@ +# +# $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 ***** +# +# + +LIBNAME = writestreamglueSTUB +DIR = $(OCGDIR)/blender/$(LIBNAME) + +include nan_compile.mk + +ifeq ($(OS),$(findstring $(OS), "beos darwin freebsd linux openbsd solaris windows")) + CFLAGS += -funsigned-char +endif + +CFLAGS += $(LEVEL_2_C_WARNINGS) + +# path to our own external headerfiles +CPPFLAGS += -I.. + +# +CPPFLAGS += -I../../../kernel/gen_messaging +CPPFLAGS += -I../../readstreamglue + +#TODO make this a seperate lib +CPPFLAGS += -I$(NAN_BLENKEY)/include + +ifeq ($(OS),$(findstring $(OS), "solaris windows")) + CPPFLAGS += -I$(NAN_ZLIB)/include +endif + diff --git a/source/blender/writestreamglue/test/Makefile b/source/blender/writestreamglue/test/Makefile new file mode 100644 index 00000000000..ee2708e55ff --- /dev/null +++ b/source/blender/writestreamglue/test/Makefile @@ -0,0 +1,37 @@ +# +# $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 ***** +# +# Bounces make to subdirectories. + +SOURCEDIR = source/blender/writestreamglue/test +DIRS = typetest #readwritetest + +include nan_subdirs.mk diff --git a/source/blender/writestreamglue/test/readwritetest/Makefile b/source/blender/writestreamglue/test/readwritetest/Makefile new file mode 100644 index 00000000000..ddd27ba9e18 --- /dev/null +++ b/source/blender/writestreamglue/test/readwritetest/Makefile @@ -0,0 +1,83 @@ +# +# $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 ***** +# +# Streamglue read/write testing +# + +DIR = $(OCGDIR)/blender/writestreamglue/readwritetest +ALLTARGETS = $(OBJS) $(DIR)/$(DEBUG_DIR)readwritetest + +include nan_compile.mk + +CFLAGS += -funsigned-char -g + +# includes: +CPPFLAGS += -I../.. +CPPFLAGS += -I../../../readstreamglue + +# libs: +TESTLIBS += $(OCGDIR)/blender/readstreamglue/$(DEBUG_DIR)libreadstreamglue.a +TESTLIBS += $(OCGDIR)/blender/writestreamglue/$(DEBUG_DIR)libwritestreamglue.a +TESTLIBS += $(OCGDIR)/blender/inflate/$(DEBUG_DIR)libinflate.a +TESTLIBS += $(OCGDIR)/blender/deflate/$(DEBUG_DIR)libdeflate.a +TESTLIBS += $(OCGDIR)/blender/encrypt/$(DEBUG_DIR)libencrypt.a +TESTLIBS += $(OCGDIR)/blender/decrypt/$(DEBUG_DIR)libdecrypt.a +TESTLIBS += $(OCGDIR)/blender/sign/$(DEBUG_DIR)libsign.a +TESTLIBS += $(OCGDIR)/blender/verify/$(DEBUG_DIR)libverify.a +TESTLIBS += $(OCGDIR)/blender/writeblenfile/$(DEBUG_DIR)libwriteblenfile.a +TESTLIBS += $(OCGDIR)/blender/writestreamglue/$(DEBUG_DIR)libwritestreamglue.a +TESTLIBS += $(OCGDIR)/blender/readstreamglue/$(DEBUG_DIR)libreadstreamglue.a +TESTLIBS += $(NAN_BLENKEY)/lib/libblenkey.a +TESTLIBS += $(OCGDIR)/blender/readblenfile/$(DEBUG_DIR)libreadblenfile.a + +ifeq ($(OS),$(findstring $(OS), "linux freebsd")) + TESTLIBS += -lz + TESTLIBS += $(NAN_OPENSSL)/lib/libcrypto.a +endif + +ifeq ($(OS),windows) + TESTLIBS += ws2_32.lib + TESTLIBS += $(NAN_ZLIB)/lib/libz.a + TESTLIBS += $(NAN_OPENSSL)/lib/libeay32.lib + TESTLIBS += kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib + TESTLIBS += advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib + TESTLIBS += winmm.lib opengl32.lib glu32.lib largeint.lib dxguid.lib +endif + + +$(DIR)/readwritetest: $(OBJS) + $(CC) $(LDFLAGS) -o $(DIR)/readwritetest $(OBJS) $(TESTLIBS) + +clean:: + $(RM) $(DIR)/readwritetest + +test:: all + $(DIR)/readwritetest $(NAN_TEST_VERBOSITY) diff --git a/source/blender/writestreamglue/test/readwritetest/readwritetest.c b/source/blender/writestreamglue/test/readwritetest/readwritetest.c new file mode 100644 index 00000000000..9006fe3345a --- /dev/null +++ b/source/blender/writestreamglue/test/readwritetest/readwritetest.c @@ -0,0 +1,188 @@ +/** + * $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 ***** + */ + +/* Test for the streamglue read/write components + * + * The streamglue functions connect dataprocessors. + * + * Tested functions + * + * - streamGlueWrite (from BLO_streamglue.h) + * - streamGlueRead (from BLO_streamglue.h) + * + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <fcntl.h> + +#include "BLO_writeStreamGlue.h" + +#ifndef _WIN32 +#define O_BINARY 0 +#endif + +struct streamGlueControlStruct *Global_streamGlueControl; + +/* Some stubs here, because otherwise we have to link all of blender... */ + +//FILE* mywfile = NULL; +int mywfile = 0; + + void * +BLO_readstreamfile_begin( + void) +{ + fprintf(stderr, "|--> BLO_readstreamfile_begin: local loopback\n"); + return NULL; +} + + int +BLO_readstreamfile_process( + void *filedataVoidPtr, + unsigned char *data, + unsigned int dataIn) +{ + fprintf(stderr, "|--> BLO_readstreamfile_process: local loopback\n"); + return 0; +} + + + int +BLO_readstreamfile_end( + void *filedataVoidPtr) +{ + fprintf(stderr, "|--> BLO_readstreamfile_end: local loopback\n"); + return 0; +} + +int main (int argc, char *argv[]) +{ + int verbose = 0; + int error_status = 0; + int retval = 0; + int i = 0; + + int datachunksize = 12345; + char* datachunk = NULL; + char* dataptr = NULL; + struct writeStreamGlueStruct *sgp = NULL; + + switch (argc) { + case 2: + verbose = atoi(argv[1]); + if (verbose < 0) verbose = 0; + break; + case 1: + default: + verbose = 0; + } + + /* ----------------------------------------------------------------- */ + + if (verbose > 0) { + fprintf(stderr,"\n*** Streamglue read/write test\n"); + } + + Global_streamGlueControl = streamGlueControlConstructor(); + +// mywfile = fopen("readwritetestdump","wb"); + mywfile = open("readwritetestdump",O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666); + + error_status = (mywfile == NULL); +// error_status |= fprintf(mywfile,"|\n|-- Opened file for testing: %d\n|\n", mywfile); + + + if (verbose > 1) { + fprintf(stderr,"|\n|-- Opened file for testing: %d with \n|\n", mywfile); + } + +/* streamGlueControlAppendAction(Global_streamGlueControl, DUMPFROMMEMORY); */ +/* streamGlueControlAppendAction(Global_streamGlueControl, DEFLATE); */ +/* streamGlueControlAppendAction(Global_streamGlueControl, ENCRYPT); */ +/* streamGlueControlAppendAction(Global_streamGlueControl, SIGN); */ + streamGlueControlAppendAction(Global_streamGlueControl, WRITEBLENFILE); + + if (verbose >1) { + fprintf(stderr,"|\n|-- Created and initialized streamGlueControl thingy \n"); + fflush(stderr); + } + + /* 2: the size */ + datachunksize = 12345; + + /* 1: a data chunk. We fill it with some numbers */ + datachunk = (char*) malloc(datachunksize); + + /* an ascending-ish thingy */ + dataptr = datachunk; + for (i = 0 ; + i < datachunksize; + i++, dataptr++) { + *dataptr = (i % 0xFF); + } + + if (verbose >1) { + fprintf(stderr,"|\n|-- Calling streamGlueWrite\n"); + fflush(stderr); + } + + retval = + writeStreamGlue( + Global_streamGlueControl, // general controller + &sgp, // ie. construct this for me + datachunk, // raw data + datachunksize, // data size + 1); // i.e. finalize this write + + if (verbose >1) { + fprintf(stderr,"|\n|-- streamGlueWrite returned with %d\n", retval); + } + + /* ----------------------------------------------------------------- */ + + if (close(mywfile)) { + error_status = 1; + if (verbose > 1) { + fprintf(stderr,"|\n|-- file close failed.\n"); + } + } + + if (verbose > 0) { + fprintf(stderr,"|\n*** Finished test\n\n"); + } + exit(error_status); +} + + +/* eof */ diff --git a/source/blender/writestreamglue/test/typetest/Makefile b/source/blender/writestreamglue/test/typetest/Makefile new file mode 100644 index 00000000000..617e358bcce --- /dev/null +++ b/source/blender/writestreamglue/test/typetest/Makefile @@ -0,0 +1,48 @@ +# +# $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 ***** +# +# Make a little test for the sys_types replacement. +# + +DIR = $(OCGDIR)/blender/writestreamglue/test +ALLTARGETS = $(OBJS) $(DIR)/typetest + +include nan_compile.mk + +$(DIR)/typetest: $(OBJS) + $(CC) $(LDFLAGS) -o $(DIR)/typetest $(OBJS) + +clean:: + $(RM) $(DIR)/typetest + +test:: $(DIR)/typetest + $(DIR)/typetest $(NAN_TEST_VERBOSITY) + diff --git a/source/blender/writestreamglue/test/typetest/typetest.c b/source/blender/writestreamglue/test/typetest/typetest.c new file mode 100644 index 00000000000..447abd9d792 --- /dev/null +++ b/source/blender/writestreamglue/test/typetest/typetest.c @@ -0,0 +1,94 @@ +/** + * $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 little test to see how our type defines behave. + */ + +#include "../../../readstreamglue/BLO_sys_types.h" +#include <stdio.h> +#include <stdlib.h> + +int main (int argc, char *argv[]) +{ + int verbose = 0; + int error_status = 0; + int char_size = 0; + int short_size = 0; + int int_size = 0; + int long_size = 0; + + switch (argc) { + case 2: + verbose = atoi(argv[1]); + if (verbose < 0) verbose = 0; + break; + case 1: + default: + verbose = 0; + } + + /* ----------------------------------------------------------------- */ + if (verbose > 0) { + printf("*** Type define size test\n|\n"); + } + /* Check if these exist, and show their sizes. */ + + + char_size = sizeof(uint8_t); + short_size = sizeof(uint16_t); + int_size = sizeof(uint32_t); + long_size = sizeof(uint64_t); + + if (verbose > 1) { + printf("|- uint8_t : \t%4d, expected 1.\n", char_size); + printf("|- uint16_t : \t%4d, expected 2.\n", short_size); + printf("|- uint32_t : \t%4d, expected 4.\n", int_size); + printf("|- uint64_t : \t%4d, expected 8.\n\n", long_size); + } + + if ((char_size != 1) + || (short_size != 2) + || (int_size != 4) + || (long_size != 8) + ) { + error_status = 1; + } + + if (verbose > 0) { + if (error_status) { + printf("|-- Size mismatch detected !!!\n|\n"); + } else { + printf("|-- Sizes are correct.\n"); + } + printf("|\n*** End of type define size test\n"); + } + + exit(error_status); +} |