t_map load_map(t_meta *meta, char *name) { int fd; int i; int ret; UCHAR *line; t_map map; fd = xopen(name, O_RDONLY, meta); map.data = xmemalloc(sizeof(UCHAR*) * 3000, meta); i = 0; map.width = -1; while ((ret = get_next_line(fd, (char**)&line)) > 0) { map.data[i] = analyse_data(line, meta, name); if (++i >= 3000) error_file(meta, name); if (map.width == -1) map.width = ret; else if (ret != map.width) error_file(meta, name); } close(fd); map.height = i; if (ret < 0 || map.height == 0 || map.width == 0) error_file(meta, name); return (map); }
void tick(int print) { time_t t; pthread_mutex_lock(&tick_mutex); t = time(NULL); if((t - last_timestamp >= RESOLUTION)&&(t - last_timestamp >= options.interval_seconds_time)) { analyse_data(); if (options.no_curses) { if (!options.timed_output || options.timed_output && t - first_timestamp >= options.timed_output) { tui_print(); if (options.timed_output) { finish(SIGINT); } } } else { ui_print(); } history_rotate(); last_timestamp = t; } else { if (options.no_curses) { tui_tick(print); } else { ui_tick(print); } } pthread_mutex_unlock(&tick_mutex); }
void tick(int print) { time_t t; pthread_mutex_lock(&tick_mutex); t = time(NULL); if(t - last_timestamp >= RESOLUTION) { //printf("TICKING\n"); analyse_data(); ui_print(); history_rotate(); last_timestamp = t; } else { ui_tick(print); } pthread_mutex_unlock(&tick_mutex); }