コード例 #1
0
ファイル: imap-commands.c プロジェクト: LTD-Beget/dovecot
bool command_exec(struct client_command_context *cmd)
{
	const struct command_hook *hook;
	long long diff;
	bool finished;

	if (cmd->last_ioloop_time.tv_sec != 0) {
		diff = timeval_diff_usecs(&ioloop_timeval, &cmd->last_ioloop_time);
		if (diff > 0)
			cmd->usecs_in_ioloop += diff;
	}

	array_foreach(&command_hooks, hook)
		hook->pre(cmd);
	finished = cmd->func(cmd);
	array_foreach(&command_hooks, hook)
		hook->post(cmd);
	if (cmd->state == CLIENT_COMMAND_STATE_DONE)
		finished = TRUE;
	if (!finished) {
		io_loop_time_refresh();
		cmd->last_ioloop_time = ioloop_timeval;
	}
	return finished;
}
コード例 #2
0
ファイル: input.c プロジェクト: truongascii/cgame
static void _cursor_pos_callback(GLFWwindow *window, double x, double y)
{
    MouseMoveCallback *f;

    array_foreach(f, mouse_move_cbs)
        (*f)(vec2(x, y));
}
コード例 #3
0
ファイル: input.c プロジェクト: truongascii/cgame
static void _char_callback(GLFWwindow *window, unsigned int c)
{
    CharCallback *f;

    array_foreach(f, char_down_cbs)
        (*f)(c);
}
コード例 #4
0
ファイル: env-util.c プロジェクト: LTD-Beget/dovecot
static void env_clean_except_real(const char *const preserve_envs[])
{
	ARRAY_TYPE(const_string) copy;
	const char *value, *const *envp;
	unsigned int i;

	t_array_init(&copy, 16);
	for (i = 0; preserve_envs[i] != NULL; i++) {
		const char *key = preserve_envs[i];

		value = getenv(key);
		if (value != NULL) {
			value = t_strconcat(key, "=", value, NULL);
			array_append(&copy, &value, 1);
		}
	}

	/* Note that if the original environment was set with env_put(), the
	   environment strings will be invalid after env_clean(). That's why
	   we t_strconcat() them above. */
	env_clean();

	array_foreach(&copy, envp)
		env_put(*envp);
}
コード例 #5
0
ファイル: program.c プロジェクト: earshinov/geany-plugins
static void recent_menu_create(void)
{
	gtk_container_foreach(GTK_CONTAINER(recent_menu), recent_menu_item_destroy, NULL);
	recent_menu_count = 0;
	array_foreach(recent_programs, (GFunc) recent_menu_item_create, NULL);
	gtk_widget_show_all(GTK_WIDGET(recent_menu));
}
コード例 #6
0
ファイル: sample.c プロジェクト: martinhath/hathstd
int main() {
    Array *array = array_create();
    array_add(array, "hath");
    array_add(array, "std");
    array_add(array, "just");
    array_add(array, "werks!");
    array_foreach(array, print);
    printf("\n");
    return 0;
}
コード例 #7
0
ファイル: input.c プロジェクト: truongascii/cgame
static void _mouse_callback(GLFWwindow *window, int mouse, int action,
                            int mods)
{
    MouseCallback *f;

    /* call all registered callbacks */
    switch (action)
    {
        case GLFW_PRESS:
            array_foreach(f, mouse_down_cbs)
                (*f)(_glfw_to_mousecode(mouse));
            break;

        case GLFW_RELEASE:
            array_foreach(f, mouse_up_cbs)
                (*f)(_glfw_to_mousecode(mouse));
            break;
    }
}
コード例 #8
0
ファイル: input.c プロジェクト: truongascii/cgame
static void _key_callback(GLFWwindow *window, int key, int scancode,
                          int action, int mods)
{
    KeyCallback *f;

    /* call all registered callbacks */
    switch (action)
    {
        case GLFW_PRESS:
            array_foreach(f, key_down_cbs)
                (*f)(_glfw_to_keycode(key));
            break;

        case GLFW_RELEASE:
            array_foreach(f, key_up_cbs)
                (*f)(_glfw_to_keycode(key));
            break;
    }
}
コード例 #9
0
ファイル: physics.c プロジェクト: andi2/cgame
/* remove chipmunk stuff (doesn't remove from pool) */
static void _remove(PhysicsInfo *info)
{
    ShapeInfo *shapeInfo;

    array_foreach(shapeInfo, info->shapes)
        _remove_shape(shapeInfo->shape);
    array_free(info->shapes);

    _remove_body(info->body);
}
コード例 #10
0
ファイル: lib.c プロジェクト: jkerihuel/dovecot
void lib_atexit_run(void)
{
	lib_atexit_callback_t *const *cbp;

	if (array_is_created(&atexit_callbacks)) {
		array_foreach(&atexit_callbacks, cbp)
			(**cbp)();
		array_free(&atexit_callbacks);
	}
}
コード例 #11
0
ファイル: iostream.c プロジェクト: bechtoldt/dovecot-core
void io_stream_free(struct iostream_private *stream)
{
	const struct iostream_destroy_callback *dc;

	if (array_is_created(&stream->destroy_callbacks)) {
		array_foreach(&stream->destroy_callbacks, dc)
			dc->callback(dc->context);
		array_free(&stream->destroy_callbacks);
	}

        i_free(stream->error);
        i_free(stream->name);
        i_free(stream);
}
コード例 #12
0
ファイル: physics.c プロジェクト: andi2/cgame
/* recalculate moment for whole body by adding up shape moments */
static void _recalculate_moment(PhysicsInfo *info)
{
    Scalar moment;
    ShapeInfo *shapeInfo;

    if (!info->body)
        return;
    if (array_length(info->shapes) == 0)
        return; /* can't set moment to zero, just leave it alone */

    moment = 0.0;
    array_foreach(shapeInfo, info->shapes)
        moment += _moment(info->body, shapeInfo);
    cpBodySetMoment(info->body, moment);
}
コード例 #13
0
ファイル: iostream.c プロジェクト: Raffprta/core
void io_stream_unref(struct iostream_private *stream)
{
	const struct iostream_destroy_callback *dc;

	i_assert(stream->refcount > 0);
	if (--stream->refcount != 0)
		return;

	stream->close(stream, FALSE);
	stream->destroy(stream);
	if (array_is_created(&stream->destroy_callbacks)) {
		array_foreach(&stream->destroy_callbacks, dc)
			dc->callback(dc->context);
		array_free(&stream->destroy_callbacks);
	}

        i_free(stream->error);
        i_free(stream->name);
        i_free(stream);
}
コード例 #14
0
ファイル: main.c プロジェクト: via/dovecot-clouddb
static void ssl_params_callback(const unsigned char *data, size_t size)
{
	const int *fds;

	buffer_set_used_size(ssl_params, 0);
	buffer_append(ssl_params, data, size);

	if (!array_is_created(&delayed_fds)) {
		/* if we don't get client connections soon, it means master
		   ran us at startup to make sure ssl parameters are generated
		   asap. if we're here because of that, don't bother hanging
		   around to see if we get any client connections. */
		to_startup = timeout_add(STARTUP_IDLE_TIMEOUT_MSECS,
					 master_service_stop, master_service);
		return;
	}

	array_foreach(&delayed_fds, fds)
		client_handle(*fds);
	array_free(&delayed_fds);
}
コード例 #15
0
ファイル: test1.c プロジェクト: blytkerchan/jail
void test1(void)
{
	static char * argv[] = 
	{
		"./test1",
		"-DHELLO=\"world\"",
		NULL
	};
	static libconf_opt_t options[] = {
		{ "define", 'D', TP_YES, PT_STRING_LIST, "define", TP_YES, PT_STRING_LIST, "define a macro", DOE_WARNING },
		{ NULL, 0, TP_NO, PT_NONE, NULL, TP_NO, PT_NONE, NULL, DOE_ERROR }
	};
	int argc = 2;
	int rc = 0;
	libconf_t * handle = NULL;
	libconf_opt_t ** t_options = libconf_optconst(options);
	array_t * array = NULL;
	struct test1_helper1_data data;
	
	handle = libconf_init(SRCDIR"/global_conf_test1", NULL, t_options, NULL, argc, argv);
	free(t_options);
	if (!rc) rc = libconf_phase1(handle);
	if (!rc) rc = libconf_phase2(handle);
	if (!rc) rc = libconf_phase3(handle);
	if (!rc) rc = libconf_phase4(handle);
	if (!rc) rc = libconf_phase5(handle);
	assert(!rc);
	if (!rc) rc = libconf_getopt(handle, "define", &array);
	if (!rc)
	{
		data.flag = 0;
		array_foreach(array, test1_helper1, &data);
		assert(!data.flag);
		array_search(array, "HELLO", test1_helper2);
	}
	
	libconf_fini(handle);
}