Browse Source

[settings] Eliminate call to store_named_setting() in nslookup.c

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
44fd309044
1 changed files with 17 additions and 6 deletions
  1. 17
    6
      src/usr/nslookup.c

+ 17
- 6
src/usr/nslookup.c View File

46
 	struct interface resolver;
46
 	struct interface resolver;
47
 
47
 
48
 	/** Setting name */
48
 	/** Setting name */
49
-	const char *setting_name;
49
+	char *setting_name;
50
 };
50
 };
51
 
51
 
52
 /**
52
 /**
71
 static void nslookup_resolv_done ( struct nslookup *nslookup,
71
 static void nslookup_resolv_done ( struct nslookup *nslookup,
72
 				   struct sockaddr *sa ) {
72
 				   struct sockaddr *sa ) {
73
 	struct sockaddr_in *sin;
73
 	struct sockaddr_in *sin;
74
-	struct setting_type *type;
74
+	struct setting_type *default_type;
75
+	struct settings *settings;
76
+	struct setting setting;
75
 	void *data;
77
 	void *data;
76
 	size_t len;
78
 	size_t len;
77
 	int rc;
79
 	int rc;
82
 		sin = ( ( struct sockaddr_in * ) sa );
84
 		sin = ( ( struct sockaddr_in * ) sa );
83
 		data = &sin->sin_addr;
85
 		data = &sin->sin_addr;
84
 		len = sizeof ( sin->sin_addr );
86
 		len = sizeof ( sin->sin_addr );
85
-		type = &setting_type_ipv4;
87
+		default_type = &setting_type_ipv4;
86
 		break;
88
 		break;
87
 	default:
89
 	default:
88
 		rc = -ENOTSUP;
90
 		rc = -ENOTSUP;
89
 		goto err;
91
 		goto err;
90
 	}
92
 	}
91
 
93
 
92
-	/* Save in specified setting */
93
-	if ( ( rc = store_named_setting ( nslookup->setting_name, type,
94
-					  data, len ) ) != 0 )
94
+	/* Parse specified setting name */
95
+	if ( ( rc = parse_setting_name ( nslookup->setting_name,
96
+					 autovivify_child_settings, &settings,
97
+					 &setting ) ) != 0 )
98
+		goto err;
99
+
100
+	/* Apply default type if necessary */
101
+	if ( ! setting.type )
102
+		setting.type = default_type;
103
+
104
+	/* Store in specified setting */
105
+	if ( ( rc = store_setting ( settings, &setting, data, len ) ) != 0 )
95
 		goto err;
106
 		goto err;
96
 
107
 
97
  err:
108
  err:

Loading…
Cancel
Save