MODULE create_transfer_pipes (THREAD *thread) { XML_ITEM *pipe, /* XML pipe item */ *instance; /* XML instance item */ XML_ATTR *attr; /* XML attribute */ char *pipe_name; qbyte inrate, /* Pipe input rate */ outrate, /* Pipe output rate */ units; /* Transfer rate multiplier */ FORCHILDREN (pipe, xml_first_child (pipes)) { pipe_name = xml_get_attr (pipe, "NAME", NULL); if (!pipe_name) { send_smtoper_error (&operq, strprintf ("smtpipe: syntax error in '%s' - no NAME", filename)); continue; } inrate = atol (xml_get_attr (pipe, "INRATE", "0")); outrate = atol (xml_get_attr (pipe, "OUTRATE", "0")); if (inrate == 0) inrate = atol (xml_get_attr (pipe, "RATE", "0")); if (outrate == 0) outrate = atol (xml_get_attr (pipe, "RATE", "0")); if (inrate == 0 || outrate == 0) { send_smtoper_error (&operq, strprintf ("smtpipe: pipe '%s' badly defined", pipe_name)); continue; } units = atol (xml_get_attr (pipe, "UNITS", "1")); inrate *= units; outrate *= units; /* Create each pipe instance that is defined */ FORCHILDREN (instance, pipe) { attr = xml_attr (instance, "NAME"); if (attr == NULL) { send_smtoper_error (&operq, strprintf ("smtpipe: pipe '%s' instance has no name", pipe_name)); continue; } send_smttran_pipe_create (&tranq, xml_attr_value (attr), inrate, outrate); }
MODULE get_next_ddns_profile (THREAD *thread) { char ddns_prefix [10]; /* "ddns.." config table prefix */ XML_ATTR *attr; /* XML attribute */ /* If we have a symbol with the name ddns... then we can assume that * this is the start of a DDNS entry. */ sprintf (ddns_prefix, "ddns%.0d", ddns_index++); ddns_service = ini_dyn_value (config, ddns_prefix, "service", NULL); if (ddns_service) { the_next_event = ok_event; ddns_username = ini_dyn_value (config, ddns_prefix, "username", ""); ddns_password = ini_dyn_value (config, ddns_prefix, "password", ""); ddns_domain = ini_dyn_value (config, ddns_prefix, "domain", ""); /* Now find service properties */ FORCHILDREN (service_item, xml_first_child (services)) { attr = xml_attr (service_item, "NAME"); if (attr == NULL) sendfmt (&operq, "ERROR", "xiddns: syntax error in definition file - no NAME"); else if (streq (ddns_service, xml_attr_value (attr))) break; } if (service_item == NULL) { sendfmt (&operq, "ERROR", "xiddns: service '%s' not defined", ddns_service); the_next_event = error_event; } }
static int xml_save_file_item (FILE *xmlfile, XML_ITEM *item, int generation) { int count = 1; /* Count 1 for current item */ XML_ITEM *child, *sibling; XML_ATTR *attr; char *item_name, *attr_name, *ptr; Bool pretty; /* First output item name and attributes */ item_name = xml_item_name (item); if (item_name) { fprintf (xmlfile, "<%s", item_name); FORATTRIBUTES (attr, item) { attr_name = xml_attr_name (attr); ptr = xml_attr_value (attr); http_encode_meta (token, &ptr, LINE_MAX, FALSE); fprintf (xmlfile, "\n%*s%s = \"%s", (generation + 1) * 4, "", attr_name, token); while (*ptr) { http_encode_meta (token, &ptr, LINE_MAX, FALSE); fprintf (xmlfile, "\n%s", token); } fprintf (xmlfile, "\""); } /* If value or children exist, use long form, otherwise short form */ if ((child = xml_first_child (item))) { fprintf (xmlfile, ">"); pretty = TRUE; for (sibling = child ; sibling != NULL ; sibling = xml_next_sibling (sibling)) if (! xml_item_name (sibling)) pretty = FALSE; else break; for ( ; child != NULL; child = xml_next_sibling (child)) { if (pretty) fprintf (xmlfile, "\n%*s", (generation + 1) * 4, ""); count += xml_save_file_item (xmlfile, child, generation + 1); if (xml_item_name (child)) { pretty = TRUE; for (sibling = xml_next_sibling (child) ; sibling != NULL ; sibling = xml_next_sibling (sibling)) if (! xml_item_name (sibling)) pretty = FALSE; else break; } } if (pretty) fprintf (xmlfile, "\n%*s", generation * 4, ""); fprintf (xmlfile, "</%s>", item_name); } else fprintf (xmlfile, "/>"); }