Exemplo n.º 1
0
int run(GList **config)
{
	char *fn, *name, *from;
	gboolean toggled;
	GList *newmirrorlist = NULL;

	if(data_get(*config, "srcdev") != NULL)
		return 0;

	GtkTreeIter iter;
	GtkTreeView *treeview = (GtkTreeView *)viewserver;
  	GtkTreeModel *model = gtk_tree_view_get_model (treeview);

	fn = g_strdup_printf("%s/%s", PACCONFPATH, PACCONF);

	if(gtk_tree_model_get_iter_first (model, &iter) == FALSE) {
		return(0);
	} else {
		do {
			gtk_tree_model_get (model, &iter, COLUMN_USE, &toggled, COLUMN_NAME, &name, COLUMN_FROM, &from, -1);
			if(toggled == TRUE) {
				newmirrorlist = g_list_prepend(newmirrorlist, strdup(from));
				newmirrorlist = g_list_prepend(newmirrorlist, strdup(name));
			} else {
				newmirrorlist = g_list_append(newmirrorlist, strdup(name));
				newmirrorlist = g_list_append(newmirrorlist, strdup(from));
			}
		} while(gtk_tree_model_iter_next(model, &iter));
	}

	updateconfig(fn, newmirrorlist);
	free(fn);
	return(0);
}
Exemplo n.º 2
0
/*
 * We try to work as much like a traditional gethostbyname() as possible.
 * Basically, any function that calls gethostbyname() can be cut in half:
 * the part before and the part after the gethostbyname call.  Move the second
 * half to the callback.  The callback will give a struct hostent * as a
 * parameter, instead of gethostbyname() returning it.  The callback returning
 * -1 should be the same as elsewhere in libnbio: the nbio_poll loop should
 * exit.
 *
 * General procedure:
 *   1) If it's an address in dotted-quad notation already, reformat/expand
 *      as appropriate, and return.
 *   2) Check in /etc/hosts (which is cached).  If there, return.
 *   3) Build DNS query according to rules in /etc/resolv.conf, send that.
 *   4) Return on success or NULL on timeout/error.
 */
int nbio_gethostbyname(nbio_t *nb, nbio_gethostbyname_callback_t ufunc, void *udata, const char *query)
{

	if (updateconfig(nb) == -1)
		return -1;

	return -1;
}