コード例 #1
0
ファイル: cfg.c プロジェクト: tdunnick/phineas
/*
 * Create a censored configuration for display purposes, and return
 * it's name.  This has the side effect of beautifying the Config XML.
 */
char *cfg_format ()
{
  char *buf, *p, *pe;

  if ((Config == NULL) || (*ConfigName == 0))
    return (NULL);
  if (*ConfigPName != 0)
    return (ConfigPName);
  strcpy (ConfigPName, ConfigName);
  if ((p = strrchr (ConfigPName, '.')) == NULL)
    p = ConfigName + strlen (ConfigPName);
  strcpy (p, "Configuration.xml");
  xml_beautify (Config, 2);
  buf = xml_format (Config);
  pe = buf;
  while ((p = strstr (pe, "<Password>")) != NULL)
  {
    p += 10;
    pe = strstr (p, "</Password>");
    if (pe == NULL)
      break;
    if (p != pe)
    {
      *p++ = '*';
      strcpy (p, pe);
    }
  }
  writefile (ConfigPName, buf, strlen (buf));
  free (buf);
  return (ConfigPName);
}
コード例 #2
0
ファイル: show_help.c プロジェクト: ORNL/ompi
static void show_accumulated_duplicates(int fd, short event, void *context)
{
    opal_list_item_t *item;
    time_t now = time(NULL);
    tuple_list_item_t *tli;
    char *tmp, *output;

    /* Loop through all the messages we've displayed and see if any
       processes have sent duplicates that have not yet been displayed
       yet */
    for (item = opal_list_get_first(&abd_tuples); 
         opal_list_get_end(&abd_tuples) != item;
         item = opal_list_get_next(item)) {
        tli = (tuple_list_item_t*) item;
        if (tli->tli_display && 
            tli->tli_count_since_last_display > 0) {
            static bool first = true;
            if (orte_xml_output) {
                asprintf(&tmp, "%d more process%s sent help message %s / %s",
                         tli->tli_count_since_last_display,
                         (tli->tli_count_since_last_display > 1) ? "es have" : " has",
                         tli->tli_filename, tli->tli_topic);
                output = xml_format((unsigned char*)tmp);
                free(tmp);
                fprintf(orte_xml_fp, "%s", output);
                free(output);
            } else {
                opal_output(0, "%d more process%s sent help message %s / %s",
                            tli->tli_count_since_last_display,
                            (tli->tli_count_since_last_display > 1) ? "es have" : " has",
                            tli->tli_filename, tli->tli_topic);
            }
            tli->tli_count_since_last_display = 0;

            if (first) {
                if (orte_xml_output) {
                    fprintf(orte_xml_fp, "<stderr>Set MCA parameter \"orte_base_help_aggregate\" to 0 to see all help / error messages</stderr>\n");
                    fflush(orte_xml_fp);
                } else {
                    opal_output(0, "Set MCA parameter \"orte_base_help_aggregate\" to 0 to see all help / error messages");
                }
                first = false;
            }
        }
    }

    show_help_time_last_displayed = now;
    show_help_timer_set = false;
}
コード例 #3
0
ファイル: xmlb.c プロジェクト: teapejon/phineas
void xmlb (FILE *fp, char *fname, int indent)
{
  XML *xml;
  char *ch;

  if ((xml = xml_load (fname)) == NULL)
    return;
  xml_beautify (xml, indent);
  ch = xml_format (xml);
  xml_free (xml);
  if (ch != NULL)
  {
    if (fp == NULL)
      fp = stdout;
    fprintf (fp, "%s", ch);
    free (ch);
  }
}
コード例 #4
0
ファイル: cfg.c プロジェクト: tdunnick/phineas
/*
 * save a configuration, encrypting it if credentials found
 */
int cfg_save (XML *xml, char *path)
{
  int r;
  XML *x;

  cfg_clean (path);
  x = xml;
  if ((ConfigCert != NULL) || (ConfigPass != NULL))
  {
    unsigned char *p;

    p = xml_format (xml);
    x = xcrypt_encrypt (p, strlen (p) + 1, ConfigCert, NULL, 
      ConfigPass, AES256);
    free (p);
  }
  r = xml_save (x, path);
  if (x != xml)
    xml_free (x);
  return (r);
}
コード例 #5
0
ファイル: show_help.c プロジェクト: ORNL/ompi
static int show_help(const char *filename, const char *topic,
                     const char *output, orte_process_name_t *sender)
{
    int rc;
    tuple_list_item_t *tli = NULL;
    orte_namelist_t *pnli;
    time_t now = time(NULL);

    /* If we're aggregating, check for duplicates.  Otherwise, don't
       track duplicates at all and always display the message. */
    if (orte_help_want_aggregate) {
        rc = get_tli(filename, topic, &tli);
    } else {
        rc = ORTE_ERR_NOT_FOUND;
    }

    /* If there's no output string (i.e., this is a control message
       asking us to suppress), then skip to the end. */
    if (NULL == output) {
        tli->tli_display = false;
        goto after_output;
    }

    /* Was it already displayed? */
    if (ORTE_SUCCESS == rc) {
        /* Yes.  But do we want to print anything?  That's complicated.

           We always show the first message of a given (filename,
           topic) tuple as soon as it arrives.  But we don't want to
           show duplicate notices often, because we could get overrun
           with them.  So we want to gather them up and say "We got N
           duplicates" every once in a while.

           And keep in mind that at termination, we'll unconditionally
           show all accumulated duplicate notices.

           A simple scheme is as follows:
           - when the first of a (filename, topic) tuple arrives
             - print the message
             - if a timer is not set, set T=now
           - when a duplicate (filename, topic) tuple arrives
             - if now>(T+5) and timer is not set (due to
               non-pre-emptiveness of our libevent, a timer *could* be
               set!)
               - print all accumulated duplicates
               - reset T=now
             - else if a timer was not set, set the timer for T+5
             - else if a timer was set, do nothing (just wait)
           - set T=now when the timer expires
        */           
        ++tli->tli_count_since_last_display;
        if (now > show_help_time_last_displayed + 5 && !show_help_timer_set) {
            show_accumulated_duplicates(0, 0, NULL);
        } else if (!show_help_timer_set) {
            opal_event_evtimer_set(orte_event_base, &show_help_timer_event,
                                   show_accumulated_duplicates, NULL);
            opal_event_evtimer_add(&show_help_timer_event, &show_help_interval);
            show_help_timer_set = true;
        }
    } 
    /* Not already displayed */
    else if (ORTE_ERR_NOT_FOUND == rc) {
        if (orte_xml_output) {
            char *tmp;
            tmp = xml_format((unsigned char*)output);
            fprintf(orte_xml_fp, "%s", tmp);
            fflush(orte_xml_fp);
            free(tmp);
        } else {
            opal_output(orte_clean_output, "%s", output);
        }
        if (!show_help_timer_set) {
            show_help_time_last_displayed = now;
        }
    }
    /* Some other error occurred */
    else {
        ORTE_ERROR_LOG(rc);
        return rc;
    }

 after_output:
    /* If we're aggregating, add this process name to the list */
    if (orte_help_want_aggregate) {
        pnli = OBJ_NEW(orte_namelist_t);
        if (NULL == pnli) {
            rc = ORTE_ERR_OUT_OF_RESOURCE;
            ORTE_ERROR_LOG(rc);
            return rc;
        }
        pnli->name = *sender;
        opal_list_append(&(tli->tli_processes), &(pnli->super));
    }
    return ORTE_SUCCESS;
}
コード例 #6
0
ファイル: ebxml_sender.c プロジェクト: tdunnick/phineas
/*
 * Get the mime header (soap) container
 */
MIME *ebxml_getsoap (XML *xml, QUEUEROW *r)
{
  XML *soap;
  MIME *msg;
  char *ch,
       *pid,
       *partyid,
       *cpa,
       *organization,
       path[MAX_PATH],
       buf[MAX_PATH];
  int route;

  debug ("getting soap container...\n");
  organization = cfg_org (xml);
  pid = queue_field_get (r, "MESSAGEID");
  if (pid != NULL)
    pid = strchr (pid, '-');
  if (pid++ == NULL)
  {
    error ("Can't get PID from MESSAGEID\n");
    return (NULL);
  }
  if ((route = cfg_route_index (xml,  queue_field_get (r, "ROUTEINFO"))) 
    < 0) return (NULL);

  debug ("getting soap template for pid=%s org=%s...\n", pid, organization);
  if ((soap = ebxml_template (xml, XSOAP)) == NULL)
  {
    error ("Can't get SOAP template\n");
    return (NULL);
  }
  xml_set_text (soap, SOAPFROMPARTY, cfg_party (xml));
  partyid = "Someone_else";
  xml_set_text (soap, SOAPTOPARTY, partyid);
  cpa = cfg_route (xml, route, "Cpa");
  xml_set_text (soap, SOAPCPAID, cpa);
  xml_set_text (soap, SOAPCONVERSEID, pid);
  xml_set_text (soap, SOAPSERVICE, queue_field_get (r, "SERVICE"));
  xml_set_text (soap, SOAPACTION, queue_field_get (r, "ACTION"));
  sprintf (buf, "%ld@%s", pid, organization);
  xml_set_text (soap, SOAPMESSAGEID, buf);
  queue_field_set (r, "MESSAGECREATIONTIME", ptime (NULL, buf));
  xml_set_text (soap, SOAPDATATIME, buf);
  if (!strcmp (queue_field_get (r, "ACTION"), "Ping"))
  {
    xml_delete (soap, SOAPBODY);
  }
  else
  {
    sprintf (buf, "cid:%s@%s", queue_field_get (r, "PAYLOADFILE"),
      organization);
    debug ("set %s xlink:href=\"%s\"\n", SOAPMREF, buf);
    xml_set_attribute (soap, SOAPMREF, "xlink:href", buf);
    sprintf (buf, "%s.%s", r->queue->name, queue_field_get (r, "RECORDID"));
    xml_set_text (soap, SOAPDBRECID, buf);
    xml_set_text (soap, SOAPDBMESSID, queue_field_get (r, "MESSAGEID"));
    xml_set_text (soap, SOAPDBARGS, queue_field_get (r, "ARGUMENTS"));
    xml_set_text (soap, SOAPDBRECP, 
	queue_field_get (r, "MESSAGERECIPIENT"));
  }
  debug ("building soap mime container...\n");
  msg = mime_alloc ();
  mime_setHeader (msg, MIME_CONTENT, MIME_XML, 99);
  sprintf (buf, "<%s%s>", "ebxml-envelope@", organization);
  mime_setHeader (msg, MIME_CONTENTID, buf, 0);
  debug ("formatting soap xml...\n");
  ch = xml_format (soap);
  debug ("soap envelope:\n%s\n", ch);
  xml_free (soap);
  mime_setBody (msg, ch, strlen (ch));
  free (ch);
  debug ("returning soap message...\n");
  return (msg);
}
コード例 #7
0
ファイル: PluginEntry.c プロジェクト: BYC/geany-plugins
void kb_run_xml_pretty_print(G_GNUC_UNUSED guint key_id)
{
    xml_format(NULL, NULL);
}