• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eclipse-bluechi / bluechi / 16743008054

05 Aug 2025 07:02AM UTC coverage: 78.083% (+7.4%) from 70.652%
16743008054

push

github

engelmi
Added pypi release section to maintainer readme

Signed-off-by: Michael Engel <mengel@redhat.com>

5369 of 6876 relevant lines covered (78.08%)

991.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/client/method-is-enabled.c
1
/*
2
 * Copyright Contributors to the Eclipse BlueChi project
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
5
 */
6
#include <stdlib.h>
7

8
#include "client.h"
9
#include "method-is-enabled.h"
10
#include "usage.h"
11

12
#include "libbluechi/common/opt.h"
13
#include "libbluechi/common/string-util.h"
14

15
static int method_is_enabled_on(Client *client, char *node_name, char *unit_file) {
×
16
        int r = 0;
×
17
        _cleanup_sd_bus_error_ sd_bus_error error = SD_BUS_ERROR_NULL;
×
18
        _cleanup_sd_bus_message_ sd_bus_message *result = NULL;
×
19
        const char *state = NULL;
×
20

21
        r = assemble_object_path_string(NODE_OBJECT_PATH_PREFIX, node_name, &client->object_path);
×
22
        if (r < 0) {
×
23
                return r;
24
        }
25

26
        r = sd_bus_call_method(
×
27
                        client->api_bus,
28
                        BC_INTERFACE_BASE_NAME,
29
                        client->object_path,
×
30
                        NODE_INTERFACE,
31
                        "GetUnitFileState",
32
                        &error,
33
                        &result,
34
                        "s",
35
                        unit_file);
36
        if (r < 0) {
×
37
                fprintf(stderr, "Failed to issue method call: %s\n", error.message);
×
38
                return r;
39
        }
40

41
        r = sd_bus_message_read(result, "s", &state);
×
42
        if (r < 0) {
×
43
                fprintf(stderr, "Failed to read result of method call: %s\n", error.message);
×
44
                return r;
45
        }
46

47
        printf("%s\n", state);
×
48

49
        if (streq(state, "enabled") || streq(state, "enabled-runtime") || streq(state, "static") ||
×
50
            streq(state, "alias") || streq(state, "indirect") || streq(state, "generated")) {
×
51
                return 0;
×
52
        }
53

54
        return -1;
55
}
56

57
int method_is_enabled(Command *command, void *userdata) {
×
58
        return method_is_enabled_on(userdata, command->opargv[0], command->opargv[1]);
×
59
}
60

61
void usage_method_is_enabled() {
×
62
        usage_print_header();
×
63
        usage_print_description("Check whether unit file is enabled");
×
64
        usage_print_usage("bluechictl is-enabled [nodename] [unit]");
×
65
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc