Exemplo n.º 1
0
int PROXY_INFO::write(MIOFILE& out) {
    char s5un[2048], s5up[2048], hun[2048], hup[2048];
    xml_escape(socks5_user_name, s5un, sizeof(s5un));
    xml_escape(socks5_user_passwd, s5up, sizeof(s5up));
    xml_escape(http_user_name, hun, sizeof(hun));
    xml_escape(http_user_passwd, hup, sizeof(hup));
    out.printf(
        "<proxy_info>\n"
        "%s"
        "%s"
        "%s"
        "    <socks_server_name>%s</socks_server_name>\n"
        "    <socks_server_port>%d</socks_server_port>\n"
        "    <http_server_name>%s</http_server_name>\n"
        "    <http_server_port>%d</http_server_port>\n"
        "    <socks5_user_name>%s</socks5_user_name>\n"
        "    <socks5_user_passwd>%s</socks5_user_passwd>\n"
        "    <socks5_remote_dns>%d</socks5_remote_dns>\n"
        "    <http_user_name>%s</http_user_name>\n"
        "    <http_user_passwd>%s</http_user_passwd>\n"
        "    <no_proxy>%s</no_proxy>\n"
        "    <no_autodetect>%d</no_autodetect>\n",
        use_http_proxy?"    <use_http_proxy/>\n":"",
        use_socks_proxy?"    <use_socks_proxy/>\n":"",
        use_http_auth?"    <use_http_auth/>\n":"",
        socks_server_name,
        socks_server_port,
        http_server_name,
        http_server_port,
        s5un,
        s5up,
        socks5_remote_dns?1:0,
        hun,
        hup,
        noproxy_hosts,
        no_autodetect?1:0
    );
    if (strlen(autodetect_server_name)) {
        out.printf(
            "    <autodetect_protocol>%d</autodetect_protocol>\n"
            "    <autodetect_server_name>%d</autodetect_server_name>\n"
            "    <autodetect_port>%d</autodetect_port>\n",
            autodetect_protocol,
            autodetect_server_name,
            autodetect_port
        );
    }
    out.printf(
        "</proxy_info>\n"
    );
    return 0;
}
Exemplo n.º 2
0
static void
print_transitions (state *s, FILE *out, int level)
{
  transitions *trans = s->transitions;
  int n = 0;
  int i;

  for (i = 0; i < trans->num; i++)
    if (!TRANSITION_IS_DISABLED (trans, i))
      {
        n++;
      }

  /* Nothing to report. */
  if (!n)
    {
      xml_puts (out, level, "<transitions/>");
      return;
    }

  /* Report lookahead tokens and shifts.  */
  xml_puts (out, level, "<transitions>");

  for (i = 0; i < trans->num; i++)
    if (!TRANSITION_IS_DISABLED (trans, i)
        && TRANSITION_IS_SHIFT (trans, i))
      {
        symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
        char const *tag = sym->tag;
        state *s1 = trans->states[i];

        xml_printf (out, level + 1,
                    "<transition type=\"shift\" symbol=\"%s\" state=\"%d\"/>",
                    xml_escape (tag), s1->number);
      }

  for (i = 0; i < trans->num; i++)
    if (!TRANSITION_IS_DISABLED (trans, i)
        && !TRANSITION_IS_SHIFT (trans, i))
      {
        symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
        char const *tag = sym->tag;
        state *s1 = trans->states[i];

        xml_printf (out, level + 1,
                    "<transition type=\"goto\" symbol=\"%s\" state=\"%d\"/>",
                    xml_escape (tag), s1->number);
      }

  xml_puts (out, level, "</transitions>");
}
Exemplo n.º 3
0
void
Server::sendXML(wstring elementName, queue<Attribute>* vAttributes)
{
	if(!isConnected())
	{
		return;
	}
	EnterCriticalSection(&sendQueueLock);
	wstring xmlDocument = L"<";
	xmlDocument += elementName;
	while(!vAttributes->empty())
	{
		Attribute att = vAttributes->front();
		vAttributes->pop();
		xmlDocument += L" ";
		xmlDocument += att.name;
		xmlDocument += L"=\"";
		xml_escape(&att.value);
		xmlDocument += att.value;
		xmlDocument += L"\"";
	}
	xmlDocument += L"/>\r\n";
	sendMessage(&xmlDocument);
	LeaveCriticalSection(&sendQueueLock);
}
Exemplo n.º 4
0
static void
print_errs (FILE *out, int level, state *s)
{
  errs *errp = s->errs;
  bool count = false;
  int i;

  for (i = 0; i < errp->num; ++i)
    if (errp->symbols[i])
      count = true;

  /* Nothing to report. */
  if (!count)
    {
      xml_puts (out, level, "<errors/>");
      return;
    }

  /* Report lookahead tokens and errors.  */
  xml_puts (out, level, "<errors>");
  for (i = 0; i < errp->num; ++i)
    if (errp->symbols[i])
      {
        char const *tag = errp->symbols[i]->tag;
        xml_printf (out, level + 1,
                    "<error symbol=\"%s\">nonassociative</error>",
                    xml_escape (tag));
      }
  xml_puts (out, level, "</errors>");
}
Exemplo n.º 5
0
static void
print_reduction (FILE *out, int level, char const *lookahead_token,
                 rule *r, bool enabled)
{
  if (r->number)
    xml_printf (out, level,
                "<reduction symbol=\"%s\" rule=\"%d\" enabled=\"%s\"/>",
                xml_escape (lookahead_token),
                r->number,
                enabled ? "true" : "false");
  else
    xml_printf (out, level,
                "<reduction symbol=\"%s\" rule=\"accept\" enabled=\"%s\"/>",
                xml_escape (lookahead_token),
                enabled ? "true" : "false");
}
Exemplo n.º 6
0
static void
print_grammar (FILE *out, int level)
{
  symbol_number i;

  fputc ('\n', out);
  xml_puts (out, level, "<grammar>");
  grammar_rules_print_xml (out, level);

  /* Terminals */
  xml_puts (out, level + 1, "<terminals>");
  for (i = 0; i < max_user_token_number + 1; i++)
    if (token_translations[i] != undeftoken->number)
      {
        char const *tag = symbols[token_translations[i]]->tag;
        int precedence = symbols[token_translations[i]]->prec;
        assoc associativity = symbols[token_translations[i]]->assoc;
        xml_indent (out, level + 2);
        fprintf (out,
                 "<terminal symbol-number=\"%d\" token-number=\"%d\""
                 " name=\"%s\" usefulness=\"%s\"",
                 token_translations[i], i, xml_escape (tag),
                 reduce_token_unused_in_grammar (token_translations[i])
                   ? "unused-in-grammar" : "useful");
        if (precedence)
          fprintf (out, " prec=\"%d\"", precedence);
        if (associativity != undef_assoc)
          fprintf (out, " assoc=\"%s\"", assoc_to_string (associativity) + 1);
        fputs ("/>\n", out);
      }
  xml_puts (out, level + 1, "</terminals>");

  /* Nonterminals */
  xml_puts (out, level + 1, "<nonterminals>");
  for (i = ntokens; i < nsyms + nuseless_nonterminals; i++)
    {
      char const *tag = symbols[i]->tag;
      xml_printf (out, level + 2,
                  "<nonterminal symbol-number=\"%d\" name=\"%s\""
                  " usefulness=\"%s\"/>",
                  i, xml_escape (tag),
                  reduce_nonterminal_useless_in_grammar (i)
                    ? "useless-in-grammar" : "useful");
    }
  xml_puts (out, level + 1, "</nonterminals>");
  xml_puts (out, level, "</grammar>");
}
Exemplo n.º 7
0
void SvgText::write( std::ostream& out, size_t indent, SvgDrawingOptions const& options ) const
{
    out << repeat( SvgDocument::indentation_string, indent );
    out << "<text";

    if( ! id.empty() ) {
        out << svg_attribute( "id", id );
    }

    out << svg_attribute( "x", position.x + options.offset_x );
    out << svg_attribute( "y", position.y + options.offset_y );

    font.write( out );
    fill.write( out );
    stroke.write( out );

    if( anchor != Anchor::kNone ) {
        out << anchor_to_string( anchor );
    }
    if( dominant_baseline != DominantBaseline::kNone ) {
        out << dominant_baseline_to_string( dominant_baseline );
    }
    if( alignment_baseline != AlignmentBaseline::kNone ) {
        out << alignment_baseline_to_string( alignment_baseline );
    }

    if( kerning != 0.0 ) {
        out << svg_attribute( "kerning", kerning );
    }
    if( letter_spacing != 0.0 ) {
        out << svg_attribute( "letter-spacing", letter_spacing );
    }
    if( word_spacing != 0.0 ) {
        out << svg_attribute( "word-spacing", word_spacing );
    }

    if( dx != "" ) {
        out << svg_attribute( "dx", dx );
    }
    if( dy != "" ) {
        out << svg_attribute( "dy", dy );
    }
    transform.write( out );

    out << ">";
    out << xml_escape( text );

    // if( alignment_baseline == AlignmentBaseline::kNone ) {
        // out << xml_escape( text );
    // } else {
    //     out << "<tspan";
    //     out << alignment_baseline_to_string( alignment_baseline );
    //     out << ">";
    //     out << xml_escape( text );
    //     out << "</tspan>";
    // }

    out << "</text>\n";
}
Exemplo n.º 8
0
Arquivo: rss.c Projeto: ezeep/cups
static int				/* O - 1 on success, 0 on failure */
save_rss(cups_array_t *rss,		/* I - RSS messages */
         const char   *filename,	/* I - File to save to */
	 const char   *baseurl)		/* I - Base URL */
{
  FILE		*fp;			/* File pointer */
  _cups_rss_t	*msg;			/* Current message */
  char		date[1024];		/* Current date */
  char		*href;			/* Escaped base URL */


  if ((fp = fopen(filename, "w")) == NULL)
  {
    fprintf(stderr, "ERROR: Unable to create %s: %s\n", filename,
            strerror(errno));
    return (0);
  }

  fchmod(fileno(fp), 0644);

  fputs("<?xml version=\"1.0\"?>\n", fp);
  fputs("<rss version=\"2.0\">\n", fp);
  fputs("  <channel>\n", fp);
  fputs("    <title>CUPS RSS Feed</title>\n", fp);

  href = xml_escape(baseurl);
  fprintf(fp, "    <link>%s</link>\n", href);
  free(href);

  fputs("    <description>CUPS RSS Feed</description>\n", fp);
  fputs("    <generator>" CUPS_SVERSION "</generator>\n", fp);
  fputs("    <ttl>1</ttl>\n", fp);

  fprintf(fp, "    <pubDate>%s</pubDate>\n",
          httpGetDateString2(time(NULL), date, sizeof(date)));

  for (msg = (_cups_rss_t *)cupsArrayLast(rss);
       msg;
       msg = (_cups_rss_t *)cupsArrayPrev(rss))
  {
    fputs("    <item>\n", fp);
    fprintf(fp, "      <title>%s</title>\n", msg->subject);
    fprintf(fp, "      <description>%s</description>\n", msg->text);
    if (msg->link_url)
      fprintf(fp, "      <link>%s</link>\n", msg->link_url);
    fprintf(fp, "      <pubDate>%s</pubDate>\n",
            httpGetDateString2(msg->event_time, date, sizeof(date)));
    fprintf(fp, "      <guid>%d</guid>\n", msg->sequence_number);
    fputs("    </item>\n", fp);
  }

  fputs(" </channel>\n", fp);
  fputs("</rss>\n", fp);

  return (!fclose(fp));
}
Exemplo n.º 9
0
char *
simple_dialog_format_message(const char *msg)
{
    char *str;

    if (msg) {
        str = xml_escape(msg);
    } else {
        str = NULL;
    }
    return str;
}
Exemplo n.º 10
0
static char*
get_link(LinkDialog *ld, JamAccount *acc) {
	char *url, *user, *text, *title;
	char *link = NULL;

	url  = gtk_editable_get_chars(GTK_EDITABLE(ld->eurl),  0, -1);
	xml_escape(&url);
	user = gtk_editable_get_chars(GTK_EDITABLE(ld->euser), 0, -1);
	xml_escape(&user);
	text = gtk_editable_get_chars(GTK_EDITABLE(ld->etext), 0, -1);
	xml_escape(&text);
	title = gtk_editable_get_chars(GTK_EDITABLE(ld->titl), 0, -1);

	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ld->rurl))) {
		/* build a "url" link. */
		if (title && *title) {
			link = g_strdup_printf("<a href=\"%s\" title=\"%s\">%s</a>", url, title, text);
		} else {
			link = g_strdup_printf("<a href=\"%s\">%s</a>", url, text);
		}
	} else if (ld->ruser &&
			gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ld->ruser))) {
		/* build a "friends" link. */
		LJServer *server = jam_account_lj_get_server(JAM_ACCOUNT_LJ(acc));
		g_free(url);
		url = g_strdup(server->url);
		xml_escape(&url);
		link = g_strdup_printf("<a href=\"%s/users/%s\">%s</a>",
				url, user, text);
	} 
	g_free(url);
	g_free(user);
	g_free(text);
	g_free(title);
	
	return link;
}
Exemplo n.º 11
0
void
print_xml (void)
{
  int level = 0;

  FILE *out = xfopen (spec_xml_file, "w");

  fputs ("<?xml version=\"1.0\"?>\n\n", out);
  xml_printf (out, level,
              "<bison-xml-report version=\"%s\" bug-report=\"%s\""
              " url=\"%s\">",
              xml_escape_n (0, VERSION),
              xml_escape_n (1, PACKAGE_BUGREPORT),
              xml_escape_n (2, PACKAGE_URL));

  fputc ('\n', out);
  xml_printf (out, level + 1, "<filename>%s</filename>",
              xml_escape (grammar_file));

  /* print grammar */
  print_grammar (out, level + 1);

  new_closure (nritems);
  no_reduce_set =  bitset_create (ntokens, BITSET_FIXED);

  /* print automaton */
  fputc ('\n', out);
  xml_puts (out, level + 1, "<automaton>");
  {
    state_number i;
    for (i = 0; i < nstates; i++)
      print_state (out, level + 2, states[i]);
  }
  xml_puts (out, level + 1, "</automaton>");

  bitset_free (no_reduce_set);
  free_closure ();

  xml_puts (out, 0, "</bison-xml-report>");

  {
    int i;
    for (i = 0; i < num_escape_bufs; ++i)
      free (escape_bufs[i].ptr);
  }

  xfclose (out);
}
Exemplo n.º 12
0
int DC_sendMessage(const char *message)
{
	char *xml, *msg;
	int ret, len;

	if (!message)
	{
		DC_log(LOG_ERR, "%s: Missing message", __func__);
		return DC_ERR_BADPARAM;
	}

	if (!wu_name[0])
	{
		DC_log(LOG_ERR, "Messaging is not available in stand-alone mode");
		return DC_ERR_NOTIMPL;
	}

	int buflen = 6 * strlen(message) + 1;
	xml = (char *)malloc(buflen);
	if (!xml)
	{
		DC_log(LOG_ERR, "Sending message: Out of memory");
		return DC_ERR_INTERNAL;
	}

	xml_escape(message, xml, buflen);
	len = strlen(xml) + 24;
	msg = (char *)malloc(len);
	if (!msg)
	{
		DC_log(LOG_ERR, "Sending message: Out of memory");
		free(xml);
		return DC_ERR_INTERNAL;
	}
	snprintf(msg, len, "<message>%s</message>", xml);

	/* We use the WU's name as the variety */
	ret = boinc_send_trickle_up(wu_name, msg);
	free(msg);
	free(xml);
	if (ret)
	{
		DC_log(LOG_ERR, "Failed to send trickle-up message");
		return DC_ERR_INTERNAL;
	}
	return 0;
}
Exemplo n.º 13
0
gchar*
link_magic(LinkRequest *lr) {
	gchar *a, *b;
	if (! ((lr->clip_type | lr->sel_type) & JAM_SELECTION_HAS_URL))
		return NULL;
	
	xml_escape(&lr->clip_input);

	/* boo for no list primitives in c */
	if (lr->clip_type & JAM_SELECTION_HAS_URL) {
		a = lr->clip_input; b = lr->sel_input;
	} else {
		b = lr->clip_input; a = lr->sel_input;
	}

	return g_strdup_printf("<a href=\"%s\">%s</a>", a, b);
}
Exemplo n.º 14
0
void
Server::sendXMLElement(Element* pElement)
{
	if(!isConnected())
	{
		return;
	}
	EnterCriticalSection(&sendQueueLock);
	wstring xmlDocument = L"<";
	xmlDocument += pElement->name;
	vector<Attribute>::iterator it;
	for(it = pElement->attributes.begin(); it < pElement->attributes.end(); it++)
	{
		xmlDocument += L" ";
		xmlDocument += it->name;
		xmlDocument += L"=\"";
		xml_escape(&it->value);
		xmlDocument += it->value;
		xmlDocument += L"\"";
	}
	if(pElement->data != NULL)
	{
		xmlDocument += L">";
		sendMessage(&xmlDocument);
		sendData(pElement->data, pElement->dataLength);
		xmlDocument = L"</";
		xmlDocument += pElement->name;
		xmlDocument += L">\r\n";
		sendMessage(&xmlDocument);
	} else {
		xmlDocument += L"/>\r\n";
		sendMessage(&xmlDocument);
	}
	LeaveCriticalSection(&sendQueueLock);
	
}
Exemplo n.º 15
0
int SCHEDULER_REPLY::write(FILE* fout, SCHEDULER_REQUEST& sreq) {

/*
                if (strstr(mode_str(), "_ci_")) {
                        system("/usr/local/bin/add-workunit-type-ci");
                }
                else {
                        system("/usr/local/bin/add-workunit-type-nci");
                }
*/

    unsigned int i;
    char buf[BLOB_SIZE];

    // Note: at one point we had
    // "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"
    // after the Content-type (to make it legit XML),
    // but this broke 4.19 clients
    //
    fprintf(fout,
        "Content-type: text/xml\n\n"
        "<scheduler_reply>\n"
        "<scheduler_version>%d</scheduler_version>\n",
        BOINC_MAJOR_VERSION*100+BOINC_MINOR_VERSION
    );
    if (strlen(config.master_url)) {
        fprintf(fout,
            "<master_url>%s</master_url>\n",
            config.master_url
        );
    }
    if (config.ended) {
        fprintf(fout, "   <ended>1</ended>\n");
    }

    // if the scheduler has requested a delay OR the sysadmin has configured
    // the scheduler with a minimum time between RPCs, send a delay request.
    // Make it 1% larger than the min required to take care of time skew.
    // If this is less than one second bigger, bump up by one sec.
    //
    if (request_delay || config.min_sendwork_interval) {
        double min_delay_needed = 1.01*config.min_sendwork_interval;
        if (min_delay_needed < config.min_sendwork_interval+1) {
            min_delay_needed = config.min_sendwork_interval+1;
        }
        if (request_delay<min_delay_needed) {
            request_delay = min_delay_needed; 
        }
        fprintf(fout, "<request_delay>%f</request_delay>\n", request_delay);
    }
    log_messages.printf(MSG_NORMAL,
        "Sending reply to [HOST#%d]: %d results, delay req %.2f\n",
        host.id, wreq.njobs_sent, request_delay
    );

    if (sreq.core_client_version <= 41900) {
        std::string msg;
        std::string pri = "low";
        for (i=0; i<messages.size(); i++) {
            USER_MESSAGE& um = messages[i];
            msg += um.message + std::string(" ");
            if (um.priority == "high") {
                pri = "high";
            }
        }
        if (messages.size()>0) {
            // any newlines will break message printing under 4.19 and under!
            // replace them with spaces.
            //
            while (1) {
                std::string::size_type pos = msg.find("\n", 0);
                if (pos == std::string::npos) break;
                msg.replace(pos, 1, " ");
            }
            fprintf(fout,
                "<message priority=\"%s\">%s</message>\n",
                pri.c_str(), msg.c_str()
            );
        }
    } else {
        for (i=0; i<messages.size(); i++) {
            USER_MESSAGE& um = messages[i];
            fprintf(fout,
                "<message priority=\"%s\">%s</message>\n",
                um.priority.c_str(),
                um.message.c_str()
            );
        }
    }
    fprintf(fout,
        "<project_name>%s</project_name>\n",
        config.long_name
    );

    if (config.request_time_stats_log) {
        if (!have_time_stats_log()) {
            fprintf(fout, "<send_time_stats_log>1</send_time_stats_log>\n");
        }
    }

    if (project_is_down) {
        fprintf(fout,"<project_is_down/>\n");
        goto end;
    }
    if (config.workload_sim) {
        fprintf(fout, "<send_full_workload\n");
    }

    if (nucleus_only) goto end;

    if (strlen(config.symstore)) {
        fprintf(fout, "<symstore>%s</symstore>\n", config.symstore);
    }
    if (config.next_rpc_delay) {
        fprintf(fout, "<next_rpc_delay>%f</next_rpc_delay>\n", config.next_rpc_delay);
    }
    if (user.id) {
        xml_escape(user.name, buf, sizeof(buf));
        fprintf(fout,
            "<user_name>%s</user_name>\n"
            "<user_total_credit>%f</user_total_credit>\n"
            "<user_expavg_credit>%f</user_expavg_credit>\n"
            "<user_create_time>%d</user_create_time>\n",
            buf,
            user.total_credit,
            user.expavg_credit,
            user.create_time
        );
        // be paranoid about the following to avoid sending null
        //
        if (strlen(email_hash)) {
            fprintf(fout,
                "<email_hash>%s</email_hash>\n",
                email_hash
            );
        }
        if (strlen(user.cross_project_id)) {
            fprintf(fout,
                "<cross_project_id>%s</cross_project_id>\n",
                user.cross_project_id
            );
        }

        if (send_global_prefs) {
            fputs(user.global_prefs, fout);
            fputs("\n", fout);
        }

        // always send project prefs
        //
        fputs(user.project_prefs, fout);
        fputs("\n", fout);

    }
    if (hostid) {
        fprintf(fout,
            "<hostid>%d</hostid>\n",
            hostid
        );
    }
    fprintf(fout,
        "<host_total_credit>%f</host_total_credit>\n"
        "<host_expavg_credit>%f</host_expavg_credit>\n"
        "<host_venue>%s</host_venue>\n"
        "<host_create_time>%d</host_create_time>\n",
        host.total_credit,
        host.expavg_credit,
        host.venue,
        host.create_time
    );

    // might want to send team credit too.
    //
    if (team.id) {
        xml_escape(team.name, buf, sizeof(buf));
        fprintf(fout,
            "<team_name>%s</team_name>\n",
            buf
        );
    } else {
        fprintf(fout,
            "<team_name></team_name>\n"
        );
    }

    // acknowledge results
    //
    for (i=0; i<result_acks.size(); i++) {
        fprintf(fout,
            "<result_ack>\n"
            "    <name>%s</name>\n"
            "</result_ack>\n",
            result_acks[i].c_str()
        );
    }

    // abort results
    //
    for (i=0; i<result_aborts.size(); i++) {
        fprintf(fout,
            "<result_abort>\n"
            "    <name>%s</name>\n"
            "</result_abort>\n",
            result_aborts[i].c_str()
        );
    }

    // abort results not started
    //
    for (i=0; i<result_abort_if_not_starteds.size(); i++) {
        fprintf(fout,
            "<result_abort_if_not_started>\n"
            "    <name>%s</name>\n"
            "</result_abort_if_not_started>\n",
            result_abort_if_not_starteds[i].c_str()
        );
    }

    for (i=0; i<apps.size(); i++) {
        apps[i].write(fout);
    }

    for (i=0; i<app_versions.size(); i++) {
        app_versions[i].write(fout);
    }

    for (i=0; i<wus.size(); i++) {
        fputs(wus[i].xml_doc, fout);
    }

    for (i=0; i<results.size(); i++) {
        results[i].write_to_client(fout);
    }

    if (strlen(code_sign_key)) {
        fputs("<code_sign_key>\n", fout);
        fputs(code_sign_key, fout);
        fputs("</code_sign_key>\n", fout);
    }

    if (strlen(code_sign_key_signature)) {
        fputs("<code_sign_key_signature>\n", fout);
        fputs(code_sign_key_signature, fout);
        fputs("</code_sign_key_signature>\n", fout);
    }

    if (send_msg_ack) {
        fputs("<message_ack/>\n", fout);
    }

    for (i=0; i<msgs_to_host.size(); i++) {
        MSG_TO_HOST& md = msgs_to_host[i];
        fprintf(fout, "%s\n", md.xml);
    }

    if (strstr(behave_str(), "_nci_")) {
//    if (config.non_cpu_intensive) {
        fprintf(fout, "<non_cpu_intensive/>\n");
    }

    if (config.verify_files_on_app_start) {
        fprintf(fout, "<verify_files_on_app_start/>\n");
    }

    for (i=0; i<file_deletes.size(); i++) {
        fprintf(fout,
            "<delete_file_info>%s</delete_file_info>\n",
            file_deletes[i].name
        );
    }

    gui_urls.get_gui_urls(user, host, team, buf);
    fputs(buf, fout);
    if (project_files.text) {
        fputs(project_files.text, fout);
        fprintf(fout, "\n");
    }

end:
    fprintf(fout,
        "</scheduler_reply>\n"
    );
    return 0;
}
Exemplo n.º 16
0
/**
 * @brief Print an XML markup (simple text).
 */
void XmlWriter::print_markup  (std::string& xml, const XmlMarkup*  value)
{
    xml += xml_escape(value->content);
}
Exemplo n.º 17
0
int					/* O - Exit status */
main(int  argc,				/* I - Number of command-line arguments */
     char *argv[])			/* I - Command-line arguments */
{
  int		i;			/* Looping var */
  ipp_t		*event;			/* Event from scheduler */
  ipp_state_t	state;			/* IPP event state */
  char		scheme[32],		/* URI scheme ("rss") */
		username[256],		/* Username for remote RSS */
		host[1024],		/* Hostname for remote RSS */
		resource[1024],		/* RSS file */
		*options;		/* Options */
  int		port,			/* Port number for remote RSS */
		max_events;		/* Maximum number of events */
  http_t	*http;			/* Connection to remote server */
  http_status_t	status;			/* HTTP GET/PUT status code */
  char		filename[1024],		/* Local filename */
		newname[1024];		/* filename.N */
  cups_lang_t	*language;		/* Language information */
  ipp_attribute_t *printer_up_time,	/* Timestamp on event */
		*notify_sequence_number,/* Sequence number */
		*notify_printer_uri;	/* Printer URI */
  char		*subject,		/* Subject for notification message */
		*text,			/* Text for notification message */
		link_url[1024],		/* Link to printer */
		link_scheme[32],	/* Scheme for link */
		link_username[256],	/* Username for link */
		link_host[1024],	/* Host for link */
		link_resource[1024];	/* Resource for link */
  int		link_port;		/* Link port */
  cups_array_t	*rss;			/* RSS message array */
  _cups_rss_t	*msg;			/* RSS message */
  char		baseurl[1024];		/* Base URL */
  fd_set	input;			/* Input set for select() */
  struct timeval timeout;		/* Timeout for select() */
  int		changed;		/* Has the RSS data changed? */
  int		exit_status;		/* Exit status */


  fprintf(stderr, "DEBUG: argc=%d\n", argc);
  for (i = 0; i < argc; i ++)
    fprintf(stderr, "DEBUG: argv[%d]=\"%s\"\n", i, argv[i]);

 /*
  * See whether we are publishing this RSS feed locally or remotely...
  */

  if (httpSeparateURI(HTTP_URI_CODING_ALL, argv[1], scheme, sizeof(scheme),
                      username, sizeof(username), host, sizeof(host), &port,
		      resource, sizeof(resource)) < HTTP_URI_OK)
  {
    fprintf(stderr, "ERROR: Bad RSS URI \"%s\"!\n", argv[1]);
    return (1);
  }

  max_events = 20;

  if ((options = strchr(resource, '?')) != NULL)
  {
    *options++ = '\0';

    if (!strncmp(options, "max_events=", 11))
    {
      max_events = atoi(options + 11);

      if (max_events <= 0)
        max_events = 20;
    }
  }

  rss = cupsArrayNew((cups_array_func_t)compare_rss, NULL);

  if (host[0])
  {
   /*
    * Remote feed, see if we can get the current file...
    */

    int	fd;				/* Temporary file */


    if ((rss_password = strchr(username, ':')) != NULL)
      *rss_password++ = '\0';

    cupsSetPasswordCB(password_cb);
    cupsSetUser(username);

    if ((fd = cupsTempFd(filename, sizeof(filename))) < 0)
    {
      fprintf(stderr, "ERROR: Unable to create temporary file: %s\n",
              strerror(errno));

      return (1);
    }

    if ((http = httpConnect(host, port)) == NULL)
    {
      fprintf(stderr, "ERROR: Unable to connect to %s on port %d: %s\n",
              host, port, strerror(errno));

      close(fd);
      unlink(filename);

      return (1);
    }

    status = cupsGetFd(http, resource, fd);

    close(fd);

    if (status != HTTP_OK && status != HTTP_NOT_FOUND)
    {
      fprintf(stderr, "ERROR: Unable to GET %s from %s on port %d: %d %s\n",
	      resource, host, port, status, httpStatus(status));

      httpClose(http);
      unlink(filename);

      return (1);
    }

    strlcpy(newname, filename, sizeof(newname));

    httpAssembleURI(HTTP_URI_CODING_ALL, baseurl, sizeof(baseurl), "http",
                    NULL, host, port, resource);
  }
  else
  {
    const char	*cachedir,		/* CUPS_CACHEDIR */
		*server_name,		/* SERVER_NAME */
		*server_port;		/* SERVER_PORT */


    http = NULL;

    if ((cachedir = getenv("CUPS_CACHEDIR")) == NULL)
      cachedir = CUPS_CACHEDIR;

    if ((server_name = getenv("SERVER_NAME")) == NULL)
      server_name = "localhost";

    if ((server_port = getenv("SERVER_PORT")) == NULL)
      server_port = "631";

    snprintf(filename, sizeof(filename), "%s/rss%s", cachedir, resource);
    snprintf(newname, sizeof(newname), "%s.N", filename);

    httpAssembleURIf(HTTP_URI_CODING_ALL, baseurl, sizeof(baseurl), "http",
                     NULL, server_name, atoi(server_port), "/rss%s", resource);
  }

 /*
  * Load the previous RSS file, if any...
  */

  load_rss(rss, filename);

  changed = cupsArrayCount(rss) == 0;

 /*
  * Localize for the user's chosen language...
  */

  language = cupsLangDefault();

 /*
  * Read events and update the RSS file until we are out of events.
  */

  for (exit_status = 0, event = NULL;;)
  {
    if (changed)
    {
     /*
      * Save the messages to the file again, uploading as needed...
      */

      if (save_rss(rss, newname, baseurl))
      {
	if (http)
	{
	 /*
          * Upload the RSS file...
	  */

          if ((status = cupsPutFile(http, resource, filename)) != HTTP_CREATED)
            fprintf(stderr, "ERROR: Unable to PUT %s from %s on port %d: %d %s\n",
	            resource, host, port, status, httpStatus(status));
	}
	else
	{
	 /*
          * Move the new RSS file over top the old one...
	  */

          if (rename(newname, filename))
            fprintf(stderr, "ERROR: Unable to rename %s to %s: %s\n",
	            newname, filename, strerror(errno));
	}

	changed = 0;
      }
    }

   /*
    * Wait up to 30 seconds for an event...
    */

    timeout.tv_sec  = 30;
    timeout.tv_usec = 0;

    FD_ZERO(&input);
    FD_SET(0, &input);

    if (select(1, &input, NULL, NULL, &timeout) < 0)
      continue;
    else if (!FD_ISSET(0, &input))
    {
      fprintf(stderr, "DEBUG: %s is bored, exiting...\n", argv[1]);
      break;
    }

   /*
    * Read the next event...
    */

    event = ippNew();
    while ((state = ippReadFile(0, event)) != IPP_DATA)
    {
      if (state <= IPP_IDLE)
        break;
    }

    if (state == IPP_ERROR)
      fputs("DEBUG: ippReadFile() returned IPP_ERROR!\n", stderr);

    if (state <= IPP_IDLE)
      break;

   /*
    * Collect the info from the event...
    */

    printer_up_time        = ippFindAttribute(event, "printer-up-time",
                                              IPP_TAG_INTEGER);
    notify_sequence_number = ippFindAttribute(event, "notify-sequence-number",
                                	      IPP_TAG_INTEGER);
    notify_printer_uri     = ippFindAttribute(event, "notify-printer-uri",
                                	      IPP_TAG_URI);
    subject                = cupsNotifySubject(language, event);
    text                   = cupsNotifyText(language, event);

    if (printer_up_time && notify_sequence_number && subject && text)
    {
     /*
      * Create a new RSS message...
      */

      if (notify_printer_uri)
      {
        httpSeparateURI(HTTP_URI_CODING_ALL,
	                notify_printer_uri->values[0].string.text,
			link_scheme, sizeof(link_scheme),
                        link_username, sizeof(link_username),
			link_host, sizeof(link_host), &link_port,
		        link_resource, sizeof(link_resource));
        httpAssembleURI(HTTP_URI_CODING_ALL, link_url, sizeof(link_url),
	                "http", link_username, link_host, link_port,
			link_resource);
      }

      msg = new_message(notify_sequence_number->values[0].integer,
                        xml_escape(subject), xml_escape(text),
			notify_printer_uri ? xml_escape(link_url) : NULL,
			printer_up_time->values[0].integer);

      if (!msg)
      {
        fprintf(stderr, "ERROR: Unable to create message: %s\n",
	        strerror(errno));
        exit_status = 1;
	break;
      }

     /*
      * Add it to the array...
      */

      cupsArrayAdd(rss, msg);

      changed = 1;

     /*
      * Trim the array as needed...
      */

      while (cupsArrayCount(rss) > max_events)
      {
        msg = cupsArrayFirst(rss);

	cupsArrayRemove(rss, msg);

	delete_message(msg);
      }
    }

    if (subject)
      free(subject);

    if (text)
      free(text);

    ippDelete(event);
    event = NULL;
  }

 /*
  * We only get here when idle or error...
  */

  ippDelete(event);

  if (http)
  {
    unlink(filename);
    httpClose(http);
  }

  return (exit_status);
}
Exemplo n.º 18
0
// write AM info to files.
// This is done after each AM RPC.
//
int ACCT_MGR_INFO::write_info() {
    FILE* f;
    if (strlen(master_url)) {
        f = fopen(ACCT_MGR_URL_FILENAME, "w");
        if (!f) {
            msg_printf(NULL, MSG_USER_ALERT,
                "Can't write to %s; check file and directory permissions",
                ACCT_MGR_URL_FILENAME
            );
            return ERR_FOPEN;
        }
        fprintf(f,
            "<acct_mgr>\n"
            "    <name>%s</name>\n"
            "    <url>%s</url>\n",
            project_name,
            master_url
        );
        if (send_gui_rpc_info) {
            fprintf(f, "    <send_gui_rpc_info/>\n");
        }
        if (strlen(signing_key)) {
            fprintf(f,
                "    <signing_key>\n%s\n</signing_key>\n",
                signing_key
            );
        }
        fprintf(f,
            "</acct_mgr>\n"
        );
        fclose(f);
    }

    if (strlen(login_name) || strlen(authenticator)) {
        f = fopen(ACCT_MGR_LOGIN_FILENAME, "w");
        if (!f) {
            msg_printf(NULL, MSG_USER_ALERT,
                "Can't write to %s; check file and directory permissions",
                ACCT_MGR_LOGIN_FILENAME
            );
            return ERR_FOPEN;
        }
        fprintf(f,
            "<acct_mgr_login>\n"
        );
        if (strlen(authenticator)) {
            fprintf(f,
                "    <authenticator>%s</authenticator>\n",
                authenticator
            );
        } else {
            fprintf(f,
                "    <login>%s</login>\n"
                "    <password_hash>%s</password_hash>\n",
                login_name,
                password_hash
            );
        }
        fprintf(f,
            "    <previous_host_cpid>%s</previous_host_cpid>\n"
            "    <next_rpc_time>%f</next_rpc_time>\n"
            "    <opaque>\n%s\n"
            "    </opaque>\n"
            "    <no_project_notices>%d</no_project_notices>\n"
            "    <dynamic>%d</dynamic>\n",
            previous_host_cpid,
            next_rpc_time,
            opaque,
            no_project_notices?1:0,
            dynamic?1:0
        );
        char buf[4096];
        if (strlen(user_name)) {
            xml_escape(user_name, buf, sizeof(buf));
            fprintf(f,    "<user_name>%s</user_name>\n", buf);
        }
        if (strlen(team_name)) {
            xml_escape(team_name, buf, sizeof(buf));
            fprintf(f,    "<team_name>%s</team_name>\n", buf);
        }


        user_keywords.write(f);
        fprintf(f,
            "</acct_mgr_login>\n"
        );
        fclose(f);
    }
    return 0;
}
Exemplo n.º 19
0
static inline void
log_resolution (rule *r, symbol_number token,
		enum conflict_resolution resolution)
{
  if (report_flag & report_solved_conflicts)
    {
      /* The description of the resolution. */
      switch (resolution)
	{
	case shift_resolution:
	case right_resolution:
	  obstack_fgrow2 (&solved_conflicts_obstack,
			  _("    Conflict between rule %d and token %s"
			    " resolved as shift"),
			  r->number,
			  symbols[token]->tag);
	  break;

	case reduce_resolution:
	case left_resolution:
	  obstack_fgrow2 (&solved_conflicts_obstack,
			  _("    Conflict between rule %d and token %s"
			    " resolved as reduce"),
			  r->number,
			  symbols[token]->tag);
	  break;

	case nonassoc_resolution:
	  obstack_fgrow2 (&solved_conflicts_obstack,
			  _("    Conflict between rule %d and token %s"
			    " resolved as an error"),
			  r->number,
			  symbols[token]->tag);
	  break;
	}

      /* The reason. */
      switch (resolution)
	{
	case shift_resolution:
	  obstack_fgrow2 (&solved_conflicts_obstack,
			  " (%s < %s)",
			  r->prec->tag,
			  symbols[token]->tag);
	  break;

	case reduce_resolution:
	  obstack_fgrow2 (&solved_conflicts_obstack,
			  " (%s < %s)",
			  symbols[token]->tag,
			  r->prec->tag);
	  break;

	case left_resolution:
	  obstack_fgrow1 (&solved_conflicts_obstack,
			  " (%%left %s)",
			  symbols[token]->tag);
	  break;

	case right_resolution:
	  obstack_fgrow1 (&solved_conflicts_obstack,
			  " (%%right %s)",
			  symbols[token]->tag);
	  break;

	case nonassoc_resolution:
	  obstack_fgrow1 (&solved_conflicts_obstack,
			  " (%%nonassoc %s)",
			  symbols[token]->tag);
	  break;
	}

      obstack_sgrow (&solved_conflicts_obstack, ".\n");
    }

  /* XML report */
  if (xml_flag)
    {
      /* The description of the resolution. */
      switch (resolution)
        {
        case shift_resolution:
        case right_resolution:
          obstack_fgrow2 (&solved_conflicts_xml_obstack,
                          "        <resolution rule=\"%d\" symbol=\"%s\""
                          " type=\"shift\">",
                          r->number,
                          xml_escape (symbols[token]->tag));
          break;

        case reduce_resolution:
        case left_resolution:
          obstack_fgrow2 (&solved_conflicts_xml_obstack,
                          "        <resolution rule=\"%d\" symbol=\"%s\""
                          " type=\"reduce\">",
                          r->number,
                          xml_escape (symbols[token]->tag));
          break;

        case nonassoc_resolution:
          obstack_fgrow2 (&solved_conflicts_xml_obstack,
                          "        <resolution rule=\"%d\" symbol=\"%s\""
                          " type=\"error\">",
                          r->number,
                          xml_escape (symbols[token]->tag));
          break;
        }

      /* The reason. */
      switch (resolution)
        {
        case shift_resolution:
          obstack_fgrow2 (&solved_conflicts_xml_obstack,
                          "%s &lt; %s",
                          xml_escape_n (0, r->prec->tag),
                          xml_escape_n (1, symbols[token]->tag));
          break;

        case reduce_resolution:
          obstack_fgrow2 (&solved_conflicts_xml_obstack,
                          "%s &lt; %s",
                          xml_escape_n (0, symbols[token]->tag),
                          xml_escape_n (1, r->prec->tag));
          break;

        case left_resolution:
          obstack_fgrow1 (&solved_conflicts_xml_obstack,
                          "%%left %s",
                          xml_escape (symbols[token]->tag));
          break;

        case right_resolution:
          obstack_fgrow1 (&solved_conflicts_xml_obstack,
                          "%%right %s",
                          xml_escape (symbols[token]->tag));
          break;

        case nonassoc_resolution:
          obstack_fgrow1 (&solved_conflicts_xml_obstack,
                          "%%nonassoc %s",
                          xml_escape (symbols[token]->tag));
      break;
        }

      obstack_sgrow (&solved_conflicts_xml_obstack, "</resolution>\n");
    }
}
Exemplo n.º 20
0
/** helper funcation to add note to formatted stats_tree */
WS_DLL_PUBLIC void stats_tree_format_node_as_str(const stat_node *node,
						 GString *s,
						 st_format_type format_type,
						 guint indent,
						 const gchar *path,
						 gint maxnamelen,
						 gint sort_column,
						 gboolean sort_descending)
{
	int count;
	int num_columns= node->st->num_columns;
	gchar **values= stats_tree_get_values_from_node(node);
	stat_node *child;
	sortinfo si;
	gchar *full_path;
	char fmt[16];

	switch(format_type)
	{
	case ST_FORMAT_YAML:
		if (indent) {
			g_sprintf(fmt, "%%%ds%%s%%s", indent*4-2);
		}
		else {
			strcpy(fmt, "%s%s%s");
		}
		g_string_append_printf(s, fmt, "", indent?"- ":"", "Description");
		g_string_append_printf(s, ": \"%s\"\n", values[0]);

		for (count = 1; count<num_columns; count++) {
			if (*values[count]) {
				g_string_append_printf(s, fmt, "", indent?"  ":"",
										stats_tree_get_column_name(count));
				g_string_append_printf(s, ": %s\n", values[count]);
			}
		}
		if (node->children) {
			g_string_append_printf(s, fmt, "", indent?"  ":"", "Items:\n");
		}
		break;
	case ST_FORMAT_XML:
		{
		char *itemname = xml_escape(values[0]);
		g_string_append_printf(s,"<stat-node name=\"%s\"%s>\n",itemname,
				node->rng?" isrange=\"true\"":"");
		g_free(itemname);
		for (count = 1; count<num_columns; count++) {
			gchar *colname= g_strdup(stats_tree_get_column_name(count));
			g_string_append_printf(s,"<%s>",clean_for_xml_tag(colname));
			g_string_append_printf(s,"%s</%s>\n",values[count],colname);
			g_free(colname);
		}
		}
		break;
	case ST_FORMAT_CSV:
		g_string_append_printf(s,"%d,\"%s\",\"%s\"",indent,path,values[0]);
		for (count = 1; count<num_columns; count++) {
			g_string_append_printf(s,",%s",values[count]);
		}
		g_string_append (s,"\n");
		break;
	case ST_FORMAT_PLAIN:
		g_sprintf (fmt,"%%%ds%%-%us",indent,maxnamelen-indent);
		g_string_append_printf(s,fmt,"",values[0]);
		for (count = 1; count<num_columns; count++) {
			g_sprintf (fmt," %%-%us",stats_tree_get_column_size(count)+1);
			g_string_append_printf(s,fmt,values[count]);
		}
		g_string_append (s,"\n");
		break;
	}

	indent++;
	indent = indent > INDENT_MAX ? INDENT_MAX : indent;
	full_path= g_strdup_printf ("%s/%s",path,values[0]);

	for (count = 0; count<num_columns; count++) {
		g_free(values[count]);
	}
	g_free(values);

	if (node->children) {
		GArray *Children= g_array_new(FALSE,FALSE,sizeof(child));
		for (child = node->children; child; child = child->next ) {
			g_array_append_val(Children,child);
		}
		si.sort_column = sort_column;
		si.sort_descending = sort_descending;
		g_array_sort_with_data(Children,stat_node_array_sortcmp,&si);
		for (count = 0; count<((int)Children->len); count++) {
			stats_tree_format_node_as_str(g_array_index(Children,stat_node*,count), s, format_type,
					indent, full_path, maxnamelen, sort_column, sort_descending);
		}
		g_array_free(Children,FALSE);
	}
	g_free(full_path);

	if (format_type==ST_FORMAT_XML) {
		g_string_append(s,"</stat-node>\n");
	}
}
Exemplo n.º 21
0
int archive_result(DB_RESULT& result) {
    int n;
    n = fprintf(re_stream,
        "<result_archive>\n"
        "    <id>%d</id>\n",
        result.id
    );

    // xml_escape can increase size by factor of 6, e.g. x -> &#NNN;
    //
    char buf[BLOB_SIZE*6];
    xml_escape(result.stderr_out, buf, sizeof(buf));

    if (n >= 0) n = fprintf(
        re_stream,
        "  <create_time>%d</create_time>\n"
        "  <workunitid>%d</workunitid>\n"
        "  <server_state>%d</server_state>\n"
        "  <outcome>%d</outcome>\n"
        "  <client_state>%d</client_state>\n"
        "  <hostid>%d</hostid>\n"
        "  <userid>%d</userid>\n"
        "  <report_deadline>%d</report_deadline>\n"
        "  <sent_time>%d</sent_time>\n"
        "  <received_time>%d</received_time>\n"
        "  <name>%s</name>\n"
        "  <cpu_time>%.15e</cpu_time>\n"
        "  <xml_doc_in>%s</xml_doc_in>\n"
        "  <xml_doc_out>%s</xml_doc_out>\n"
        "  <stderr_out>%s</stderr_out>\n"
        "  <batch>%d</batch>\n"
        "  <file_delete_state>%d</file_delete_state>\n"
        "  <validate_state>%d</validate_state>\n"
        "  <claimed_credit>%.15e</claimed_credit>\n"
        "  <granted_credit>%.15e</granted_credit>\n"
        "  <opaque>%f</opaque>\n"
        "  <random>%d</random>\n"
        "  <app_version_num>%d</app_version_num>\n"
        "  <appid>%d</appid>\n"
        "  <exit_status>%d</exit_status>\n"
        "  <teamid>%d</teamid>\n"
        "  <priority>%d</priority>\n"
        "  <mod_time>%s</mod_time>\n",
        result.create_time,
        result.workunitid,
        result.server_state,
        result.outcome,
        result.client_state,
        result.hostid,
        result.userid,
        result.report_deadline,
        result.sent_time,
        result.received_time,
        result.name,
        result.cpu_time,
        result.xml_doc_in,
        result.xml_doc_out,
        buf,
        result.batch,
        result.file_delete_state,
        result.validate_state,
        result.claimed_credit,
        result.granted_credit,
        result.opaque,
        result.random,
        result.app_version_num,
        result.appid,
        result.exit_status,
        result.teamid,
        result.priority,
        result.mod_time
    );

    if (n >= 0) n = fprintf(re_stream,
        "</result_archive>\n"
    );

    if (n >= 0) {
        n = fprintf(re_index_stream,
            "%d     %d    %s\n",
            result.id, time_int, result.name
        );
    }

    if (n < 0) fail("fprintf() failed\n");

    return 0;
}
Exemplo n.º 22
0
// Write project information to client state file or GUI RPC reply
//
int PROJECT::write_state(MIOFILE& out, bool gui_rpc) {
    unsigned int i;
    char un[2048], tn[2048];

    out.printf(
        "<project>\n"
    );

    xml_escape(user_name, un, sizeof(un));
    xml_escape(team_name, tn, sizeof(tn));
    out.printf(
        "    <master_url>%s</master_url>\n"
        "    <project_name>%s</project_name>\n"
        "    <symstore>%s</symstore>\n"
        "    <user_name>%s</user_name>\n"
        "    <team_name>%s</team_name>\n"
        "    <host_venue>%s</host_venue>\n"
        "    <email_hash>%s</email_hash>\n"
        "    <cross_project_id>%s</cross_project_id>\n"
        "    <external_cpid>%s</external_cpid>\n"
        "    <cpid_time>%f</cpid_time>\n"
        "    <user_total_credit>%f</user_total_credit>\n"
        "    <user_expavg_credit>%f</user_expavg_credit>\n"
        "    <user_create_time>%f</user_create_time>\n"
        "    <rpc_seqno>%d</rpc_seqno>\n"
        "    <userid>%d</userid>\n"
        "    <teamid>%d</teamid>\n"
        "    <hostid>%d</hostid>\n"
        "    <host_total_credit>%f</host_total_credit>\n"
        "    <host_expavg_credit>%f</host_expavg_credit>\n"
        "    <host_create_time>%f</host_create_time>\n"
        "    <nrpc_failures>%d</nrpc_failures>\n"
        "    <master_fetch_failures>%d</master_fetch_failures>\n"
        "    <min_rpc_time>%f</min_rpc_time>\n"
        "    <next_rpc_time>%f</next_rpc_time>\n"
        "    <rec>%f</rec>\n"
        "    <rec_time>%f</rec_time>\n"
        "    <resource_share>%f</resource_share>\n"
        "    <desired_disk_usage>%f</desired_disk_usage>\n"
        "    <duration_correction_factor>%f</duration_correction_factor>\n"
        "    <sched_rpc_pending>%d</sched_rpc_pending>\n"
        "    <send_time_stats_log>%d</send_time_stats_log>\n"
        "    <send_job_log>%d</send_job_log>\n"
        "    <njobs_success>%d</njobs_success>\n"
        "    <njobs_error>%d</njobs_error>\n"
        "    <elapsed_time>%f</elapsed_time>\n"
        "    <last_rpc_time>%f</last_rpc_time>\n"
        "%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
        master_url,
        project_name,
        symstore,
        un,
        tn,
        host_venue,
        email_hash,
        cross_project_id,
        external_cpid,
        cpid_time,
        user_total_credit,
        user_expavg_credit,
        user_create_time,
        rpc_seqno,
        userid,
        teamid,
        hostid,
        host_total_credit,
        host_expavg_credit,
        host_create_time,
        nrpc_failures,
        master_fetch_failures,
        min_rpc_time,
        next_rpc_time,
        pwf.rec,
        pwf.rec_time,
        resource_share,
        desired_disk_usage,
        duration_correction_factor,
        sched_rpc_pending,
        send_time_stats_log,
        send_job_log,
        njobs_success,
        njobs_error,
        elapsed_time,
        last_rpc_time,
        anonymous_platform?"    <anonymous_platform/>\n":"",
        master_url_fetch_pending?"    <master_url_fetch_pending/>\n":"",
        trickle_up_pending?"    <trickle_up_pending/>\n":"",
        send_full_workload?"    <send_full_workload/>\n":"",
        dont_use_dcf?"    <dont_use_dcf/>\n":"",
        non_cpu_intensive?"    <non_cpu_intensive/>\n":"",
        verify_files_on_app_start?"    <verify_files_on_app_start/>\n":"",
        suspended_via_gui?"    <suspended_via_gui/>\n":"",
        dont_request_more_work?"    <dont_request_more_work/>\n":"",
        detach_when_done?"    <detach_when_done/>\n":"",
        ended?"    <ended/>\n":"",
        attached_via_acct_mgr?"    <attached_via_acct_mgr/>\n":"",
        (this == gstate.scheduler_op->cur_proj)?"   <scheduler_rpc_in_progress/>\n":"",
        use_symlinks?"    <use_symlinks/>\n":""
    );
    for (int j=0; j<coprocs.n_rsc; j++) {
        out.printf(
            "    <rsc_backoff_time>\n"
            "        <name>%s</name>\n"
            "        <value>%f</value>\n"
            "    </rsc_backoff_time>\n"
            "    <rsc_backoff_interval>\n"
            "        <name>%s</name>\n"
            "        <value>%f</value>\n"
            "    </rsc_backoff_interval>\n",
            rsc_name(j), rsc_pwf[j].backoff_time,
            rsc_name(j), rsc_pwf[j].backoff_interval
        );
        if (no_rsc_ams[j]) {
            out.printf("    <no_rsc_ams>%s</no_rsc_ams>\n", rsc_name(j));
        }
        if (no_rsc_apps[j]) {
            out.printf("    <no_rsc_apps>%s</no_rsc_apps>\n", rsc_name(j));
        }
        if (no_rsc_pref[j]) {
            out.printf("    <no_rsc_pref>%s</no_rsc_pref>\n", rsc_name(j));
        }
        if (j>0 && gui_rpc && (rsc_pwf[j].ncoprocs_excluded == rsc_work_fetch[j].ninstances)) {
            out.printf("    <no_rsc_config>%s</no_rsc_config>\n", rsc_name(j));
        }
    }
    if (ams_resource_share >= 0) {
        out.printf("    <ams_resource_share_new>%f</ams_resource_share_new>\n",
            ams_resource_share
        );
    }
    if (gui_rpc) {
        out.printf(
            "%s"
            "    <sched_priority>%f</sched_priority>\n"
            "    <project_files_downloaded_time>%f</project_files_downloaded_time>\n",
            gui_urls.c_str(),
            sched_priority,
            project_files_downloaded_time
        );
        if (download_backoff.next_xfer_time > gstate.now) {
            out.printf(
                "    <download_backoff>%f</download_backoff>\n",
                download_backoff.next_xfer_time - gstate.now
            );
        }
        if (upload_backoff.next_xfer_time > gstate.now) {
            out.printf(
                "    <upload_backoff>%f</upload_backoff>\n",
                upload_backoff.next_xfer_time - gstate.now
            );
        }
        if (strlen(host_venue)) {
            out.printf("    <venue>%s</venue>\n", host_venue);
        }
        out.printf("    <project_dir>%s</project_dir>\n", project_dir_absolute());
    } else {
       for (i=0; i<scheduler_urls.size(); i++) {
            out.printf(
                "    <scheduler_url>%s</scheduler_url>\n",
                scheduler_urls[i].c_str()
            );
        }
        if (strlen(code_sign_key)) {
            out.printf(
                "    <code_sign_key>\n%s\n</code_sign_key>\n", code_sign_key
            );
        }
        for (i=0; i<trickle_up_ops.size(); i++) {
            TRICKLE_UP_OP* t = trickle_up_ops[i];
            out.printf(
                "    <trickle_up_url>%s</trickle_up_url>\n",
                t->url.c_str()
            );
        }
    }
    out.printf(
        "</project>\n"
    );
    return 0;
}
Exemplo n.º 23
0
// Write the host information to either:
// - client state XML file (net info, coprocs)
// - a GUI RPC reply (net info, coprocs)
// - a scheduler request message
//   (net info unless config says otherwise, no coprocs)
// - account manager request
//   (net info unless config says otherwise, coprocs)
// - app init file (net info, coprocs)
//
int HOST_INFO::write(
    MIOFILE& out, bool include_net_info, bool include_coprocs
) {
    char pv[265], pm[256], pf[1024], osn[256], osv[256];
    out.printf(
        "<host_info>\n"
        "    <timezone>%d</timezone>\n",
        timezone
    );
    if (include_net_info) {
        out.printf(
            "    <domain_name>%s</domain_name>\n"
            "    <ip_addr>%s</ip_addr>\n",
            domain_name,
            ip_addr
        );
    }
    xml_escape(p_vendor, pv, sizeof(pv));
    xml_escape(p_model, pm, sizeof(pm));
    xml_escape(p_features, pf, sizeof(pf));
    xml_escape(os_name, osn, sizeof(osn));
    xml_escape(os_version, osv, sizeof(osv));
    out.printf(
        "    <host_cpid>%s</host_cpid>\n"
        "    <p_ncpus>%d</p_ncpus>\n"
        "    <p_vendor>%s</p_vendor>\n"
        "    <p_model>%s</p_model>\n"
        "    <p_features>%s</p_features>\n"
        "    <p_fpops>%f</p_fpops>\n"
        "    <p_iops>%f</p_iops>\n"
        "    <p_membw>%f</p_membw>\n"
        "    <p_calculated>%f</p_calculated>\n"
        "    <p_vm_extensions_disabled>%d</p_vm_extensions_disabled>\n"
        "    <m_nbytes>%f</m_nbytes>\n"
        "    <m_cache>%f</m_cache>\n"
        "    <m_swap>%f</m_swap>\n"
        "    <d_total>%f</d_total>\n"
        "    <d_free>%f</d_free>\n"
        "    <os_name>%s</os_name>\n"
        "    <os_version>%s</os_version>\n",
        host_cpid,
        p_ncpus,
        pv,
        pm,
        pf,
        p_fpops,
        p_iops,
        p_membw,
        p_calculated,
        p_vm_extensions_disabled?1:0,
        m_nbytes,
        m_cache,
        m_swap,
        d_total,
        d_free,
        osn,
        osv
    );
    if (strlen(virtualbox_version)) {
        char buf[256];
        xml_escape(virtualbox_version, buf, sizeof(buf));
        out.printf(
            "    <virtualbox_version>%s</virtualbox_version>\n",
            buf
        );
    }
    if (include_coprocs) {
        _coprocs.write_xml(out, false);
    }
    out.printf(
        "</host_info>\n"
    );
    return 0;
}