Page MenuHome

commandport_win32_msvc.patch

File Metadata

Author
Toni Alatalo (antont)
Created
Nov 13 2013, 1:25 PM

commandport_win32_msvc.patch

=== modified file 'source/blender/commandport/blender/src/bcp_blender.c'
--- source/blender/commandport/blender/src/bcp_blender.c 2008-11-14 09:48:02 +0000
+++ source/blender/commandport/blender/src/bcp_blender.c 2009-09-10 07:49:01 +0000
@@ -35,7 +35,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include <pthread.h>
+#include "pthread.h"
#include <Python.h>
@@ -184,7 +184,11 @@
/* get the condition variable and the mutex
to synchronize command port and blender thread
- */
+ */
+
+ void* args;
+ char* result;
+
pthread_mutex_t* mutex = &handler->mutex;
pthread_cond_t* condition = &handler->condition;
@@ -195,7 +199,7 @@
handler->result = NULL;
/* enter the command request into the blender main queue */
- void* args = (void*) handler;
+ args = (void*) handler;
mainqenter_args(COMMAND_PORT_INPUT, 1, 0, args); /* dtodo: why 1 ?? */
/* wait on the condition variable for the command being executed and
@@ -211,8 +215,8 @@
exit(ERROR_SYNCHRONIZATION);
}
- /* get the result */
- char* result = handler->result;
+ /* get the result */
+ result = handler->result;
if (pthread_mutex_unlock(mutex)) {
fprintf(stderr, "[BCP] ERROR: BCP thread couldn't unlock the result mutex!\n");
=== modified file 'source/blender/commandport/blender/src/bcp_handle_client.c'
--- source/blender/commandport/blender/src/bcp_handle_client.c 2008-11-14 09:48:02 +0000
+++ source/blender/commandport/blender/src/bcp_handle_client.c 2009-09-10 08:37:53 +0000
@@ -36,7 +36,7 @@
#include <stdio.h> /* for printf() */
#include <stdlib.h> /* for free() */
#include <string.h> /* strlen(), memcpy() */
-#include <unistd.h>
+#include "unistd.h"
#include "message_handler.h"
#include "string_buffer.h"
=== modified file 'source/blender/commandport/blender/src/bcp_server.c'
--- source/blender/commandport/blender/src/bcp_server.c 2008-11-14 09:48:02 +0000
+++ source/blender/commandport/blender/src/bcp_server.c 2009-09-10 08:50:31 +0000
@@ -34,9 +34,10 @@
*/
#include <stdio.h> /* printf(), fprintf() */
-#include <sys/socket.h> /* socket(), bind(), connect() */
-#include <arpa/inet.h> /* sockaddr_in, inet_ntoa() */
-#include <pthread.h> /* pthread */
+//#include <sys/socket.h> /* socket(), bind(), connect() */
+#include <winsock.h>
+//#include <arpa/inet.h> /* sockaddr_in, inet_ntoa() */
+#include "pthread.h" /* pthread */
#include <stdlib.h> /* atoi(), exit() */
#include <string.h> /* memset() */
#include <unistd.h> /* close() */
@@ -132,8 +133,8 @@
if (ret != 0) {
printf("ERROR: Couldn't create a Blender Command Port client thread!\n");
} else if (bcp_debug()) {
- printf("Blender Command Port client thread %x started!\n",
- (int) client_thread);
+ printf("Blender Command Port client thread x started!\n");
+ //, (int) client_thread);
}
}
@@ -155,7 +156,7 @@
/* get my thread handle */
client_thread = pthread_self();
if (bcp_debug())
- printf("Blender Command Port client thread %x running!\n", (int) client_thread);
+ printf("Blender Command Port client thread x running!\n"); //, (int) client_thread);
/* Detache the Blender Command Port thread */
pthread_detach(client_thread);
=== modified file 'source/blender/commandport/blender/src/bcp_thread.c'
--- source/blender/commandport/blender/src/bcp_thread.c 2008-11-14 09:48:02 +0000
+++ source/blender/commandport/blender/src/bcp_thread.c 2009-09-10 08:53:15 +0000
@@ -39,8 +39,9 @@
#include <string.h> /* memset() */
#include <errno.h>
#include <pthread.h>
-#include <sys/socket.h> /* socket(), bind(), and connect() */
-#include <arpa/inet.h> /* sockaddr_in and inet_ntoa() */
+//#include <sys/socket.h> /* socket(), bind(), and connect() */
+//#include <arpa/inet.h> /* sockaddr_in and inet_ntoa() */
+#include <winsock.h>
#include <stdlib.h> /* atoi() and exit() */
#include "bcp_debug.h" /* bcp_debug() */
@@ -86,9 +87,9 @@
if (ret != 0) {
bcp_error("Can't create Blender Command Port server thread!\n");
} else if (bcp_debug()) {
- printf("Blender Command Port server thread %x started "
+ printf("Blender Command Port server thread x started "
"(port: %hu)!\n",
- (int) bcpthread, port);
+ port); //(int) bcpthread
}
}
@@ -109,7 +110,7 @@
/* get my thread handle */
server_thread = pthread_self();
if (bcp_debug())
- printf("Blender Command Port server thread %x running!\n", (int) server_thread);
+ printf("Blender Command Port server thread x running!\n"); //, (int) server_thread);
/* Detache the Blender Command Port thread */
pthread_detach(server_thread);
=== modified file 'source/blender/commandport/blender/src/py_stdouterr_buffer.c'
--- source/blender/commandport/blender/src/py_stdouterr_buffer.c 2008-11-14 09:48:02 +0000
+++ source/blender/commandport/blender/src/py_stdouterr_buffer.c 2009-09-10 09:01:49 +0000
@@ -65,7 +65,8 @@
py_stdouterr_buffer py_stdouterr_buffer_new()
{
py_stdouterr_buffer buffer;
- PyGILState_STATE gstate;
+ PyGILState_STATE gstate;
+ PyObject *func_StringIO, *args_StringIO;
buffer = (py_stdouterr_buffer) malloc(sizeof(py_stdouterr_buffer_struct));
@@ -85,7 +86,6 @@
buffer->stderr_obj = PyObject_GetAttrString(buffer->mod_sys, "stderr");
/* make new string buffer for stdout and stderr */
- PyObject *func_StringIO, *args_StringIO;
func_StringIO = PyObject_GetAttrString(buffer->mod_cStringIO, "StringIO");
args_StringIO = Py_BuildValue("()");
buffer->outbuf_obj = PyEval_CallObject(func_StringIO, args_StringIO);
@@ -226,22 +226,25 @@
*/
char* py_buffer_get_content_allocate(PyObject *buffer)
{
- PyGILState_STATE gstate;
-
+ PyGILState_STATE gstate;
+ PyObject *func_getvalue, *args_getvalue, *buffer_obj;
+ char* buf_pointer;
+ int content_length;
+ char* content;
+
/* aquire python thread */
gstate = PyGILState_Ensure();
/* access the stored stderr string buffer content as c string */
- PyObject *func_getvalue, *args_getvalue, *buffer_obj;
func_getvalue = PyObject_GetAttrString(buffer, "getvalue");
args_getvalue = Py_BuildValue("()");
buffer_obj = PyEval_CallObject(func_getvalue, args_getvalue);
- char* buf_pointer;
+
PyArg_Parse(buffer_obj, "s", &buf_pointer);
/* allocate a c string buffer to return the string */
- int content_length = strlen(buf_pointer);
- char* content;
+ content_length = strlen(buf_pointer);
+
content = (char*) malloc((content_length + 1) * sizeof(char));
/* copy the content string into the new buffer */
@@ -329,7 +332,8 @@
void py_stdouterr_buffer_clear_buffers(py_stdouterr_buffer buffer)
{
PyGILState_STATE gstate;
-
+ PyObject *func_StringIO, *args_StringIO;
+
/* aquire python thread */
gstate = PyGILState_Ensure();
@@ -338,7 +342,6 @@
Py_DECREF(buffer->outbuf_obj);
/* make new string buffer for stdout and stderr */
- PyObject *func_StringIO, *args_StringIO;
func_StringIO = PyObject_GetAttrString(buffer->mod_cStringIO, "StringIO");
args_StringIO = Py_BuildValue("()");
buffer->outbuf_obj = PyEval_CallObject(func_StringIO, args_StringIO);
=== modified file 'source/blender/commandport/blender/src/py_stdouterr_buffer_test.c'
--- source/blender/commandport/blender/src/py_stdouterr_buffer_test.c 2008-11-14 09:48:02 +0000
+++ source/blender/commandport/blender/src/py_stdouterr_buffer_test.c 2009-09-10 09:06:01 +0000
@@ -52,7 +52,12 @@
PySys_WriteStderr(buffer);
}
-main() {
+main() {
+ py_stdouterr_buffer buffer;
+ int i, j;
+ char* stdout_str;
+ char* stderr_str;
+
/* initialize python */
Py_Initialize();
@@ -63,12 +68,9 @@
printf("\n");
/* make a stdout/stderr string buffer */
- py_stdouterr_buffer buffer;
buffer = py_stdouterr_buffer_new();
- int i, j;
for (i = 0, j = 0; i < 3; i++, j = 0) {
-
printf(">>> ========================================================\n");
printf(">>> experiment %d\n", i);
printf(">>> --------------------------------------------------------\n");
@@ -99,7 +101,6 @@
j++;
/* retrive buffered stdout */
- char* stdout_str;
stdout_str = py_stdouterr_buffer_get_stdout_allocate(buffer);
printf("\n");
printf("# here comes the buffered stdout:\n");
@@ -110,7 +111,6 @@
stdout_str = NULL;
/* retrive buffered stderr */
- char* stderr_str;
stderr_str = py_stdouterr_buffer_get_stderr_allocate(buffer);
printf("# here comes the buffered stderr:\n");
printf("\n");
=== modified file 'source/blender/commandport/blender/src/test.c'
--- source/blender/commandport/blender/src/test.c 2008-11-14 09:48:02 +0000
+++ source/blender/commandport/blender/src/test.c 2009-09-10 09:07:45 +0000
@@ -34,8 +34,9 @@
*/
#include <stdio.h> /* for printf() and fprintf() */
-#include <sys/socket.h> /* for socket(), connect(), send(), and recv() */
-#include <arpa/inet.h> /* for sockaddr_in and inet_addr() */
+//#include <sys/socket.h> /* for socket(), connect(), send(), and recv() */
+//#include <arpa/inet.h> /* for sockaddr_in and inet_addr() */
+#include <winsock.h>
#include <stdlib.h> /* for atoi() and exit() */
#include <string.h> /* for memset() */
#include <unistd.h> /* for close() */
=== modified file 'source/blender/commandport/utilities/src/SConscript'
--- source/blender/commandport/utilities/src/SConscript 2008-11-14 09:48:02 +0000
+++ source/blender/commandport/utilities/src/SConscript 2009-09-11 08:08:18 +0000
@@ -32,7 +32,10 @@
Import ('env')
-sources = env.Glob('*.c')
+sources = env.Glob('*.c')
+rmlist = ["bcp_shell.c", "string_buffer_test.c"]
+for rm in rmlist:
+ sources.remove(rm) #is there really no single call for this? sets of course..
incs = '''
../include
=== modified file 'source/blender/commandport/utilities/src/bcp_package.c'
--- source/blender/commandport/utilities/src/bcp_package.c 2008-11-14 09:48:02 +0000
+++ source/blender/commandport/utilities/src/bcp_package.c 2009-09-10 09:34:39 +0000
@@ -136,9 +136,10 @@
Empty a package.
*/
void bcp_package_make_empty(bcp_package package)
-{
+{
+ element e;
/* delete all elements */
- element e = package->first;
+ e = package->first;
for( ; e != NULL; e = e->next) {
delete_element(e);
}
@@ -276,12 +277,13 @@
Calculate the length of an integers string representation.
*/
int intlen(int i)
-{
+{
+ int length;
+
/* 0 has the length 1 */
if (i == 0) return 1;
/* calculate length for i > 0 */
- int length;
for (length = 0; i > 0; i /= 10, length++);
/* done */
@@ -293,13 +295,14 @@
*/
int length_packed_element(element e)
{
+ /* length accumulator */
+ int length = 0;
+ int vlen;
+
/* an undefined element will not be packed
- return 0 */
if (e->type == BCP_PACKAGE_TYPE_UNDEFINED) return 0;
- /* length accumulator */
- int length = 0;
-
/* add length of prefix '#' */
length += 1;
@@ -311,7 +314,6 @@
length += 1;
/* the rest of the header depends on the element type */
- int vlen;
switch (e->type) {
case BCP_PACKAGE_TYPE_INT:
@@ -377,8 +379,9 @@
int length_packed(bcp_package p)
{
/* add the length of all elements */
- int length = 0;
- element e = p->first;
+ int length = 0;
+ element e;
+ e = p->first;
for( ; e != NULL; e = e->next) {
length += length_packed_element(e);
}
@@ -394,18 +397,21 @@
char* bcp_package_pack_allocate(bcp_package package)
{
/* calculate length */
- int length = length_packed(package);
+ int length = length_packed(package);
+ char* packed;
+ char* p;
+ element e;
/* allocate memory for the packed string representation */
- char* packed = (char*) malloc((length + 1) * sizeof(char));
+ packed = (char*) malloc((length + 1) * sizeof(char));
if (packed == NULL) {
fprintf(stderr, "Couldn't allocate memory to pack a bcp_package!\n");
exit(ERROR_MEMORY);
}
/* write all elements to the buffer */
- char* p = packed;
- element e = package->first;
+ p = packed;
+ e = package->first;
for( ; e != NULL; e = e->next) {
p = pack_element(p, e);
}
@@ -485,13 +491,12 @@
bcp_package bcp_package_unpack(char* packed)
{
/* make a new empty package */
- bcp_package package;
+ bcp_package package;
+ char** p = &packed;
+ char type;
package = bcp_package_new();
/* unpack all elements */
- char** p = &packed;
- char type;
-
do {
type = unpack_element(package, p);
} while (*p != NULL);
@@ -508,6 +513,13 @@
*/
char unpack_element(bcp_package p, char** packed)
{
+ char type;
+
+ /* print value */
+ int integer;
+ char* str;
+ char command;
+
/* set return *packed to NULL and
return BCP_PACKAGE_TYPE_EMPTY
if there are no more elements to parse */
@@ -518,14 +530,9 @@
}
/* unpack element type */
- char type;
type = parse_type(packed);
/* DEBUG: printf("type: %c, rest: \"%s\"\n", type, *packed); */
- /* print value */
- int integer;
- char* str;
- char command;
switch (type) {
case BCP_PACKAGE_TYPE_UNDEFINED:
@@ -603,7 +610,8 @@
{
/* parse character */
int i;
- int parsed;
+ int parsed;
+ int length;
parsed = sscanf(*s, "%d", &i);
/* check if the item could be parsed */
@@ -613,7 +621,6 @@
}
/* calculate length of parsed integer string */
- int length;
length = intlen(i);
/* advance to the next caracters */
@@ -631,6 +638,7 @@
{
/* parse number sign (#) */
char number_sign;
+ char type;
number_sign = parse_char(s);
/* check if the item could be parsed */
@@ -640,7 +648,6 @@
}
/* parse the type caracter */
- char type;
type = parse_char(s);
/* return parsed type */
@@ -688,13 +695,13 @@
{
/* extract the length of the string */
int length;
+ char* str;
length = parse_int(s);
/* parse the newline terminating the header */
parse_newline(s);
/* store pointer to found string */
- char* str;
str = *s;
/* calculate the position of the newline caracter
@@ -851,18 +858,24 @@
{
/* stuff needed for the tests */
char buffers[BUFFER_SIZE][BUFFER_SIZE];
-
+ int i;
+ int j = 1;
+ char* packed;
+ void* elem;
+ char type;
+ char command;
+ bcp_package package;
+ bcp_package package2;
+ bcp_package_enumerator enumerator;
+
/* test */
printf("[test] Make a package, add elements, delete package:\n");
printf("\n");
/* make a new package */
- bcp_package package;
package = bcp_package_new();
/* add some elements */
- int i;
- int j = 1;
for (i = 0; i < 3; i++) {
/* add an integer */
@@ -873,7 +886,7 @@
bcp_package_add_string(package, buffers[i]);
/* add a command */
- char command = 'a' + i;
+ command = 'a' + i;
bcp_package_add_command(package, command);
/* calculate a new example integer */
@@ -892,7 +905,6 @@
*/
/* pack */
- char* packed;
packed = bcp_package_pack_allocate(package);
/* print packed package */
@@ -904,7 +916,6 @@
bcp_package_delete(package);
/* unpack the string `packed' */
- bcp_package package2;
package2 = bcp_package_unpack(packed);
/* dump */
@@ -922,8 +933,7 @@
printf(">>> testing enumerator functions:\n");
printf("\n");
- /* make new package enumerator */
- bcp_package_enumerator enumerator;
+ /* make new package enumerator */
enumerator = bcp_package_enumerator_new(package2);
/* header */
@@ -931,8 +941,6 @@
/* print element */
i = 0;
- void* elem;
- char type;
while (1) {
/* get next element */
@@ -1008,12 +1016,13 @@
*/
void dump_package(bcp_package p)
{
+ int i = 0;
+ element e;
/* print first line: type and length of the package */
printf(" (package,%d): {\n", length_packed(p));
/* print elements */
- int i = 0;
- element e = p->first;
+ e = p->first;
for( ; e != NULL; i++, e = e->next) {
/* print number, type and value of the ith element */
@@ -1062,6 +1071,9 @@
*/
void dump_packed_package(bcp_package p)
{
+ int i = 0;
+ element e;
+
/* print first line: type and length of the package */
printf(" package:\n");
printf("\n");
@@ -1070,8 +1082,7 @@
printf("\n");
/* print elements */
- int i = 0;
- element e = p->first;
+ e = p->first;
for( ; e != NULL; i++, e = e->next) {
/* print ith element */
@@ -1091,10 +1102,12 @@
void dump_packed_element(element e)
{
/* calculate length */
- int length = length_packed_element(e);
+ int length;
+ char* packed;
+ length = length_packed_element(e);
/* allocate memory for the packed string representation */
- char* packed = (char*) malloc((length + 1) * sizeof(char));
+ packed = (char*) malloc((length + 1) * sizeof(char));
if (packed == NULL) {
fprintf(stderr, "Couldn't allocate memory to pack an element!\n");
exit(ERROR_MEMORY);
=== modified file 'source/blender/commandport/utilities/src/fsleep.c'
--- source/blender/commandport/utilities/src/fsleep.c 2008-11-14 09:48:02 +0000
+++ source/blender/commandport/utilities/src/fsleep.c 2009-09-11 06:24:55 +0000
@@ -33,8 +33,8 @@
*
*/
-#include <stdlib.h>
-
+#include <stdlib.h>
+#include "timespec.h"
/**
sleep for an amount of time -
@@ -42,12 +42,12 @@
*/
int fsleep(float seconds)
{
- /* separate in seconds and nanoseconds */
+ /* separate in seconds and nanoseconds */
+ struct timespec requested_time, remaining;
int sec = (int) seconds;
int nsec = (int) ((seconds - (float) sec) * 1.0e9);
/* fill timespec to pass to nanosleep() */
- struct timespec requested_time, remaining;
requested_time.tv_sec = sec;
requested_time.tv_nsec = nsec;
=== modified file 'source/blender/commandport/utilities/src/hexdump_string.c'
--- source/blender/commandport/utilities/src/hexdump_string.c 2008-11-14 09:48:02 +0000
+++ source/blender/commandport/utilities/src/hexdump_string.c 2009-09-10 10:09:13 +0000
@@ -91,32 +91,34 @@
*/
void hexdump_string(char* prefix, char* string)
{
+ char hexbuf[50]; /* ex: */
+ char* ihex; /* >1234567890123456789012345678901234567890123456789< + \0 */
char* c; /* pointer to current char in string */
- c = string;
-
+ char charbuf[17]; /* ex: */
+ char* ichar; /* >1234567890123456< + \0 */
+ int ifirst;
+ int iline;
+ int hex_per_line;
+ ifirst = 0;
+ iline = 0;
+ hex_per_line = 16;
+
+ c = string;
+
/* print a header */
printf("%s==============================================================================\n", prefix);
printf("%saddr 0 1 2 3 4 5 6 7 8 9 A B C D E F | printable repr.|\n", prefix);
- printf("%s------------------------------------------------------------+----------------+\n", prefix);
-
+ printf("%s------------------------------------------------------------+----------------+\n", prefix);
+
/* string buffer to print the hex values into */
- char hexbuf[50]; /* ex: */
hexbuf[0] = '\0'; /* "65 69 6e 73 20 7a 77 65 69 20 64 72 65 69 20 76 " */
- char* ihex; /* >1234567890123456789012345678901234567890123456789< + \0 */
- ihex = hexbuf;
-
+ ihex = hexbuf;
+
/* string buffer to print the printable chars into */
- char charbuf[17]; /* ex: */
charbuf[0] = '\0'; /* "eins zwei drei v" */
- char* ichar; /* >1234567890123456< + \0 */
- ichar = charbuf;
-
- int ifirst = 0;
- int iline = 0;
- int hex_per_line = 16;
-
+ ichar = charbuf;
+
while (1) {
-
/* hex column separator between 8th and 9th hex column */
if (iline == (hex_per_line / 2) ) { /* an extra space between the 8th and 9th column */
sprintf(ihex, " "); /* to make the grouping easier to grap for the eyes */
@@ -256,10 +258,11 @@
*/
void simple_hexdump_string(char* string)
{
- char* c;
+ char* c;
+ int i;
c = string;
- int i = 0;
+ i = 0;
while (1) {
if ((i > 0) && (i % 8) == 0) printf(" ");
@@ -282,7 +285,15 @@
Test the hexdump functions.
*/
void hexdump_string_test()
-{
+{
+ char* example_str;
+ char* prefix;
+
+ char hexbuf[0x7f + 1];
+ char* c;
+ char code;
+
+
/* print a header */
printf("# ==========================================================\n");
printf("# Test: Hexdump String Functions:\n");
@@ -303,12 +314,12 @@
/* example string */
/* simple example: char* example_str = "eins zwei drei vier fuenf sechs sieben."; */
/* slightly more complicated: */
- char* example_str =
+ example_str =
"eins zwei drei vier fuenf sechs sieben, "
"tab: '\t', newline: '\n' and - to terminate the string - the nullchar: ";
/* prefix to indent the dumps */
- char* prefix = " ";
+ prefix = " ";
/* print example text */
printf(" Dumping the following string:\n");
@@ -328,10 +339,8 @@
/* dumping all ASCII between 0 and 127 */
printf(" A dump of all ASCII between 01 and 7F - and the 00-char at the end:\n");
- /* making a code buffer with all ASCII between 0 and 127 */
- char hexbuf[0x7f + 1];
- char* c = hexbuf;
- char code;
+ /* making a code buffer with all ASCII between 0 and 127 */
+ c = hexbuf;
*c++ = ' '; /* The first char is a blank... */
for (code = 1; 1 /* 0 <= code <= 0x7f */; code++, c++) {
/* fill the buffer with ASCII char codes */
=== modified file 'source/blender/commandport/utilities/src/message_client.c'
--- source/blender/commandport/utilities/src/message_client.c 2008-11-14 09:48:02 +0000
+++ source/blender/commandport/utilities/src/message_client.c 2009-09-10 10:11:33 +0000
@@ -36,11 +36,12 @@
*
*/
-#include <stdio.h> /* for printf() and fprintf() */
-#include <arpa/inet.h> /* for sockaddr_in and inet_addr() */
+#include <stdio.h> /* for printf() and fprintf() */
+//#include <arpa/inet.h> /* for sockaddr_in and inet_addr() */
+#include <winsock.h>
#include <stdlib.h> /* for atoi() and exit() */
#include <string.h> /* for memset() */
-#include <unistd.h> /* for close() */
+#include "unistd.h" /* for close() */
#include "message_handler.h" /* message handler to send and receive messages */
@@ -161,9 +162,11 @@
/* utility functions */
char* string_copy_allocate(char* str)
-{
- int length = strlen(str);
- char* copy = (char*) malloc( (length + 1) * sizeof(char) );
+{
+ int length;
+ char* copy;
+ length = strlen(str);
+ copy = (char*) malloc( (length + 1) * sizeof(char) );
memcpy(copy, str, length);
copy[length]= '\0';
return copy;
@@ -218,6 +221,8 @@
{
/* socket descriptor */
int socket_descriptor;
+ int i;
+ int connected;
/* Create reliable stream socket using TCP */
if ((socket_descriptor = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
@@ -228,8 +233,7 @@
/* Try to establish a connection to the echo server -
retry `retries' times and sleep `retry_sleeptime' seconds in between.
*/
- int connected = -1; /* when a connection could be established, this should be 0 and -1 otherwise */
- int i;
+ connected = -1; /* when a connection could be established, this should be 0 and -1 otherwise */
for (i = 0; i <= retries; i++) {
/* sleep `retry_sleeptime' seconds between attempts to connect to the server */
=== modified file 'source/blender/commandport/utilities/src/message_handler.c'
--- source/blender/commandport/utilities/src/message_handler.c 2008-11-14 09:48:02 +0000
+++ source/blender/commandport/utilities/src/message_handler.c 2009-09-10 10:21:46 +0000
@@ -45,7 +45,8 @@
#include <stdio.h> /* for printf() and fprintf() */
#include <string.h> /* for strlen() */
#include <stdlib.h>
-#include <sys/socket.h> /* for recv() and send() */
+//#include <sys/socket.h> /* for recv() and send() */
+#include <winsock.h>
#include <unistd.h> /* for close() */
#include "error_codes.h" /* error codes */
@@ -143,12 +144,17 @@
/**
*/
char* message_handler_receive_message_allocate(message_handler handler)
-{
+{
+ int received_chars; /* Size of chunk */
+ int length;
+ int last_chunk_flag;
+ int chars_remaining_flag;
+ char* message;
+
/* empty the message buffer */
string_buffer_make_empty(handler->message_buffer);
/* get first chunk of message */
- int received_chars; /* Size of chunk */
if (handler->chars_remaining) { /* first message chunk is still / already
in internal receive buffer - start with it */
received_chars = handler->chars_remaining;
@@ -176,18 +182,18 @@
- received_chars if no '\0' was found and
- the position of '\0' in `buffer' if '\0' was found.
*/
- int length = scan_for_0_char(handler->socket_buffer, received_chars);
+ length = scan_for_0_char(handler->socket_buffer, received_chars);
/* If '\0' was found (length != received_chars)
this is the last chunk of the current message
=> set the `last_chunk_flag' */
- int last_chunk_flag = (length != received_chars);
+ last_chunk_flag = (length != received_chars);
/* If the chunk size is one longer than the number of receive chars
(bytes + '\0') no bytes from the next message are received.
=> If the number of received chars is bigger
set the `chars_remaining_flag' */
- int chars_remaining_flag = ((length+1) < received_chars);
+ chars_remaining_flag = ((length+1) < received_chars);
/* DEBUG: dump the received message chunk */
IF_DEBUG(dump_message_chunk(handler->socket_buffer, length);
@@ -232,8 +238,8 @@
allocate a char array in the length of the received message
and store the message in the array
*/
- int length; /* length of the message */
- char* message = string_buffer_to_char_array_allocate(handler->message_buffer, &length);
+ //int length; /* length of the message */
+ message = string_buffer_to_char_array_allocate(handler->message_buffer, &length);
/* empty the message buffer */
string_buffer_make_empty(handler->message_buffer);
@@ -263,8 +269,8 @@
*/
void dump_message_chunk(char* buffer, int length)
{
+ int i;
printf("DEBUG: received %d bytes: [ ", length);
- int i;
for(i = 0; i < length; i++) {
if (i > 0) printf(", ");
printf("`%c' (%u)", buffer[i], buffer[i]);
=== modified file 'source/blender/commandport/utilities/src/string_buffer.c'
--- source/blender/commandport/utilities/src/string_buffer.c 2008-11-14 09:48:02 +0000
+++ source/blender/commandport/utilities/src/string_buffer.c 2009-09-11 08:22:03 +0000
@@ -46,8 +46,8 @@
#include <string.h>
#include <ctype.h> /* isspace(c) */
#include <stdlib.h>
-#include <readline/readline.h>
-#include <readline/history.h>
+//#include "readline/readline.h"
+//#include "readline/history.h"
#include "error_codes.h"
@@ -155,12 +155,14 @@
Set a prompt.
*/
void set_prompt(char** target, char* prompt)
-{
+{
+ char* newprompt;
+
/* if defined, free memory of former prompt */
if (*target != NULL) { free(*target); }
/* copy the prompt */
- char* newprompt = copy_string_allocate(prompt);
+ newprompt = copy_string_allocate(prompt);
/* setting new prompt */
*target = newprompt;
@@ -276,7 +278,10 @@
If the 'append_newline_flag' is set, append a newline to 'string'.
*/
string_slice new_string_slice(char* str, int append_newline_flag)
-{
+{
+ int length;
+ char* newstr;
+
/* Make a new string_slice for the string */
string_slice sliceBuffer;
sliceBuffer = (string_slice) malloc(sizeof(string_slice_struct));
@@ -289,11 +294,11 @@
/* Copy the string into the new slice struct */
/* allocate memory and copy the string */
- int length = strlen(str);
+ length = strlen(str);
if (append_newline_flag) {
length++; /* add 1 for the newline */
}
- char* newstr = (char*) malloc((length + 1) * sizeof(char));
+ newstr = (char*) malloc((length + 1) * sizeof(char));
memcpy(newstr, str, length);
if (append_newline_flag) {
newstr[length - 1]= '\n'; /* append the newline */
@@ -391,7 +396,10 @@
into one single string slice.
*/
int string_buffer_cleanup(string_buffer buffer)
-{
+{
+ int length;
+ char* content;
+ string_slice sliceBuffer;
/* no cleanup necessary if the buffer is empty
('buffer->first' and 'buffer->last->next' are both NULL)
or there is only one string slice in the string buffer
@@ -405,14 +413,12 @@
}
/* copy the content of the string_buffer into a newly allocated char array */
- int length;
- char* content = string_buffer_to_char_array_allocate(buffer, &length);
+ content = string_buffer_to_char_array_allocate(buffer, &length);
/* free the old slices */
string_buffer_make_empty(buffer);
/* Make a new string_slice for the content */
- string_slice sliceBuffer;
sliceBuffer = (string_slice) malloc(sizeof(string_slice_struct));
if (sliceBuffer == NULL) {
@@ -452,12 +458,14 @@
Return 1 if this is the case and 0 otherwise.
*/
int string_buffer_starts_with_prefix(string_buffer buffer, char* prefix)
-{
+{
+ int length;
+
/* simlify the buffer by copying all slices into a single one */
string_buffer_cleanup(buffer);
/* get the length of the prefix */
- int length = strlen(prefix);
+ length = strlen(prefix);
/* compare the first 'length' caracters of the string buffer
to the prefix and return the result of the comparison */
@@ -476,19 +484,22 @@
*/
int string_buffer_is_empty_or_white_space_string(string_buffer buffer)
{
- /* if string buffer is empty return true */
+ int length;
+ char* c;
+ char* limit;
+
+ /* if string buffer is empty return true */
if (string_buffer_is_empty(buffer)) return 1;
/* simlify the buffer by copying all slices into a single one */
string_buffer_cleanup(buffer);
/* get the length of the buffer content */
- int length;
length = string_buffer_get_length(buffer);
/* get pointer to first char in the buffer */
- char* c = buffer->first->str;
- char* limit = c + length;
+ c = buffer->first->str;
+ limit = c + length;
/* if one of the characters in the buffer is not a white space character, return false */
for ( ; c < limit; c++) {
@@ -512,15 +523,18 @@
{
/* allocate a new buffer 'content'
to hold the whole content of the current string buffer */
- int buffer_length;
+ int buffer_length;
+ char* content;
+ char* p;
+ int slice_length;
+ string_slice slice;
buffer_length = string_buffer_get_length(buffer);
- char* content = (char*) malloc( (buffer_length + 1) * sizeof(char) );
+ content = (char*) malloc( (buffer_length + 1) * sizeof(char) );
/* copy the content of the slices into the newly allocated buffer */
- string_slice slice;
- char* p = content; /* init pointer to position in new string buffer */
+ p = content; /* init pointer to position in new string buffer */
for (slice = buffer->first; slice != NULL; slice = slice->next) {
- int slice_length = strlen(slice->str); /* get length of the current string slice */
+ slice_length = strlen(slice->str); /* get length of the current string slice */
memcpy(p, slice->str, slice_length);
p += slice_length; /* set pointer to the end in new string buffer */
}
@@ -535,41 +549,41 @@
Read a single line from stdin.
The function returns the accumulated length of lines in 'buffer'.
*/
-int string_buffer_read_line_from_stdin(string_buffer buffer)
-{
- /* print prompt and
- get the next line using GNU readline() */
- char* line = NULL;
- line = readline(buffer->line_prompt);
-
- /* checking the result */
- if (line == NULL) {
-
- /* - either there was a problem while trying to read a line from stdin -
- - or blash received an EOT (End-Of-Transmission character)
- for example because CTRL-D was pressed...
- */
-
- return -1;
- }
+//~ int string_buffer_read_line_from_stdin(string_buffer buffer)
+//~ {
+ //~ /* print prompt and
+ //~ get the next line using GNU readline() */
+ //~ char* line = NULL;
+ //~ line = readline(buffer->line_prompt);
+
+ //~ /* checking the result */
+ //~ if (line == NULL) {
+
+ //~ /* - either there was a problem while trying to read a line from stdin -
+ //~ - or blash received an EOT (End-Of-Transmission character)
+ //~ for example because CTRL-D was pressed...
+ //~ */
+
+ //~ return -1;
+ //~ }
- /* save non-empty lines in readline() history */
- if (strlen(line) > 0) {
- add_history(line);
- }
-
- /* append read line to buffer */
- string_buffer_append(buffer, line);
-
- /* free the string buffer allocated by readline() */
- free(line);
-
- /* clean up the buffer buffer */
- int length = string_buffer_cleanup(buffer);
+ //~ /* save non-empty lines in readline() history */
+ //~ if (strlen(line) > 0) {
+ //~ add_history(line);
+ //~ }
+
+ //~ /* append read line to buffer */
+ //~ string_buffer_append(buffer, line);
+
+ //~ /* free the string buffer allocated by readline() */
+ //~ free(line);
+
+ //~ /* clean up the buffer buffer */
+ //~ int length = string_buffer_cleanup(buffer);
- /* return the length of the read buffer */
- return length;
-}
+ //~ /* return the length of the read buffer */
+ //~ return length;
+//~ }
/**
Read a text (a sequence of lines) from stdin.
@@ -580,65 +594,65 @@
If the there was a problem while trying to read an input
- for example because CTRL-D was hit - -1 is returned.
*/
-int string_buffer_read_text_from_stdin(string_buffer buffer)
-{
- /* set prompt for first line */
- char* prompt = NULL;
- prompt = buffer->text_prompt;
-
- /* loop to read a sequence of lines from stdin */
- char* line = NULL;
- while (1) {
-
- /* print prompt and get the next line */
- line = readline(prompt);
-
- /* checking the result */
- if (line == NULL) {
-
- /* - either there was a problem while trying to read a line from stdin -
- - or blash received an EOT (End-Of-Transmission character)
- for example because CTRL-D was pressed...
- */
-
- return -1;
- }
-
- /* save non-empty lines in readline() history */
- if (strlen(line) > 0) {
- add_history(line);
- }
-
- /* a line containing only a '.' signals the end of the sequence of input lines */
- if (strcmp(line, ".") == 0) {
-
- /* if the buffer is still empty an empty text was entered:
- Set the buffer to an empty text */
- if (string_buffer_is_empty(buffer)) {
- string_buffer_append(buffer, "");
- }
+//~ int string_buffer_read_text_from_stdin(string_buffer buffer)
+//~ {
+ //~ /* set prompt for first line */
+ //~ char* prompt = NULL;
+ //~ prompt = buffer->text_prompt;
+
+ //~ /* loop to read a sequence of lines from stdin */
+ //~ char* line = NULL;
+ //~ while (1) {
+
+ //~ /* print prompt and get the next line */
+ //~ line = readline(prompt);
+
+ //~ /* checking the result */
+ //~ if (line == NULL) {
+
+ //~ /* - either there was a problem while trying to read a line from stdin -
+ //~ - or blash received an EOT (End-Of-Transmission character)
+ //~ for example because CTRL-D was pressed...
+ //~ */
+
+ //~ return -1;
+ //~ }
+
+ //~ /* save non-empty lines in readline() history */
+ //~ if (strlen(line) > 0) {
+ //~ add_history(line);
+ //~ }
+
+ //~ /* a line containing only a '.' signals the end of the sequence of input lines */
+ //~ if (strcmp(line, ".") == 0) {
+
+ //~ /* if the buffer is still empty an empty text was entered:
+ //~ Set the buffer to an empty text */
+ //~ if (string_buffer_is_empty(buffer)) {
+ //~ string_buffer_append(buffer, "");
+ //~ }
- free(line); /* free the string buffer allocated by readline() */
- break; /* exit the readline loop */
- }
+ //~ free(line); /* free the string buffer allocated by readline() */
+ //~ break; /* exit the readline loop */
+ //~ }
- /* append read line to buffer */
- string_buffer_append_newline(buffer, line);
+ //~ /* append read line to buffer */
+ //~ string_buffer_append_newline(buffer, line);
- /* free the string buffer allocated by readline() */
- free(line);
-
- /* use "continue prompt" for all following lines...
- signalling that the loop is in the process to read a buffer */
- prompt = buffer->text_coninue_prompt;
- }
-
- /* clean up the buffer buffer */
- int length = string_buffer_cleanup(buffer);
+ //~ /* free the string buffer allocated by readline() */
+ //~ free(line);
+
+ //~ /* use "continue prompt" for all following lines...
+ //~ signalling that the loop is in the process to read a buffer */
+ //~ prompt = buffer->text_coninue_prompt;
+ //~ }
+
+ //~ /* clean up the buffer buffer */
+ //~ int length = string_buffer_cleanup(buffer);
- /* return the length of the read buffer */
- return length;
-}
+ //~ /* return the length of the read buffer */
+ //~ return length;
+//~ }
/**
Print a string buffer.
@@ -656,11 +670,12 @@
Note: This function is only for use during development.
*/
void string_buffer_dump(string_buffer buffer)
-{
+{
+ string_slice slice;
+ int i;
+
printf("===\n");
- string_slice slice;
- int i;
for (slice = buffer->first, i = 0; slice != NULL; slice = slice->next, i++) {
if (i > 0) printf("---\n");
printf(">>> Slice #%d, length %d:\n", i, strlen(slice->str));
@@ -678,8 +693,10 @@
char* copy_string_allocate(char* string)
{
/* allocating memory for the copy */
- int length = strlen(string);
- char* newstr = (char*) malloc((length + 1) * sizeof(char));
+ int length;
+ char* newstr;
+ length = strlen(string);
+ newstr = (char*) malloc((length + 1) * sizeof(char));
memcpy(newstr, string, length);
newstr[length]= '\0';
=== modified file 'tools/Blender.py'
--- tools/Blender.py 2009-07-26 14:27:44 +0000
+++ tools/Blender.py 2009-09-11 06:48:50 +0000
@@ -192,9 +192,9 @@
if not lenv['WITH_BF_STATICOPENGL']:
syslibs += Split(lenv['BF_OPENGL_LIB'])
if lenv['OURPLATFORM'] in ('win32-vc', 'win32-mingw','linuxcross'):
- syslibs += Split(lenv['BF_PTHREADS_LIB'])
- if lenv['WITH_COMMAND_PORT'] or lenv['WITH_BLASH']:
- syslibs += Split(lenv['READLINE_LIB'])
+ syslibs += Split(lenv['BF_PTHREADS_LIB'])
+ if lenv['WITH_COMMAND_PORT'] or lenv['WITH_BLASH']:
+ syslibs += Split(lenv['READLINE_LIB'])
syslibs += lenv['LLIBS']
@@ -465,13 +465,16 @@
variant = 'Release',
auto_build_solution=0)
vcp.append(vcproject)
- SConsEnvironment.Default(self, vcproject)
+ SConsEnvironment.Default(self, vcproject)
+
+ # note: libs is a global
+ #XXX --antont: didn't work with quickie
+ add_lib_to_dict(self, libs, libtype, libname, priority)
+ if lenv['WITH_COMMAND_PORT']: # (dietrich)
+ lenv.Append(CPPDEFINES = ['WITH_COMMAND_PORT'])
+
else:
- print bc.WARNING+'Not building '+bc.ENDC+bc.OKGREEN+libname+bc.ENDC+' for '+bc.OKBLUE+'BF_QUICK'+bc.ENDC
- # note: libs is a global
- add_lib_to_dict(self, libs, libtype, libname, priority)
- if lenv['WITH_COMMAND_PORT']: # (dietrich)
- lenv.Append(CPPDEFINES = ['WITH_COMMAND_PORT'])
+ print bc.WARNING+'Not building '+bc.ENDC+bc.OKGREEN+libname+bc.ENDC+' for '+bc.OKBLUE+'BF_QUICK'+bc.ENDC
def BlenderProg(self=None, builddir=None, progname=None, sources=None, includes=None, libs=None, libpath=None, binarykind=''):
global vcp

Event Timeline