void mysql::flush() { flush_users(); flush_torrents(); flush_snatches(); flush_peers(); flush_peer_hist(); flush_tokens(); }
/* * For any block B_i in the queue, we know that the bsize for * that block is at least (f->length - B_i->col). * * If (f->length - B_0->col > f->max_width) then we can set B_0's * bsize to infinity (PP_MAX_BSIZE), update the csize of the head * token, and remove B_0 from the queue. The head token is ready to be * printed at this point (since its csize, bsize and fsize fields are * known). */ static void flush_wide_blocks(formatter_t *f) { pp_block_t *b; pp_open_token_t *tk, *head; while (!block_queue_is_empty(&f->block_queue)) { b = first_block(&f->block_queue); assert(b->col <= f->length); if (f->length - b->col <= f->max_width) break; /* * b has bsize > max_width: set its bsize to MAX * then remove it from the block queue */ tk = b->token; tk->bsize = PP_MAX_BSIZE; head = f->head_token; if (head != NULL) { // update csize and fsize of the head token head->csize = PP_MAX_BSIZE; if (head->fsize == 0) { head->fsize = PP_MAX_BSIZE; } } // print all queued tokens, until tk flush_tokens(f, tag_open(tk)); // tk becomes the head token assert(ptr_queue_first(&f->token_queue) == tag_open(tk)); f->head_token = tk; if (f->nclosed == f->queue_size) { f->nclosed --; } pop_first_block(&f->block_queue); f->queue_size --; } }
// runs a script // returns -1 is esc was pressed, 0 o/w int run_script(char *script, DATAFILE *d) { char buf[512]; Ttoken *token; int i; // set datafile data = d; clear_keybuf(); // init sound memory for(i = 0; i < MAX_SCRIPT_SOUNDS; i ++) active_sounds[i] = -1; // create gfx buffers swap_buffer = create_bitmap(160, 120); buffer = create_bitmap(160, 120); script_done = FALSE; while(!script_done) { // get commands from script string script = get_line(buf, script); if (buf[0] != '#' && buf[0] != '\n' && buf[0] != '\r' && buf[0] != '-') { token = tokenize(buf); if (token != NULL) { if (!stricmp(token->word, "load_map")) cmd_loadmap(get_next_word(token)); else if (!stricmp(token->word, "draw_map")) cmd_drawmap(); else if (!stricmp(token->word, "set")) cmd_set((Ttoken *)token->next); else if (!stricmp(token->word, "move")) cmd_move((Ttoken *)token->next); else if (!stricmp(token->word, "delete")) cmd_del((Ttoken *)token->next); else if (!stricmp(token->word, "run")) cmd_run((Ttoken *)token->next); else if (!stricmp(token->word, "speak")) cmd_speak((Ttoken *)token->next, 1); else if (!stricmp(token->word, "text")) cmd_speak((Ttoken *)token->next, 0); else if (!stricmp(token->word, "save_buffer")) cmd_savebmp(); else if (!stricmp(token->word, "show_bmp")) cmd_showbmp(get_next_word(token)); else if (!stricmp(token->word, "blit")) cmd_blit(); else if (!stricmp(token->word, "fade_in")) cmd_fadein(); else if (!stricmp(token->word, "fade_out")) cmd_fadeout(); else if (!stricmp(token->word, "wait")) cmd_wait(atoi(get_next_word(token))); else if (!stricmp(token->word, "play_sample")) cmd_play_sample((Ttoken *)token->next); else if (!stricmp(token->word, "stop_sample")) cmd_stop_sample((Ttoken *)token->next); else if (!stricmp(token->word, "end_script")) cmd_end(); else { char msg[256]; sprintf(msg, "unknown: %s", token->word); msg_box(msg); } flush_tokens(token); } } } // destroy buffers delete_all_objects(); destroy_bitmap(buffer); destroy_bitmap(swap_buffer); // stop old sounds for(i = 0; i < MAX_SCRIPT_SOUNDS; i ++) { if (active_sounds[i] != -1) { stop_sound_id(active_sounds[i]); forget_sound(active_sounds[i]); } } return (script_done == -1 ? -1 : 0); }
// frees all tokens void flush_tokens(Ttoken *head) { if (head == NULL) return; if (head->next != NULL) flush_tokens((Ttoken *)head->next); destroy_token(head); }