| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* GATE PROJECT LICENSE: | ||
| 2 | +----------------------------------------------------------------------------+ | ||
| 3 | | Copyright(c) 2018-2025, Stefan Meislinger | | ||
| 4 | | All rights reserved. | | ||
| 5 | | | | ||
| 6 | | Redistribution and use in source and binary forms, with or without | | ||
| 7 | | modification, are permitted provided that the following conditions are met:| | ||
| 8 | | | | ||
| 9 | | 1. Redistributions of source code must retain the above copyright notice, | | ||
| 10 | | this list of conditions and the following disclaimer. | | ||
| 11 | | 2. Redistributions in binary form must reproduce the above copyright | | ||
| 12 | | notice, this list of conditions and the following disclaimer in the | | ||
| 13 | | documentation and/or other materials provided with the distribution. | | ||
| 14 | | | | ||
| 15 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"| | ||
| 16 | | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | ||
| 17 | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | ||
| 18 | | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | | ||
| 19 | | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | ||
| 20 | | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | ||
| 21 | | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | ||
| 22 | | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | ||
| 23 | | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | ||
| 24 | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | | ||
| 25 | | THE POSSIBILITY OF SUCH DAMAGE. | | ||
| 26 | +----------------------------------------------------------------------------+ | ||
| 27 | */ | ||
| 28 | |||
| 29 | #include "gate/system/services.h" | ||
| 30 | #include "gate/debugging.h" | ||
| 31 | |||
| 32 | |||
| 33 | #if defined(GATE_SYS_WIN) | ||
| 34 | /* not handled here, see services_win.c */ | ||
| 35 | #elif defined(GATE_SYS_POSIX) | ||
| 36 | /* not handled here, see services_posix.c */ | ||
| 37 | #elif defined(GATE_SYS_EFI) | ||
| 38 | # define GATE_SYSTEM_SERVICES_NO_IMPL | ||
| 39 | #elif defined(GATE_SYS_DOS) | ||
| 40 | # define GATE_SYSTEM_SERVICES_NO_IMPL | ||
| 41 | #else | ||
| 42 | # define GATE_SYSTEM_SERVICES_NO_IMPL | ||
| 43 | #endif | ||
| 44 | |||
| 45 | |||
| 46 | |||
| 47 | /* generic implementation: */ | ||
| 48 | 1 | char const* gate_service_print_state(gate_enumint_t state) | |
| 49 | { | ||
| 50 |
1/7✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
1 | switch (state) |
| 51 | { | ||
| 52 | ✗ | case GATE_SERVICE_STATE_STOPPED: return "Stopped"; | |
| 53 | 1 | case GATE_SERVICE_STATE_RUNNING: return "Running"; | |
| 54 | ✗ | case GATE_SERVICE_STATE_ERROR: return "Error"; | |
| 55 | ✗ | case GATE_SERVICE_STATE_PAUSED: return "Paused"; | |
| 56 | ✗ | case GATE_SERVICE_STATE_STARTING: return "Starting"; | |
| 57 | ✗ | case GATE_SERVICE_STATE_STOPPING: return "Stopping"; | |
| 58 | ✗ | default: | |
| 59 | ✗ | case GATE_SERVICE_STATE_UNKNOWN: return "Unknown"; | |
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | |||
| 64 | |||
| 65 | #if defined(GATE_SYSTEM_SERVICES_NO_IMPL) | ||
| 66 | |||
| 67 | gate_result_t gate_services_enum(gate_service_enum_callback_t callback, void* user_param) | ||
| 68 | { | ||
| 69 | (void)callback; | ||
| 70 | (void)user_param; | ||
| 71 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 72 | } | ||
| 73 | |||
| 74 | gate_result_t gate_service_start(gate_string_t const* name, gate_service_message_callback_t msg_callback, void* user_param) | ||
| 75 | { | ||
| 76 | (void)name; | ||
| 77 | (void)msg_callback; | ||
| 78 | (void)user_param; | ||
| 79 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 80 | } | ||
| 81 | |||
| 82 | gate_result_t gate_service_stop(gate_string_t const* name, gate_uint32_t wait_timeout, gate_bool_t force, | ||
| 83 | gate_service_message_callback_t msg_callback, void* user_param) | ||
| 84 | { | ||
| 85 | (void)name; | ||
| 86 | (void)wait_timeout; | ||
| 87 | (void)force; | ||
| 88 | (void)msg_callback; | ||
| 89 | (void)user_param; | ||
| 90 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 91 | } | ||
| 92 | |||
| 93 | gate_result_t gate_service_get_config(gate_string_t const* name, gate_service_config_t* config) | ||
| 94 | { | ||
| 95 | (void)name; | ||
| 96 | (void)config; | ||
| 97 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 98 | } | ||
| 99 | |||
| 100 | gate_result_t gate_service_get_status(gate_string_t const* name, gate_enumint_t* state, gate_string_t* process_id) | ||
| 101 | { | ||
| 102 | (void)name; | ||
| 103 | (void)state; | ||
| 104 | (void)process_id; | ||
| 105 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 106 | } | ||
| 107 | |||
| 108 | gate_result_t gate_service_register(gate_string_t const* name, gate_string_t const* command, gate_string_t const* descr, | ||
| 109 | gate_uint32_t flags, gate_string_t const* dependencies, | ||
| 110 | gate_service_message_callback_t msg_callback, void* user_param) | ||
| 111 | { | ||
| 112 | (void)name; | ||
| 113 | (void)command; | ||
| 114 | (void)descr; | ||
| 115 | (void)flags; | ||
| 116 | (void)dependencies; | ||
| 117 | (void)msg_callback; | ||
| 118 | (void)user_param; | ||
| 119 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 120 | } | ||
| 121 | |||
| 122 | gate_result_t gate_service_unregister(gate_string_t const* name, | ||
| 123 | gate_service_message_callback_t msg_callback, void* user_param) | ||
| 124 | { | ||
| 125 | (void)name; | ||
| 126 | (void)msg_callback; | ||
| 127 | (void)user_param; | ||
| 128 | return GATE_RESULT_NOTIMPLEMENTED; | ||
| 129 | } | ||
| 130 | |||
| 131 | |||
| 132 | #endif /* GATE_SYSTEM_SERVICES_NO_IMPL */ | ||
| 133 |