root/modules/ubasic.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ubasic_run_restore
  2. _set_variable
  3. ubasic_init_file
  4. ubasic_script_shoot_hook_run
  5. module_unloader

   1 #include "camera_info.h"
   2 #include "stdlib.h"
   3 #include "gui.h"
   4 #include "fileutil.h"
   5 #include "conf.h"
   6 
   7 #include "script_api.h"
   8 #include "module_def.h"
   9 #include "gui_lang.h"
  10 
  11 /***************** BEGIN OF AUXILARY PART *********************
  12   ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION
  13  **************************************************************/
  14 
  15 int ubasic_init(const char *program, int is_ptp);
  16 int ubasic_run(void);
  17 void ubasic_end(void);
  18 void ubasic_set_variable(int varum, int value);
  19 void ubasic_set_as_ret(int md_ret);
  20 int jump_label(char * label);
  21 
  22 static int ubasic_run_restore(void)             { return jump_label("restore"); }
  23 
  24 static void _set_variable(char *name, int value, int isBool, int isTable, int labelCount, 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 // shoot hooks not supported in ubasic
  49 static void ubasic_script_shoot_hook_run(int hook) { return; }
  50 /******************** Module Information structure ******************/
  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,                 // Module version
  83 
  84     ANY_CHDK_BRANCH, 0, OPT_ARCHITECTURE,                       // Requirements of CHDK version
  85     ANY_PLATFORM_ALLOWED,               // Specify platform dependency
  86 
  87     -LANG_MODULE_UBASIC,        // Module name
  88     MTYPE_SCRIPT_LANG,          //Run uBasic Scripts
  89 
  90     &_libubasic.base,
  91 
  92     CONF_VERSION,               // CONF version
  93     CAM_SCREEN_VERSION,         // CAM SCREEN version
  94     CAM_SENSOR_VERSION,         // CAM SENSOR version
  95     CAM_INFO_VERSION,           // CAM INFO version
  96 };
  97 
  98 /*************** END OF AUXILARY PART *******************/

/* [<][>][^][v][top][bottom][index][help] */