Beispiel #1
0
void load_config(void)
{
     struct stat sfile;
     int load_context;
     char *rcpath;

     load_context = error_new_context(_("Error loading configfile"), NULL);

     rcpath = filename_config(load_context);
     if(!rcpath) {
	  error_flush(load_context);
	  return;
     }

     /* no config file is fine */
     if(stat(rcpath, &sfile) == -1 || !sfile.st_size) {
	  error_flush(load_context);
	  /* If there is no configuration file, we start with the
	     current configuration file version */
	  config->config_version = CURRENT_CONFIG_VERSION;
	  config->asked_version = CURRENT_CONFIG_VERSION;
	  g_free(rcpath);
	  return;
     }

     /* refuse to read config file if world readable (bind passwords) */
     if( ((sfile.st_mode & ~S_IFMT) & (S_IRWXG|S_IRWXO)) != 0 ) {
	  error_push(load_context,
		     _("%s is group and/or world readable or writeable.\n"
		       "This file can contain passwords in cleartext,\n"
		       "and is recommended to have mode 0600.\n\n"
		       "Continuing with default settings...\n"),
		     rcpath);
	  error_flush(load_context);
	  g_free(rcpath);
	  return;
     }

     config = process_rcfile_XML(load_context, rcpath);
/*      printf("config = %08lx\n", config); */
/*      process_rcfile(rcfile) */

     g_free(rcpath);

     if (config == NULL) {
	  error_push(load_context, 
		     _("No valid configuration found. Using default (empty) configuration"));

	  config = new_config();
     }

     error_flush(load_context);
}
Beispiel #2
0
/* ---------------------------------------------------------------------- */
void PHRQ_io::
error_msg(const char *err_str, bool stop)
/* ---------------------------------------------------------------------- */
{

	io_error_count++;
	if (error_ostream != NULL && error_on)
	{
		//(*error_ostream) << err_str;
		screen_msg(err_str);
		error_flush();
	}
	if (stop)
	{
		if (error_ostream != NULL && error_on)
		{
			//(*error_ostream) << "Stopping.\n";
			screen_msg("Stopping.\n");
			error_ostream->flush();
		}
		output_msg("Stopping.\n");
		log_msg("Stopping.\n");

		throw PhreeqcStop();
	}
}
Beispiel #3
0
void error_popup(char *title, char *message, GtkWidget *transient_for)
{
     int context;

     context = error_new_context(title, transient_for);
     error_push(context, message);
     error_flush(context);

}
static void browse_new_from_entry_callback(GtkMenuItem *widget,
					   GqBrowserNodeDn *entry)
{
     if (GQ_IS_BROWSER_NODE_DN(entry)) {
	  char *dn = entry->dn;
	  int error_context =
	       error_new_context(_("Creating new entry from existing entry"),
				 GTK_WIDGET(widget));

	  GqServer *server =
	       GQ_SERVER(gtk_object_get_data(GTK_OBJECT(widget),
							 "server"));

	  new_from_entry(error_context, server, dn);

	  error_flush(error_context);
     }
}
Beispiel #5
0
/* ---------------------------------------------------------------------- */
void PHRQ_io::
warning_msg(const char *err_str)
/* ---------------------------------------------------------------------- */
{
	if (error_file != NULL && error_on)
	{
		//(*error_file) << err_str << "\n";
		std::string err_stdstr(err_str);
		err_stdstr.append("\n");
		screen_msg(err_stdstr.c_str());
		error_flush();
	}
	std::ostringstream warn_str;
	warn_str << err_str << "\n";
	log_msg(warn_str.str().c_str());
	log_flush();
	output_msg(warn_str.str().c_str());
	output_flush();
}
static void dump_server(GtkWidget *widget, GqTab *tab)
{
     GQTreeWidget *ctree;
     GQTreeWidgetNode *node;
     GqBrowserNode *e;
     GqServer *server;
     GList *bases = NULL;
     GList *to_export = NULL, *I;
     struct dn_on_server *dos;
     int error_context;

     ctree = GQ_TAB_BROWSE(tab)->ctreeroot;
     node = GQ_TAB_BROWSE(tab)->tree_row_popped_up;
     e = GQ_BROWSER_NODE(gq_tree_get_node_data (ctree, node));

     g_assert(GQ_IS_BROWSER_NODE_SERVER(e));

     server = server_from_node(ctree, node);

     if (e == NULL || server == NULL)
	  return;

     error_context = error_new_context(_("Exporting server to LDIF"),
				       tab->win->mainwin);

     bases = get_suffixes(error_context, GQ_BROWSER_NODE_SERVER(e)->server);

     /* turn suffixes list into a list of dn_on_server objects
	(impedance match) */
     for (I = g_list_first(bases) ; I ; I = g_list_next(I) ) {
	  dos = new_dn_on_server(I->data, server);
	  dos->flags = LDAP_SCOPE_SUBTREE; /* default is LDAP_SCOPE_BASE */
	  to_export = g_list_append(to_export, dos);
	  g_free(I->data);
	  I->data = NULL;
     }
     g_list_free(bases);

     export_many(error_context, tab->win->mainwin, to_export);

     error_flush(error_context);
}
Beispiel #7
0
/* ---------------------------------------------------------------------- */
void PHRQ_io::
error_msg(const char *err_str, bool stop)
/* ---------------------------------------------------------------------- */
{

	io_error_count++;
	if (error_file != NULL && error_on)
	{
		//(*error_file) << err_str;
		screen_msg(err_str);
		error_flush();
	}
	if (stop)
	{
		if (error_file != NULL && error_on)
		{
			//(*error_file) << "Stopping.\n";
			screen_msg("Stopping.\n");
			fflush(error_file);
		}
		output_msg("Stopping.\n");
		log_msg("Stopping.\n");
	}
}