gboolean is_po (const gchar *f) { if (check_ext (f, ".pot") || check_ext (f, ".po")) return TRUE; else return FALSE; }
gboolean is_pascal (const gchar *f) { if (check_ext (f, ".pas") || check_ext (f, ".dpr") || check_ext (f, ".pp") ) return TRUE; return FALSE; }
gboolean is_markup (const gchar *f) { if ((check_ext (f, ".html")) || (check_ext (f, ".htm")) || (check_ext (f, ".shtml")) || (check_ext (f, ".xml")) || (check_ext (f, ".xhtml")) ) return TRUE; return FALSE; }
void iload(void) { nialptr x = apop(); int n = ngetname(x, gcharbuf); freeup(x); if (n == 0) buildfault("invalid file name"); else { FILE *f1; check_ext(gcharbuf, ".nws",FORCE_EXTENSION); f1 = openfile(gcharbuf, 'r', 'b'); if (f1 == OPENFAILED) { buildfault("cannot open nws file"); return; } wsfileport = f1; /* jump to do1command */ longjmp(loadsave_env, NC_WS_LOAD); } #ifdef DEBUG if (debug) { memchk(); nprintf(OF_DEBUG, "after iload memchk\n"); } #endif }
gboolean is_php (const gchar *f) { if (check_ext (f, ".php")) return TRUE; else return FALSE; }
int check_shader_ext() { if (check_ext("ARB_shading_language_100") && check_ext("ARB_vertex_shader") && check_ext("ARB_shader_objects") && check_ext("ARB_fragment_shader") ) { //printf("GL: ready for glsl\n"); return 0; } else { printf("GL: not ready for glsl\n"); exit(0); } }
int spcf_find_file_type(char *filename, int *ftp, int *ftsubp) { int i; int found; if(*ftp >= 0 && *ftsubp >= 0) return 1; found = 0; for(i = 0; extensions[i].ext != NULL; i++) if((*ftp < 0 || *ftp == extensions[i].type) && (*ftsubp < 0 || *ftsubp == extensions[i].subtype) && check_ext(filename, extensions[i].ext)) { found = 1; *ftp = extensions[i].type; *ftsubp = extensions[i].subtype; break; } if(!found) for(i = 0; extensions[i].ext != NULL; i++) if((*ftp < 0 || *ftp == extensions[i].type) && (*ftsubp < 0 || *ftsubp == extensions[i].subtype) && try_extension(filename, extensions[i].ext)) { found = 1; *ftp = extensions[i].type; *ftsubp = extensions[i].subtype; break; } return found; }
gboolean is_rtf (const gchar *filename) { if (check_ext (filename, ".rtf")) return TRUE; return FALSE; }
int check_multitex_ext() { if(check_ext("ARB_multitexture")) { return 1; } return 0; }
int check_vbo_ext() { if( check_ext("ARB_vertex_buffer_object")) { return 1; } else return 0; }
int check_fbo_ext() { if( check_ext("EXT_framebuffer_object") ) { return 1; } return 0; }
void iloaddefs(void) { nialptr nm, x = apop(); int mode; /* get the file name as a Nial array */ if (atomic(x) || kind(x) == chartype) nm = x; else if (kind(x) == atype) nm = fetch_array(x, 0); else { buildfault("invalid file name"); freeup(x); return; } mode = 0; /* default to silent mode */ if (kind(x) == atype && tally(x) == 2) { /* argument has a mode filed, select it */ nialptr it = fetch_array(x, 1); if (kind(it) == inttype) mode = intval(it); if (kind(it) == booltype) mode = boolval(it); } /* try to put filename into gcharbuf */ if (!ngetname(nm, gcharbuf)) { buildfault("invalid file name"); freeup(x); } else { /* check the extension as .ndf */ check_ext(gcharbuf, ".ndf",NOFORCE_EXTENSION); freeup(x); /* do freeup here so file name doesn't show in iusedspace */ /* load the definition file */ if (loaddefs(true, gcharbuf, mode)) { apush(Nullexpr); } else buildfault(errmsgptr); /* this is safe since call is from iloaddefs */ } #ifdef DEBUG memchk(); #endif }
static EGLBoolean egl_init(EGLmanager *eglman) { EGLint pbuffer_attrib[] = { EGL_WIDTH, 128, EGL_HEIGHT, 128, EGL_NONE }; // Check extension support if (check_ext(eglman) != EGL_TRUE) { return EGL_FALSE; } // Create GL context eglBindAPI(EGL_OPENGL_ES_API); eglman->es_ctx = eglCreateContext(eglman->dpy, eglman->conf, NULL, NULL); if (eglman->es_ctx == EGL_NO_CONTEXT || eglGetError() != EGL_SUCCESS) { return EGL_FALSE; } // Create VG context eglBindAPI(EGL_OPENVG_API); eglman->vg_ctx = eglCreateContext(eglman->dpy, eglman->conf, NULL, NULL); if (eglman->vg_ctx == EGL_NO_CONTEXT || eglGetError() != EGL_SUCCESS) { return EGL_FALSE; } // Create window surface eglman->win_surface = eglCreateWindowSurface(eglman->dpy, eglman->conf, eglman->xwin, NULL); if (eglman->win_surface == EGL_NO_SURFACE || eglGetError() != EGL_SUCCESS) { return EGL_FALSE; } // Create pbuffer surface eglman->pbuf_surface = eglCreatePbufferSurface(eglman->dpy, eglman->conf, pbuffer_attrib); if (eglman->pbuf_surface == EGL_NO_SURFACE || eglGetError() != EGL_SUCCESS) { return EGL_FALSE; } return EGL_TRUE; }
struct song * do_read_song (char *s, int type) { struct song *song; struct compression *comp; FILE *fp; char buf[200]; PRINT (("Loading %s... ", s)); fflush (stdout); /* Check if the filename matches any compression extentions */ for (comp = comp_table; comp->extension != NULL; comp++) { if (check_ext (comp->extension, s)) { sprintf (buf, comp->decomp_cmd, s); fp = popen (buf, "rb"); if (fp == NULL) { fprintf (stderr, "Unable to open compressed file %s\n", s); return NULL; } song = read_song (fp, type, transpose); /* now flush pipe, needed for compressed files that fail */ while (fgetc(fp) != EOF); pclose (fp); break; } } /* No compression extentions matched, so just load it straight */ if (!comp->extension) { fp = fopen (s, "rb"); if (fp == NULL) { fprintf (stderr, "Unable to open tune file %s\n", s); return NULL; } song = read_song (fp, type, transpose); fclose (fp); } if (song) PRINT (("Ok!\n")); return song; }
gboolean is_css (const gchar *filename) { if (! filename) return FALSE; gchar *f = g_ascii_strdown (filename, -1); if (check_ext (f, ".css")) { g_free (f); return TRUE; } g_free (f); return FALSE; }
gboolean is_c (const gchar *f) { if (check_ext (f, ".c") || check_ext (f, ".h") || check_ext (f, ".cpp") || check_ext (f, ".cxx") || check_ext (f, ".cc") || check_ext (f, ".cp") || check_ext (f, ".c++") ) return TRUE; return FALSE; }
gboolean is_image (const gchar *filename) { if (! filename) return FALSE; if (check_ext (filename, ".png") || check_ext (filename, ".gif") || check_ext (filename, ".jpg") || check_ext (filename, ".jpeg")|| check_ext (filename, ".wbmp")|| check_ext (filename, ".bmp")|| check_ext (filename, ".mng") ) return TRUE; return FALSE; }
void isave(void) { nialptr x = apop(); int n = ngetname(x, gcharbuf); freeup(x); /* not needed */ if (n == 0) buildfault("invalid file name"); else { FILE *f1; check_ext(gcharbuf, ".nws",FORCE_EXTENSION); f1 = openfile(gcharbuf, 'w', 'b'); if (f1 == OPENFAILED) { buildfault("cannot open nws file"); return; } wsfileport = f1; /* jump to do1command */ longjmp(loadsave_env, NC_WS_SAVE); } }
int main(int argc, char** argv) { unsigned char dx = 0; unsigned char dy = 0; const char* arg_format = NULL; const char* arg_src = NULL; const char* arg_dst = NULL; if(argc == 6) { dx = (unsigned char) strtoul(argv[2], (char**) NULL, 10); dy = (unsigned char) strtoul(argv[3], (char**) NULL, 10); arg_format = argv[1]; arg_src = argv[4]; arg_dst = argv[5]; } else if(argc == 4) { arg_format = argv[1]; arg_src = argv[2]; arg_dst = argv[3]; if(check_ext(arg_src, "mgm")) { usage(argv[0]); return EXIT_FAILURE; } } else { usage(argv[0]); return EXIT_FAILURE; } // parse format int type; int format; if(strcmp(arg_format, "RGBA-8888") == 0) { type = TEXGZ_UNSIGNED_BYTE; format = TEXGZ_RGBA; } else if(strcmp(arg_format, "BGRA-8888") == 0) { type = TEXGZ_UNSIGNED_BYTE; format = TEXGZ_BGRA; } else if(strcmp(arg_format, "RGB-565") == 0) { type = TEXGZ_UNSIGNED_SHORT_5_6_5; format = TEXGZ_RGB; } else if(strcmp(arg_format, "RGBA-4444") == 0) { type = TEXGZ_UNSIGNED_SHORT_4_4_4_4; format = TEXGZ_RGBA; } else if(strcmp(arg_format, "RGB-888") == 0) { type = TEXGZ_UNSIGNED_BYTE; format = TEXGZ_RGB; } else if(strcmp(arg_format, "RGBA-5551") == 0) { type = TEXGZ_UNSIGNED_SHORT_5_5_5_1; format = TEXGZ_RGBA; } else if(strcmp(arg_format, "LUMINANCE") == 0) { type = TEXGZ_UNSIGNED_BYTE; format = TEXGZ_LUMINANCE; } else if(strcmp(arg_format, "LUMINANCE-F") == 0) { type = TEXGZ_FLOAT; format = TEXGZ_LUMINANCE; } else { LOGE("invalid format=%s", arg_format); return EXIT_FAILURE; } // import src texgz_tex_t* tex = NULL; if(check_ext(arg_src, "texgz")) { tex = texgz_tex_import(arg_src); } else if(check_ext(arg_src, "jpg")) { tex = texgz_jpeg_import(arg_src); } else if(check_ext(arg_src, "png")) { tex = texgz_png_import(arg_src); } else if(check_ext(arg_src, "mgm")) { tex = texgz_mgm_import(arg_src, dx, dy); } else { LOGE("invalid src=%s", arg_src); return EXIT_FAILURE; } if(tex == NULL) { return EXIT_FAILURE; } // convert to format if(texgz_tex_convert(tex, type, format) == 0) { goto fail_convert; } // export dst int ret = 0; if(check_ext(arg_dst, "texgz")) { ret = texgz_tex_export(tex, arg_dst); } else if(check_ext(arg_dst, "jpg")) { ret = texgz_jpeg_export(tex, arg_dst); } else if(check_ext(arg_dst, "png")) { ret = texgz_png_export(tex, arg_dst); } else { LOGE("invalid dst=%s", arg_dst); goto fail_dst; } if(ret == 0) { goto fail_export; } texgz_tex_delete(&tex); // success return EXIT_SUCCESS; // failure fail_export: fail_dst: fail_convert: texgz_tex_delete(&tex); return EXIT_FAILURE; }
gchar* get_hl_name (gchar *file_name) { gchar *b; if (check_ext (file_name, ".html") || check_ext (file_name, ".htm")) return g_strdup (HL_MARKUP); if (check_ext (file_name, ".xml")) return g_strdup (HL_XML); if (check_ext (file_name, ".js")) return g_strdup (HL_JAVASCRIPT); if (check_ext (file_name, ".c") || check_ext (file_name, ".h")) return g_strdup (HL_C); if (check_ext (file_name, ".jar") || check_ext (file_name, ".jav") || check_ext (file_name, ".java") || check_ext (file_name, ".class")) return g_strdup (HL_JAVA); if (check_ext (file_name, ".py")) return g_strdup (HL_PYTHON); if (check_ext (file_name, ".rb")) return g_strdup (HL_RUBY); if (check_ext (file_name, ".php")) return g_strdup (HL_PHP); if (check_ext (file_name, ".cpp")) return g_strdup (HL_CPP); if (check_ext (file_name, ".css")) return g_strdup (HL_CSS); if (check_ext (file_name, ".pl")) return g_strdup (HL_PERL); if (check_ext (file_name, ".sh")) return g_strdup (HL_BASH); if (is_po (file_name)) return g_strdup (HL_PO); if (confile.do_det_scripts_by_content) { b = str_file_read (file_name); if (b) { if (strstr (b, "#!/bin/bash") || strstr (b, "#!/bin/sh")) { g_free (b); return g_strdup (HL_BASH); } if (strstr (b, "#!/bin/perl") || strstr (b, "#!/usr/bin/perl")) { g_free (b); return g_strdup (HL_PERL); } g_free (b); } } return g_strdup (HL_NONE); }
int check_recttex_ext() { return check_ext("ARB_texture_rectangle"); }
int check_pbo_ext() { return check_ext("ARB_pixel_buffer_object"); }
int check_cubemap_ext() { return check_ext("ARB_texture_cube_map"); }
int check_texlodbias_ext() { return check_ext("EXT_texture_lod_bias"); }
int check_comptex_ext() { return check_ext("ARB_texture_compression"); }
//MRT: Multiple Render Target int check_MRT_ext() { return check_ext("ARB_draw_buffers"); }
char *FileReq(char *dir, const char *ext, char *result) { static char *cwd = NULL; static s32 cursor_pos = 1; static s32 first_visible; static s32 num_items = 0; DIR *dirstream; struct dirent *direntry; static s32 row; char tmp_string[41]; u32 keys; if (dir) ChDir(dir); cwd = GetCwd(); for (;;) { keys = key_read(); video_clear(); if (keys & KEY_SELECT) { FREE_LIST(); key_reset(); return NULL; } if (num_items == 0) { dirstream = opendir(cwd); if (dirstream == NULL) { port_printf(0, 20, "error opening directory"); return NULL; } // read directory entries while ((direntry = readdir(dirstream))) { s32 type = get_entry_type(cwd, direntry->d_name); // this is a very ugly way of only accepting a certain extension if ((type == 0 && strcmp(direntry->d_name, ".")) || check_ext(direntry->d_name) || (ext && (strlen(direntry->d_name) > 4 &&0 == strncasecmp(direntry->d_name + (strlen(direntry->d_name) - strlen(ext)), ext, strlen(ext))))) { // Hide ".." if at Unix root dir. Don't display Unix hidden files (.file). if ((!strcmp(direntry->d_name, "..") && strcmp(cwd, "/")) || direntry->d_name[0] != '.') { filereq_dir_items[num_items].name = (char *)malloc(strlen(direntry->d_name) + 1); strcpy(filereq_dir_items[num_items].name, direntry->d_name); filereq_dir_items[num_items].type = type; num_items++; if (num_items > 1024) break; } } } closedir(dirstream); sort_dir(filereq_dir_items, num_items); cursor_pos = 0; first_visible = 0; } // display current directory int len = strlen(cwd); if (len > 40) { strcpy(tmp_string, ".."); strcat(tmp_string, cwd + len - 38); port_printf(0, MENU_Y, tmp_string); } else port_printf(0, MENU_Y, cwd); if (keys & KEY_DOWN) { //down if (++cursor_pos >= num_items) { cursor_pos = 0; first_visible = 0; } if ((cursor_pos - first_visible) >= MENU_HEIGHT) first_visible++; } else if (keys & KEY_UP) { // up if (--cursor_pos < 0) { cursor_pos = num_items - 1; first_visible = cursor_pos - MENU_HEIGHT + 1; if (first_visible < 0) first_visible = 0; } if (cursor_pos < first_visible) first_visible--; } else if (keys & KEY_LEFT) { //left if (cursor_pos >= 10) cursor_pos -= 10; else cursor_pos = 0; if (cursor_pos < first_visible) first_visible = cursor_pos; } else if (keys & KEY_RIGHT) { //right if (cursor_pos < (num_items - 11)) cursor_pos += 10; else cursor_pos = num_items - 1; if ((cursor_pos - first_visible) >= MENU_HEIGHT) first_visible = cursor_pos - (MENU_HEIGHT - 1); } else if (keys & KEY_A) { // button 1 // directory selected if (filereq_dir_items[cursor_pos].type == 0) { strcat(cwd, "/"); strcat(cwd, filereq_dir_items[cursor_pos].name); ChDir(cwd); cwd = GetCwd(); FREE_LIST(); key_reset(); } else { sprintf(result, "%s/%s", cwd, filereq_dir_items[cursor_pos].name); if (dir) strcpy(dir, cwd); video_clear(); port_printf(16 * 8, 120, "LOADING"); video_flip(); FREE_LIST(); key_reset(); return result; } } else if (keys & KEY_B) { cursor_pos = 0; first_visible = 0; key_reset(); } // display directory contents row = 0; while (row < num_items && row < MENU_HEIGHT) { if (row == (cursor_pos - first_visible)) { // draw cursor port_printf(MENU_X + 16, MENU_LS + (10 * row), "-->"); } if (filereq_dir_items[row + first_visible].type == 0) port_printf(MENU_X, MENU_LS + (10 * row), "DIR"); int len = strlen(filereq_dir_items[row + first_visible].name); if (len > 32) { snprintf(tmp_string, 16, "%s", filereq_dir_items[row + first_visible].name); strcat(tmp_string, ".."); strcat(tmp_string, &filereq_dir_items[row + first_visible].name[len - 15]); } else snprintf(tmp_string, 33, "%s", filereq_dir_items[row + first_visible].name); port_printf(MENU_X + (8 * 5), MENU_LS + (10 * row), tmp_string); row++; } while (row < MENU_HEIGHT) row++; video_flip(); timer_delay(75); if (keys & (KEY_A | KEY_B | KEY_X | KEY_Y | KEY_L | KEY_R | KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN)) timer_delay(50); } return NULL; }
void parse_arg(int argc, const char** argv, const char*& input, output_list& outputs, size_t& optimize, bool& bench, bool& verbose, Mode& mode, InputFileType& inputType) { int state = 0; for (int i = 1; i < argc; ++i) { std::string opt(argv[i]); if (opt == "-h" or opt == "--help") { mode = helpMode; break; } if (state == 0) { if (opt == "-o" or opt == "--optimize") { ++i; if (i == argc) { std::cout << opt << " needs optimize level (0-3)." << std::endl; mode = helpMode; break; } std::string level(argv[i]); if (level == "0") { optimize = 0; } else if (level == "1") { optimize = 1; } else if (level == "2") { optimize = 2; } else if (level == "3") { optimize = 3; } else { std::cout << " Optimization level should be 0-3, but was " << level << "." << std::endl; mode = helpMode; break; } } else if (opt == "-b" or opt == "--benchmark") { bench = true; } else if (opt == "-v" or opt == "--verbose") { verbose = true; } else if (check_ext(opt, ".png")) { input = argv[i]; inputType = PNGFile; state = 1; } else if (check_ext(opt, ".jpg") or check_ext(opt, ".jpeg")) { input = argv[i]; inputType = JPEGFile; state = 1; } else { std::cout << "Unknown Parameter: " << opt << std::endl; mode = helpMode; break; } } else if (state == 1) { if ((opt == "-16a") or (opt == "-p16a") or (opt == "-16") or (opt == "-p16")) { i++; if (i == argc) { std::cout << opt << " needs file path" << std::endl; mode = helpMode; break; } std::string path(argv[i]); if (check_ext(path, ".png")) { if (opt == "-16a" or opt == "-16") { outputs.push_back(output_type(AlphaPNGFile, path)); } else { outputs.push_back(output_type(PreviewAlphaPNGFile, path)); } } else { std::cout << opt << " file should be .png " << path << std::endl; mode = helpMode; break; } } else if ((opt == "-16m") or (opt == "-p16m")) { i++; if (i == argc) { std::cout << opt << " needs file path" << std::endl; mode = helpMode; break; } std::string path(argv[i]); if (check_ext(path, ".png")) { if (opt == "-16m") { outputs.push_back(output_type(MaskPNGFile, path)); } else { outputs.push_back(output_type(PreviewMaskPNGFile, path)); } } else { std::cout << opt << " file should be .png " << path << std::endl; mode = helpMode; break; } } else if ((opt == "-16i") or (opt == "-p16i")) { i++; if (i == argc) { std::cout << opt << " needs file path" << std::endl; mode = helpMode; break; } std::string path(argv[i]); if (check_ext(path, ".png")) { if (opt == "-16i") { outputs.push_back(output_type(IndexedReducedColorPNGFile, path)); } else { outputs.push_back(output_type(PreviewIndexedReducedColorPNGFile, path)); } } else { std::cout << opt << " file should be .png " << path << std::endl; mode = helpMode; break; } } else if (opt == "-32") { i++; if (i == argc) { std::cout << "-32 needs file path" << std::endl; mode = helpMode; break; } std::string path(argv[i]); if (check_ext(path, ".png")) { outputs.push_back(output_type(FullColorPNGFile, path)); } else { std::cout << "-32 file should be .png " << path << std::endl; mode = helpMode; break; } } else if (opt == "-32i") { i++; if (i == argc) { std::cout << "-32i needs file path" << std::endl; mode = helpMode; break; } std::string path(argv[i]); if (check_ext(path, ".png")) { outputs.push_back(output_type(IndexedColorPNGFile, path)); } else { std::cout << "-32i file should be .png " << path << std::endl; mode = helpMode; break; } } else { std::cout << "Unknown Parameter: " << opt << std::endl; mode = helpMode; break; } } } }