*
* Connection Manager
*
- * Copyright (C) 2013 BWM CarIT GmbH. All rights reserved.
+ * Copyright (C) 2013-2014 BMW Car IT GmbH.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
#endif
#include <glib.h>
+#include <errno.h>
#include "../src/connman.h"
-static connman_bool_t assert_rule(const char *table_name, const char *rule)
+static bool assert_rule(const char *table_name, const char *rule)
{
char *cmd, *output, **lines;
GError **error = NULL;
int i;
+ bool ret = true;
cmd = g_strdup_printf(IPTABLES_SAVE " -t %s", table_name);
g_spawn_command_line_sync(cmd, &output, NULL, NULL, error);
lines = g_strsplit(output, "\n", 0);
g_free(output);
+ if (!lines)
+ return false;
- for (i = 0; lines[i] != NULL; i++) {
+ for (i = 0; lines[i]; i++) {
DBG("lines[%02d]: %s\n", i, lines[i]);
if (g_strcmp0(lines[i], rule) == 0)
break;
}
- g_strfreev(lines);
- if (lines[i] == NULL)
- return FALSE;
+ if (!lines[i])
+ ret = false;
- return TRUE;
+ g_strfreev(lines);
+ return ret;
}
static void assert_rule_exists(const char *table_name, const char *rule)
static gchar *option_debug = NULL;
-static gboolean parse_debug(const char *key, const char *value,
+static bool parse_debug(const char *key, const char *value,
gpointer user_data, GError **error)
{
if (value)
else
option_debug = g_strdup("*");
- return TRUE;
+ return true;
}
static GOptionEntry options[] = {
context = g_option_context_new(NULL);
g_option_context_add_main_entries(context, options, NULL);
- if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) {
- if (error != NULL) {
+ if (!g_option_context_parse(context, &argc, &argv, &error)) {
+ if (error) {
g_printerr("%s\n", error->message);
g_error_free(error);
} else
g_option_context_free(context);
- __connman_log_init(argv[0], option_debug, FALSE, FALSE,
+ __connman_log_init(argv[0], option_debug, false, false,
"Unit Tests Connection Manager", VERSION);
__connman_iptables_init();