1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <cstdio>
17 #include <cstring>
18 #include <string>
19 #include "log/log.h"
20 #include "utils.h"
21 
main(int argc,char ** argv)22 int main(int argc, char **argv)
23 {
24     if (argc > Updater::Utils::ARGC_TWO_NUMS) {
25         Updater::LOG(Updater::ERROR) << "param must be nullptr or updater.";
26         return 1;
27     }
28     if (argc == 1) {
29         Updater::LOG(Updater::INFO) << "Updater::Utils::UpdaterDoReboot nullptr";
30         Updater::Utils::UpdaterDoReboot("");
31     } else {
32         std::string updaterStr = "updater";
33         if (!memcmp(argv[1], updaterStr.c_str(), updaterStr.length())) {
34             Updater::Utils::UpdaterDoReboot(argv[1]);
35         } else if (strcmp(argv[1], "flashd") == 0) {
36             Updater::Utils::UpdaterDoReboot(argv[1]);
37         } else if (strncmp(argv[1], "flashd:", strlen("flashd:")) == 0) {
38             Updater::Utils::UpdaterDoReboot("flashd", argv[1] + strlen("flashd:"));
39         } else {
40             Updater::LOG(Updater::INFO) << "param must be updater/flashd!";
41         }
42     }
43     return 0;
44 }
45 
46