void QGLExtensions::init() { static bool init_done = false; if (init_done) return; init_done = true; GLint attribs[] = { AGL_RGBA, AGL_NONE }; AGLPixelFormat fmt = aglChoosePixelFormat(0, 0, attribs); if (!fmt) { qDebug("QGLExtensions: Couldn't find any RGB visuals"); return; } AGLContext ctx = aglCreateContext(fmt, 0); if (!ctx) { qDebug("QGLExtensions: Unable to create context"); } else { aglSetCurrentContext(ctx); init_extensions(); aglSetCurrentContext(0); aglDestroyContext(ctx); } aglDestroyPixelFormat(fmt); }
int main(int argc, char *argv[]) { int ret; char *table = "filter"; ip6tc_handle_t handle = NULL; program_name = "ip6tables"; program_version = IPTABLES_VERSION; lib_dir = getenv("IP6TABLES_LIB_DIR"); if (!lib_dir) lib_dir = IP6T_LIB_DIR; #ifdef NO_SHARED_LIBS init_extensions(); #endif ret = do_command6(argc, argv, &table, &handle); if (ret) ret = ip6tc_commit(&handle); if (!ret) fprintf(stderr, "ip6tables: %s\n", ip6tc_strerror(errno)); exit(!ret); }
int main(int argc, char* argv[]) { assert(argc == 2); Py_SetProgramName(argv[0]); Py_Initialize(); init_extensions(); // initialize curses initscr(); // don't buffer user input into lines, // but Ctrl-Z and Ctrl-C work as usual cbreak(); // don't echo user input. noecho(); // getch returns ERR if the user takes more than a tenth of a second // halfdelay(1); // don't ignore function keys F1, F2, etc. keypad(stdscr, TRUE); // TODO: seed the random number generator with the time. PyRun_SimpleFile(fopen(argv[1], "r"), argv[1]); endwin(); Py_Finalize(); return 0; }
int main (int argc, char *argv[]) { unicap_handle_t handle; unicap_format_t format; /* Initialize */ gtk_init (&argc, &argv); g_thread_init(NULL); gdk_threads_init (); gtk_gl_init (&argc, &argv); init_extensions (); init_gl_resources (); handle = open_device(); set_format( handle ); unicap_get_format( handle, &format ); if( ( format.size.width != 640 ) || ( format.size.height != 480 ) ) { g_warning( "The default .cg file assumes a video format of 640x480 pixels. \nYou need to change the yuv.cg file to match your size.\n" ); } prepare_yuv_buffer(&yuvbuffer, &format); unicap_register_callback( handle, UNICAP_EVENT_NEW_FRAME, (unicap_callback_t)new_frame_cb, NULL ); unicap_start_capture( handle ); /* Gtk window & container */ GtkWindow *window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL)); glarea = gtk_drawing_area_new (); gtk_widget_set_size_request (GTK_WIDGET (glarea), WINDOW_WIDTH, WINDOW_HEIGHT); g_signal_connect (glarea, "expose-event", G_CALLBACK (on_expose), NULL); g_signal_connect (glarea, "configure-event", G_CALLBACK (on_configure), NULL); g_signal_connect (glarea, "map-event", G_CALLBACK (on_mapped), NULL); g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL); GdkGLConfig *gl_config; gl_config = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGBA | GDK_GL_MODE_DOUBLE); if (gl_config == NULL) g_critical ("Failed to setup a double-buffered RGB visual"); if (! gtk_widget_set_gl_capability (GTK_WIDGET (glarea), gl_config, NULL, TRUE, GDK_GL_RGBA_TYPE)) g_critical ("Failed to add gl capability"); gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (glarea)); gtk_widget_show_all (GTK_WIDGET (window)); /* Main loop */ gtk_main (); return 0; }
void QGLExtensions::init() { static bool init_done = false; if (init_done) return; init_done = true; init_extensions(); }
///////////////////////////////////// // init() ///////////////////////////////////// void GLExtensions::internal_init() { assert(!_init); err_mesg(ERR_LEV_INFO, "GLExtensions::init() - Initializing GL extensions..."); init_extensions(); _init = true; err_mesg(ERR_LEV_INFO, "GLExtensions::init() - ...done."); }
int iptables_main(int argc, char *argv[]) { int ret; char *table = "filter"; struct xtc_handle *handle = NULL; FILE *pfLockFile = NULL; pfLockFile = ATP_UTIL_LockProc(IPTABLES_LOCK_FILE); if (NULL == pfLockFile) { printf("iptables get lock failed\n"); exit(-1); } ATP_UTIL_RegUnLock(pfLockFile); iptables_globals.program_name = "iptables"; ret = xtables_init_all(&iptables_globals, NFPROTO_IPV4); if (ret < 0) { fprintf(stderr, "%s/%s Failed to initialize xtables\n", iptables_globals.program_name, iptables_globals.program_version); exit(1); } #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS) init_extensions(); init_extensions4(); #endif ret = do_command4(argc, argv, &table, &handle); if (ret) { ret = iptc_commit(handle); iptc_free(handle); } if (!ret) { if (errno == EINVAL) { fprintf(stderr, "iptables: %s. " "Run `dmesg' for more information.\n", iptc_strerror(errno)); } else { fprintf(stderr, "iptables: %s.\n", iptc_strerror(errno)); } if (errno == EAGAIN) { exit(RESOURCE_PROBLEM); } } exit(!ret); }
int main(int argc, char *argv[]) #endif { const char *tablename = NULL; int c; iptables_globals.program_name = "iptables-save"; c = xtables_init_all(&iptables_globals, NFPROTO_IPV4); if (c < 0) { fprintf(stderr, "%s/%s Failed to initialize xtables\n", iptables_globals.program_name, iptables_globals.program_version); exit(1); } #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS) init_extensions(); init_extensions4(); #endif while ((c = getopt_long(argc, argv, "bcdt:", options, NULL)) != -1) { switch (c) { case 'b': show_binary = 1; break; case 'c': show_counters = 1; break; case 't': tablename = optarg; break; case 'M': xtables_modprobe_program = optarg; break; case 'd': do_output(tablename); exit(0); } } if (optind < argc) { fprintf(stderr, "Unknown arguments found on commandline\n"); exit(1); } return !do_output(tablename); }
int main(int argc, char *argv[]) #endif { const char *tablename = NULL; int c; program_name = "ip6tables-save"; program_version = IPTABLES_VERSION; lib_dir = getenv("IP6TABLES_LIB_DIR"); if (!lib_dir) lib_dir = IP6T_LIB_DIR; #ifdef NO_SHARED_LIBS init_extensions(); #endif while ((c = getopt_long(argc, argv, "bcdt:", options, NULL)) != -1) { switch (c) { case 'b': binary = 1; break; case 'c': counters = 1; break; case 't': /* Select specific table. */ tablename = optarg; break; case 'd': do_output(tablename); exit(0); } } if (optind < argc) { fprintf(stderr, "Unknown arguments found on commandline"); exit(1); } return !do_output(tablename); }
PBuffer* GimRasterizer::get_pbuffer(int width, int height) { if(pbuffer_pool_[0] == nil) { init_extensions() ; } for(unsigned int i=0; i<PBUFFER_POOL_SIZE; i++) { if( pbuffer_pool_[i] != nil && width == pbuffer_pool_[i]->GetWidth() && height == pbuffer_pool_[i]->GetHeight() ) { pbuffer_pool_timestamp_[i] = SystemStopwatch::now() ; return pbuffer_pool_[i] ; } } PBuffer* new_pbuffer = new PBuffer("float=32 depth") ; bool ok = new_pbuffer->Initialize( width, height, false, true ) ; ogf_assert(ok) ; for(unsigned int i=0; i<PBUFFER_POOL_SIZE; i++) { if(pbuffer_pool_[i] == nil) { pbuffer_pool_[i] = new_pbuffer ; pbuffer_pool_timestamp_[i] = SystemStopwatch::now() ; return new_pbuffer ; } } int lru = 0 ; for(unsigned int i=0; i<PBUFFER_POOL_SIZE; i++) { if(pbuffer_pool_timestamp_[i] < pbuffer_pool_timestamp_[lru]) { lru = i ; } } delete pbuffer_pool_[lru] ; pbuffer_pool_[lru] = new_pbuffer ; pbuffer_pool_timestamp_[lru] = SystemStopwatch::now() ; return new_pbuffer ; }
int main(int argc, char *argv[]) #endif { int ret; char *table = "filter"; struct ip6tc_handle *handle = NULL; ip6tables_globals.program_name = "ip6tables"; #if !defined(ALL_INCLUSIVE) && !defined(NO_SHARED_LIBS) ret = xtables_init_all(&ip6tables_globals, NFPROTO_IPV6); if (ret < 0) { fprintf(stderr, "%s/%s Failed to initialize xtables\n", ip6tables_globals.program_name, ip6tables_globals.program_version); exit(1); } #endif #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS) init_extensions(); #endif ret = do_command6(argc, argv, &table, &handle); if (ret) { ret = ip6tc_commit(handle); ip6tc_free(handle); } if (!ret) { if (errno == EINVAL) { fprintf(stderr, "ip6tables: %s. " "Run `dmesg' for more information.\n", ip6tc_strerror(errno)); } else { fprintf(stderr, "[%s %d]ip6tables: %s.\n", __FILE__,__LINE__,ip6tc_strerror(errno)); } } exit(!ret); }
int main(int argc, char *argv[]) { int ret = 1; int c; int numtok; size_t llen = 0; char* iline = NULL; ssize_t r = -1; int nargc = 0; char* nargv[256]; FILE* fp = stdin; #ifdef IP6T prog_name = "ip6tables-batch"; #else prog_name = "iptables-batch"; #endif #ifdef IP6T c = xtables_init_all(&ip6tables_globals, NFPROTO_IPV6); #else c = xtables_init_all(&iptables_globals, NFPROTO_IPV4); #endif if(c < 0) { fprintf(stderr, "%s/%s Failed to initialize xtables\n", prog_name, prog_ver); exit(1); } #ifdef NO_SHARED_LIBS init_extensions(); #ifdef IP6T init_extensions6(); else
int main(int argc, char *argv[]) { ip6tc_handle_t handle; char buffer[10240]; unsigned int line = 0; int c; char curtable[IP6T_TABLE_MAXNAMELEN + 1]; FILE *in; const char *modprobe = 0; program_name = "ip6tables-restore"; program_version = IPTABLES_VERSION; #ifdef NO_SHARED_LIBS init_extensions(); #endif while ((c = getopt_long(argc, argv, "bcvhnM:", options, NULL)) != -1) { switch (c) { case 'b': binary = 1; break; case 'c': counters = 1; break; case 'v': verbose = 1; break; case 'h': print_usage("ip6tables-restore", IPTABLES_VERSION); break; case 'n': noflush = 1; break; case 'M': modprobe = optarg; break; } } if (optind == argc - 1) { in = fopen(argv[optind], "r"); if (!in) { fprintf(stderr, "Can't open %s: %s", argv[optind], strerror(errno)); exit(1); } } else if (optind < argc) { fprintf(stderr, "Unknown arguments found on commandline"); exit(1); } else in = stdin; /* Grab standard input. */ while (fgets(buffer, sizeof(buffer), in)) { int ret; line++; if (buffer[0] == '\n') continue; else if (buffer[0] == '#') { if (verbose) fputs(buffer, stdout); continue; } else if (strcmp(buffer, "COMMIT\n") == 0) { DEBUGP("Calling commit\n"); ret = ip6tc_commit(&handle); } else if (buffer[0] == '*') { /* New table */ char *table; table = strtok(buffer+1, " \t\n"); DEBUGP("line %u, table '%s'\n", line, table); if (!table) { exit_error(PARAMETER_PROBLEM, "%s: line %u table name invalid\n", program_name, line); exit(1); } strncpy(curtable, table, IP6T_TABLE_MAXNAMELEN); handle = create_handle(table, modprobe); if (noflush == 0) { DEBUGP("Cleaning all chains of table '%s'\n", table); for_each_chain(flush_entries, verbose, 1, &handle); DEBUGP("Deleting all user-defined chains " "of table '%s'\n", table); for_each_chain(delete_chain, verbose, 0, &handle) ; } ret = 1; } else if (buffer[0] == ':') { /* New chain. */ char *policy, *chain; chain = strtok(buffer+1, " \t\n"); DEBUGP("line %u, chain '%s'\n", line, chain); if (!chain) { exit_error(PARAMETER_PROBLEM, "%s: line %u chain name invalid\n", program_name, line); exit(1); } if (!ip6tc_builtin(chain, handle)) { DEBUGP("Creating new chain '%s'\n", chain); if (!ip6tc_create_chain(chain, &handle)) exit_error(PARAMETER_PROBLEM, "error creating chain " "'%s':%s\n", chain, strerror(errno)); } policy = strtok(NULL, " \t\n"); DEBUGP("line %u, policy '%s'\n", line, policy); if (!policy) { exit_error(PARAMETER_PROBLEM, "%s: line %u policy invalid\n", program_name, line); exit(1); } if (strcmp(policy, "-") != 0) { struct ip6t_counters count; if (counters) { char *ctrs; ctrs = strtok(NULL, " \t\n"); parse_counters(ctrs, &count); } else { memset(&count, 0, sizeof(struct ip6t_counters)); } DEBUGP("Setting policy of chain %s to %s\n", chain, policy); if (!ip6tc_set_policy(chain, policy, &count, &handle)) exit_error(OTHER_PROBLEM, "Can't set policy `%s'" " on `%s' line %u: %s\n", chain, policy, line, ip6tc_strerror(errno)); } ret = 1; } else { int a; char *ptr = buffer; char *pcnt = NULL; char *bcnt = NULL; char *parsestart; /* the parser */ char *param_start, *curchar; int quote_open; /* reset the newargv */ newargc = 0; if (buffer[0] == '[') { /* we have counters in our input */ ptr = strchr(buffer, ']'); if (!ptr) exit_error(PARAMETER_PROBLEM, "Bad line %u: need ]\n", line); pcnt = strtok(buffer+1, ":"); if (!pcnt) exit_error(PARAMETER_PROBLEM, "Bad line %u: need :\n", line); bcnt = strtok(NULL, "]"); if (!bcnt) exit_error(PARAMETER_PROBLEM, "Bad line %u: need ]\n", line); /* start command parsing after counter */ parsestart = ptr + 1; } else { /* start command parsing at start of line */ parsestart = buffer; } add_argv(argv[0]); add_argv("-t"); add_argv((char *) &curtable); if (counters && pcnt && bcnt) { add_argv("--set-counters"); add_argv((char *) pcnt); add_argv((char *) bcnt); } /* After fighting with strtok enough, here's now * a 'real' parser. According to Rusty I'm now no * longer a real hacker, but I can live with that */ quote_open = 0; param_start = parsestart; for (curchar = parsestart; *curchar; curchar++) { if (*curchar == '"') { if (quote_open) { quote_open = 0; *curchar = ' '; } else { quote_open = 1; param_start++; } } if (*curchar == ' ' || *curchar == '\t' || * curchar == '\n') { char param_buffer[1024]; int param_len = curchar-param_start; if (quote_open) continue; if (!param_len) { /* two spaces? */ param_start++; continue; } /* end of one parameter */ strncpy(param_buffer, param_start, param_len); *(param_buffer+param_len) = '\0'; /* check if table name specified */ if (!strncmp(param_buffer, "-t", 3) || !strncmp(param_buffer, "--table", 8)) { exit_error(PARAMETER_PROBLEM, "Line %u seems to have a " "-t table option.\n", line); exit(1); } add_argv(param_buffer); param_start += param_len + 1; } else { /* regular character, skip */ } } DEBUGP("calling do_command6(%u, argv, &%s, handle):\n", newargc, curtable); for (a = 0; a < newargc; a++) DEBUGP("argv[%u]: %s\n", a, newargv[a]); ret = do_command6(newargc, newargv, &newargv[2], &handle); free_argv(); } if (!ret) { fprintf(stderr, "%s: line %u failed\n", program_name, line); exit(1); } } return 0; }
int iptables_restore_main(int argc, char *argv[]) { struct xtc_handle *handle = NULL; char buffer[10240]; int c; char curtable[XT_TABLE_MAXNAMELEN + 1]; FILE *in; int in_table = 0, testing = 0; const char *tablename = NULL; const struct xtc_ops *ops = &iptc_ops; line = 0; iptables_globals.program_name = "iptables-restore"; c = xtables_init_all(&iptables_globals, NFPROTO_IPV4); if (c < 0) { fprintf(stderr, "%s/%s Failed to initialize xtables\n", iptables_globals.program_name, iptables_globals.program_version); exit(1); } #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS) init_extensions(); init_extensions4(); #endif while ((c = getopt_long(argc, argv, "bcvthnM:T:", options, NULL)) != -1) { switch (c) { case 'b': binary = 1; break; case 'c': counters = 1; break; case 'v': verbose = 1; break; case 't': testing = 1; break; case 'h': print_usage("iptables-restore", IPTABLES_VERSION); break; case 'n': noflush = 1; break; case 'M': xtables_modprobe_program = optarg; break; case 'T': tablename = optarg; break; } } if (optind == argc - 1) { in = fopen(argv[optind], "re"); if (!in) { fprintf(stderr, "Can't open %s: %s\n", argv[optind], strerror(errno)); exit(1); } } else if (optind < argc) { fprintf(stderr, "Unknown arguments found on commandline\n"); exit(1); } else in = stdin; /* Grab standard input. */ while (fgets(buffer, sizeof(buffer), in)) { int ret = 0; line++; if (buffer[0] == '\n') continue; else if (buffer[0] == '#') { if (verbose) fputs(buffer, stdout); continue; } else if ((strcmp(buffer, "COMMIT\n") == 0) && (in_table)) { if (!testing) { DEBUGP("Calling commit\n"); ret = ops->commit(handle); ops->free(handle); handle = NULL; } else { DEBUGP("Not calling commit, testing\n"); ret = 1; } in_table = 0; } else if ((buffer[0] == '*') && (!in_table)) { /* New table */ char *table; table = strtok(buffer+1, " \t\n"); DEBUGP("line %u, table '%s'\n", line, table); if (!table) { xtables_error(PARAMETER_PROBLEM, "%s: line %u table name invalid\n", xt_params->program_name, line); exit(1); } strncpy(curtable, table, XT_TABLE_MAXNAMELEN); curtable[XT_TABLE_MAXNAMELEN] = '\0'; if (tablename && (strcmp(tablename, table) != 0)) continue; if (handle) ops->free(handle); handle = create_handle(table); if (noflush == 0) { DEBUGP("Cleaning all chains of table '%s'\n", table); for_each_chain4(flush_entries4, verbose, 1, handle); DEBUGP("Deleting all user-defined chains " "of table '%s'\n", table); for_each_chain4(delete_chain4, verbose, 0, handle); } ret = 1; in_table = 1; } else if ((buffer[0] == ':') && (in_table)) { /* New chain. */ char *policy, *chain; chain = strtok(buffer+1, " \t\n"); DEBUGP("line %u, chain '%s'\n", line, chain); if (!chain) { xtables_error(PARAMETER_PROBLEM, "%s: line %u chain name invalid\n", xt_params->program_name, line); exit(1); } if (strlen(chain) >= XT_EXTENSION_MAXNAMELEN) xtables_error(PARAMETER_PROBLEM, "Invalid chain name `%s' " "(%u chars max)", chain, XT_EXTENSION_MAXNAMELEN - 1); if (ops->builtin(chain, handle) <= 0) { if (noflush && ops->is_chain(chain, handle)) { DEBUGP("Flushing existing user defined chain '%s'\n", chain); if (!ops->flush_entries(chain, handle)) xtables_error(PARAMETER_PROBLEM, "error flushing chain " "'%s':%s\n", chain, strerror(errno)); } else { DEBUGP("Creating new chain '%s'\n", chain); if (!ops->create_chain(chain, handle)) xtables_error(PARAMETER_PROBLEM, "error creating chain " "'%s':%s\n", chain, strerror(errno)); } } policy = strtok(NULL, " \t\n"); DEBUGP("line %u, policy '%s'\n", line, policy); if (!policy) { xtables_error(PARAMETER_PROBLEM, "%s: line %u policy invalid\n", xt_params->program_name, line); exit(1); } if (strcmp(policy, "-") != 0) { struct xt_counters count; if (counters) { char *ctrs; ctrs = strtok(NULL, " \t\n"); if (!ctrs || !parse_counters(ctrs, &count)) xtables_error(PARAMETER_PROBLEM, "invalid policy counters " "for chain '%s'\n", chain); } else { memset(&count, 0, sizeof(count)); } DEBUGP("Setting policy of chain %s to %s\n", chain, policy); if (!ops->set_policy(chain, policy, &count, handle)) xtables_error(OTHER_PROBLEM, "Can't set policy `%s'" " on `%s' line %u: %s\n", policy, chain, line, ops->strerror(errno)); } ret = 1; } else if (in_table) { int a; char *ptr = buffer; char *pcnt = NULL; char *bcnt = NULL; char *parsestart; /* reset the newargv */ newargc = 0; if (buffer[0] == '[') { /* we have counters in our input */ ptr = strchr(buffer, ']'); if (!ptr) xtables_error(PARAMETER_PROBLEM, "Bad line %u: need ]\n", line); pcnt = strtok(buffer+1, ":"); if (!pcnt) xtables_error(PARAMETER_PROBLEM, "Bad line %u: need :\n", line); bcnt = strtok(NULL, "]"); if (!bcnt) xtables_error(PARAMETER_PROBLEM, "Bad line %u: need ]\n", line); /* start command parsing after counter */ parsestart = ptr + 1; } else { /* start command parsing at start of line */ parsestart = buffer; } add_argv(argv[0]); add_argv("-t"); add_argv(curtable); if (counters && pcnt && bcnt) { add_argv("--set-counters"); add_argv((char *) pcnt); add_argv((char *) bcnt); } add_param_to_argv(parsestart); DEBUGP("calling do_command4(%u, argv, &%s, handle):\n", newargc, curtable); for (a = 0; a < newargc; a++) DEBUGP("argv[%u]: %s\n", a, newargv[a]); ret = do_command4(newargc, newargv, &newargv[2], &handle); free_argv(); fflush(stdout); } if (tablename && (strcmp(tablename, curtable) != 0)) continue; if (!ret) { fprintf(stderr, "%s: line %u failed\n", xt_params->program_name, line); exit(1); } } if (in_table) { fprintf(stderr, "%s: COMMIT expected at line %u\n", xt_params->program_name, line + 1); exit(1); } fclose(in); return 0; }
bool gr_opengl_init(std::unique_ptr<os::GraphicsOperations>&& graphicsOps) { if (GL_initted) { gr_opengl_cleanup(false); GL_initted = false; } mprintf(( "Initializing OpenGL graphics device at %ix%i with %i-bit color...\n", gr_screen.max_w, gr_screen.max_h, gr_screen.bits_per_pixel )); graphic_operations = std::move(graphicsOps); if ( opengl_init_display_device() ) { Error(LOCATION, "Unable to initialize display device!\n" "This most likely means that your graphics drivers do not support the minimum required OpenGL version which is %d.%d.\n", (MIN_REQUIRED_GL_VERSION / 10), (MIN_REQUIRED_GL_VERSION % 10)); } // Initialize function pointers if (!gladLoadGLLoader(GL_context->getLoaderFunction())) { Error(LOCATION, "Failed to load OpenGL!"); } // version check GL_version = (GLVersion.major * 10) + GLVersion.minor; if (GL_version < MIN_REQUIRED_GL_VERSION) { Error(LOCATION, "Current GL Version of %d.%d is less than the " "required version of %d.%d.\n" "Switch video modes or update your drivers.", GLVersion.major, GLVersion.minor, (MIN_REQUIRED_GL_VERSION / 10), (MIN_REQUIRED_GL_VERSION % 10)); } GL_initted = true; #ifndef NDEBUG // Set up the debug extension if present if (GLAD_GL_ARB_debug_output) { nprintf(("OpenGL Debug", "Using OpenGL debug extension\n")); glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); GLuint unusedIds = 0; glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, &unusedIds, true); glDebugMessageCallbackARB(debug_callback, nullptr); // Now print all pending log messages while (hasPendingDebugMessage()) { printNextDebugMessage(); } } #endif // this MUST be done before any other gr_opengl_* or // opengl_* function calls!! opengl_setup_function_pointers(); mprintf(( " OpenGL Vendor : %s\n", glGetString(GL_VENDOR) )); mprintf(( " OpenGL Renderer : %s\n", glGetString(GL_RENDERER) )); mprintf(( " OpenGL Version : %s\n", glGetString(GL_VERSION) )); mprintf(( "\n" )); if (Cmdline_fullscreen_window || Cmdline_window) { opengl_go_windowed(); } else { opengl_go_fullscreen(); } init_extensions(); // init state system (must come AFTER light is set up) GL_state.init(); GLint max_texture_units = GL_supported_texture_units; GLint max_texture_coords = GL_supported_texture_units; glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_units); max_texture_coords = 1; // create vertex array object to make OpenGL Core happy glGenVertexArrays(1, &GL_vao); glBindVertexArray(GL_vao); GL_state.Texture.init(max_texture_units); GL_state.Array.init(max_texture_coords); GL_state.Constants.init(); opengl_set_texture_target(); GL_state.Texture.SetActiveUnit(0); GL_state.Texture.SetTarget(GL_TEXTURE_2D); GL_state.Texture.Enable(); // ready the texture system opengl_tcache_init(); opengl_tnl_init(); // setup default shaders, and shader related items opengl_shader_init(); // post processing effects, after shaders are initialized opengl_setup_scene_textures(); opengl_post_process_init(); // must be called after extensions are setup opengl_set_vsync( !Cmdline_no_vsync ); gr_reset_matrices(); gr_setup_viewport(); glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_STENCIL_BUFFER_BIT); glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); glDepthRange(0.0, 1.0); glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glFlush(); Gr_current_red = &Gr_red; Gr_current_blue = &Gr_blue; Gr_current_green = &Gr_green; Gr_current_alpha = &Gr_alpha; gr_opengl_reset_clip(); gr_opengl_clear(); gr_opengl_flip(); gr_opengl_clear(); gr_opengl_flip(); gr_opengl_clear(); glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &GL_max_elements_vertices); glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &GL_max_elements_indices); mprintf(( " Max texture units: %i (%i)\n", GL_supported_texture_units, max_texture_units )); mprintf(( " Max client texture states: %i (%i)\n", GL_supported_texture_units, max_texture_coords )); mprintf(( " Max elements vertices: %i\n", GL_max_elements_vertices )); mprintf(( " Max elements indices: %i\n", GL_max_elements_indices )); mprintf(( " Max texture size: %ix%i\n", GL_max_texture_width, GL_max_texture_height )); mprintf(( " Max render buffer size: %ix%i\n", GL_max_renderbuffer_size, GL_max_renderbuffer_size )); mprintf(( " Can use compressed textures: %s\n", Use_compressed_textures ? NOX("YES") : NOX("NO") )); mprintf(( " Texture compression available: %s\n", Texture_compression_available ? NOX("YES") : NOX("NO") )); mprintf(( " Post-processing enabled: %s\n", (Cmdline_postprocess) ? "YES" : "NO")); mprintf(( " Using %s texture filter.\n", (GL_mipmap_filter) ? NOX("trilinear") : NOX("bilinear") )); mprintf(( " OpenGL Shader Version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION) )); mprintf((" Max uniform block size: %d\n", GL_state.Constants.GetMaxUniformBlockSize())); mprintf((" Max uniform buffer bindings: %d\n", GL_state.Constants.GetMaxUniformBlockBindings())); mprintf((" Uniform buffer byte offset alignment: %d\n", GL_state.Constants.GetUniformBufferOffsetAlignment())); // This stops fred crashing if no textures are set gr_screen.current_bitmap = -1; mprintf(("... OpenGL init is complete!\n")); if (Cmdline_ati_color_swap) GL_read_format = GL_RGBA; return true; }
// cc-firewall; fire it up! int main(int argc, char *argv[]) { int c; float seconds; struct timeval tva, tvb; iptables_globals.program_name = "firewall"; if (xtables_init_all(&iptables_globals, FIREWALL_NFPROTO) < 0) { fprintf(stderr, "%s: Failed to initialize xtables\n", argv[0]); exit(1); } #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS) init_extensions(); #endif // Command-line processing while((c = getopt_long(argc, argv, "hVdps", options, NULL)) != -1) { switch(c) { case 'p': pretend = 1; // fall through to enable debug also... case 'd': debug = 1; break; case 's': strict = 1; break; case 'V': fprintf(stderr, "%s v%s\n", iptables_globals.program_name, iptables_globals.program_version); fprintf(stderr, "Copyright (C) 2005-2008 Point Clark Networks\n"); fprintf(stderr, "Copyright (C) 2009-2011 ClearFoundation\n"); exit(1); case 'h': default: fprintf(stderr, "%s [-h|--help]\n", argv[0]); fprintf(stderr, "%s [-V|--version]\n", argv[0]); fprintf(stderr, "%s [-s|--strict] [-d|--debug] [-p|--pretend] <configuration>\n", argv[0]); exit(1); } } // Can only be run by the superuser (root) if(getuid() != 0 && geteuid() != 0) { fprintf(stderr, "%s: %s.\n", argv[0], strerror(EPERM)); exit(1); } // Must be passed a Lua script filename to execute if(optind != argc - 1) { // No script filename supplied fprintf(stderr, "%s: Required argument missing.\n", iptables_globals.program_name); exit(1); } // Pre-load ip_tables kernel module //iptables_insmod("ip_tables", NULL); // Install exit handler atexit(exit_handler); // Initialize ifconfig context IFC = if_init(); // Initialize Lua state LUA = lua_open(); // Load Lua libraries luaL_openlibs(LUA); // Utility bindings lua_pushcfunction(LUA, __lua_b_and); lua_setglobal(LUA, "b_and"); lua_pushcfunction(LUA, __lua_b_or); lua_setglobal(LUA, "b_or"); lua_pushcfunction(LUA, __lua_iptc_ip2bin); lua_setglobal(LUA, "ip2bin"); lua_pushcfunction(LUA, __lua_iptc_bin2ip); lua_setglobal(LUA, "bin2ip"); lua_pushcfunction(LUA, __lua_p_name); lua_setglobal(LUA, "p_name"); lua_pushcfunction(LUA, __lua_gethostbyname); lua_setglobal(LUA, "gethostbyname"); lua_pushcfunction(LUA, __lua_debug); lua_setglobal(LUA, "debug"); lua_pushcfunction(LUA, __lua_echo); lua_setglobal(LUA, "echo"); lua_pushcfunction(LUA, __lua_execute); lua_setglobal(LUA, "execute"); // Iptables bindings lua_pushcfunction(LUA, __lua_iptc_init); lua_setglobal(LUA, "iptc_init"); lua_pushcfunction(LUA, __lua_iptc_create_chain); lua_setglobal(LUA, "iptc_create_chain"); lua_pushcfunction(LUA, __lua_iptc_delete_chain); lua_setglobal(LUA, "iptc_delete_chain"); lua_pushcfunction(LUA, __lua_iptc_delete_user_chains); lua_setglobal(LUA, "iptc_delete_user_chains"); lua_pushcfunction(LUA, __lua_iptc_flush_chain); lua_setglobal(LUA, "iptc_flush_chain"); lua_pushcfunction(LUA, __lua_iptc_flush_all_chains); lua_setglobal(LUA, "iptc_flush_all_chains"); lua_pushcfunction(LUA, __lua_iptables); lua_setglobal(LUA, "iptables"); lua_pushcfunction(LUA, __lua_iptc_set_policy); lua_setglobal(LUA, "iptc_set_policy"); lua_pushcfunction(LUA, __lua_iptc_commit); lua_setglobal(LUA, "iptc_commit"); // Network interface bindings (ifconfig.o) lua_pushcfunction(LUA, __lua_if_list); lua_setglobal(LUA, "if_list"); lua_pushcfunction(LUA, __lua_if_list_pppoe); lua_setglobal(LUA, "if_list_pppoe"); lua_pushcfunction(LUA, __lua_if_address); lua_setglobal(LUA, "if_address"); lua_pushcfunction(LUA, __lua_if_dst_address); lua_setglobal(LUA, "if_dst_address"); lua_pushcfunction(LUA, __lua_if_netmask); lua_setglobal(LUA, "if_netmask"); lua_pushcfunction(LUA, __lua_if_network); lua_setglobal(LUA, "ip_network"); lua_pushcfunction(LUA, __lua_if_prefix); lua_setglobal(LUA, "ip_prefix"); lua_pushcfunction(LUA, __lua_if_isup); lua_setglobal(LUA, "if_isup"); lua_pushcfunction(LUA, __lua_if_isppp); lua_setglobal(LUA, "if_isppp"); // Open syslog { int f; char *facility = getenv("FW_FACILITY"); if(facility == NULL) f = LOG_LOCAL0; else if(strncasecmp(facility, "local0", 6) == 0) f = LOG_LOCAL0; else if(strncasecmp(facility, "local1", 6) == 0) f = LOG_LOCAL1; else if(strncasecmp(facility, "local2", 6) == 0) f = LOG_LOCAL2; else if(strncasecmp(facility, "local3", 6) == 0) f = LOG_LOCAL3; else if(strncasecmp(facility, "local4", 6) == 0) f = LOG_LOCAL4; else if(strncasecmp(facility, "local5", 6) == 0) f = LOG_LOCAL5; else if(strncasecmp(facility, "local6", 6) == 0) f = LOG_LOCAL6; else f = LOG_LOCAL0; if(!debug) openlog(iptables_globals.program_name, 0, f); else openlog(iptables_globals.program_name, LOG_PERROR, f); } gettimeofday(&tva, NULL); // Load, compile, and execute supplied Lua script if(luaL_loadfile(LUA, (source = argv[optind])) || lua_pcall(LUA, 0, 0, 0)) { syslog(LOG_ERR, "Error: %s\n", lua_tostring(LUA, -1)); return 1; } gettimeofday(&tvb, NULL); if(!pretend) { seconds = tvb.tv_sec - tva.tv_sec; seconds += (tvb.tv_usec - tva.tv_usec) / 1000000.0f; syslog(LOG_INFO, "Execution time: %.03fs\n", seconds); } closelog(); return grc; }
int main(int argc, char *argv[]) #endif { struct ip6tc_handle *handle = NULL; char buffer[10240]; int c; char curtable[IP6T_TABLE_MAXNAMELEN + 1]; FILE *in; int in_table = 0, testing = 0; line = 0; ip6tables_globals.program_name = "ip6tables-restore"; c = xtables_init_all(&ip6tables_globals, NFPROTO_IPV6); if (c < 0) { fprintf(stderr, "%s/%s Failed to initialize xtables\n", ip6tables_globals.program_name, ip6tables_globals.program_version); exit(1); } #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS) init_extensions(); init_extensions6(); #endif while ((c = getopt_long(argc, argv, "bcvthnM:", options, NULL)) != -1) { switch (c) { case 'b': binary = 1; break; case 'c': counters = 1; break; case 'v': verbose = 1; break; case 't': testing = 1; break; case 'h': print_usage("ip6tables-restore", IPTABLES_VERSION); break; case 'n': noflush = 1; break; case 'M': xtables_modprobe_program = optarg; break; } } if (optind == argc - 1) { in = fopen(argv[optind], "re"); if (!in) { fprintf(stderr, "Can't open %s: %s\n", argv[optind], strerror(errno)); exit(1); } } else if (optind < argc) { fprintf(stderr, "Unknown arguments found on commandline\n"); exit(1); } else in = stdin; /* Grab standard input. */ while (fgets(buffer, sizeof(buffer), in)) { int ret = 0; line++; if (buffer[0] == '\n') continue; else if (buffer[0] == '#') { if (verbose) fputs(buffer, stdout); continue; } else if ((strcmp(buffer, "COMMIT\n") == 0) && (in_table)) { if (!testing) { DEBUGP("Calling commit\n"); ret = ip6tc_commit(handle); ip6tc_free(handle); handle = NULL; } else { DEBUGP("Not calling commit, testing\n"); ret = 1; } in_table = 0; } else if ((buffer[0] == '*') && (!in_table)) { /* New table */ char *table; table = strtok(buffer+1, " \t\n"); DEBUGP("line %u, table '%s'\n", line, table); if (!table) { xtables_error(PARAMETER_PROBLEM, "%s: line %u table name invalid\n", ip6tables_globals.program_name, line); exit(1); } strncpy(curtable, table, IP6T_TABLE_MAXNAMELEN); curtable[IP6T_TABLE_MAXNAMELEN] = '\0'; if (handle) ip6tc_free(handle); handle = create_handle(table); if (noflush == 0) { DEBUGP("Cleaning all chains of table '%s'\n", table); for_each_chain6(flush_entries6, verbose, 1, handle); DEBUGP("Deleting all user-defined chains " "of table '%s'\n", table); for_each_chain6(delete_chain6, verbose, 0, handle); } ret = 1; in_table = 1; } else if ((buffer[0] == ':') && (in_table)) { /* New chain. */ char *policy, *chain; chain = strtok(buffer+1, " \t\n"); DEBUGP("line %u, chain '%s'\n", line, chain); if (!chain) { xtables_error(PARAMETER_PROBLEM, "%s: line %u chain name invalid\n", ip6tables_globals.program_name, line); exit(1); } if (strlen(chain) >= XT_EXTENSION_MAXNAMELEN) xtables_error(PARAMETER_PROBLEM, "Invalid chain name `%s' " "(%u chars max)", chain, XT_EXTENSION_MAXNAMELEN - 1); if (ip6tc_builtin(chain, handle) <= 0) { if (noflush && ip6tc_is_chain(chain, handle)) { DEBUGP("Flushing existing user defined chain '%s'\n", chain); if (!ip6tc_flush_entries(chain, handle)) xtables_error(PARAMETER_PROBLEM, "error flushing chain " "'%s':%s\n", chain, strerror(errno)); } else { DEBUGP("Creating new chain '%s'\n", chain); if (!ip6tc_create_chain(chain, handle)) xtables_error(PARAMETER_PROBLEM, "error creating chain " "'%s':%s\n", chain, strerror(errno)); } } policy = strtok(NULL, " \t\n"); DEBUGP("line %u, policy '%s'\n", line, policy); if (!policy) { xtables_error(PARAMETER_PROBLEM, "%s: line %u policy invalid\n", ip6tables_globals.program_name, line); exit(1); } if (strcmp(policy, "-") != 0) { struct ip6t_counters count; if (counters) { char *ctrs; ctrs = strtok(NULL, " \t\n"); if (!ctrs || !parse_counters(ctrs, &count)) xtables_error(PARAMETER_PROBLEM, "invalid policy counters " "for chain '%s'\n", chain); } else { memset(&count, 0, sizeof(struct ip6t_counters)); } DEBUGP("Setting policy of chain %s to %s\n", chain, policy); if (!ip6tc_set_policy(chain, policy, &count, handle)) xtables_error(OTHER_PROBLEM, "Can't set policy `%s'" " on `%s' line %u: %s\n", policy, chain, line, ip6tc_strerror(errno)); } ret = 1; } else if (in_table) { int a; char *ptr = buffer; char *pcnt = NULL; char *bcnt = NULL; char *parsestart; /* the parser */ char *curchar; int quote_open, escaped; size_t param_len; /* reset the newargv */ newargc = 0; if (buffer[0] == '[') { /* we have counters in our input */ ptr = strchr(buffer, ']'); if (!ptr) xtables_error(PARAMETER_PROBLEM, "Bad line %u: need ]\n", line); pcnt = strtok(buffer+1, ":"); if (!pcnt) xtables_error(PARAMETER_PROBLEM, "Bad line %u: need :\n", line); bcnt = strtok(NULL, "]"); if (!bcnt) xtables_error(PARAMETER_PROBLEM, "Bad line %u: need ]\n", line); /* start command parsing after counter */ parsestart = ptr + 1; } else { /* start command parsing at start of line */ parsestart = buffer; } add_argv(argv[0]); add_argv("-t"); add_argv(curtable); if (counters && pcnt && bcnt) { add_argv("--set-counters"); add_argv((char *) pcnt); add_argv((char *) bcnt); } /* After fighting with strtok enough, here's now * a 'real' parser. According to Rusty I'm now no * longer a real hacker, but I can live with that */ quote_open = 0; escaped = 0; param_len = 0; for (curchar = parsestart; *curchar; curchar++) { char param_buffer[1024]; if (quote_open) { if (escaped) { param_buffer[param_len++] = *curchar; escaped = 0; continue; } else if (*curchar == '\\') { escaped = 1; continue; } else if (*curchar == '"') { quote_open = 0; *curchar = ' '; } else { param_buffer[param_len++] = *curchar; continue; } } else { if (*curchar == '"') { quote_open = 1; continue; } } if (*curchar == ' ' || *curchar == '\t' || * curchar == '\n') { if (!param_len) { /* two spaces? */ continue; } param_buffer[param_len] = '\0'; /* check if table name specified */ if (!strncmp(param_buffer, "-t", 2) || !strncmp(param_buffer, "--table", 8)) { xtables_error(PARAMETER_PROBLEM, "Line %u seems to have a " "-t table option.\n", line); exit(1); } add_argv(param_buffer); param_len = 0; } else { /* regular character, copy to buffer */ param_buffer[param_len++] = *curchar; if (param_len >= sizeof(param_buffer)) xtables_error(PARAMETER_PROBLEM, "Parameter too long!"); } } DEBUGP("calling do_command6(%u, argv, &%s, handle):\n", newargc, curtable); for (a = 0; a < newargc; a++) DEBUGP("argv[%u]: %s\n", a, newargv[a]); ret = do_command6(newargc, newargv, &newargv[2], &handle); free_argv(); fflush(stdout); } if (!ret) { fprintf(stderr, "%s: line %u failed\n", ip6tables_globals.program_name, line); exit(1); } } if (in_table) { fprintf(stderr, "%s: COMMIT expected at line %u\n", ip6tables_globals.program_name, line + 1); exit(1); } if (in != NULL) fclose(in); return 0; }
int main(int argc, char *argv[]) #endif { iptc_handle_t handle = NULL; char buffer[10240]; int c; char curtable[IPT_TABLE_MAXNAMELEN + 1]; FILE *in; const char *modprobe = 0; int in_table = 0, testing = 0; const char *tablename = 0; program_name = "iptables-restore"; program_version = IPTABLES_VERSION; line = 0; lib_dir = getenv("IPTABLES_LIB_DIR"); if (!lib_dir) lib_dir = IPT_LIB_DIR; #ifdef NO_SHARED_LIBS init_extensions(); #endif while ((c = getopt_long(argc, argv, "bcvthnM:T:", options, NULL)) != -1) { switch (c) { case 'b': binary = 1; break; case 'c': counters = 1; break; case 'v': verbose = 1; break; case 't': testing = 1; break; case 'h': print_usage("iptables-restore", IPTABLES_VERSION); break; case 'n': noflush = 1; break; case 'M': modprobe = optarg; break; case 'T': tablename = optarg; break; } } if (optind == argc - 1) { in = fopen(argv[optind], "r"); if (!in) { fprintf(stderr, "Can't open %s: %s\n", argv[optind], strerror(errno)); exit(1); } } else if (optind < argc) { fprintf(stderr, "Unknown arguments found on commandline\n"); exit(1); } else in = stdin; /* Grab standard input. */ while (fgets(buffer, sizeof(buffer), in)) { int ret = 0; line++; if (buffer[0] == '\n') continue; else if (buffer[0] == '#') { if (verbose) fputs(buffer, stdout); continue; } else if ((strcmp(buffer, "COMMIT\n") == 0) && (in_table)) { if (!testing) { DEBUGP("Calling commit\n"); ret = iptc_commit(&handle); } else { DEBUGP("Not calling commit, testing\n"); ret = 1; } in_table = 0; } else if ((buffer[0] == '*') && (!in_table)) { /* New table */ char *table; table = strtok(buffer+1, " \t\n"); DEBUGP("line %u, table '%s'\n", line, table); if (!table) { exit_error(PARAMETER_PROBLEM, "%s: line %u table name invalid\n", program_name, line); exit(1); } strncpy(curtable, table, IPT_TABLE_MAXNAMELEN); curtable[IPT_TABLE_MAXNAMELEN] = '\0'; if (tablename && (strcmp(tablename, table) != 0)) continue; if (handle) iptc_free(&handle); handle = create_handle(table, modprobe); if (noflush == 0) { DEBUGP("Cleaning all chains of table '%s'\n", table); for_each_chain(flush_entries, verbose, 1, &handle); DEBUGP("Deleting all user-defined chains " "of table '%s'\n", table); for_each_chain(delete_chain, verbose, 0, &handle) ; } ret = 1; in_table = 1; } else if ((buffer[0] == ':') && (in_table)) { /* New chain. */ char *policy, *chain; chain = strtok(buffer+1, " \t\n"); DEBUGP("line %u, chain '%s'\n", line, chain); if (!chain) { exit_error(PARAMETER_PROBLEM, "%s: line %u chain name invalid\n", program_name, line); exit(1); } if (iptc_builtin(chain, handle) <= 0) { if (noflush && iptc_is_chain(chain, handle)) { DEBUGP("Flushing existing user defined chain '%s'\n", chain); if (!iptc_flush_entries(chain, &handle)) exit_error(PARAMETER_PROBLEM, "error flushing chain " "'%s':%s\n", chain, strerror(errno)); } else { DEBUGP("Creating new chain '%s'\n", chain); if (!iptc_create_chain(chain, &handle)) exit_error(PARAMETER_PROBLEM, "error creating chain " "'%s':%s\n", chain, strerror(errno)); } } policy = strtok(NULL, " \t\n"); DEBUGP("line %u, policy '%s'\n", line, policy); if (!policy) { exit_error(PARAMETER_PROBLEM, "%s: line %u policy invalid\n", program_name, line); exit(1); } if (strcmp(policy, "-") != 0) { struct ipt_counters count; if (counters) { char *ctrs; ctrs = strtok(NULL, " \t\n"); if (!ctrs || !parse_counters(ctrs, &count)) exit_error(PARAMETER_PROBLEM, "invalid policy counters " "for chain '%s'\n", chain); } else { memset(&count, 0, sizeof(struct ipt_counters)); } DEBUGP("Setting policy of chain %s to %s\n", chain, policy); if (!iptc_set_policy(chain, policy, &count, &handle)) exit_error(OTHER_PROBLEM, "Can't set policy `%s'" " on `%s' line %u: %s\n", chain, policy, line, iptc_strerror(errno)); } ret = 1; } else if (in_table) { int a; char *ptr = buffer; char *pcnt = NULL; char *bcnt = NULL; char *parsestart; /* the parser */ char *curchar; int quote_open; int param_len; /* reset the newargv */ newargc = 0; if (buffer[0] == '[') { /* we have counters in our input */ ptr = strchr(buffer, ']'); if (!ptr) exit_error(PARAMETER_PROBLEM, "Bad line %u: need ]\n", line); pcnt = strtok(buffer+1, ":"); if (!pcnt) exit_error(PARAMETER_PROBLEM, "Bad line %u: need :\n", line); bcnt = strtok(NULL, "]"); if (!bcnt) exit_error(PARAMETER_PROBLEM, "Bad line %u: need ]\n", line); /* start command parsing after counter */ parsestart = ptr + 1; } else { /* start command parsing at start of line */ parsestart = buffer; } add_argv(argv[0]); add_argv("-t"); add_argv((char *) &curtable); if (counters && pcnt && bcnt) { add_argv("--set-counters"); add_argv((char *) pcnt); add_argv((char *) bcnt); } /* After fighting with strtok enough, here's now * a 'real' parser. According to Rusty I'm now no * longer a real hacker, but I can live with that */ quote_open = 0; param_len = 0; for (curchar = parsestart; *curchar; curchar++) { char param_buffer[1024]; if (*curchar == '"') { /* quote_open cannot be true if there * was no previous character. Thus, * curchar-1 has to be within bounds */ if (quote_open && *(curchar-1) != '\\') { quote_open = 0; *curchar = ' '; } else if (!quote_open) { quote_open = 1; continue; } } if (*curchar == ' ' || *curchar == '\t' || * curchar == '\n') { if (quote_open) { param_buffer[param_len++] = *curchar; continue; } if (!param_len) { /* two spaces? */ continue; } param_buffer[param_len] = '\0'; /* check if table name specified */ if (!strncmp(param_buffer, "-t", 3) || !strncmp(param_buffer, "--table", 8)) { exit_error(PARAMETER_PROBLEM, "Line %u seems to have a " "-t table option.\n", line); exit(1); } add_argv(param_buffer); param_len = 0; } else { /* Skip backslash that escapes quote: * the standard input does not require * escaping. However, the output * generated by iptables-save * introduces bashlash to keep * consistent with iptables */ if (quote_open && *curchar == '\\' && *(curchar+1) == '"') continue; /* regular character, copy to buffer */ param_buffer[param_len++] = *curchar; if (param_len >= sizeof(param_buffer)) exit_error(PARAMETER_PROBLEM, "Parameter too long!"); } } DEBUGP("calling do_command(%u, argv, &%s, handle):\n", newargc, curtable); for (a = 0; a < newargc; a++) DEBUGP("argv[%u]: %s\n", a, newargv[a]); ret = do_command(newargc, newargv, &newargv[2], &handle); free_argv(); } if (tablename && (strcmp(tablename, curtable) != 0)) continue; if (!ret) { fprintf(stderr, "%s: line %u failed\n", program_name, line); exit(1); } } if (in_table) { fprintf(stderr, "%s: COMMIT expected at line %u\n", program_name, line + 1); exit(1); } return 0; }
int main (int argc, char *argv[]) { /* Initialize */ gst_init (&argc, &argv); gtk_init (&argc, &argv); gdk_threads_init (); gtk_gl_init (&argc, &argv); init_extensions (); init_gl_resources (); /* Gtk window & container */ GtkWindow *window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL)); glarea = gtk_drawing_area_new (); gtk_widget_set_size_request (GTK_WIDGET (glarea), WINDOW_WIDTH, WINDOW_HEIGHT); g_signal_connect (glarea, "expose-event", G_CALLBACK (on_expose), NULL); g_signal_connect (glarea, "configure-event", G_CALLBACK (on_configure), NULL); g_signal_connect (glarea, "map-event", G_CALLBACK (on_mapped), NULL); g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL); GdkGLConfig *gl_config; gl_config = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGBA | GDK_GL_MODE_DOUBLE); if (gl_config == NULL) g_critical ("Failed to setup a double-buffered RGB visual"); if (! gtk_widget_set_gl_capability (GTK_WIDGET (glarea), gl_config, NULL, TRUE, GDK_GL_RGBA_TYPE)) g_critical ("Failed to add gl capability"); gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (glarea)); gtk_widget_show_all (GTK_WIDGET (window)); /* Create the elements */ pipeline = gst_pipeline_new (NULL); source = gst_element_factory_make ("filesrc", "filesrc"); decodebin = gst_element_factory_make ("decodebin", "decodebin"); videosink = gst_element_factory_make ("fakesink", "videosink"); audiosink = gst_element_factory_make ("alsasink", "audiosink"); audioconvert = gst_element_factory_make ("audioconvert", "audioconvert"); audioqueue = gst_element_factory_make ("queue", "audioqueue"); videoqueue = gst_element_factory_make ("queue", "videoqueue"); if (pipeline == NULL || source == NULL || decodebin == NULL || videosink == NULL || audiosink == NULL || audioconvert == NULL || audioqueue == NULL || videoqueue == NULL) g_critical ("One of the GStreamer decoding elements is missing"); /* Setup the pipeline */ g_object_set (G_OBJECT (source), "location", "video.avi", NULL); gst_bin_add_many (GST_BIN (pipeline), source, decodebin, videosink, audiosink, audioconvert, audioqueue, videoqueue, NULL); g_signal_connect (decodebin, "pad-added", G_CALLBACK (on_new_pad), NULL); /* Link the elements */ gst_element_link (source, decodebin); gst_element_link (audioqueue, audioconvert); gst_element_link (audioconvert, audiosink); gst_element_link (videoqueue, videosink); /* Now run the pipeline... */ gst_element_set_state (pipeline, GST_STATE_PLAYING); /* Main loop */ gtk_main (); return 0; }
int main(){ MSG message; HSTREAM stream = 0; object *room; object *sphere; object *sphere_copy; rtt_target *rendertarget; rtt_target *fucking_shit; int loading; int bjork_texture; int yo_plus; int carlb; int i; int veldig_kule; int greets; int mothafuckas; vector particles[PARTICLE_COUNT]; make_random_particles(particles, PARTICLE_COUNT, 200); if(!mumps_open("CARL B!!!!1",WIDTH,HEIGHT,32,32,-1,FULLSCREEN)) error("kunne ikke lage bartevindu"); if(!init_extensions()){ mumps_close(); error("kunne ikke bruke fet opengl-extension"); } if (!BASS_Init(-1, 44100, 0, 0, 0)) { mumps_close(); error("kunne ikke åpne fet lyd"); } stream = BASS_StreamCreateFile(FALSE, "data/uglespy.ogg", 0, 0, BASS_MP3_SETPOS | BASS_STREAM_PRESCAN | 0); if (!stream) { BASS_Free(); mumps_close(); error("kunne ikke åpne fet lyd 2.0"); } loading = load_texture("loading.jpg", FALSE); if(loading==-1){ BASS_StreamFree(stream); BASS_Free(); mumps_close(); error("kunne ikke åpne fett bilde"); } glClearColor(0,0,0,0); glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); fullscreen_image(loading); glFlush(); mumps_update(); room = load_object("cylinder01.kro"); if(!room){ BASS_StreamFree(stream); BASS_Free(); mumps_close(); error("kunne ikke åpne fett objekt"); } sphere = load_object("sphere01.kro"); if(!sphere){ BASS_StreamFree(stream); BASS_Free(); mumps_close(); error("kunne ikke åpne fett objekt"); } sphere_copy = copy_object(sphere); bjork_texture = load_texture("bjork.jpg", FALSE); if(bjork_texture==-1){ BASS_StreamFree(stream); BASS_Free(); mumps_close(); error("kunne ikke åpne fett bilde"); } yo_plus = load_texture("yo_plus.jpg", FALSE); if(yo_plus==-1){ BASS_StreamFree(stream); BASS_Free(); mumps_close(); error("kunne ikke åpne fett bilde"); } carlb = load_texture("carlb.jpg", FALSE); if(carlb==-1){ BASS_StreamFree(stream); BASS_Free(); mumps_close(); error("kunne ikke åpne fett bilde"); } veldig_kule = load_texture("veldig_kule.jpg", FALSE); if(veldig_kule==-1){ BASS_StreamFree(stream); BASS_Free(); mumps_close(); error("kunne ikke åpne fett bilde"); } greets = load_texture("greets.jpg", FALSE); if(greets==-1){ BASS_StreamFree(stream); BASS_Free(); mumps_close(); error("kunne ikke åpne fett bilde"); } mothafuckas = load_texture("mothefuckas.jpg", FALSE); if(mothafuckas==-1){ BASS_StreamFree(stream); BASS_Free(); mumps_close(); error("kunne ikke åpne fett bilde"); } rendertarget = init_rtt(512,256,(float)WIDTH/(float)HEIGHT, FALSE, FALSE); fucking_shit = init_rtt(512,256,(float)WIDTH/(float)HEIGHT, FALSE, TRUE); init_blur(256,256); glEnable(GL_NORMALIZE); BASS_Start(); BASS_ChannelPlay(stream, FALSE); do { QWORD pos = BASS_ChannelGetPosition(stream, BASS_POS_BYTE); double time = BASS_ChannelBytes2Seconds(stream, pos); glViewport(0,0,mumps_width,mumps_height); if(time<25.55f){ glClearColor(1,1,1,0); glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(120, ASPECT, 1.f, 500); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glFogi(GL_FOG_MODE, GL_EXP2); glFogfv(GL_FOG_COLOR,black_color); glFogf(GL_FOG_DENSITY, 0.02f); glEnable(GL_FOG); set_camera( vector_make( // pos (float)sin(time*0.1f)*50, (float)sin(time*1.2f*0.1f+1)*50, (float)cos(sin(time*0.1f)-time*0.1f)*50 ), vector_make( // look_at 0, 0, 0 ), 0 ); draw_particles(particles,PARTICLE_COUNT,yo_plus, (float)15); if(time<2){ float alpha = 1.f-time*0.5f; glPushAttrib(GL_ALL_ATTRIB_BITS); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glColor4f(1,1,1, alpha ); glEnable(GL_BLEND); fullscreen_image(loading); glPopAttrib(); } if(time>17.5f){ float alpha = (time-17.5); glPushAttrib(GL_ALL_ATTRIB_BITS); glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT); glBlendFunc( GL_SRC_ALPHA, GL_ONE ); glColor4f(1,1,1, alpha ); glEnable(GL_BLEND); fullscreen_image(carlb); glPopAttrib(); } }else if(time<51.0f){ float flash = 1.f-(time-25.55f); glClearColor(1,1,1,0); glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(90, ASPECT, 1.f, 500); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glDisable(GL_FOG); gluLookAt( sin(time*0.1f)*90,-50,cos(time*0.1f)*90, 0,-30,0, 0,1,0 ); start_rtt(rendertarget); set_light(0, (float)sin(time)*50,0,(float)cos(time)*50,TRUE); set_light(1, (float)sin(time+1)*50,0,(float)cos(time+1)*50,TRUE); glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); glPushMatrix(); glTranslatef(100,0,-100); draw_object(room); glPopMatrix(); glPushMatrix(); glTranslatef(0,-30,0); glScalef(0.7f,0.7f,0.7f); glRotatef(time*15,1,0,1); glRotatef(time*15,1,0,0); glRotatef(time*15.2f,0,1,0); glRotatef(time*15,0,0,1); glRotatef(time*25,1,0,0); glRotatef(time*15.2f,0,1,0); blob_distort(sphere, sphere_copy, vector_make((float)sin(time),time,-time), vector_make( (float)(1+sin(time))*0.1f, (float)(1+sin(time))*0.1f, (float)(1+sin(time))*0.1f ),vector_make(0.3f,0.3f,0.3f) ); draw_object(sphere_copy); glPopMatrix(); end_rtt(rendertarget); i = blur((float)sin(time*0.3f)*0.3f, 0.1f+(1+(float)sin(time*0.1f))*0.2f, 0.2f, FALSE, rendertarget->texture); fullscreen_image(i); glEnable(GL_COLOR_MATERIAL); glColor4f(1,1,1, (1+(float)sin(time*0.5f))*0.3f ); glBlendFunc( GL_SRC_ALPHA, GL_ONE ); glEnable(GL_BLEND); fullscreen_image(bjork_texture); glDisable(GL_BLEND); if(time>38.35f){ flash = 1.f-(time-38.4f); if(time>44.75f){ flash = 1.f-(time-44.75f); } } if(flash<0) flash = 0; superflash(flash); if(time>38.35f){ overlay(veldig_kule, 1); } }else if(time<(60+16.8f)){ float flash = (1.f-(time-51.f)); float flash2 = sin(-(3.1415f/2)+(time-51.f)*(117.5f/60.f)*8); if(flash<0) flash = 0; flash *= flash; flash2 *= (1+flash2)*0.5f; flash2 *= 20; start_rtt(fucking_shit); draw_dilldallscene(room, sphere, sphere_copy,time,flash,flash2); end_rtt(fucking_shit); glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); draw_dilldallscene(room, sphere, sphere_copy,time,flash,flash2); glLoadIdentity(); glEnable(GL_COLOR_MATERIAL); glColor4f(1,1,1, 0.5+(1+(float)sin(time*0.5f))*0.5f ); glBlendFunc( GL_SRC_ALPHA, GL_ONE ); glEnable(GL_BLEND); fullscreen_image_flip(fucking_shit->texture,1); fullscreen_image_flip(fucking_shit->texture,2); fullscreen_image_flip(fucking_shit->texture,3); glDisable(GL_BLEND); fuss(50,time, 1, 1, 0.1f); if(time>(60+3.9f)){ flash=(1.f-(time-(60+3.9f))); overlay(greets, 1); } superflash(flash); }else{ float flash = (1.f-(time-(60+16.8f))); fullscreen_image(mothafuckas); superflash(flash); if(time>(60+23.f)){ float flash = (time-(60+23.f)); superflash2(flash*0.5f); } } glFlush(); mumps_update(); if(time>60+30) PostQuitMessage(0); while(PeekMessage(&message,NULL,0,0,PM_REMOVE)){ TranslateMessage(&message); DispatchMessage(&message); if(message.message == WM_QUIT) break; } }while(message.message!=WM_QUIT && !GetAsyncKeyState(VK_ESCAPE)); BASS_StreamFree(stream); BASS_Free(); mumps_close(); MessageBox(NULL,"Frigi minnet ditt sjøl, taper","In your face",MB_OK); return 0; }
/* Format: * :Chain name POLICY packets bytes * rule */ static int xtables_save_main(int family, const char *progname, int argc, char *argv[]) { const char *tablename = NULL; bool dump = false; struct nft_handle h = { .family = family, }; int c; xtables_globals.program_name = progname; c = xtables_init_all(&xtables_globals, family); if (c < 0) { fprintf(stderr, "%s/%s Failed to initialize xtables\n", xtables_globals.program_name, xtables_globals.program_version); exit(1); } #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS) init_extensions(); init_extensions4(); #endif if (nft_init(&h, xtables_ipv4) < 0) { fprintf(stderr, "%s/%s Failed to initialize nft: %s\n", xtables_globals.program_name, xtables_globals.program_version, strerror(errno)); exit(EXIT_FAILURE); } while ((c = getopt_long(argc, argv, "bcdt:M:46", options, NULL)) != -1) { switch (c) { case 'b': fprintf(stderr, "-b/--binary option is not implemented\n"); break; case 'c': show_counters = true; break; case 't': /* Select specific table. */ tablename = optarg; break; case 'M': xtables_modprobe_program = optarg; break; case 'd': dump = true; break; case '4': h.family = AF_INET; break; case '6': h.family = AF_INET6; xtables_set_nfproto(AF_INET6); break; } } if (optind < argc) { fprintf(stderr, "Unknown arguments found on commandline\n"); exit(1); } if (dump) { do_output(&h, tablename, show_counters); exit(0); } return !do_output(&h, tablename, show_counters); }
/** The cfg_str looks like... * * apikey=jidname@jhostname%jpassword,config=config,host=host * or... * jidname@jhostname%jpassword,config=config,host=host * * Only the apikey is needed, so it can also look like... * * jidname@jhostname%jpassword */ int cproxy_init_agent(char *cfg_str, proxy_behavior behavior, int nthreads) { init_extensions(); if (cfg_str == NULL) { fprintf(stderr, "missing cfg\n"); exit(EXIT_FAILURE); } int cfg_len = strlen(cfg_str); if (cfg_len <= 0) { fprintf(stderr, "empty cfg\n"); exit(EXIT_FAILURE); } char *buff; if (strncmp(cfg_str, "apikey=", 7) == 0) { buff = trimstrdup(cfg_str); } else { buff = calloc(cfg_len + 50, sizeof(char)); if (buff != NULL) { snprintf(buff, cfg_len + 50, "apikey=%s", cfg_str); } buff = trimstr(buff); } char *next = buff; int rv = 0; while (next != NULL) { char *jid = NULL; char *jpw = NULL; char *jpwmem = NULL; char *config = NULL; char *host = NULL; char *cur = trimstr(strsep(&next, ";")); while (cur != NULL) { char *key_val = trimstr(strsep(&cur, ",\r\n")); if (key_val != NULL) { char *key = trimstr(strsep(&key_val, "=")); char *val = trimstr(key_val); bool handled = true; if (key != NULL && val != NULL) { if (wordeq(key, "apikey")) { jid = strsep(&val, "%"); jpw = val; } else if (wordeq(key, "config")) { config = val; } else if (wordeq(key, "host")) { host = val; } else { handled = false; } } else { handled = false; } if (handled == false && key != NULL && key[0] != '#' && key[0] != '\0') { if (settings.verbose > 0) { fprintf(stderr, "unknown configuration key: %s\n", key); } } } } if (jid == NULL || strlen(jid) <= 0) { fprintf(stderr, "missing conflate id\n"); exit(EXIT_FAILURE); } if (jpw == NULL) { // Handle if jid/jpw is in user:password@fqdn format // instead of user@fqdn%password format. // char *colon = strchr(jid, ':'); char *asign = strchr(jid, '@'); if (colon != NULL && asign != NULL && asign > colon) { *asign = '\0'; jpw = jpwmem = strdup(colon + 1); *asign = '@'; do { *colon = *asign; colon++; asign++; } while (*asign != '\0'); *colon = '\0'; } } if (jpw == NULL || strlen(jpw) <= 0) { fprintf(stderr, "missing conflate password\n"); exit(EXIT_FAILURE); } int config_alloc = 0; if (config == NULL) { config_alloc = strlen(jid) + 100; config = calloc(config_alloc, 1); if (config != NULL) { snprintf(config, config_alloc, CONFLATE_DB_PATH "/%s.cfg", jid); } else { fprintf(stderr, "conflate config buf alloc\n"); exit(EXIT_FAILURE); } } if (settings.verbose > 1) { fprintf(stderr, "cproxy_init jid %s\n", jid); } if (cproxy_init_agent_start(jid, jpw, config, host, behavior, nthreads) != NULL) { rv++; } if (config_alloc > 0 && config != NULL) { free(config); } if (jpwmem) { free(jpwmem); } } free(buff); return rv; }