hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdbool.h>
#include <sys/types.h>
#include <unistd.h>
#include <ctype.h>
#include <inttypes.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
 
#include <glib.h>
#include <pthread.h>
 
#include "json-c/json.h"
#include "system_manager.h"
 
static char command[128] = {""};
static char path[128] = {""};
 
void usage() {
    printf("Usage: %s [reboot|factory_reset|import_db|export_db|export_log|upgrade] file\n");
    exit(-1);
}
 
int main(int argc ,char **argv) {
    if (argc < 2)
        usage();
 
    if (!strcmp(argv[1], "reboot")) {
        system_reboot();
        return 0;
    }
    if (!strcmp(argv[1], "factory_reset")) {
        system_factory_reset();
        return 0;
    }
 
    if (argc < 3)
        usage();
    char *path = argv[2];
 
    if (!strcmp(argv[1], "import_db")) {
        system_import_db(path);
        return 0;
    }
    if (!strcmp(argv[1], "export_db")) {
        system_export_db(path);
        return 0;
    }
    if (!strcmp(argv[1], "export_log")) {
        system_export_log(path);
        return 0;
    }
    if (!strcmp(argv[1], "upgrade")) {
        system_upgrade(path);
        return 0;
    }
 
    return 0;
}