forked from KomodoPlatform/dPoW
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pnacl_main.h
executable file
·669 lines (604 loc) · 20.8 KB
/
pnacl_main.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#ifdef _WIN32
#include "OSlibs/win/pthread.h"
#include <windows.h>
//static inline void sleep(unsigned ms) { Sleep(ms*1000); }
#else
#include <unistd.h>
#include <pthread.h>
#endif
int MAIN_initflag;
#ifndef __PNACL
#define PNACL_message printf
#else
void PNACL_message(const char* format, ...);
#endif
void OS_init();
void *OS_filestr(long *allocsizep,char *fname);
char *clonestr(char *);
void CHROMEAPP_MAIN(void *arg);
void *CHROMEAPP_NAME(void *arg)
{
if ( arg == 0 )
#ifdef __linux__
arg = 0;
#else
arg = 0;
#endif
while ( MAIN_initflag == 0 )
usleep(1000000);
PNACL_message("%s start.(%s)\n",CHROMEAPP_STR,(char *)arg);
CHROMEAPP_MAIN(arg);
return(0);
}
#ifdef __PNACL
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/param.h>
#include <sys/select.h>
#include <sys/stat.h>
#include "includes/ppapi/c/ppb.h"
#include "includes/ppapi/c/ppb_var.h"
#include "includes/ppapi/c/ppb_instance.h"
#include "includes/ppapi/c/ppb_messaging.h"
#include "includes/ppapi/c/ppb_var_array.h"
#include "includes/ppapi/c/ppb_var_dictionary.h"
#include "includes/ppapi/c/pp_errors.h"
#include "includes/ppapi/c/ppp_messaging.h"
#include "includes/ppapi/c/ppp_instance.h"
typedef int (*PSMainFunc_t)(int argc, char *argv[]);
#if defined(WIN32)
#define va_copy(d, s) ((d) = (s))
#endif
#ifndef __PNACL
/*int32_t PSGetInstanceId()
{
return(4);
}*/
#endif
typedef int (*HandleFunc)(struct PP_Var params,struct PP_Var* out_var,const char** error);
typedef struct { const char* name; HandleFunc function; } FuncNameMapping;
static PP_Instance g_instance = 0;
static PPB_GetInterface g_get_browser_interface = NULL;
static PPB_Messaging* g_ppb_messaging = NULL;
PPB_Var* g_ppb_var = NULL;
PPB_VarArray* g_ppb_var_array = NULL;
PPB_VarDictionary* g_ppb_var_dictionary = NULL;
int CHROMEAPP_HANDLER(struct PP_Var params,struct PP_Var *output,const char **out_error);
static FuncNameMapping g_function_map[] = { { CHROMEAPP_STR, CHROMEAPP_HANDLER }, { NULL, NULL } };
struct PP_Var CStrToVar(const char* str) { return g_ppb_var->VarFromUtf8(str, (int32_t)strlen(str)); }
char *VprintfToNewString(const char* format, va_list args)
{
va_list args_copy; int length; char *buffer; int result;
va_copy(args_copy, args);
length = vsnprintf(NULL, 0, format, args);
buffer = (char*)malloc(length + 1); // +1 for NULL-terminator.
result = vsnprintf(&buffer[0], length + 1, format, args_copy);
if ( result != length )
{
assert(0);
return NULL;
}
return buffer;
}
char *PrintfToNewString(const char *format, ...)
{
va_list args; char *result;
va_start(args, format);
result = VprintfToNewString(format, args);
va_end(args);
return result;
}
struct PP_Var VprintfToVar(const char* format, va_list args)
{
struct PP_Var var; char *string = VprintfToNewString(format, args);
var = g_ppb_var->VarFromUtf8(string, (int32_t)strlen(string));
free(string);
return var;
}
static const char *VarToCStr(struct PP_Var var)
{
uint32_t length; char *new_str; const char *str = g_ppb_var->VarToUtf8(var, &length);
if ( str == NULL )
return NULL;
new_str = (char*)malloc(length + 1);
memcpy(new_str, str, length); // str is NOT NULL-terminated. Copy using memcpy.
new_str[length] = 0;
return new_str;
}
struct PP_Var GetDictVar(struct PP_Var dict, const char* key)
{
struct PP_Var key_var = CStrToVar(key);
struct PP_Var value = g_ppb_var_dictionary->Get(dict, key_var);
g_ppb_var->Release(key_var);
return value;
}
void PNACL_message(const char* format, ...)
{
va_list args;
va_start(args, format);
#ifdef __PNACL
struct PP_Var var;
var = VprintfToVar(format, args);
g_ppb_messaging->PostMessage(g_instance, var);
g_ppb_var->Release(var);
#else
printf(format,args);
#endif
va_end(args);
}
void PostMessage(const char* format, ...)
{
va_list args;
va_start(args, format);
#ifdef __PNACL
struct PP_Var var;
var = VprintfToVar(format, args);
g_ppb_messaging->PostMessage(g_instance, var);
g_ppb_var->Release(var);
#else
printf(format,args);
#endif
va_end(args);
}
/**
* Given a message from JavaScript, parse it for functions and parameters.
*
* The format of the message is:
* {
* "cmd": <function name>,
* "args": [<arg0>, <arg1>, ...]
* }
*
* @param[in] message The message to parse.
* @param[out] out_function The function name.
* @param[out] out_params A PP_Var array.
* @return 0 if successful, otherwise 1.
*/
static int ParseMessage(struct PP_Var message,const char **out_function,struct PP_Var *out_params)
{
char *jsonstr=0;
if ( message.type != PP_VARTYPE_DICTIONARY )
{
PNACL_message("illegal message.%d != %d\n",message.type,PP_VARTYPE_DICTIONARY);
return(1);
}
struct PP_Var cmd_value = GetDictVar(message, "cmd");
*out_function = VarToCStr(cmd_value);
g_ppb_var->Release(cmd_value);
*out_params = GetDictVar(message, "args");
jsonstr = (char *)VarToCStr(*out_params);
PNACL_message("Parse.(%s) cmd.(%s) cmdtype.%d out.%d\n",*out_function,jsonstr!=0?jsonstr:"null",cmd_value.type,out_params->type);
if ( jsonstr != 0 )
{
PNACL_message("Parse.(%s) cmd.(%s)\n",*out_function,jsonstr);
if ( cmd_value.type != PP_VARTYPE_STRING )
return(1);
if ( out_params->type != PP_VARTYPE_ARRAY )
return(1);
return(0);
} else return(1);
}
static HandleFunc GetFunctionByName(const char* function_name)
{
FuncNameMapping* map_iter = g_function_map;
for (; map_iter->name; ++map_iter)
{
if (strcmp(map_iter->name, function_name) == 0)
return map_iter->function;
}
return NULL;
}
/**
* Handle as message from JavaScript on the worker thread.
*
* @param[in] message The message to parse and handle.
*/
static void HandleMessage(struct PP_Var message)
{
const char *function_name,*error; struct PP_Var params,result_var;
if ( ParseMessage(message, &function_name, ¶ms) != 0 )
{
PNACL_message("Error: Unable to parse message");
return;
}
HandleFunc function = GetFunctionByName(function_name);
if ( function == 0 )
{
PNACL_message("Error: Unknown function \"%s\"", function_name); // Function name wasn't found.
return;
}
// Function name was found, call it.
int result = (*function)(params, &result_var, &error);
if ( result != 0 )
{
if ( error != NULL )
{
PNACL_message("Error: \"%s\" failed: %s.", function_name, error);
free((void*)error);
}
else PNACL_message("Error: \"%s\" failed.", function_name);
return;
}
// Function returned an output dictionary. Send it to JavaScript.
g_ppb_messaging->PostMessage(g_instance, result_var);
g_ppb_var->Release(result_var);
}
#define MAX_QUEUE_SIZE 256
// A mutex that guards |g_queue|.
static pthread_mutex_t g_queue_mutex;
// A condition variable that is signalled when |g_queue| is not empty.
static pthread_cond_t g_queue_not_empty_cond;
/** A circular queue of messages from JavaScript to be handled.
*
* If g_queue_start < g_queue_end:
* all elements in the range [g_queue_start, g_queue_end) are valid.
* If g_queue_start > g_queue_end:
* all elements in the ranges [0, g_queue_end) and
* [g_queue_start, MAX_QUEUE_SIZE) are valid.
* If g_queue_start == g_queue_end, and g_queue_size > 0:
* all elements in the g_queue are valid.
* If g_queue_start == g_queue_end, and g_queue_size == 0:
* No elements are valid. */
static struct PP_Var g_queue[MAX_QUEUE_SIZE];
static int g_queue_start = 0; // The index of the head of the queue
static int g_queue_end = 0; // The index of the tail of the queue, non-inclusive.
static int g_queue_size = 0;
// NOTE: this function assumes g_queue_mutex lock is held. @return non-zero if the queue is empty
static int IsQueueEmpty() { return g_queue_size == 0; }
// NOTE: this function assumes g_queue_mutex lock is held. @return non-zero if the queue is full
static int IsQueueFull() { return g_queue_size == MAX_QUEUE_SIZE; }
void InitializeMessageQueue()
{
pthread_mutex_init(&g_queue_mutex, NULL);
pthread_cond_init(&g_queue_not_empty_cond, NULL);
}
int EnqueueMessage(struct PP_Var message)
{
pthread_mutex_lock(&g_queue_mutex);
// We shouldn't block the main thread waiting for the queue to not be full, so just drop the message.
if ( IsQueueFull() != 0)
{
PNACL_message("EnqueueMessage: full Q, drop message\n");
pthread_mutex_unlock(&g_queue_mutex);
return(0);
}
g_queue[g_queue_end] = message;
g_queue_end = (g_queue_end + 1) % MAX_QUEUE_SIZE;
g_queue_size++;
pthread_cond_signal(&g_queue_not_empty_cond);
pthread_mutex_unlock(&g_queue_mutex);
return 1;
}
struct PP_Var DequeueMessage()
{
struct PP_Var message;
pthread_mutex_lock(&g_queue_mutex);
while ( IsQueueEmpty() != 0 )
pthread_cond_wait(&g_queue_not_empty_cond, &g_queue_mutex);
message = g_queue[g_queue_start];
g_queue_start = (g_queue_start + 1) % MAX_QUEUE_SIZE;
g_queue_size--;
pthread_mutex_unlock(&g_queue_mutex);
return(message);
}
/**
* A worker thread that handles messages from JavaScript.
* @param[in] user_data Unused.
* @return unused.
*/
void *HandleMessageThread(void *user_data)
{
while ( 1 )
{
struct PP_Var message = DequeueMessage();
HandleMessage(message);
g_ppb_var->Release(message);
}
}
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#undef mount
#undef umount
static PP_Bool Instance_DidCreate(PP_Instance instance,uint32_t argc,const char* argn[],const char* argv[])
{
int nacl_io_init_ppapi(PP_Instance instance, PPB_GetInterface get_interface);
static pthread_t g_handle_message_thread,chromeapp_thread;
long allocsize;
g_instance = instance;
// By default, nacl_io mounts / to pass through to the original NaCl
// filesystem (which doesn't do much). Let's remount it to a memfs filesystem.
OS_init();
InitializeMessageQueue();
pthread_create(&g_handle_message_thread, NULL, &HandleMessageThread, NULL);
pthread_create(&chromeapp_thread,NULL,&CHROMEAPP_NAME,OS_filestr(&allocsize,CHROMEAPP_CONF));
nacl_io_init_ppapi(instance,g_get_browser_interface);
umount("/");
mount("", "/", "memfs", 0, "");
//mkdir("/tmp",0755);
mkdir("DB",0755);
//mount("","/tmp","html5fs",0,"type=TEMPORARY,expected_size=2000000000");
mount("","DB","html5fs",0,"type=PERSISTENT,expected_size=10000000000");
/*mount("", // source. Use relative URL
"/http", // target
"httpfs", // filesystemtype
0, // mountflags
""); // data*/
PNACL_message("finished DidCreate %s\n",CHROMEAPP_STR);
MAIN_initflag = 1;
return PP_TRUE;
}
static void Instance_DidDestroy(PP_Instance instance) { }
static void Instance_DidChangeView(PP_Instance instance,PP_Resource view_resource) { }
static void Instance_DidChangeFocus(PP_Instance instance, PP_Bool has_focus) { }
static PP_Bool Instance_HandleDocumentLoad(PP_Instance instance,PP_Resource url_loader)
{
// NaCl modules do not need to handle the document load function.
return PP_FALSE;
}
static void Messaging_HandleMessage(PP_Instance instance,struct PP_Var message)
{
if ( message.type != PP_VARTYPE_DICTIONARY ) // Special case for jspipe input handling
{
PNACL_message("Got unexpected message type: %d\n", message.type);
return;
}
struct PP_Var pipe_var = CStrToVar("pipe");
struct PP_Var pipe_name = g_ppb_var_dictionary->Get(message, pipe_var);
g_ppb_var->Release(pipe_var);
if ( pipe_name.type == PP_VARTYPE_STRING ) // Special case for jspipe input handling
{
char file_name[PATH_MAX];
snprintf(file_name, PATH_MAX, "/dev/%s", VarToCStr(pipe_name));
int fd = open(file_name, O_RDONLY);
g_ppb_var->Release(pipe_name);
if ( fd < 0 )
{
PNACL_message("Warning: opening %s failed.", file_name);
goto done;
}
//if ( ioctl(fd, NACL_IOC_HANDLEMESSAGE, &message) != 0 )
// PNACL_message("Error: ioctl on %s failed: %s", file_name, strerror(errno));
close(fd);
goto done;
}
g_ppb_var->AddRef(message);
if ( !EnqueueMessage(message) )
{
g_ppb_var->Release(message);
PNACL_message("Warning: dropped message because the queue was full.");
}
done:
g_ppb_var->Release(pipe_name);
}
#define GET_INTERFACE(var, type, name) \
var = (type*)(get_browser(name)); \
if (!var) { \
printf("Unable to get interface " name "\n"); \
return PP_ERROR_FAILED; \
}
//PP_EXPORT
int32_t PPP_InitializeModule(PP_Module a_module_id,PPB_GetInterface get_browser)
{
g_get_browser_interface = get_browser;
GET_INTERFACE(g_ppb_messaging, PPB_Messaging, PPB_MESSAGING_INTERFACE);
GET_INTERFACE(g_ppb_var, PPB_Var, PPB_VAR_INTERFACE);
GET_INTERFACE(g_ppb_var_array, PPB_VarArray, PPB_VAR_ARRAY_INTERFACE);
GET_INTERFACE(g_ppb_var_dictionary, PPB_VarDictionary, PPB_VAR_DICTIONARY_INTERFACE);
return PP_OK;
}
//PP_EXPORT
const void *PPP_GetInterface(const char* interface_name)
{
if ( strcmp(interface_name,PPP_INSTANCE_INTERFACE) == 0 )
{
static PPP_Instance instance_interface =
{
&Instance_DidCreate,
&Instance_DidDestroy,
&Instance_DidChangeView,
&Instance_DidChangeFocus,
&Instance_HandleDocumentLoad,
};
return &instance_interface;
}
else if ( strcmp(interface_name, PPP_MESSAGING_INTERFACE) == 0 )
{
static PPP_Messaging messaging_interface = { &Messaging_HandleMessage };
return &messaging_interface;
}
return NULL;
}
//PP_EXPORT
void PPP_ShutdownModule() { }
#define CHECK_PARAM_COUNT(name, expected) \
if (GetNumParams(params) != expected) { \
*out_error = PrintfToNewString(#name " takes " #expected " parameters." \
" Got %d", GetNumParams(params)); \
return 1; \
}
#define PARAM_STRING(index, var) \
char* var; \
uint32_t var##_len; \
if (GetParamString(params, index, &var, &var##_len, out_error)) { \
return 1; \
}
#define CREATE_RESPONSE(name) CreateResponse(output, name, out_error)
#define RESPONSE_STRING(var) AppendResponseString(output, var, out_error)
#define RESPONSE_INT(var) AppendResponseInt(output, var, out_error)
#define MAX_PARAMS 4
static char* g_ParamStrings[MAX_PARAMS];
/**
* Get the number of parameters.
* @param[in] params The parameter array.
* @return uint32_t The number of parameters in the array.
*/
static uint32_t GetNumParams(struct PP_Var params) {
return g_ppb_var_array->GetLength(params);
}
/**
* Create a response PP_Var to send back to JavaScript.
* @param[out] response_var The response PP_Var.
* @param[in] cmd The name of the function that is being executed.
* @param[out] out_error An error message, if this call failed.
*/
static void CreateResponse(struct PP_Var* response_var,
const char* cmd,
const char** out_error) {
PP_Bool result;
struct PP_Var dict_var = g_ppb_var_dictionary->Create();
struct PP_Var cmd_key = CStrToVar("cmd");
struct PP_Var cmd_value = CStrToVar(cmd);
result = g_ppb_var_dictionary->Set(dict_var, cmd_key, cmd_value);
g_ppb_var->Release(cmd_key);
g_ppb_var->Release(cmd_value);
if (!result) {
g_ppb_var->Release(dict_var);
*out_error =
PrintfToNewString("Unable to set \"cmd\" key in result dictionary");
return;
}
struct PP_Var args_key = CStrToVar("args");
struct PP_Var args_value = g_ppb_var_array->Create();
result = g_ppb_var_dictionary->Set(dict_var, args_key, args_value);
g_ppb_var->Release(args_key);
g_ppb_var->Release(args_value);
if (!result) {
g_ppb_var->Release(dict_var);
*out_error =
PrintfToNewString("Unable to set \"args\" key in result dictionary");
return;
}
*response_var = dict_var;
}
/**
* Append a PP_Var to the response dictionary.
* @param[in,out] response_var The response PP_var.
* @param[in] value The value to add to the response args.
* @param[out] out_error An error message, if this call failed.
*/
static void AppendResponseVar(struct PP_Var* response_var,
struct PP_Var value,
const char** out_error) {
struct PP_Var args_value = GetDictVar(*response_var, "args");
uint32_t args_length = g_ppb_var_array->GetLength(args_value);
PP_Bool result = g_ppb_var_array->Set(args_value, args_length, value);
if (!result) {
// Release the dictionary that was there before.
g_ppb_var->Release(*response_var);
// Return an error message instead.
*response_var = PP_MakeUndefined();
*out_error = PrintfToNewString("Unable to append value to result");
return;
}
}
/**
* Append a string to the response dictionary.
* @param[in,out] response_var The response PP_var.
* @param[in] value The value to add to the response args.
* @param[out] out_error An error message, if this call failed.
*/
static void AppendResponseString(struct PP_Var* response_var,
const char* value,
const char** out_error) {
struct PP_Var value_var = CStrToVar(value);
AppendResponseVar(response_var, value_var, out_error);
g_ppb_var->Release(value_var);
}
/**
* Get a parameter at |index| as a string.
* @param[in] params The parameter array.
* @param[in] index The index in |params| to get.
* @param[out] out_string The output string.
* @param[out] out_string_len The length of the output string.
* @param[out] out_error An error message, if this operation failed.
* @return int 0 if successful, otherwise 1.
*/
static int GetParamString(struct PP_Var params,
uint32_t index,
char** out_string,
uint32_t* out_string_len,
const char** out_error) {
if (index >= MAX_PARAMS) {
*out_error = PrintfToNewString("Param index %u >= MAX_PARAMS (%d)",
index, MAX_PARAMS);
return 1;
}
struct PP_Var value = g_ppb_var_array->Get(params, index);
if (value.type != PP_VARTYPE_STRING) {
*out_error =
PrintfToNewString("Expected param at index %d to be a string not.%d", index,value.type);
return 1;
}
uint32_t length;
const char* var_str = g_ppb_var->VarToUtf8(value, &length);
char* string = (char*)malloc(length + 1);
memcpy(string, var_str, length);
string[length] = 0;
/* Put the allocated string in g_ParamStrings. This keeps us from leaking
* each parameter string, without having to do manual cleanup in every
* Handle* function below.
*/
free(g_ParamStrings[index]);
g_ParamStrings[index] = string;
*out_string = string;
*out_string_len = length;
return 0;
}
int CHROMEAPP_HANDLER(struct PP_Var params,struct PP_Var *output,const char **out_error)
{
char *CHROMEAPP_JSON(void *_myinfo,void *_coin,char *,uint16_t port);
char *retstr;
PNACL_message("inside Handle_%s\n",CHROMEAPP_STR);
CHECK_PARAM_COUNT(CHROMEAPP_STR, 1);
PARAM_STRING(0,jsonstr);
if ( jsonstr == 0 )
retstr = clonestr("{\"error\":\"illegal null jsonstr received\"}");
else if ( (retstr= CHROMEAPP_JSON(0,0,jsonstr,7778)) == 0 )
retstr = clonestr("{\"error\":\"null return\"}");
CREATE_RESPONSE(CHROMEAPP_STR);
RESPONSE_STRING(retstr);
return 0;
}
int example_main()
{
PNACL_message("Started %s example main.\n",CHROMEAPP_STR);
while ( 1 )
{
sleep(777);
}
return 0;
}
PSMainFunc_t PSUserMainGet()
{
return(example_main);
}
#else
int main(int argc, const char * argv[])
{
char *jsonstr;
if ( argc < 2 )
jsonstr = 0;
else jsonstr = (char *)argv[1];
MAIN_initflag = 1;
OS_init();
printf("%s main\n",CHROMEAPP_STR);
CHROMEAPP_NAME(jsonstr);
return 0;
}
#endif