diff options
author | Doug Zongker | 2009-06-11 19:21:44 -0500 |
---|---|---|
committer | Doug Zongker | 2009-06-12 11:40:37 -0500 |
commit | 8edb00c990e563e6f91b278a212f2edf877cf763 (patch) | |
tree | dcd6c0fb2ce82fcb5b43ed47dc74879cfe71b647 /edify | |
parent | 9dbc027b5f540bcf23c968398f8a70e92abd56cd (diff) | |
download | platform-bootable-recovery-8edb00c990e563e6f91b278a212f2edf877cf763.tar.gz platform-bootable-recovery-8edb00c990e563e6f91b278a212f2edf877cf763.tar.xz platform-bootable-recovery-8edb00c990e563e6f91b278a212f2edf877cf763.zip |
edify extensions for OTA package installation, part 2
Adds more edify functions for OTAs:
is_mounted getprop apply_patch apply_patch_check apply_patch_space
write_raw_image write_firmware_image package_extract_file
This allows us to install radios, hboots, boot images, and install
incremental OTA packages.
Fixes a couple of dumb bugs in edify itself:
- we were doubling the size of the function table each time it was
*not* full, rather than each time it was full
- "no such function" errors weren't visible to the parser, so they
didn't prevent execution of the script.
Diffstat (limited to 'edify')
-rw-r--r-- | edify/expr.c | 2 | ||||
-rw-r--r-- | edify/main.c | 7 | ||||
-rw-r--r-- | edify/parser.y | 10 |
3 files changed, 11 insertions, 8 deletions
diff --git a/edify/expr.c b/edify/expr.c index 129fbd96..5470a2ba 100644 --- a/edify/expr.c +++ b/edify/expr.c | |||
@@ -283,7 +283,7 @@ static int fn_size = 0; | |||
283 | NamedFunction* fn_table = NULL; | 283 | NamedFunction* fn_table = NULL; |
284 | 284 | ||
285 | void RegisterFunction(const char* name, Function fn) { | 285 | void RegisterFunction(const char* name, Function fn) { |
286 | if (fn_entries <= fn_size) { | 286 | if (fn_entries >= fn_size) { |
287 | fn_size = fn_size*2 + 1; | 287 | fn_size = fn_size*2 + 1; |
288 | fn_table = realloc(fn_table, fn_size * sizeof(NamedFunction)); | 288 | fn_table = realloc(fn_table, fn_size * sizeof(NamedFunction)); |
289 | } | 289 | } |
diff --git a/edify/main.c b/edify/main.c index c9596837..7da89e2e 100644 --- a/edify/main.c +++ b/edify/main.c | |||
@@ -153,10 +153,11 @@ int main(int argc, char** argv) { | |||
153 | buffer[size] = '\0'; | 153 | buffer[size] = '\0'; |
154 | 154 | ||
155 | Expr* root; | 155 | Expr* root; |
156 | int error_count = 0; | ||
156 | yy_scan_bytes(buffer, size); | 157 | yy_scan_bytes(buffer, size); |
157 | int error = yyparse(&root); | 158 | int error = yyparse(&root, &error_count); |
158 | printf("parse returned %d\n", error); | 159 | printf("parse returned %d; %d errors encountered\n", error, error_count); |
159 | if (error == 0) { | 160 | if (error == 0 || error_count > 0) { |
160 | char* result = Evaluate(NULL, root); | 161 | char* result = Evaluate(NULL, root); |
161 | if (result == NULL) { | 162 | if (result == NULL) { |
162 | char* errmsg = GetError(); | 163 | char* errmsg = GetError(); |
diff --git a/edify/parser.y b/edify/parser.y index 67a210fc..cf163c02 100644 --- a/edify/parser.y +++ b/edify/parser.y | |||
@@ -25,8 +25,8 @@ | |||
25 | extern int gLine; | 25 | extern int gLine; |
26 | extern int gColumn; | 26 | extern int gColumn; |
27 | 27 | ||
28 | void yyerror(Expr** root, const char* s); | 28 | void yyerror(Expr** root, int* error_count, const char* s); |
29 | int yyparse(Expr** root); | 29 | int yyparse(Expr** root, int* error_count); |
30 | 30 | ||
31 | %} | 31 | %} |
32 | 32 | ||
@@ -45,6 +45,7 @@ int yyparse(Expr** root); | |||
45 | %type <args> arglist | 45 | %type <args> arglist |
46 | 46 | ||
47 | %parse-param {Expr** root} | 47 | %parse-param {Expr** root} |
48 | %parse-param {int* error_count} | ||
48 | %error-verbose | 49 | %error-verbose |
49 | 50 | ||
50 | /* declarations in increasing order of precedence */ | 51 | /* declarations in increasing order of precedence */ |
@@ -86,7 +87,7 @@ expr: STRING { | |||
86 | if ($$->fn == NULL) { | 87 | if ($$->fn == NULL) { |
87 | char buffer[256]; | 88 | char buffer[256]; |
88 | snprintf(buffer, sizeof(buffer), "unknown function \"%s\"", $1); | 89 | snprintf(buffer, sizeof(buffer), "unknown function \"%s\"", $1); |
89 | yyerror(root, buffer); | 90 | yyerror(root, error_count, buffer); |
90 | YYERROR; | 91 | YYERROR; |
91 | } | 92 | } |
92 | $$->name = $1; | 93 | $$->name = $1; |
@@ -113,9 +114,10 @@ arglist: /* empty */ { | |||
113 | 114 | ||
114 | %% | 115 | %% |
115 | 116 | ||
116 | void yyerror(Expr** root, const char* s) { | 117 | void yyerror(Expr** root, int* error_count, const char* s) { |
117 | if (strlen(s) == 0) { | 118 | if (strlen(s) == 0) { |
118 | s = "syntax error"; | 119 | s = "syntax error"; |
119 | } | 120 | } |
120 | printf("line %d col %d: %s\n", gLine, gColumn, s); | 121 | printf("line %d col %d: %s\n", gLine, gColumn, s); |
122 | ++*error_count; | ||
121 | } | 123 | } |