diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-04-30 14:12:58 +0300 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2012-05-01 06:08:49 +0200 |
commit | 90438269a0a7932755c14f436310f3436d98efd4 (patch) | |
tree | d233d8b62ff613c25ab718902b3f66b51f72c8e4 | |
parent | 0fb6b7e00d52b28c573cb5fde4262760fab9daca (diff) | |
download | connman-90438269a0a7932755c14f436310f3436d98efd4.tar.gz connman-90438269a0a7932755c14f436310f3436d98efd4.tar.bz2 connman-90438269a0a7932755c14f436310f3436d98efd4.zip |
timeserver: Helper function for adding timeservers once to a list
-rw-r--r-- | src/connman.h | 2 | ||||
-rw-r--r-- | src/timeserver.c | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/connman.h b/src/connman.h index 8610d9b8..550107ca 100644 --- a/src/connman.h +++ b/src/connman.h @@ -369,6 +369,8 @@ void __connman_timeserver_cleanup(void); char **__connman_timeserver_system_get(); +GSList *__connman_timeserver_add_list(GSList *server_list, + const char *timeserver); GSList *__connman_timeserver_get_all(struct connman_service *service); int __connman_timeserver_sync(struct connman_service *service); void __connman_timeserver_sync_next(); diff --git a/src/timeserver.c b/src/timeserver.c index 62e050ed..847f74ff 100644 --- a/src/timeserver.c +++ b/src/timeserver.c @@ -156,6 +156,23 @@ void __connman_timeserver_sync_next() return; } +GSList *__connman_timeserver_add_list(GSList *server_list, + const char *timeserver) +{ + GSList *list = server_list; + + if (timeserver == NULL) + return server_list; + + while (list != NULL) { + char *existing_server = list->data; + if (strcmp(timeserver, existing_server) == 0) + return server_list; + list = g_slist_next(list); + } + return g_slist_prepend(server_list, g_strdup(timeserver)); +} + /* * __connman_timeserver_get_all function creates the timeserver * list which will be used to determine NTP server for time corrections. |