Ejemplo n.º 1
0
cl_thread_t *flt_xmlarc_getthread(const u_char *year,const u_char *month,const u_char *tid) {
  cf_string_t str;
  cl_thread_t *thr = cf_alloc(NULL,1,sizeof(*thr),CF_ALLOC_CALLOC);

  GdomeException e;
  GdomeDocument *doc;
  GdomeDOMImplementation *impl;

  /* {{{ generate thread file name */
  cf_str_init(&str);
  cf_str_char_set(&str,flt_xmlarc_apath,strlen(flt_xmlarc_apath));
  cf_str_char_append(&str,'/');
  cf_str_chars_append(&str,year,strlen(year));
  cf_str_char_append(&str,'/');
  cf_str_chars_append(&str,month,strlen(month));
  cf_str_char_append(&str,'/');
  if(*tid != 't') cf_str_char_append(&str,'t');
  cf_str_chars_append(&str,tid,strlen(tid));
  cf_str_chars_append(&str,".xml",4);
  /* }}} */

  impl = gdome_di_mkref();
  if((doc = gdome_di_createDocFromURI(impl,str.content,GDOME_LOAD_PARSING,&e)) == NULL) return NULL;

  thr->tid = cf_str_to_uint64(*tid == 't' ? tid+1 : tid);

  if(flt_xmlarc_cts(doc,thr) != 0) return NULL;

  gdome_doc_unref(doc,&e);
  gdome_di_unref(impl,&e);

  return thr;
}
Ejemplo n.º 2
0
/**
 * \internal
 * Reads the list of accounts and the list of queue_list returned by the MOAB cluster
 * "mcredctl" command and places them on \p accounts and \p queue_list, respectively.
 */
static void server_moab_read_credentials(GString *accounts, GString *queue_list)
{
	GString *cmd_line = NULL;
	gchar *std_out = NULL;
	gchar *std_err = NULL;
	gint exit_status;

	GdomeDOMImplementation *dom_impl = NULL;
	GdomeDocument *doc = NULL;
	GdomeElement *element = NULL;
	GdomeException exception;
	GdomeDOMString *attribute_name;

	cmd_line = g_string_new("");
	g_string_printf(cmd_line, "mcredctl -q accessfrom user:%s --format=xml", getenv("USER"));
	if (g_spawn_command_line_sync(cmd_line->str, &std_out, &std_err, &exit_status, NULL) == FALSE)
		goto err;

	if ((dom_impl = gdome_di_mkref()) == NULL)
		goto err;

	if ((doc = gdome_di_createDocFromMemory(dom_impl, std_out, GDOME_LOAD_PARSING, &exception)) == NULL) {
		gdome_di_unref(dom_impl, &exception);
		goto err;
	}

	if ((element = gdome_doc_documentElement(doc, &exception)) == NULL) {
		gdome_doc_unref(doc, &exception);
		gdome_di_unref(dom_impl, &exception);
		goto err;
	}

	if ((element = (GdomeElement *) gdome_el_firstChild(element, &exception)) == NULL) {
		gdome_doc_unref(doc, &exception);
		gdome_di_unref(dom_impl, &exception);
		goto err;
	}

	attribute_name = gdome_str_mkref("AList");
	g_string_assign(accounts, (gdome_el_getAttribute(element, attribute_name, &exception))->str);
	gdome_str_unref(attribute_name);

	attribute_name = gdome_str_mkref("CList");
	g_string_assign(queue_list, (gdome_el_getAttribute(element, attribute_name, &exception))->str);
	gdome_str_unref(attribute_name);

	gdome_doc_unref(doc, &exception);
	gdome_di_unref(dom_impl, &exception);

 err:	g_string_free(cmd_line, TRUE);
	g_free(std_out);
	g_free(std_err);
}