static void load_form_element(const xmlNode *cur_node, form_element_t *parent) { if (is_oftype(cur_node, "Group")) { const xmlNode *p = find_by_path(cur_node, "Properties/Type")->children; if (xstrcmp(p->content, "UsualGroup") == 0) load_usual_group(cur_node, parent); } if (is_oftype(cur_node, "Text")) { load_text_entry(cur_node, parent, false); } if (is_oftype(cur_node, "Input")) { load_input(cur_node, parent); } if (is_oftype(cur_node, "CheckBox")) { load_check_box(cur_node, parent); } if (is_oftype(cur_node, "Pages")) { load_pages(cur_node, parent); } if (is_oftype(cur_node, "Table")) { load_table(cur_node, parent); } if (is_oftype(cur_node, "CommandBar")) { load_command_bar(cur_node, parent); } }
// // compress() is the public function used to compress // a single file. It has to take care of opening the // input and output files and setting up the buffers for // Zlib. It then calls deflate() repeatedly until all // input and output processing has been done, and finally // closes the files and cleans up the Zlib structures. // void CStdCompress::CompressFile( const char *input, const char *output, int level ) { try { err = Z_OK; avail_in = 0; avail_out = output_length; next_out = output_buffer; m_AbortFlag = 0; fin = fopen( input, "rb" ); fout = fopen( output, "wb" ); length = filelength( fileno( fin ) ); deflateInit( this, level ); for ( ; ; ) { if ( m_AbortFlag ) break; if ( !load_input() ) break; err = deflate( this, Z_NO_FLUSH ); flush_output(); if ( err != Z_OK ) break; progress( percent() ); } for ( ; ; ) { if ( m_AbortFlag ) break; err = deflate( this, Z_FINISH ); if ( !flush_output() ) break; if ( err != Z_OK ) break; } progress( percent() ); deflateEnd( this ); if ( m_AbortFlag ) status( "User Abort" ); else if ( err != Z_OK && err != Z_STREAM_END ) status( "Zlib Error" ); else { status( "Success" ); err = Z_OK; } fclose( fin ); fclose( fout ); fin = 0; fout = 0; if(err != Z_OK && !m_AbortFlag) THROW_ERROR(Std_Err_ZLIB_lCompress, Std_Err_ZLIB_strCompress); } catch(CStdErrorInfo oError) {RELAY_ERROR(oError);} catch(...) {THROW_ERROR(Std_Err_ZLIB_lUnspecifiedError, Std_Err_ZLIB_strUnspecifiedError);} }
// main entry point for the program; initializes parameters, reads input file name argument if provided, // declares two 2-dimensional arrays used as buffers to simulate the evolution of the cellular automaton // grid, loads initial generation from input file into grid, runs automaton for 30 generations, prints // results of evolution silently to file "output.txt" using a grid of 48 rows by 64 columns, (not including // the additional frame which is printed at the perimeter of the grid), and prints error messages and exits // if any part of this process fails; int main( int argc, char ** argv ) { char even_grid[ROWS][COLUMNS]; // for double-buffering the grid, used for even-numbered generations char odd_grid[ROWS][COLUMNS]; // other buffer, used for odd-numbered generations int g, r, c; // indices char * input_filename; // "input.txt" if user does not provide a different file char * output_filename = "output.txt"; // hardwired to always create or overwrite same output file FILE * output_file_pointer; // used to print results to file as they are generated for ( r = 0; r < ROWS; r++ ) { // initialize buffers so they are full of dead cells (spaces) for ( c = 0; c < COLUMNS; c++ ) { even_grid[r][c] = ' '; odd_grid[r][c] = ' '; } } // allow user to specify input file as command line argument to program if ( 1 < argc ) { // if arguments are given, assume first is the name of input file input_filename = argv[1]; } else { // no input filename provided, so use default name, "input.txt" input_filename = "input.txt"; } if ( !load_input( input_filename, even_grid ) ) { fprintf( stderr, "usage: %s [ input_file ]\n", argv[0] ); fprintf( stderr, " quitting...\n" ); exit( EXIT_FAILURE ); } if ( NULL == ( output_file_pointer = fopen( output_filename, "w" ) ) ) { fprintf( stderr, "error: in 'main()', call to 'fopen(%s, 'w')' failed\n", output_filename ); perror( " " ); fprintf( stderr, "usage: %s [ input_file ]\n", argv[0] ); fprintf( stderr, " quitting...\n" ); exit( EXIT_FAILURE ); } // run the 'Game of Life' on the provided input; for ( g = 0; g < GENERATIONS; g++ ) { // iterate automaton for hardwired number of times; if ( 0 == g % 2 ) { // modulo for double-buffering; even generations use even_grid; print_grid( even_grid, g, output_file_pointer ); // once it's loaded or computed, print it; generate_grid( even_grid, odd_grid ); // use even_grid to compute new odd_grid; } else { // odd generations use odd grid print_grid( odd_grid, g, output_file_pointer ); // once it's computed, print it; generate_grid( odd_grid, even_grid ); // use odd_grid to compute new even_grid; } } if ( EOF == fclose( output_file_pointer ) ) { fprintf( stderr, "error: in 'main()', call to 'fclose(%s)' failed\n", output_filename ); perror( " " ); fprintf( stderr, "usage: %s [ input_file ]\n", argv[0] ); fprintf( stderr, " quitting...\n" ); exit( EXIT_FAILURE ); } exit( EXIT_SUCCESS ); }
int main(int argc, char **argv) { if (pif_error(argc < 2, "No command specified")) return usage(-1); if (pif_error(argc < 3, "No DB path specified")) return usage(-1); char *cmd = argv[1]; char *keyData[JFT_KEY_LIMIT]; JFDB *db; JFT_Stem prefix = (JFT_Stem) {.data = (uint8_t *)keyData}; JFT_Symbol *stop = NULL; JFT_Offset offset; switch (cmd[0]) { case 'm': case 'n': case 'k': case 'f': case 'l': db = JFDB_open(argv[2], 0); if (JFDB_pif_error(db, "Failed to open")) return -1; switch (cmd[0]) { case 'm': print_meta(db); break; case 'n': offset = argc > 3 ? atoi(argv[3]) : db->tip.cp.offset; offset = MAX(offset, sizeof(JFDB_Header)); print_info(db, &prefix, db->kmap.map + offset, &null); break; case 'k': if (!prefix_opts(&prefix, &stop, argc - 2, argv + 2)) print_keys(db, &prefix, stop); break; case 'f': if (!prefix_opts(&prefix, &stop, argc - 2, argv + 2)) print_find(db, &prefix, stop); break; case 'l': load_input(db, stdin); break; } if (JFDB_close(db)) return -1; break; case 'w': if (pif_error(JFDB_wipe(argv[2]), "Failed to wipe")) return -1; break; default: usage(1); break; } return 0; }
void compile_repo() { auto ues = load_input(); std::cout << folly::format("{} units\n", ues.size()); ues = whole_program(std::move(ues)); { trace_time timer("writing output repo"); write_output(std::move(ues)); } }
int main(void) { int i = 0, T = 0; scanf("%d", &T); for(i = 0;i < T;++i) { load_input(); handle(); printf("Case %d: %d\n", i+1, maxsize); } return 0; }
void load_config(t_data *data) { if ((CONFIG = bunny_malloc(sizeof(t_config))) == NULL) exit(1); if ((CONFIG->ini = bunny_load_ini("files/ini/config.ini")) != NULL) { data->config->fullscreen = my_getnbr((char *)BGF(CONFIG->ini, "config", "fullscreen", 0)); WIDTH = my_getnbr((char *)BGF(CONFIG->ini, "config", "width", 0)); HEIGHT = my_getnbr((char *)BGF(CONFIG->ini, "config", "height", 0)); VOLUME = my_getnbr((char *)BGF(CONFIG->ini, "config", "volume", 0)); CONFIG->fov = my_getnbr((char *)BGF(CONFIG->ini, "config", "fov", 0)); load_input(data); } else default_config(data); }
int rpexpose_select(){ g.status=S_STARTUP; g.x.display = XOpenDisplay(getenv("DISPLAY")); load_rcdefaults(); load_rcfile(); load_input(); load_xwindow(); load_buffer(); atexit(clean_up); // And here is when the magic is supposed to happen... XMapWindow(g.x.display,g.x.window); g.status=S_RUNNING; XEvent e; for(;;){ XNextEvent(g.x.display, &e); switch(e.type){ case MapNotify: XGrabKeyboard(g.x.display,g.x.window,False,GrabModeSync,GrabModeAsync,CurrentTime); break; case KeyPress:{ KeySym keysym=XKeycodeToKeysym(g.x.display,e.xkey.keycode,0); if( keysym<256 && isdigit(keysym) ){ if( g.p.selected->children[keysym-'0'] ){ g.p.selected=g.p.selected->children[keysym-'0']; event_move(g.p.selected->window); } break; } KeyCode keycode=XKeysymToKeycode(g.x.display,keysym); parse_command(g.rc.keybindings[keycode]); break; } case Expose: event_redraw(e.xexpose.x,e.xexpose.y,e.xexpose.width,e.xexpose.height); event_move(g.gui.selected); } } return 0; }
int ZlibEngine::filetofile( const char *input, const char *output, int level, bool deflation) { err = Z_OK; avail_in = 0; avail_out = output_length; next_out = output_buffer; m_AbortFlag = 0; fin = fopen( input, "rb" ); fout = fopen( output, "wb" ); statResult = stat(input,&fileStatus); length = fileStatus.st_size; if (deflation) deflateInit( this, level); else inflateInit( this ); for ( ; ; ) { if ( m_AbortFlag ) break; if ( !load_input() ) break; if (deflation) err = deflate( this, Z_NO_FLUSH ); else err = inflate( this, Z_NO_FLUSH ); flush_output(); if ( err != Z_OK ) break; progress( percent() ); } for ( ; ; ) { if ( m_AbortFlag ) break; if (deflation) err = deflate( this, Z_FINISH ); else err = inflate( this, Z_FINISH ); if ( !flush_output() ) break; if ( err != Z_OK ) break; } progress( percent() ); if (deflation) deflateEnd( this ); else inflateEnd( this ); if ( m_AbortFlag ) status( (char *)"User Abort" ); else if ( err != Z_OK && err != Z_STREAM_END ) status( (char *)"Zlib Error" ); else { status( (char *)"Success" ); err = Z_OK; } if ( fin ) fclose( fin ); fin = 0; if ( fout ) fclose( fout ); fout = 0; if ( m_AbortFlag ) return Z_USER_ABORT; else return err; }