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.
22 #include "wmesh-log.h"
23 #include "wmesh-util.h"
24 #include "wmesh-service.h"
26 wmesh_service *wmeshd_service_new()
28 wmesh_service *service;
30 service = g_malloc0(sizeof(struct _wmesh_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 WMESH_LOGE("g-main loop creation failed!!!");
43 void wmeshd_service_free(wmesh_service *service)
45 wmeshd_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 wmeshd_service_run(wmesh_service *service)
56 wmeshd_check_null_ret_error("service", service, FALSE);
57 wmeshd_check_null_ret_error("service->main_loop", service->main_loop, FALSE);
59 g_main_loop_run(service->main_loop);
64 gboolean wmeshd_service_exit(wmesh_service *service)
66 wmeshd_check_null_ret_error("service", service, FALSE);
67 wmeshd_check_null_ret_error("service->main_loop", service->main_loop, FALSE);
69 g_main_loop_quit(service->main_loop);