コード例 #1
0
ファイル: testgnome.c プロジェクト: Distrotech/libgnomeui
static void
create_color_picker (void)
{
	TestGnomeApp *app;
	GtkWidget *table;
	GtkWidget *w;

	app = create_newwin (TRUE, "testGNOME", "Color Picker");

	table = gtk_table_new (3, 3, FALSE);
	gtk_container_set_border_width (GTK_CONTAINER (table), GNOME_PAD_SMALL);
	gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
	gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
	bonobo_window_set_contents (BONOBO_WINDOW (app->app), table);
	gtk_widget_show (table);

	/* Labels */

	w = gtk_label_new ("Dither");
	gtk_table_attach (GTK_TABLE (table), w,
			  1, 2, 0, 1,
			  GTK_FILL,
			  GTK_FILL,
			  0, 0);
	gtk_widget_show (w);

	w = gtk_label_new ("No dither");
	gtk_table_attach (GTK_TABLE (table), w,
			  2, 3, 0, 1,
			  GTK_FILL,
			  GTK_FILL,
			  0, 0);
	gtk_widget_show (w);

	w = gtk_label_new ("No alpha");
	gtk_table_attach (GTK_TABLE (table), w,
			  0, 1, 1, 2,
			  GTK_FILL,
			  GTK_FILL,
			  0, 0);
	gtk_widget_show (w);

	w = gtk_label_new ("Alpha");
	gtk_table_attach (GTK_TABLE (table), w,
			  0, 1, 2, 3,
			  GTK_FILL,
			  GTK_FILL,
			  0, 0);
	gtk_widget_show (w);

	/* Color pickers */

	create_cp (table, TRUE,  FALSE, 1, 2, 1, 2);
	create_cp (table, FALSE, FALSE, 2, 3, 1, 2);
	create_cp (table, TRUE,  TRUE,  1, 2, 2, 3);
	create_cp (table, FALSE, TRUE,  2, 3, 2, 3);

	gtk_widget_show (app->app);
}
コード例 #2
0
ファイル: refresher.cpp プロジェクト: Patrickxzm/P_Arthur
	void CRefresher::deal(workbench_t &bench)
	{
		char * tmp;
		tmp = create_cp(bench);
		string new_cp(tmp);
		
		bool changed = false;
		int old_timeout = bench.timeout;
#ifndef _TEST
		//if there is no url=bench.url in our file, we write delete log too
		if (bench.reply.status.code == 404)	
		{
			time_t timep;
			time(&timep);
//			fprintf(deletelog,"delete url %s %s\n",
//				bench.url->str().c_str(), ctime(&timep));
		return;
	}
#endif
	if (bench.timeout == 0)
	{
		changed = true;	//first time crawled
		time_t timep;
		time(&timep);
//		fprintf(newlog,"new url %s %s\n",
//			bench.url->str().c_str(), ctime(&timep));
	}
	else{
		if (new_cp != bench.checkpoint)
		{				//changed
			changed = true;
	
			time_t timep;
			time(&timep);
//			fprintf(changelog,"change url %s %s\n",
//				bench.url->str().c_str(), ctime(&timep));
		}
	}
	
	bench.changed = changed;	
	bench.timeout = rconfig.calculate(bench.url.str().c_str(),old_timeout,changed,bench.depth);
	
	CTime_struct real_time = get_real_time(bench.timeout);
#ifdef _TEST
	cout << "new real_time = " << real_time.time_to_string() << endl;
#endif
	
#ifndef _TEST
	bench.checkpoint = new_cp;
#endif

	save_to_file(bench,real_time);
}
コード例 #3
0
ファイル: pool_connection_pool.c プロジェクト: anchowee/pqc
static POOL_CONNECTION_POOL *new_connection(POOL_CONNECTION_POOL *p)
{
	/* create master connection */
	MASTER_CONNECTION(p) = malloc(sizeof(POOL_CONNECTION_POOL_SLOT));
	if (MASTER_CONNECTION(p) == NULL)
	{
		pool_error("pool_create_cp: malloc() failed");
		return NULL;
	}
	create_cp(MASTER_CONNECTION(p), 0);

	/* initialize Paramter Status save structure */
	if (pool_init_params(&MASTER(p)->params))
	{
		return NULL;
	}
	p->num = 1;	/* number of slots */

	/* create secondary connection */
	if (DUAL_MODE)
	{
		SECONDARY_CONNECTION(p) = malloc(sizeof(POOL_CONNECTION_POOL_SLOT));
		if (SECONDARY_CONNECTION(p) == NULL)
		{
			pool_error("pool_create_cp: malloc() failed");
			return NULL;
		}
		create_cp(SECONDARY_CONNECTION(p), 1);

		/* initialize Paramter Status save structure */
		if (pool_init_params(&SECONDARY(p)->params))
		{
			return NULL;
		}

		p->num++;	/* number of slots */
	}

	return p;
}
コード例 #4
0
/*
 * create actual connections to backends
 */
static POOL_CONNECTION_POOL *new_connection(POOL_CONNECTION_POOL *p)
{
	POOL_CONNECTION_POOL_SLOT *s;
	int active_backend_count = 0;
	int i;

	for (i=0;i<NUM_BACKENDS;i++)
	{
		pool_debug("new_connection: connecting %d backend", i);

		if (!VALID_BACKEND(i))
		{
			pool_debug("new_connection: skipping slot %d because backend_status = %d",
					   i, BACKEND_INFO(i).backend_status);
			continue;
		}

		s = malloc(sizeof(POOL_CONNECTION_POOL_SLOT));
		if (s == NULL)
		{
			pool_error("new_connection: malloc() failed");
			return NULL;
		}

		if (create_cp(s, i) == NULL)
		{
			/* connection failed. mark this backend down */
			pool_error("new_connection: create_cp() failed");

			/* If fail_over_on_backend_error is true, do failover.
			 * Otherwise, just exit this session.
			 */
			if (pool_config->fail_over_on_backend_error)
			{
				notice_backend_error(i);
			}
			else
			{
				pool_log("new_connection: do not failover because fail_over_on_backend_error is off");
			}
			child_exit(1);
		}

		p->info[i].create_time = time(NULL);
		p->slots[i] = s;

		if (pool_init_params(&s->con->params))
		{
			return NULL;
		}

		BACKEND_INFO(i).backend_status = CON_UP;
		active_backend_count++;
	}

	if (active_backend_count > 0)
	{
		return p;
	}

	return NULL;
}