2
* $Id: UnixShell.c 16961 2008-10-07 17:13:35Z eof $
4
* ***** BEGIN GPL LICENSE BLOCK *****
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software Foundation,
18
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21
* All rights reserved.
23
* The Original Code is: all of this file.
25
* Contributor(s): Enrico Fracasso
27
* ***** END GPL LICENSE BLOCK *****
28
* NS api template, adapted to link to our own internals.
31
#define UNIXSH_VERSION "$Id: UnixShell.c 16961 2008-10-07 17:13:35Z eof $"
34
/* -*- Mode: C; tab-width: 8; c-set-style: bsd -*- */
36
/* UnixShell.c was adapted from the template in the Netscape API. */
43
/* All nsapi stuff. nsapi now needs FILE, so include stdio as well. */
54
/* Threading the NSPR way: */
58
#include "blender_plugin_types.h"
62
/* --------------------------------------------------------------------- */
64
/** If defined: write to the plugin log file */
66
#define NZC_GENERATE_LOG
71
/** Generate a log file. */
77
execute_blenderplayer(BlenderPluginInstance*);
79
/* --------------------------------------------------------------------- */
80
/* Implementations: */
81
/* --------------------------------------------------------------------- */
83
/* NPP_GetMIMEDescription() and NPP_GetValue() are called to determine
84
* the mime types supported by this plugin. */
86
NPP_GetMIMEDescription( void )
88
log_entry("NPP_GetMIMEDescription");
89
return("application/x-blender-plugin:blend:Blender 3D web plugin");
99
NPError err = NPERR_NO_ERROR;
101
log_entry("NPP_GetValue");
104
case NPPVpluginNeedsXEmbed:
105
log_entry("NPP_GetValue::NPPVpluginNeedsXEmbed");
106
*((PRBool *)value) = PR_TRUE;
108
case NPPVpluginNameString:
109
log_entry("NPP_GetValue::NPPVpluginNameString");
110
*((char **)value) = "Blender";
112
case NPPVpluginDescriptionString:
113
log_entry("NPP_GetValue::NPPVpluginDescriptionString");
114
*((char **)value) = "Player for interactive 3D content";
116
case NPPVpluginWindowBool:
117
log_entry("NPP_GetValue::NPPVpluginWindowBool");
118
*((PRBool *)value) = PR_FALSE; //not windowless
120
case NPPVpluginTransparentBool:
121
log_entry("NPP_GetValue::NPPVpluginTransparentBool");
122
*((PRBool *)value) = PR_FALSE; // not trasparent
125
err = NPERR_GENERIC_ERROR;
130
/* --------------------------------------------------------------------- */
131
/* Mozilla: NPP_Initialize() is called when
132
* starting the browser, and then every time the plugin is started*/
136
log_entry("NPP_Initialize");
137
return NPERR_NO_ERROR;
140
/* --------------------------------------------------------------------- */
145
log_entry("NPP_Shutdown");
151
NPMIMEType pluginType,
160
BlenderPluginInstance* This = NULL;
164
log_entry("NPP_New");
166
if (instance == NULL)
167
return NPERR_INVALID_INSTANCE_ERROR;
169
instance->pdata = NPN_MemAlloc(sizeof(BlenderPluginInstance));
170
if (instance->pdata == 0)
171
return NPERR_OUT_OF_MEMORY_ERROR;
173
This = (BlenderPluginInstance*) instance->pdata;
174
This->browser_instance = instance;
176
This->blend_file = 0;
177
This->temp_mail_file_name = 0;
178
This->main_file_store = 0;
179
This->display = NULL;
182
/* Parse the options from the file. Should I do this in the
183
* implementation file maybe? Now we do a lot with
184
* instance-specific data. */
187
if (!strcmp(argn[i],"src")) {
188
The blend file to load.
189
int url_len = strlen(argv[i]);
190
if ((url_len > 0) && (url_len < 4096) ) {
191
This->blend_file = NPN_MemAlloc(url_len + 1);
192
if (This->blend_file == 0)
193
return NPERR_OUT_OF_MEMORY_ERROR;
194
strcpy(This->blend_file, argv[i]);
196
retval = NPN_GetURL(This->browser_instance,
199
if (retval != NPERR_NO_ERROR) {
200
log_entry("Cannot read animation");
201
NPN_Status(instance, "Cannot read animation file");
202
This->blend_file = NULL;
203
return NPERR_NO_ERROR;
205
log_entry("Animation loaded");
212
return NPERR_NO_ERROR;
214
return NPERR_OUT_OF_MEMORY_ERROR;
219
NPP_Destroy( NPP instance, NPSavedData** save )
221
BlenderPluginInstance* This;
223
log_entry("NPP_Destroy");
225
if (instance == NULL)
226
return NPERR_INVALID_INSTANCE_ERROR;
228
This = (BlenderPluginInstance*) instance->pdata;
229
printf("NPP_Destroy ID: 0x%x %d\n", This->window, This->window);
233
if (This->pID != 0) {
235
kill(This->pID, SIGTERM);
237
kill(This->pID, SIGKILL); //if I have to kill blenderplayer directly I need to send SIGKILL
240
unlink(This->temp_mail_file_name);
243
// sometimes FF doesn't delete it's own window...
244
//printf("%s \n", NPN_UserAgent(instance));
245
/*if (This->display != NULL && This->window != 0)
246
XDestroyWindow(This->display, This->window);
248
if (This->blend_file) NPN_MemFree(This->blend_file);
249
if (This->temp_mail_file_name) NPN_MemFree(This->temp_mail_file_name);
250
if (This->main_file_store) NPN_MemFree(This->main_file_store);
251
NPN_MemFree(instance->pdata);
252
instance->pdata = NULL;
255
return NPERR_NO_ERROR;
261
NPP_SetWindow( NPP instance,NPWindow* window )
263
BlenderPluginInstance* This;
265
log_entry("NPP_SetWindow");
267
if (instance == NULL)
268
return NPERR_INVALID_INSTANCE_ERROR;
271
if ((window == NULL) || (window->window == NULL)) {
272
return NPERR_NO_ERROR; /* mmmmmm */
275
if (window->ws_info == NULL)
276
return NPERR_NO_ERROR; /* mmmmmm */
278
This = (BlenderPluginInstance*) instance->pdata;
281
This->window = (Window) window->window;
283
NPSetWindowCallbackStruct* window_info = window->ws_info;
284
This->display = window_info->display;
286
printf("ID window 0x%x %d\n", window->window, window->window);
287
return NPERR_NO_ERROR;
289
return NPERR_INVALID_INSTANCE_ERROR;
304
BlenderPluginInstance* This;
306
log_entry("NPP_NewStream");
308
if (instance == NULL)
309
return NPERR_INVALID_INSTANCE_ERROR;
311
This = (BlenderPluginInstance*) instance->pdata;
314
return NPERR_INVALID_INSTANCE_ERROR;
316
printf("Loading main file %s (%s)\n", stream->url, type);
317
if ( strcmp(type,"text/html") == 0 ) // original HTML file
318
return NPERR_NO_ERROR;
320
This->stream_total = stream->end;
321
This->stream_retrieved = 0;
322
This->main_file_store = NPN_MemAlloc(stream->end*sizeof(unsigned char));
323
if (!This->main_file_store) {
324
fprintf(stderr, "Blender plugin: Out of memory! "
325
"Cannot get chunk for loading animation.\n");
326
return NPERR_OUT_OF_MEMORY_ERROR;
329
This->main_file_stream = stream;
331
return NPERR_NO_ERROR;
336
/* PLUGIN DEVELOPERS:
337
* These next 2 functions are directly relevant in a plug-in which
338
* handles the data in a streaming manner. If you want zero bytes
339
* because no buffer space is YET available, return 0. As long as
340
* the stream has not been written to the plugin, Navigator will
341
* continue trying to send bytes. If the plugin doesn't want them,
342
* just return some large number from NPP_WriteReady(), and
343
* ignore them in NPP_Write(). For a NP_ASFILE stream, they are
344
* still called but can safely be ignored using this strategy.
347
int32 STREAMBUFSIZE = 0X0FFFFFFF; /* If we are reading from a file in NPAsFile
348
* mode so we can take any size stream in our
349
* write call (since we ignore it) */
357
BlenderPluginInstance* This = NULL;
360
log_entry("NPP_WriteReady");
362
if (instance == NULL)
363
return NPERR_INVALID_INSTANCE_ERROR;
365
This = (BlenderPluginInstance*) instance->pdata;
368
return NPERR_INVALID_INSTANCE_ERROR;
370
/* Check whether buffers already exist: */
372
if ((This->main_file_stream && This->main_file_store)) {
373
acceptable = STREAMBUFSIZE;
390
BlenderPluginInstance* This = NULL;
393
log_entry("NPP_Write");
395
if (instance == NULL)
396
return NPERR_INVALID_INSTANCE_ERROR;
398
This = (BlenderPluginInstance*) instance->pdata;
401
return NPERR_INVALID_INSTANCE_ERROR;
404
if (stream == This->main_file_stream) {
405
log_entry("NPP_Write: loading main_file_stream");
406
memcpy(((unsigned char*)This->main_file_store) + This->stream_retrieved, buffer, len);
408
This->stream_retrieved += len;
409
if (This->stream_retrieved >= This->stream_total) {
410
log_entry("NPP_Write: main_file_stream loaded");
411
execute_blenderplayer(This);
414
/* the stream ref wasn't set yet..*/
415
log_entry("NPP_Write: not main stream");
416
log_entry(stream->url);
433
BlenderPluginInstance* This = NULL;
435
log_entry("NPP_DestroyStream");
437
if (instance == NULL)
438
return NPERR_INVALID_INSTANCE_ERROR;
439
This = (BlenderPluginInstance*) instance->pdata;
442
if (reason != NPRES_DONE) {
443
if (stream == This->main_file_stream) {
444
// stream destroyed by NPP_Destroy
445
NPN_Status(instance, "Cannot read animation file");
446
//main_file_failed(This->application);
449
return NPERR_NO_ERROR;
451
return NPERR_INVALID_INSTANCE_ERROR;
457
/* Not supposed to be called anymore... Anyway, we don't need the
458
* results. Some Moz implementations will call this one regardless the
459
* desired transfer mode! */
461
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname )
463
/* log_entry("NPP_StreamAsFile"); */
468
NPP_Print(NPP instance, NPPrint* printInfo )
471
log_entry("NPP_Print");
472
if(printInfo == NULL)
474
if (instance != NULL) {
475
if (printInfo->mode == NP_FULL) {
476
printInfo->print.fullPrint.pluginPrinted = FALSE;
478
else { /* If not fullscreen, we must be embedded */
485
execute_blenderplayer(BlenderPluginInstance* instance){
487
char file_name[] = "/tmp/blender.XXXXXX";
488
int fd = mkstemp(file_name);
490
ssize_t real_size = write(fd, instance->main_file_store, instance->stream_retrieved);
493
instance->temp_mail_file_name = NPN_MemAlloc(strlen(file_name) + 1);
494
strcpy(instance->temp_mail_file_name, file_name);
496
instance->pID = fork();
497
//XSelectInput(This->display , This->window, SubstructureNotifyMask);
498
//XSync(This->display, FALSE);
501
#if defined(WITH_APPARMOR)
502
const char* executable = "blenderplayer-web";
503
#elif defined(WITH_PRIVSEP)
504
const char* executable = "blenderplayer-wrapper";
506
const char* executable = "blenderplayer";
509
if (instance->pID == 0) { // child
511
sprintf(window_id, "%d", instance->window);
514
execlp(executable, executable, file_name, window_id, (char*)NULL);
516
execlp(executable, executable, "-i", window_id, file_name, (char*)NULL);
519
} else if (instance->pID < 0) { // failed to fork
520
printf("Failed to fork!!!\n");
526
XNextEvent(This->display, &e);
527
printf("Event type %d\n", e.type);
528
if (e.type == MapNotify) {
530
XCreateWindowEvent event = e.xcreatewindow;
531
printf("Created window x:%d, y: %d, h: %d, w: %d\n", event.x, event.y, event.height, event.width);
538
/* --------------------------------------------------------------------- */
543
#ifdef NZC_GENERATE_LOG
544
FILE* fp = fopen("/tmp/plugin_log","a");
546
fprintf(fp, "--> Unixshell:: %s\n",
553
/* --------------------------------------------------------------------- */
2
* $Id: UnixShell.c 19485 2009-03-31 22:34:34Z gsrb3d $
4
* ***** BEGIN GPL LICENSE BLOCK *****
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software Foundation,
18
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21
* All rights reserved.
23
* The Original Code is: all of this file.
25
* Contributor(s): Enrico Fracasso
27
* ***** END GPL LICENSE BLOCK *****
28
* NS api template, adapted to link to our own internals.
31
#define UNIXSH_VERSION "$Id: UnixShell.c 19485 2009-03-31 22:34:34Z gsrb3d $"
34
/* -*- Mode: C; tab-width: 8; c-set-style: bsd -*- */
36
/* UnixShell.c was adapted from the template in the Netscape API. */
43
/* All nsapi stuff. nsapi now needs FILE, so include stdio as well. */
54
/* Threading the NSPR way: */
58
#include "blender_plugin_types.h"
62
/* --------------------------------------------------------------------- */
64
/** If defined: write to the plugin log file */
66
#define NZC_GENERATE_LOG
71
/** Generate a log file. */
77
execute_blenderplayer(BlenderPluginInstance*);
79
/* --------------------------------------------------------------------- */
80
/* Implementations: */
81
/* --------------------------------------------------------------------- */
83
/* NPP_GetMIMEDescription() and NPP_GetValue() are called to determine
84
* the mime types supported by this plugin. */
86
NPP_GetMIMEDescription( void )
88
log_entry("NPP_GetMIMEDescription");
89
return("application/x-blender-plugin:blend:Blender 3D web plugin");
99
NPError err = NPERR_NO_ERROR;
101
log_entry("NPP_GetValue");
104
case NPPVpluginNeedsXEmbed:
105
log_entry("NPP_GetValue::NPPVpluginNeedsXEmbed");
106
*((PRBool *)value) = PR_TRUE;
108
case NPPVpluginNameString:
109
log_entry("NPP_GetValue::NPPVpluginNameString");
110
*((char **)value) = "Blender";
112
case NPPVpluginDescriptionString:
113
log_entry("NPP_GetValue::NPPVpluginDescriptionString");
114
*((char **)value) = "Player for interactive 3D content";
116
case NPPVpluginWindowBool:
117
log_entry("NPP_GetValue::NPPVpluginWindowBool");
118
*((PRBool *)value) = PR_FALSE; //not windowless
120
case NPPVpluginTransparentBool:
121
log_entry("NPP_GetValue::NPPVpluginTransparentBool");
122
*((PRBool *)value) = PR_FALSE; // not trasparent
125
err = NPERR_GENERIC_ERROR;
130
/* --------------------------------------------------------------------- */
131
/* Mozilla: NPP_Initialize() is called when
132
* starting the browser, and then every time the plugin is started*/
136
log_entry("NPP_Initialize");
137
return NPERR_NO_ERROR;
140
/* --------------------------------------------------------------------- */
145
log_entry("NPP_Shutdown");
151
NPMIMEType pluginType,
160
BlenderPluginInstance* This = NULL;
164
log_entry("NPP_New");
166
if (instance == NULL)
167
return NPERR_INVALID_INSTANCE_ERROR;
169
instance->pdata = NPN_MemAlloc(sizeof(BlenderPluginInstance));
170
if (instance->pdata == 0)
171
return NPERR_OUT_OF_MEMORY_ERROR;
173
This = (BlenderPluginInstance*) instance->pdata;
174
This->browser_instance = instance;
176
This->blend_file = 0;
177
This->temp_mail_file_name = 0;
178
This->main_file_store = 0;
179
This->display = NULL;
182
/* Parse the options from the file. Should I do this in the
183
* implementation file maybe? Now we do a lot with
184
* instance-specific data. */
187
if (!strcmp(argn[i],"src")) {
188
The blend file to load.
189
int url_len = strlen(argv[i]);
190
if ((url_len > 0) && (url_len < 4096) ) {
191
This->blend_file = NPN_MemAlloc(url_len + 1);
192
if (This->blend_file == 0)
193
return NPERR_OUT_OF_MEMORY_ERROR;
194
strcpy(This->blend_file, argv[i]);
196
retval = NPN_GetURL(This->browser_instance,
199
if (retval != NPERR_NO_ERROR) {
200
log_entry("Cannot read animation");
201
NPN_Status(instance, "Cannot read animation file");
202
This->blend_file = NULL;
203
return NPERR_NO_ERROR;
205
log_entry("Animation loaded");
212
return NPERR_NO_ERROR;
214
return NPERR_OUT_OF_MEMORY_ERROR;
219
NPP_Destroy( NPP instance, NPSavedData** save )
221
BlenderPluginInstance* This;
223
log_entry("NPP_Destroy");
225
if (instance == NULL)
226
return NPERR_INVALID_INSTANCE_ERROR;
228
This = (BlenderPluginInstance*) instance->pdata;
229
printf("NPP_Destroy ID: 0x%x %d\n", This->window, This->window);
233
if (This->pID != 0) {
235
kill(This->pID, SIGTERM);
237
kill(This->pID, SIGKILL); //if I have to kill blenderplayer directly I need to send SIGKILL
240
unlink(This->temp_mail_file_name);
243
// sometimes FF doesn't delete it's own window...
244
//printf("%s \n", NPN_UserAgent(instance));
245
/*if (This->display != NULL && This->window != 0)
246
XDestroyWindow(This->display, This->window);
248
if (This->blend_file) NPN_MemFree(This->blend_file);
249
if (This->temp_mail_file_name) NPN_MemFree(This->temp_mail_file_name);
250
if (This->main_file_store) NPN_MemFree(This->main_file_store);
251
NPN_MemFree(instance->pdata);
252
instance->pdata = NULL;
255
return NPERR_NO_ERROR;
261
NPP_SetWindow( NPP instance,NPWindow* window )
263
BlenderPluginInstance* This;
265
log_entry("NPP_SetWindow");
267
if (instance == NULL)
268
return NPERR_INVALID_INSTANCE_ERROR;
271
if ((window == NULL) || (window->window == NULL)) {
272
return NPERR_NO_ERROR; /* mmmmmm */
275
if (window->ws_info == NULL)
276
return NPERR_NO_ERROR; /* mmmmmm */
278
This = (BlenderPluginInstance*) instance->pdata;
281
This->window = (Window) window->window;
283
NPSetWindowCallbackStruct* window_info = window->ws_info;
284
This->display = window_info->display;
286
printf("ID window 0x%x %d\n", window->window, window->window);
287
return NPERR_NO_ERROR;
289
return NPERR_INVALID_INSTANCE_ERROR;
304
BlenderPluginInstance* This;
306
log_entry("NPP_NewStream");
308
if (instance == NULL)
309
return NPERR_INVALID_INSTANCE_ERROR;
311
This = (BlenderPluginInstance*) instance->pdata;
314
return NPERR_INVALID_INSTANCE_ERROR;
316
printf("Loading main file %s (%s)\n", stream->url, type);
317
if ( strcmp(type,"text/html") == 0 ) // original HTML file
318
return NPERR_NO_ERROR;
320
This->stream_total = stream->end;
321
This->stream_retrieved = 0;
322
This->main_file_store = NPN_MemAlloc(stream->end*sizeof(unsigned char));
323
if (!This->main_file_store) {
324
fprintf(stderr, "Blender plugin: Out of memory! "
325
"Cannot get chunk for loading animation.\n");
326
return NPERR_OUT_OF_MEMORY_ERROR;
329
This->main_file_stream = stream;
331
return NPERR_NO_ERROR;
336
/* PLUGIN DEVELOPERS:
337
* These next 2 functions are directly relevant in a plug-in which
338
* handles the data in a streaming manner. If you want zero bytes
339
* because no buffer space is YET available, return 0. As long as
340
* the stream has not been written to the plugin, Navigator will
341
* continue trying to send bytes. If the plugin doesn't want them,
342
* just return some large number from NPP_WriteReady(), and
343
* ignore them in NPP_Write(). For a NP_ASFILE stream, they are
344
* still called but can safely be ignored using this strategy.
347
int32 STREAMBUFSIZE = 0X0FFFFFFF; /* If we are reading from a file in NPAsFile
348
* mode so we can take any size stream in our
349
* write call (since we ignore it) */
357
BlenderPluginInstance* This = NULL;
360
log_entry("NPP_WriteReady");
362
if (instance == NULL)
363
return NPERR_INVALID_INSTANCE_ERROR;
365
This = (BlenderPluginInstance*) instance->pdata;
368
return NPERR_INVALID_INSTANCE_ERROR;
370
/* Check whether buffers already exist: */
372
if ((This->main_file_stream && This->main_file_store)) {
373
acceptable = STREAMBUFSIZE;
390
BlenderPluginInstance* This = NULL;
393
log_entry("NPP_Write");
395
if (instance == NULL)
396
return NPERR_INVALID_INSTANCE_ERROR;
398
This = (BlenderPluginInstance*) instance->pdata;
401
return NPERR_INVALID_INSTANCE_ERROR;
404
if (stream == This->main_file_stream) {
405
log_entry("NPP_Write: loading main_file_stream");
406
memcpy(((unsigned char*)This->main_file_store) + This->stream_retrieved, buffer, len);
408
This->stream_retrieved += len;
409
if (This->stream_retrieved >= This->stream_total) {
410
log_entry("NPP_Write: main_file_stream loaded");
411
execute_blenderplayer(This);
414
/* the stream ref wasn't set yet..*/
415
log_entry("NPP_Write: not main stream");
416
log_entry(stream->url);
433
BlenderPluginInstance* This = NULL;
435
log_entry("NPP_DestroyStream");
437
if (instance == NULL)
438
return NPERR_INVALID_INSTANCE_ERROR;
439
This = (BlenderPluginInstance*) instance->pdata;
442
if (reason != NPRES_DONE) {
443
if (stream == This->main_file_stream) {
444
// stream destroyed by NPP_Destroy
445
NPN_Status(instance, "Cannot read animation file");
446
//main_file_failed(This->application);
449
return NPERR_NO_ERROR;
451
return NPERR_INVALID_INSTANCE_ERROR;
457
/* Not supposed to be called anymore... Anyway, we don't need the
458
* results. Some Moz implementations will call this one regardless the
459
* desired transfer mode! */
461
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname )
463
/* log_entry("NPP_StreamAsFile"); */
468
NPP_Print(NPP instance, NPPrint* printInfo )
471
log_entry("NPP_Print");
472
if(printInfo == NULL)
474
if (instance != NULL) {
475
if (printInfo->mode == NP_FULL) {
476
printInfo->print.fullPrint.pluginPrinted = FALSE;
478
else { /* If not fullscreen, we must be embedded */
485
execute_blenderplayer(BlenderPluginInstance* instance){
487
char file_name[] = "/tmp/blender.XXXXXX";
488
int fd = mkstemp(file_name);
490
ssize_t real_size = write(fd, instance->main_file_store, instance->stream_retrieved);
493
instance->temp_mail_file_name = NPN_MemAlloc(strlen(file_name) + 1);
494
strcpy(instance->temp_mail_file_name, file_name);
496
instance->pID = fork();
497
//XSelectInput(This->display , This->window, SubstructureNotifyMask);
498
//XSync(This->display, FALSE);
501
#if defined(WITH_APPARMOR)
502
const char* executable = "blenderplayer-web";
503
#elif defined(WITH_PRIVSEP)
504
const char* executable = "blenderplayer-wrapper";
506
const char* executable = "blenderplayer";
509
if (instance->pID == 0) { // child
511
sprintf(window_id, "%d", instance->window);
514
execlp(executable, executable, file_name, window_id, (char*)NULL);
516
execlp(executable, executable, "-i", window_id, file_name, (char*)NULL);
519
} else if (instance->pID < 0) { // failed to fork
520
printf("Failed to fork!!!\n");
526
XNextEvent(This->display, &e);
527
printf("Event type %d\n", e.type);
528
if (e.type == MapNotify) {
530
XCreateWindowEvent event = e.xcreatewindow;
531
printf("Created window x:%d, y: %d, h: %d, w: %d\n", event.x, event.y, event.height, event.width);
538
/* --------------------------------------------------------------------- */
543
#ifdef NZC_GENERATE_LOG
544
FILE* fp = fopen("/tmp/plugin_log","a");
546
fprintf(fp, "--> Unixshell:: %s\n",
553
/* --------------------------------------------------------------------- */