#pragma once
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <errno.h>
#include <inttypes.h>
#include <systemd/sd-bus.h>
#include <systemd/sd-id128.h>
#include <syslog.h>
#include <dirent.h>
#include <sys/stat.h>
#include "cJSON.h"
#include <sqlcipher/sqlite3.h>
#include <sqlcipher/sqlite3ext.h>
//#include <unistd.h>

#define new0(t, n) ((t*) calloc((n), sizeof(t)))

#define SERVICE_NAME "com.kylin.kydoctor"
#define OBJECT_PATH "/com/kylin/kydoctor"
#define INTERFACE_NAME "com.kylin.kydoctor"

#define DEFAULT_EXIT_USEC 60*1000000

//"/opt/kydoctor/common/checkitem.json"
//"/tmp/kydoctor" 
#define CHECECKITEM_JSON_PATH   "/tmp/kydoctor" 
#define CHECKITEMS_SIZE 10240
#define CHECKITEM_LINE_SIZE 1024

#define READ_DATA_SIZE  2048

#define CHECK_PRG_PATH "/opt/kydoctor/check/"
#define REPAIR_PRG_PATH "/opt/kydoctor/repair/"

struct check_pathmap
{
        int64_t typecode;
        char* path;
}check_pathmaps[] = {
        {0x0100040000000000, "/opt/kydoctor/check/hardware/memory/"},
        {0x0100050000000000, "/opt/kydoctor/check/hardware/disk/"},
        {0x0100070000000000, "/opt/kydoctor/check/hardware/netcard/"},
        {0x0100090000000000, "/opt/kydoctor/check/hardware/monitor/"},
        {0x0200030000000000, "/opt/kydoctor/check/kernel/memory/"},
        {0x0300090000000000, "/opt/kydoctor/check/system_service/power_manager/"},
        {0x0300060000000000, "/opt/kydoctor/check/system_service/network/"},
        {0x0500230000000000, "/opt/kydoctor/check/application_software/qaxsafe/"},
};

enum solutiontype {
        USER_CMD = 0x0100000000000000,
        ROOT_CMD = 0x0101000000000000,
        UPDATE_PACKAGE = 0x0201000000000000,
        //后续继续补充
};

typedef struct Manager Manager;

struct Manager {
        sd_bus* bus;
        sd_bus_slot* slot;

        // Add some configurations here.
};

extern Manager* manager;

