2 * Network Configuration Module
4 * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
23 #include "mesh-util.h"
24 #include "mesh-service.h"
26 mesh_service *meshd_service_new()
28 mesh_service *service;
30 service = g_malloc0(sizeof(struct _mesh_service));
32 /* Create g-main loop */
33 service->main_loop = g_main_loop_new(NULL, FALSE);
34 if (G_UNLIKELY(NULL == service->main_loop)) {
35 MESH_LOGE("g-main loop creation failed!!!");
43 void meshd_service_free(mesh_service *service)
45 meshd_check_null_ret("service", service);
47 /* Unref 'g-main loop' */
48 if (service->main_loop)
49 g_main_loop_unref(service->main_loop);
54 gboolean meshd_service_run(mesh_service *service)
56 meshd_check_null_ret_error("service", service, FALSE);
57 meshd_check_null_ret_error("service->main_loop", service->main_loop, FALSE);
59 g_main_loop_run(service->main_loop);
64 gboolean meshd_service_exit(mesh_service *service)
66 meshd_check_null_ret_error("service", service, FALSE);
67 meshd_check_null_ret_error("service->main_loop", service->main_loop, FALSE);
69 g_main_loop_quit(service->main_loop);