int main(int argc, char** argv) { int ch, profile = 0, strategy = 0, major = 1, minor = 0, revision; GLboolean debug = GL_FALSE, forward = GL_FALSE, list = GL_FALSE; GLint flags, mask; GLFWwindow window; while ((ch = getopt(argc, argv, "dfhlm:n:p:r:")) != -1) { switch (ch) { case 'd': debug = GL_TRUE; break; case 'f': forward = GL_TRUE; break; case 'h': usage(); exit(EXIT_SUCCESS); case 'l': list = GL_TRUE; break; case 'm': major = atoi(optarg); break; case 'n': minor = atoi(optarg); break; case 'p': if (strcasecmp(optarg, PROFILE_NAME_CORE) == 0) profile = GLFW_OPENGL_CORE_PROFILE; else if (strcasecmp(optarg, PROFILE_NAME_COMPAT) == 0) profile = GLFW_OPENGL_COMPAT_PROFILE; else if (strcasecmp(optarg, PROFILE_NAME_ES2) == 0) profile = GLFW_OPENGL_ES2_PROFILE; else { usage(); exit(EXIT_FAILURE); } break; case 'r': if (strcasecmp(optarg, STRATEGY_NAME_NONE) == 0) strategy = GLFW_OPENGL_NO_RESET_NOTIFICATION; else if (strcasecmp(optarg, STRATEGY_NAME_LOSE) == 0) strategy = GLFW_OPENGL_LOSE_CONTEXT_ON_RESET; else { usage(); exit(EXIT_FAILURE); } break; default: usage(); exit(EXIT_FAILURE); } } argc -= optind; argv += optind; glfwSetErrorCallback(error_callback); if (!glfwInit()) { fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); exit(EXIT_FAILURE); } if (major != 1 || minor != 0) { glfwWindowHint(GLFW_OPENGL_VERSION_MAJOR, major); glfwWindowHint(GLFW_OPENGL_VERSION_MINOR, minor); } if (debug) glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); if (forward) glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); if (profile != 0) glfwWindowHint(GLFW_OPENGL_PROFILE, profile); if (strategy) glfwWindowHint(GLFW_OPENGL_ROBUSTNESS, strategy); // We assume here that we stand a better chance of success by leaving all // possible details of pixel format selection to GLFW window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Version", NULL); if (!window) exit(EXIT_FAILURE); glfwMakeContextCurrent(window); // Report GLFW version glfwGetVersion(&major, &minor, &revision); printf("GLFW header version: %u.%u.%u\n", GLFW_VERSION_MAJOR, GLFW_VERSION_MINOR, GLFW_VERSION_REVISION); printf("GLFW library version: %u.%u.%u\n", major, minor, revision); if (major != GLFW_VERSION_MAJOR || minor != GLFW_VERSION_MINOR || revision != GLFW_VERSION_REVISION) { printf("*** WARNING: GLFW version mismatch! ***\n"); } printf("GLFW library version string: \"%s\"\n", glfwGetVersionString()); // Report OpenGL version printf("OpenGL context version string: \"%s\"\n", glGetString(GL_VERSION)); major = glfwGetWindowParam(window, GLFW_OPENGL_VERSION_MAJOR); minor = glfwGetWindowParam(window, GLFW_OPENGL_VERSION_MINOR); revision = glfwGetWindowParam(window, GLFW_OPENGL_REVISION); printf("OpenGL context version parsed by GLFW: %u.%u.%u\n", major, minor, revision); // Report OpenGL context properties if (major >= 3) { glGetIntegerv(GL_CONTEXT_FLAGS, &flags); printf("OpenGL context flags (0x%08x):", flags); if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) printf(" forward-compatible"); if (flags & 0) printf(" debug"); putchar('\n'); printf("OpenGL context flags parsed by GLFW:"); if (glfwGetWindowParam(window, GLFW_OPENGL_FORWARD_COMPAT)) printf(" forward-compatible"); if (glfwGetWindowParam(window, GLFW_OPENGL_DEBUG_CONTEXT)) printf(" debug"); putchar('\n'); } if (major > 3 || (major == 3 && minor >= 2)) { glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask); printf("OpenGL profile mask (0x%08x): %s\n", mask, get_profile_name(mask)); printf("OpenGL profile mask parsed by GLFW: %s\n", get_glfw_profile_name(glfwGetWindowParam(window, GLFW_OPENGL_PROFILE))); } printf("OpenGL context renderer string: \"%s\"\n", glGetString(GL_RENDERER)); printf("OpenGL context vendor string: \"%s\"\n", glGetString(GL_VENDOR)); if (major > 1) { printf("OpenGL context shading language version: \"%s\"\n", glGetString(GL_SHADING_LANGUAGE_VERSION)); } // Report OpenGL extensions if (list) list_extensions(major, minor); glfwTerminate(); exit(EXIT_SUCCESS); }
int main(int argc, char** argv) { int ch, api = 0, profile = 0, strategy = 0, major = 1, minor = 0, revision; GLboolean debug = GL_FALSE, forward = GL_FALSE, list = GL_FALSE; GLint flags, mask; GLFWwindow* window; if (!valid_version()) exit(EXIT_FAILURE); while ((ch = getopt(argc, argv, "a:dfhlm:n:p:r:")) != -1) { switch (ch) { case 'a': if (strcasecmp(optarg, API_OPENGL) == 0) api = GLFW_OPENGL_API; else if (strcasecmp(optarg, API_OPENGL_ES) == 0) api = GLFW_OPENGL_ES_API; else { usage(); exit(EXIT_FAILURE); } case 'd': debug = GL_TRUE; break; case 'f': forward = GL_TRUE; break; case 'h': usage(); exit(EXIT_SUCCESS); case 'l': list = GL_TRUE; break; case 'm': major = atoi(optarg); break; case 'n': minor = atoi(optarg); break; case 'p': if (strcasecmp(optarg, PROFILE_NAME_CORE) == 0) profile = GLFW_OPENGL_CORE_PROFILE; else if (strcasecmp(optarg, PROFILE_NAME_COMPAT) == 0) profile = GLFW_OPENGL_COMPAT_PROFILE; else { usage(); exit(EXIT_FAILURE); } break; case 'r': if (strcasecmp(optarg, STRATEGY_NAME_NONE) == 0) strategy = GLFW_NO_RESET_NOTIFICATION; else if (strcasecmp(optarg, STRATEGY_NAME_LOSE) == 0) strategy = GLFW_LOSE_CONTEXT_ON_RESET; else { usage(); exit(EXIT_FAILURE); } break; default: usage(); exit(EXIT_FAILURE); } } argc -= optind; argv += optind; // Initialize GLFW and create window glfwSetErrorCallback(error_callback, NULL); if (!glfwInit()) exit(EXIT_FAILURE); if (major != 1 || minor != 0) { glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor); } if (api != 0) glfwWindowHint(GLFW_CLIENT_API, api); if (debug) glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); if (forward) glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); if (profile != 0) glfwWindowHint(GLFW_OPENGL_PROFILE, profile); if (strategy) glfwWindowHint(GLFW_CONTEXT_ROBUSTNESS, strategy); glfwWindowHint(GLFW_VISIBLE, GL_FALSE); window = glfwCreateWindow(200, 200, "Version", NULL, NULL); if (!window) { glfwTerminate(); exit(EXIT_FAILURE); } glfwMakeContextCurrent(window); // Report client API version api = glfwGetWindowAttrib(window, GLFW_CLIENT_API); major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR); minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR); revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION); printf("%s context version string: \"%s\"\n", get_client_api_name(api), glGetString(GL_VERSION)); printf("%s context version parsed by GLFW: %u.%u.%u\n", get_client_api_name(api), major, minor, revision); // Report client API context properties if (api == GLFW_OPENGL_API) { if (major >= 3) { glGetIntegerv(GL_CONTEXT_FLAGS, &flags); printf("%s context flags (0x%08x):", get_client_api_name(api), flags); if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) printf(" forward-compatible"); if (flags & GL_CONTEXT_FLAG_DEBUG_BIT) printf(" debug"); if (flags & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB) printf(" robustness"); putchar('\n'); printf("%s context flags parsed by GLFW:", get_client_api_name(api)); if (glfwGetWindowAttrib(window, GLFW_OPENGL_FORWARD_COMPAT)) printf(" forward-compatible"); if (glfwGetWindowAttrib(window, GLFW_OPENGL_DEBUG_CONTEXT)) printf(" debug"); if (glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS) != GLFW_NO_ROBUSTNESS) printf(" robustness"); putchar('\n'); } if (major > 3 || (major == 3 && minor >= 2)) { int profile = glfwGetWindowAttrib(window, GLFW_OPENGL_PROFILE); glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask); printf("%s profile mask (0x%08x): %s\n", get_client_api_name(api), mask, get_profile_name_gl(mask)); printf("%s profile mask parsed by GLFW: %s\n", get_client_api_name(api), get_profile_name_glfw(profile)); } if (glfwExtensionSupported("GL_ARB_robustness")) { int robustness; GLint strategy; glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy); printf("%s robustness strategy (0x%08x): %s\n", get_client_api_name(api), strategy, get_strategy_name_gl(strategy)); robustness = glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS); printf("%s robustness strategy parsed by GLFW: %s\n", get_client_api_name(api), get_strategy_name_glfw(robustness)); } } printf("%s context renderer string: \"%s\"\n", get_client_api_name(api), glGetString(GL_RENDERER)); printf("%s context vendor string: \"%s\"\n", get_client_api_name(api), glGetString(GL_VENDOR)); if (major > 1) { printf("%s context shading language version: \"%s\"\n", get_client_api_name(api), glGetString(GL_SHADING_LANGUAGE_VERSION)); } // Report client API extensions if (list) list_extensions(api, major, minor); glfwTerminate(); exit(EXIT_SUCCESS); }
void main (int argc, char *argv []) { FILE *in, *out; int toprg = TRUE, mult = FALSE, lower = TRUE, stomp = FALSE; int filegiven = FALSE, i, k, casemode = TRUE, colmode = FALSE; char fin [MAXPATH], fout [MAXPATH], inmode [3], outmode [3]; char in_ext [MAXEXT], out_ext [MAXEXT], fext [MAXEXT]; kw_list [0] = keywords; kw_list [1] = KW_NULL; get_prog_name (argv [0]); if (argc == 1) usage (); else { for (i = 1; i < argc; i++) { for (k = 0; k < (int)strlen (argv [i]); k++) argv [i][k] = tolower (argv [i][k]); if (argv [i][0] == '/' || argv [i][0] == '-') { if (! strcmp (argv [i], cmds [TOTXT].command)) toprg = FALSE; else if (! strcmp (argv [i], cmds [TOPRG].command)) toprg = TRUE; else if (! strcmp (argv [i], cmds [MULT].command)) mult = TRUE; else if (! strcmp (argv [i], cmds [NOMULT].command)) mult = FALSE; else if (! (strcmp (argv [i], cmds [HELP].command) && strcmp (argv [i], "/h") && strcmp (argv [i], "/?") && strcmp (argv [i], "-h"))) help (); else if (! strcmp (argv [i], cmds [LIST].command)) list_cmds (); else if (! strcmp (argv [i], cmds [KEYWORDS].command)) list_keywords (); else if (! strcmp (argv [i], cmds [SPECIAL].command)) list_special (); else if (! strcmp (argv [i], cmds [EXTENSIONS].command)) list_extensions (); else if (! strcmp (argv [i], cmds [LOWER].command)) lower = TRUE; else if (! strcmp (argv [i], cmds [UPPER].command)) lower = FALSE; else if (! strcmp (argv [i], cmds [LOWCASE].command)) casemode = FALSE; else if (! strcmp (argv [i], cmds [CASE].command)) casemode = TRUE; else if (! strcmp (argv [i], cmds [COL].command)) colmode = TRUE; else if (! strcmp (argv [i], cmds [NOCOL].command)) colmode = FALSE; else if (! strcmp (argv [i], cmds [STOMP].command)) stomp = TRUE; else if (! strcmp (argv [i], cmds [NOSTOMP].command)) stomp = FALSE; else if (! strcmp (argv [i], cmds [FINCART3].command)) { kw_list [0] = final_cart_3; kw_list [1] = keywords; kw_list [2] = KW_NULL; } else if (! strcmp (argv [i], cmds [GRAPH52].command)) { kw_list [0] = graphics_52; kw_list [1] = keywords; kw_list [2] = KW_NULL; } else if (! strcmp (argv [i], cmds [ASM6510PLUS].command)) { kw_list [0] = asm6510plus; kw_list [1] = keywords; kw_list [2] = KW_NULL; } else if (! strcmp (argv [i], cmds [C64].command)) { kw_list [0] = keywords; kw_list [1] = KW_NULL; } else { fprintf (stderr, "%s: invalid command \"%s\".\n", program, argv [i]); exit (EXITBAD); } } else { filegiven = TRUE; if (toprg) { strcpy (in_ext, TXT_EXT); strcpy (out_ext, PRG_EXT); strcpy (inmode, "rt"); strcpy (outmode, "wb"); } else { strcpy (in_ext, PRG_EXT); strcpy (out_ext, TXT_EXT); strcpy (inmode, "rb"); strcpy (outmode, "wt"); } /* get base name and check if there's an extension */ if (! basename (argv [i], fout, MAXPATH - 1)) { /* nope, no extension specified */ strcpy (fin, fout); strncat (fin, in_ext, MAXPATH - 1); } else { strncpy (fin, argv [i], MAXPATH - 1); extension (fin, fext, MAXEXT - 1); if (! strcmp (fext, out_ext)) { fprintf (stderr, "%s: not expecting \"%s\" as input.\n", program, argv [i]); exit (EXITBAD); } } strncat (fout, out_ext, MAXPATH - 1); if ((in = fopen (fin, inmode)) == NULL) { fprintf (stderr, "%s: Can't open %s for input.\n", program, fin); exit (EXITBAD); } else if (mult) { fprintf (stderr, "processing %s ...\n", fin); process_mult (in, stomp, casemode, colmode); fprintf (stderr, "processing of %s complete.\n", fin); } else { if (! exit_exists (stomp, in, fout)) { if ((out = fopen (fout, outmode)) == NULL) { fprintf (stderr, "%s: Can't open %s for output\n", program, fout); exit (EXITBAD); } else { fprintf (stderr, "%s ==> %s ...", fin, fout); if (toprg) txt2prg (in, out, casemode, colmode); else prg2txt (in, out, fin, lower); fclose (out); fprintf (stderr, " done.\n"); } } fclose (in); } /* end can open input file */ } /* end command line arg check */ } /* end for loop thru args */ } /* end if check for args */ if (! filegiven) usage (); exit (EXITOK); } /* end main */
int dbdelete (MYDBM_FILE dbf, const char *name, struct mandata *info) { datum key, cont; memset (&key, 0, sizeof key); memset (&cont, 0, sizeof cont); /* get entry for info */ debug ("Attempting delete of %s(%s) entry.\n", name, info->ext); MYDBM_SET (key, name_to_key (name)); cont = MYDBM_FETCH (dbf, key); if (!MYDBM_DPTR (cont)) { /* 0 entries */ MYDBM_FREE_DPTR (key); return NO_ENTRY; } else if (*MYDBM_DPTR (cont) != '\t') { /* 1 entry */ MYDBM_DELETE (dbf, key); MYDBM_FREE_DPTR (cont); } else { /* 2+ entries */ char **names, **ext; char *multi_content = NULL; datum multi_key; int refs, i, j; /* Extract all of the extensions associated with this key */ refs = list_extensions (MYDBM_DPTR (cont) + 1, &names, &ext); for (i = 0; i < refs; ++i) if (STREQ (names[i], name) && STREQ (ext[i], info->ext)) break; if (i >= refs) { free (names); free (ext); MYDBM_FREE_DPTR (cont); MYDBM_FREE_DPTR (key); return NO_ENTRY; } multi_key = make_multi_key (names[i], ext[i]); if (!MYDBM_EXISTS (dbf, multi_key)) { error (0, 0, _( "multi key %s does not exist"), MYDBM_DPTR (multi_key)); gripe_corrupt_data (); } MYDBM_DELETE (dbf, multi_key); MYDBM_FREE_DPTR (multi_key); /* refs *may* be 1 if all manual pages with this name have been deleted. In this case, we'll have to remove the key too */ if (refs == 1) { free (names); free (ext); MYDBM_FREE_DPTR (cont); MYDBM_DELETE (dbf, key); MYDBM_FREE_DPTR (key); return 0; } /* create our new multi content */ for (j = 0; j < refs; ++j) if (i != j) multi_content = appendstr (multi_content, "\t", names[j], "\t", ext[j], NULL); MYDBM_FREE_DPTR (cont); /* if refs = 2 do something else. Doesn't really matter as the gdbm db file does not shrink any after a deletion anyway */ MYDBM_SET (cont, multi_content); if (MYDBM_REPLACE (dbf, key, cont)) gripe_replace_key (MYDBM_DPTR (key)); free (names); free (ext); } MYDBM_FREE_DPTR (key); return 0; }
int main(int argc, char** argv) { int ch, profile = 0, major = 1, minor = 1, revision; GLboolean debug = GL_FALSE, forward = GL_FALSE, list = GL_FALSE; GLint flags, mask; while ((ch = getopt(argc, argv, "dfhlm:n:p:")) != -1) { switch (ch) { case 'd': debug = GL_TRUE; break; case 'f': forward = GL_TRUE; break; case 'h': usage(); exit(0); case 'l': list = GL_TRUE; break; case 'm': major = atoi(optarg); break; case 'n': minor = atoi(optarg); break; case 'p': if (strcasecmp(optarg, "core") == 0) profile = GLFW_OPENGL_CORE_PROFILE; else if (strcasecmp(optarg, "compat") == 0) profile = GLFW_OPENGL_COMPAT_PROFILE; else { usage(); exit(1); } break; default: usage(); exit(1); } } argc -= optind; argv += optind; if (!glfwInit()) { fprintf(stderr, "Failed to initialize GLFW\n"); exit(1); } if (major != 1 || minor != 1) { glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, major); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, minor); } if (debug) glfwOpenWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); if (forward) glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); if (profile != 0) glfwOpenWindowHint(GLFW_OPENGL_PROFILE, profile); // We assume here that we stand a better chance of success by leaving all // possible details of pixel format selection to GLFW if (!glfwOpenWindow(0, 0, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) { glfwTerminate(); fprintf(stderr, "Failed to open GLFW window\n"); exit(1); } // Report GLFW version glfwGetVersion(&major, &minor, &revision); printf("GLFW header version: %u.%u.%u\n", GLFW_VERSION_MAJOR, GLFW_VERSION_MINOR, GLFW_VERSION_REVISION); printf("GLFW library version: %u.%u.%u\n", major, minor, revision); if (major != GLFW_VERSION_MAJOR || minor != GLFW_VERSION_MINOR || revision != GLFW_VERSION_REVISION) printf("*** WARNING: GLFW version mismatch! ***\n"); // Report OpenGL version printf("OpenGL context version string: \"%s\"\n", glGetString(GL_VERSION)); glfwGetGLVersion(&major, &minor, &revision); printf("OpenGL context version parsed by GLFW: %u.%u.%u\n", major, minor, revision); // Report OpenGL context properties if (major >= 3) { glGetIntegerv(GL_CONTEXT_FLAGS, &flags); printf("OpenGL context flags:"); if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) puts(" forward-compatible"); else puts(" none"); } if (major > 3 || (major == 3 && minor >= 2)) { glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask); printf("OpenGL profile mask: 0x%08x (%s)\n", mask, get_profile_name(mask)); } printf("OpenGL context renderer string: \"%s\"\n", glGetString(GL_RENDERER)); printf("OpenGL context vendor string: \"%s\"\n", glGetString(GL_VENDOR)); if (major > 1) { printf("OpenGL context shading language version: \"%s\"\n", glGetString(GL_SHADING_LANGUAGE_VERSION)); } // Report OpenGL extensions if (list) list_extensions(major, minor); glfwTerminate(); exit(0); }