+ index_opt = "";
+ }
+
+ if (dp->kencrypt) {
+ kencrypt_opt = " <kencrypt>YES</kencrypt>\n";
+ } else {
+ kencrypt_opt = "";
+ }
+
+ if (am_has_feature(their_features, fe_xml_data_path)) {
+ switch(dp->data_path) {
+ case DATA_PATH_AMANDA:
+ amfree(data_path_opt);
+ data_path_opt = stralloc(" <datapath>AMANDA</datapath>\n");
+ break;
+ case DATA_PATH_DIRECTTCP:
+ { /* dp->dataport_list is not set for selfcheck/sendsize */
+ if (am_has_feature(their_features, fe_xml_directtcp_list)) {
+ char *s, *sc;
+ char *value, *b64value;
+
+ amfree(data_path_opt);
+ data_path_opt = stralloc(" <datapath>DIRECTTCP");
+ if (dp->dataport_list) {
+ s = sc = stralloc(dp->dataport_list);
+ do {
+ value = s;
+ s = strchr(s, ';');
+ if (s) {
+ *s++ = '\0';
+ }
+
+ b64value = amxml_format_tag("directtcp", value);
+ vstrextend(&data_path_opt, "\n ", b64value, NULL);
+ amfree(b64value);
+ } while (s);
+ amfree(sc);
+ strappend(data_path_opt, "\n ");
+ }
+ strappend(data_path_opt, "</datapath>\n");
+ }
+ }
+ break;
+ }
+ }
+
+ exclude_file = stralloc("");
+ if (dp->exclude_file != NULL && dp->exclude_file->nb_element > 0) {
+ for(excl = dp->exclude_file->first; excl != NULL;
+ excl = excl->next) {
+ q64name = amxml_format_tag("file", excl->name);
+ exc = newvstralloc( exc, " ", q64name, "\n", NULL);
+ strappend(exclude_file, exc);
+ amfree(q64name);
+ }
+ }
+ exclude_list = stralloc("");
+ if (dp->exclude_list != NULL && dp->exclude_list->nb_element > 0) {
+ for(excl = dp->exclude_list->first; excl != NULL;
+ excl = excl->next) {
+ q64name = amxml_format_tag("list", excl->name);
+ exc = newvstralloc(exc, " ", q64name, "\n", NULL);
+ strappend(exclude_list, exc);
+ amfree(q64name);
+ }
+ }
+
+ include_file = stralloc("");
+ if (dp->include_file != NULL && dp->include_file->nb_element > 0) {
+ for(excl = dp->include_file->first; excl != NULL;
+ excl = excl->next) {
+ q64name = amxml_format_tag("file", excl->name);
+ exc = newvstralloc( exc, " ", q64name, "\n", NULL);
+ strappend(include_file, exc);
+ amfree(q64name);
+ }
+ }
+ include_list = stralloc("");
+ if (dp->include_list != NULL && dp->include_list->nb_element > 0) {
+ for(excl = dp->include_list->first; excl != NULL;
+ excl = excl->next) {
+ q64name = amxml_format_tag("list", excl->name);
+ exc = newvstralloc( exc, " ", q64name, "\n", NULL);
+ strappend(include_list, exc);
+ amfree(q64name);
+ }
+ }
+
+ if (dp->exclude_optional) {
+ excl_opt = " <optional>YES</optional>\n";
+ }
+ if (dp->include_optional) {
+ incl_opt = " <optional>YES</optional>\n";
+ }
+
+ if (dp->exclude_file || dp->exclude_list)
+ exclude = newvstralloc(exclude,
+ " <exclude>\n",
+ exclude_file,
+ exclude_list,
+ excl_opt,
+ " </exclude>\n", NULL);
+ if (dp->include_file || dp->include_list)
+ include = newvstralloc(include,
+ " <include>\n",
+ include_file,
+ include_list,
+ incl_opt,
+ " </include>\n", NULL);
+ script_opt = xml_scripts(dp->pp_scriptlist, their_features);
+ result = vstralloc(auth_opt,
+ kencrypt_opt,
+ compress_opt,
+ encrypt_opt,
+ record_opt,
+ index_opt,
+ data_path_opt,
+ exclude,
+ include,
+ script_opt,
+ NULL);
+
+ amfree(qdpname);
+ amfree(auth_opt);
+ amfree(data_path_opt);
+ amfree(compress_opt);
+ amfree(exclude);
+ amfree(exclude_list);
+ amfree(exclude_file);
+ amfree(include);
+ amfree(include_file);
+ amfree(include_list);
+ amfree(exc);
+ amfree(decrypt_opt);
+ amfree(encrypt_opt);
+ amfree(script_opt);
+
+ /* result contains at least 'auth=...' */
+ return result;
+}
+
+char *
+xml_estimate(
+ estimatelist_t estimatelist,
+ am_feature_t *their_features)
+{
+ estimatelist_t el;
+ char *l = NULL;
+
+ if (am_has_feature(their_features, fe_xml_estimatelist)) {
+ vstrextend(&l, " <estimate>", NULL);
+ for (el=estimatelist; el != NULL; el = el->next) {
+ switch (GPOINTER_TO_INT(el->data)) {
+ case ES_CLIENT : vstrextend(&l, "CLIENT ", NULL); break;
+ case ES_SERVER : vstrextend(&l, "SERVER ", NULL); break;
+ case ES_CALCSIZE: vstrextend(&l, "CALCSIZE ", NULL); break;
+ }
+ }
+ vstrextend(&l, "</estimate>", NULL);
+ } else { /* add the first estimate only */
+ if (am_has_feature(their_features, fe_xml_estimate)) {
+ vstrextend(&l, " <estimate>", NULL);
+ switch (GPOINTER_TO_INT(estimatelist->data)) {
+ case ES_CLIENT : vstrextend(&l, "CLIENT", NULL); break;
+ case ES_SERVER : vstrextend(&l, "SERVER", NULL); break;
+ case ES_CALCSIZE: vstrextend(&l, "CALCSIZE", NULL); break;
+ }
+ }
+ vstrextend(&l, "</estimate>", NULL);
+ if (GPOINTER_TO_INT(estimatelist->data) == ES_CALCSIZE) {
+ vstrextend(&l, " <calcsize>YES</calcsize>", NULL);
+ }