aboutsummaryrefslogtreecommitdiff
path: root/ares/ares_init.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2008-12-03 09:59:50 +0000
committerDaniel Stenberg <daniel@haxx.se>2008-12-03 09:59:50 +0000
commitdd3594c6b3271e47d9b3bfcb1b6045b4da8820cd (patch)
tree111418ac692ae2ebd0ce016175e072b7cde0cb29 /ares/ares_init.c
parentf7ea43151623042dc8e51d6c4076bdddf515f5a1 (diff)
Introduce ares_dup(3) and new thoughts about API/ABI and how to move forwards.
Also discussed on the ml.
Diffstat (limited to 'ares/ares_init.c')
-rw-r--r--ares/ares_init.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/ares/ares_init.c b/ares/ares_init.c
index 79a9f0f55..faa41581b 100644
--- a/ares/ares_init.c
+++ b/ares/ares_init.c
@@ -257,6 +257,39 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options,
return ARES_SUCCESS;
}
+/* ares_dup() duplicates a channel handle with all its options and returns a
+ new channel handle */
+int ares_dup(ares_channel *dest, ares_channel src)
+{
+ struct ares_options opts;
+ int rc;
+ int optmask;
+
+ *dest = NULL; /* in case of failure return NULL explicitly */
+
+ /* First get the options supported by the old ares_save_options() function,
+ which is most of them */
+ rc = ares_save_options(src, &opts, &optmask);
+ if(rc)
+ return rc;
+
+ /* Then create the new channel with those options */
+ rc = ares_init_options(dest, &opts, optmask);
+
+ /* destroy the options copy to not leak any memory */
+ ares_destroy_options(&opts);
+
+ if(rc)
+ return rc;
+
+ /* Now clone the options that ares_save_options() doesn't support. */
+
+ /* No such options available yet */
+
+ return ARES_SUCCESS; /* everything went fine */
+
+}
+
/* Save options from initialized channel */
int ares_save_options(ares_channel channel, struct ares_options *options,
int *optmask)