1 /* 2 * Copyright (C) 2015-2019 Alibaba Group Holding Limited 3 */ 4 5 #ifndef APP_MGR_H 6 #define APP_MGR_H 7 8 #include <stdio.h> 9 #include <string.h> 10 // #include <unistd.h> 11 12 /* complete = 0 success, 1 check success(EOF), -1 check failed */ 13 typedef int (*write_js_cb_t)(const char *filename, int32_t file_size, 14 int32_t type, int32_t offset, uint8_t *buf, 15 int32_t buf_len, int32_t complete); 16 17 /* write js file into filesystem, callback function */ 18 int write_app_pack(const char *filename, int32_t file_size, int32_t type, 19 int32_t offset, uint8_t *buf, int32_t buf_len, 20 int32_t complete); 21 22 /* js pack parser */ 23 void apppack_init(write_js_cb_t cb); 24 25 int apppack_update(uint8_t *ptr, int size); 26 27 void apppack_final(void); 28 29 /* report process state to webIDE */ 30 void apppack_post_process_state(void); 31 32 /* get apppack from URL */ 33 typedef int (*download_js_cb_t)(uint8_t *buf, int32_t buf_len); 34 int apppack_download(char *url, download_js_cb_t func); 35 36 /* get apppack and upgrade from URL */ 37 int apppack_upgrade(char *url); 38 39 #ifdef LINUXOSX 40 typedef struct { 41 char *url; 42 int file_size; 43 char md5[32 + 1]; 44 int type; 45 } upgrade_image_param_t; 46 int simulator_upgrade(upgrade_image_param_t *p_info); 47 #endif 48 49 int app_mgr_open_file(const char *targetname); 50 51 void app_js_stop(void); 52 53 int32_t app_js_restart(void); 54 55 #endif /* APP_MGR_H */ 56