#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
#include <sys/wait.h>
#include <time.h>
#include <math.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#include <syslog.h>
#include <dirent.h>
#include <stdbool.h>
#include <linux/version.h>
#include <sys/wait.h>

#include <syslog.h>
#include "bus-wait-for-jobs.h"
#include "main-func.h"
#include "sd-bus.h"

static int run(int argc, char* argv[])
{
    _cleanup_(sd_bus_message_unrefp) sd_bus_message *msg = NULL, *reply = NULL;
    _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
    _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
    const char *object = NULL;
    int r, ret = 0;

    ret = sd_bus_open_system(&bus);
    if (ret < 0) {
        fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-ret));
    }

    r = sd_bus_call_method(
            bus,
            "org.freedesktop.systemd1",
            "/org/freedesktop/systemd1",
            "org.freedesktop.systemd1.Manager",
            "StartUnit",
            &error,
            &msg,
            "ss",
            "systemd-logind.service",
            "fail");
    if (r >= 0) {
        r = sd_bus_message_read(msg, "o", &object);
        if (r >= 0) {
             log_info("preload systemd-logind.service object:%s", object);
        }
    }

    return EXIT_SUCCESS;
}

DEFINE_MAIN_FUNCTION(run);