summaryrefslogtreecommitdiff
path: root/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
commite61d4b9e21578a5b77118030a6711bbbb9abd7de (patch)
treeff192f64441998a74a164678cdb192133d746c50 /ares_init.c
parentefa7c4807b26bf919b72d9392a036601a88b717b (diff)
downloadc-ares-e61d4b9e21578a5b77118030a6711bbbb9abd7de.tar.gz
c-ares-e61d4b9e21578a5b77118030a6711bbbb9abd7de.tar.bz2
c-ares-e61d4b9e21578a5b77118030a6711bbbb9abd7de.zip
Introduce ares_dup(3) and new thoughts about API/ABI and how to move forwards.
Also discussed on the ml.
Diffstat (limited to 'ares_init.c')
-rw-r--r--ares_init.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/ares_init.c b/ares_init.c
index 79a9f0f..faa4158 100644
--- a/ares_init.c
+++ b/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)