1 /*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <stdio.h>
18 #include <errno.h>
19 #include <stdarg.h>
20 #include <stdlib.h>
21 #include <string.h>
22
23 #include "edify/expr.h"
24 #include "update_cdma_modem.h"
25
UpdateCdmaModemFn(const char * name,State * state,int argc,Expr * argv[])26 Value* UpdateCdmaModemFn(const char* name, State* state, int argc, Expr* argv[])
27 {
28 int result = -1;
29 Value* img;
30
31 if (argc != 1) {
32 return ErrorAbort(state, "%s() expects 1 arg, got %d", name, argc);
33 }
34
35 if (ReadValueArgs(state, argv, 1, &img) < 0) {
36 return NULL;
37 }
38
39 if(img->type != VAL_BLOB) {
40 FreeValue(img);
41 return ErrorAbort(state, "%s(): argument types are incorrect", name);
42 }
43
44 result = update_cdma_modem(img->data, img->size);
45 FreeValue(img);
46 return StringValue(strdup(result == 0 ? "t" : ""));
47 }
48
Register_librecovery_updater_toro()49 void Register_librecovery_updater_toro() {
50 fprintf(stderr, "installing samsung updater extensions for toro\n");
51
52 RegisterFunction("samsung.update_cdma_modem", UpdateCdmaModemFn);
53 }
54