dnscrypto-proxy: Update to release 1.3.0
[tomato.git] / release / src / router / dnscrypt / src / proxy / plugin_options.c
blob726b04759fb1770e8e2f07d3e74fcb00519c0be9
2 #include <config.h>
3 #include <assert.h>
4 #include <errno.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <stdio.h>
9 #include "plugin_options.h"
10 #include "plugin_support.h"
12 int
13 plugin_options_parse_str(DCPluginSupportContext * const dcps_context,
14 char * const str)
16 DCPluginSupport *dcps = NULL;
17 char *arg;
18 char *plugin_file;
19 char *tmp;
21 assert(dcps_context != NULL);
22 assert(str != NULL);
23 if (*(plugin_file = str) == 0) {
24 return -1;
26 arg = str;
27 while (arg != NULL) {
28 if ((tmp = strchr(arg, ',')) != NULL) {
29 *tmp++ = 0;
31 if (dcps == NULL && (dcps = plugin_support_new(plugin_file)) == NULL) {
32 return -1;
34 if (plugin_support_add_option(dcps, arg) != 0) {
35 return -1;
37 arg = tmp;
39 return plugin_support_context_insert(dcps_context, dcps);