Exemplo n.º 1
0
void p_free(void *pointer, const char *file, unsigned int line) {
  struct s_memory_head *head = (struct s_memory_head *)(pointer - sizeof(struct s_memory_head));
  struct s_memory_tail *tail;
  if (head->checksum == (unsigned int)d_memory_checksum) {
    tail = (struct s_memory_tail *)(pointer + head->dimension);
    if (tail->checksum == (unsigned int)d_memory_checksum) {
      if (head->next)
        head->next->back = head->back;
      if (head->back)
        head->back->next = head->next;
      else
        v_memory_root = head->next;
      head->back = NULL;
      head->next = NULL;
      free(head);
    } else
      d_err(e_log_level_ever, "wrong tail checksum with %p (%s::%d)", pointer, file, line);
  } else
    d_err(e_log_level_ever, "wrong head checksum with %p (%s::%d)", pointer, file, line);
}
Exemplo n.º 2
0
struct s_object *f_environment_new_flags(struct s_object *self, int width, int height, int flags) {
	struct s_environment_attributes *attributes = p_environment_alloc(self);
	int surface, index, initialized_systems;
	t_boolean initialized = d_true;
	for (surface = 0; surface < e_environment_surface_NULL; ++surface)
		for (index = 0; index < d_environment_layers; ++index)
			memset(&(attributes->drawable[surface][index]), 0, sizeof(struct s_list));
	memset(&(attributes->eventable), 0, sizeof(struct s_list));
	if ((initialized_systems = SDL_WasInit(d_environment_default_systems)) != d_environment_default_systems)
		if (SDL_Init(d_environment_default_systems&(d_environment_default_systems&(~initialized_systems))) < 0) {
			d_err(e_log_level_ever, "SDL graphical system returns an error during the initialization (flags 0x%08x)",
					(d_environment_default_systems&(~initialized_systems)));
			initialized = d_false;
		}
	if (initialized) {
		/* TTF initialization */
		if (TTF_WasInit() == 0)
			if (TTF_Init() < 0) {
				initialized = d_false;
				d_err(e_log_level_ever, "SDL font system returns an error during the initialization");
			}
		if ((attributes->window = SDL_CreateWindow(d_environment_default_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height,
						(flags|SDL_WINDOW_OPENGL))))
			attributes->renderer = SDL_CreateRenderer(attributes->window, -1, (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC));
	}
	attributes->fps = d_environment_default_fps;
	/* geometry */
	attributes->reference_w = d_environment_default_reference_w;
	attributes->reference_h = d_environment_default_reference_h;
	attributes->current_w = width;
	attributes->current_h = height;
	attributes->camera_origin_x = 0;
	attributes->camera_origin_y = 0;
	attributes->camera_focus_x = (width / 2.0);
	attributes->camera_focus_y = (height / 2.0);
	attributes->zoom = 1;
	attributes->continue_loop = d_true;
	return self;
}
Exemplo n.º 3
0
int f_analyze_directory(char *directory, struct s_analyzer_action *actions, const char *directory_ignore_list) {
	struct s_mysql_local_parameters db_parameters = {
		NULL, /* socket connection */
		"root",
		"digitare",
		"dampefm"
	};
	int index, load_result, result = d_false;
	if ((result = p_analyze_directory(directory, actions, directory_ignore_list))) {
		if (f_mysql_local_init(&db_parameters)) {
			for (index = 0; actions[index].extension; ++index)
				if (actions[index].load)
					if (!(load_result = actions[index].load()))
						d_err(e_log_level_low, "unable to run '.%s' LOAD function which returns code %d", actions[index].extension,
								load_result);
			f_mysql_local_destroy();
		} else
			d_err(e_log_level_ever, "mysql deamon '%s' is unreachable", db_parameters.server);
	}
	for (index = 0; actions[index].extension; ++index)
		if (actions[index].destroy)
			actions[index].destroy();
	return result;
}
Exemplo n.º 4
0
int main (int argc, char *argv[]) {
	char buffer[d_string_buffer_size] = {0};
	int index;
	/* ./ localhost port {command} */
	if (argc >= 4) {
		for (index = 3; index < argc; ++index) {
			strncat(buffer, argv[index], (d_string_buffer_size-f_string_strlen(buffer)));
			strncat(buffer, d_remote_separator, (d_string_buffer_size-f_string_strlen(buffer)));
		}
		strncat(buffer, d_remote_final, (d_string_buffer_size-f_string_strlen(buffer)));
		if (!f_remote_inject(argv[1], argv[2], buffer))
			d_err(e_log_level_ever, "error, unable to communicate with %s:%s", argv[1], argv[2]);
	} else
		fprintf(stderr, "magrathea_remote usage:\n%s <IP> <port> {command ...}\n", argv[0]);
	return 0;
}