This source file includes following definitions.
- ubasic_run_restore
- _set_variable
- ubasic_init_file
- ubasic_script_shoot_hook_run
- module_unloader
1 #include "camera_info.h"
2 #include "gui.h"
3 #include "fileutil.h"
4 #include "conf.h"
5
6 #include "script_api.h"
7 #include "module_def.h"
8 #include "gui_lang.h"
9
10
11
12
13
14 int ubasic_init(const char *program, int is_ptp);
15 int ubasic_run(void);
16 void ubasic_end(void);
17 void ubasic_set_variable(int varum, int value);
18 void ubasic_set_as_ret(int md_ret);
19 int jump_label(char * label);
20
21 static int ubasic_run_restore(void) { return jump_label("restore"); }
22
23 static void _set_variable(char *name, int value,
24 __attribute__ ((unused))int isBool, __attribute__ ((unused))int isTable, __attribute__ ((unused))int labelCount, __attribute__ ((unused))const char **labels)
25 {
26 ubasic_set_variable(name[0] - (name[0]>='a'?'a':('A'-26)), value);
27 }
28
29 static char *script_source = 0;
30 static char last_script[100] = "";
31
32 static int ubasic_init_file(char const* filename)
33 {
34 if (strcmp(last_script, filename) != 0)
35 {
36 strcpy(last_script, filename);
37 if (script_source)
38 free(script_source);
39 script_source = load_file(filename, 0, 1);
40 }
41 if (script_source)
42 {
43 return ubasic_init(script_source, 0);
44 }
45 return 0;
46 }
47
48
49 static void ubasic_script_shoot_hook_run(__attribute__ ((unused))int hook) { return; }
50
51
52 static int module_unloader()
53 {
54 if (script_source)
55 {
56 free(script_source);
57 script_source = 0;
58 }
59 return 0;
60 }
61
62 libscriptapi_sym _libubasic =
63 {
64 {
65 0, module_unloader, 0, 0, 0
66 },
67
68 ubasic_init,
69 ubasic_init_file,
70 ubasic_run,
71 ubasic_end,
72 _set_variable,
73 ubasic_set_as_ret,
74 ubasic_run_restore,
75 ubasic_script_shoot_hook_run,
76 };
77
78 ModuleInfo _module_info =
79 {
80 MODULEINFO_V1_MAGICNUM,
81 sizeof(ModuleInfo),
82 SCRIPT_API_VERSION,
83
84 ANY_CHDK_BRANCH, 0, OPT_ARCHITECTURE,
85 ANY_PLATFORM_ALLOWED,
86
87 -LANG_MODULE_UBASIC,
88 MTYPE_SCRIPT_LANG,
89
90 &_libubasic.base,
91
92 CONF_VERSION,
93 CAM_SCREEN_VERSION,
94 CAM_SENSOR_VERSION,
95 CAM_INFO_VERSION,
96
97 0,
98 };
99
100