settings/ifupdown: adjust coding style for "nms-ifupdown-interface-parser"
This commit is contained in:
@@ -34,25 +34,25 @@
|
||||
|
||||
if_block* first;
|
||||
if_block* last;
|
||||
|
||||
if_data* last_data;
|
||||
|
||||
void add_block(const char *type, const char* name)
|
||||
void
|
||||
add_block (const char *type, const char* name)
|
||||
{
|
||||
if_block *ret = g_slice_new0 (struct _if_block);
|
||||
ret->name = g_strdup (name);
|
||||
ret->type = g_strdup (type);
|
||||
if (first == NULL)
|
||||
first = last = ret;
|
||||
else
|
||||
{
|
||||
else {
|
||||
last->next = ret;
|
||||
last = ret;
|
||||
}
|
||||
last_data = NULL;
|
||||
}
|
||||
|
||||
void add_data(const char *key,const char *data)
|
||||
void
|
||||
add_data (const char *key, const char *data)
|
||||
{
|
||||
if_data *ret;
|
||||
char *idx;
|
||||
@@ -71,20 +71,18 @@ void add_data(const char *key,const char *data)
|
||||
}
|
||||
ret->data = g_strdup (data);
|
||||
|
||||
if (last->info == NULL)
|
||||
{
|
||||
if (last->info == NULL) {
|
||||
last->info = ret;
|
||||
last_data = ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
last_data->next = ret;
|
||||
last_data = last_data->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* join values in src with spaces into dst; dst needs to be large enough */
|
||||
static char *join_values_with_spaces(char *dst, char **src)
|
||||
static char *
|
||||
join_values_with_spaces (char *dst, char **src)
|
||||
{
|
||||
if (dst != NULL) {
|
||||
*dst = '\0';
|
||||
@@ -126,8 +124,7 @@ _recursive_ifparser (const char *eni_file, int quiet)
|
||||
if (!quiet)
|
||||
nm_log_info (LOGD_SETTINGS, " interface-parser: parsing file %s\n", eni_file);
|
||||
|
||||
while (!feof(inp))
|
||||
{
|
||||
while (!feof (inp)) {
|
||||
char *token[128]; /* 255 chars can only be split into 127 tokens */
|
||||
char value[255]; /* large enough to join previously split tokens */
|
||||
char *safeptr;
|
||||
@@ -301,13 +298,15 @@ _ifparser_source (const char *path, const char *en_dir, int quiet, int dir)
|
||||
g_free (abs_path);
|
||||
}
|
||||
|
||||
void ifparser_init (const char *eni_file, int quiet)
|
||||
void
|
||||
ifparser_init (const char *eni_file, int quiet)
|
||||
{
|
||||
first = last = NULL;
|
||||
_recursive_ifparser (eni_file, quiet);
|
||||
}
|
||||
|
||||
void _destroy_data(if_data *ifd)
|
||||
void
|
||||
_destroy_data (if_data *ifd)
|
||||
{
|
||||
if (ifd == NULL)
|
||||
return;
|
||||
@@ -318,7 +317,8 @@ void _destroy_data(if_data *ifd)
|
||||
return;
|
||||
}
|
||||
|
||||
void _destroy_block(if_block* ifb)
|
||||
void
|
||||
_destroy_block (if_block* ifb)
|
||||
{
|
||||
if (ifb == NULL)
|
||||
return;
|
||||
@@ -330,7 +330,8 @@ void _destroy_block(if_block* ifb)
|
||||
return;
|
||||
}
|
||||
|
||||
void ifparser_destroy(void)
|
||||
void
|
||||
ifparser_destroy (void)
|
||||
{
|
||||
_destroy_block (first);
|
||||
first = last = NULL;
|
||||
@@ -353,11 +354,11 @@ int ifparser_get_num_blocks(void)
|
||||
return i;
|
||||
}
|
||||
|
||||
if_block *ifparser_getif(const char* iface)
|
||||
if_block *
|
||||
ifparser_getif (const char* iface)
|
||||
{
|
||||
if_block *curr = first;
|
||||
while(curr!=NULL)
|
||||
{
|
||||
while (curr != NULL) {
|
||||
if (strcmp (curr->type,"iface")==0 && strcmp (curr->name,iface)==0)
|
||||
return curr;
|
||||
curr = curr->next;
|
||||
@@ -365,11 +366,11 @@ if_block *ifparser_getif(const char* iface)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *ifparser_getkey(if_block* iface, const char *key)
|
||||
const char *
|
||||
ifparser_getkey (if_block* iface, const char *key)
|
||||
{
|
||||
if_data *curr = iface->info;
|
||||
while(curr!=NULL)
|
||||
{
|
||||
while (curr != NULL) {
|
||||
if (strcmp (curr->key,key)==0)
|
||||
return curr->data;
|
||||
curr = curr->next;
|
||||
@@ -390,7 +391,8 @@ ifparser_haskey(if_block* iface, const char *key)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int ifparser_get_num_info(if_block* iface)
|
||||
int
|
||||
ifparser_get_num_info (if_block* iface)
|
||||
{
|
||||
int i = 0;
|
||||
if_data *iter = iface->info;
|
||||
|
@@ -23,15 +23,13 @@
|
||||
#ifndef _INTERFACE_PARSER_H
|
||||
#define _INTERFACE_PARSER_H
|
||||
|
||||
typedef struct _if_data
|
||||
{
|
||||
typedef struct _if_data {
|
||||
char *key;
|
||||
char *data;
|
||||
struct _if_data *next;
|
||||
} if_data;
|
||||
|
||||
typedef struct _if_block
|
||||
{
|
||||
typedef struct _if_block {
|
||||
char *type;
|
||||
char *name;
|
||||
if_data *info;
|
||||
@@ -52,4 +50,5 @@ void add_block(const char *type, const char* name);
|
||||
void add_data (const char *key,const char *data);
|
||||
void _destroy_data (if_data *ifd);
|
||||
void _destroy_block (if_block* ifb);
|
||||
|
||||
#endif
|
||||
|
@@ -131,8 +131,8 @@ update_wireless_setting_from_if_block(NMConnection *connection,
|
||||
newkey, curr->data,
|
||||
NULL);
|
||||
}
|
||||
} else if(strlen(curr->key) > wpa_l &&
|
||||
!strncmp("wpa-", curr->key, wpa_l)) {
|
||||
} else if ( strlen (curr->key) > wpa_l
|
||||
&& !strncmp ("wpa-", curr->key, wpa_l)) {
|
||||
const char* newkey = map_by_mapping (mapping, curr->key+wpa_l);
|
||||
|
||||
if (newkey && !strcmp ("ssid", newkey)) {
|
||||
@@ -310,12 +310,11 @@ update_wireless_security_setting_from_if_block(NMConnection *connection,
|
||||
g_return_if_fail (s_wireless);
|
||||
|
||||
nm_log_info (LOGD_SETTINGS, "update wireless security settings (%s).", block->name);
|
||||
wireless_security_setting =
|
||||
NM_SETTING_WIRELESS_SECURITY(nm_setting_wireless_security_new());
|
||||
wireless_security_setting = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ());
|
||||
|
||||
while (curr) {
|
||||
if(strlen(curr->key) > wireless_l &&
|
||||
!strncmp("wireless-", curr->key, wireless_l)) {
|
||||
if ( strlen (curr->key) > wireless_l
|
||||
&& !strncmp ("wireless-", curr->key, wireless_l)) {
|
||||
|
||||
char *property_value = NULL;
|
||||
gpointer typed_property_value = NULL;
|
||||
@@ -347,8 +346,8 @@ update_wireless_security_setting_from_if_block(NMConnection *connection,
|
||||
if (typed_property_value && free_func)
|
||||
(*free_func) (typed_property_value);
|
||||
|
||||
} else if(strlen(curr->key) > wpa_l &&
|
||||
!strncmp("wpa-", curr->key, wpa_l)) {
|
||||
} else if ( strlen (curr->key) > wpa_l
|
||||
&& !strncmp ("wpa-", curr->key, wpa_l)) {
|
||||
|
||||
char *property_value = NULL;
|
||||
gpointer typed_property_value = NULL;
|
||||
@@ -574,8 +573,9 @@ update_ip6_setting_from_if_block(NMConnection *connection,
|
||||
{
|
||||
NMSettingIPConfig *s_ip6 = NM_SETTING_IP_CONFIG (nm_setting_ip6_config_new ());
|
||||
const char *type = ifparser_getkey (block, "inet6");
|
||||
gboolean is_static = type && (!strcmp("static", type) ||
|
||||
!strcmp("v4tunnel", type));
|
||||
gboolean is_static = type
|
||||
&& ( !strcmp ("static", type)
|
||||
|| !strcmp ("v4tunnel", type));
|
||||
|
||||
if (!is_static) {
|
||||
g_object_set (s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL);
|
||||
|
Reference in New Issue
Block a user