/* All good things come to an end, and * just like after a fine dinner, someone has to do * the dishes. */ static void destroy_level_data(struct level_data* ldata) { destroy_sound(ldata->music); destroy_font(ldata->font); cleanup_title(&ldata->title); cleanup_tree(&ldata->tree); destroy_image(ldata->grass_tile); destroy_image(ldata->earth_tile); destroy_wizard(ldata->wizard); destroy_timeline(ldata->timeline); free(ldata); }
int main() { setlocale(LC_ALL,""); clit_config *config = malloc(sizeof(clit_config)); if(parse_config(config) == -1) { // first run int res = authorize(config); if(res == -1) { printf("Please retry.\n"); } else printf("Authorization finished. Run the program again.\n"); free(config); exit(0); } me = newuser(); me->screen_name = config->screen_name; me->id = config->user_id; init_oauth(config->key,config->secret); free(config); init_mutex(); raw_event_stream = new_raw_event_queue(); printf("Loading the timelines....\n"); if(init_timelines() == -1) { pthread_mutex_lock(&error_mutex); printf("Cannot load the timeline. Please check your network connection.\n"); pthread_mutex_unlock(&error_mutex); goto exit_twilc; } initscr(); curs_set(0); //if(has_colors() == FALSE) //goto exit_twilc; raw(); keypad(stdscr,TRUE); noecho(); start_color(); move(0,0); refresh(); if(init_ui() == -1) goto exit_twilc; start_userstream(); wait_command(tl_win); exit_twilc: destroy_ui(); curs_set(1); endwin(); destroy_mutex(); for(int i = 0; i < TIMELINE_COUNT; ++i) destroy_timeline(timelines[i]); stop_userstream(); pthread_mutex_lock(&event_buffer_mutex); destroy_raw_event_queue(raw_event_stream); raw_event_stream = NULL; pthread_mutex_unlock(&event_buffer_mutex); return 0; }