/* Scan the command line, extract arguments and init variables */ int scan_cmdline(int argc, char **argv) { int cnt; char *p; char *q; char msg[80]; for(cnt=1; cnt<argc; cnt++) { p=argv[cnt]; if(*p=='-' ) { // an option p++; } else { // a ROM to load g_free(params.rom_file); params.rom_file = g_strdup(p); } if(strstr (msg, "rom_file=" )) { q=msg+9; g_free(params.rom_file); params.rom_file = g_strdup(p); } if(strstr (msg, "sav_file=" )) { q=msg+9; g_free(params.sav_file); params.sav_file = g_strdup(p); } if(strexact(msg, "-help" )) help(); if(strexact(msg, "-version" )) { version(); exit(0); } } return 0; }
/* Scan the command line, extract arguments and init variables */ int scan_cmdline(int argc, char **argv) { int cnt; char *p; char *q; char msg[80]; for(cnt=1; cnt<argc; cnt++) { p=argv[cnt]; if(*p=='-' ) { // an option p++; } else { // a ROM to load g_free((options.params)->rom_file); (options.params)->rom_file = g_strdup(p); } if(strstr (msg, "rom_file=" )) { q=msg+9; g_free((options.params)->rom_file); (options.params)->rom_file = g_strdup(p); } if(strstr (msg, "ram_file=" )) { q=msg+9; g_free((options.params)->ram_file); (options.params)->ram_file = g_strdup(p); } if(strstr (msg, "gray_planes=")) (options.params)->n_grayplanes = (int) atol(&msg[12]); if(strstr (msg, "tick_rate=" )) (options.params)->tick_rate = (int) atol(&msg[10]); if(strstr (msg, "cycle_rate=" )) (options.params)->cycle_rate = (int) atol(&msg[11]); if(strstr (msg, "sync_one=" )) (options.params)->sync_one = (int) atol(&msg[9]); if(strstr (msg, "background=" )) (options.params)->background = (int) atol(&msg[11]); if(strstr (msg, "link=" )) { q=msg+5; if(!strcmp(q, "par")) (options.link_cable)->link_type = LINK_PAR; if(!strcmp(q, "ser")) (options.link_cable)->link_type = LINK_SER; if(!strcmp(q, "tgl")) (options.link_cable)->link_type = LINK_TGL; if(!strcmp(q, "avr")) (options.link_cable)->link_type = LINK_AVR; if(!strcmp(q, "tie")) (options.link_cable)->link_type = LINK_TIE; if(!strcmp(q, "vti")) (options.link_cable)->link_type = LINK_VTI; if(!strcmp(q, "tpu")) (options.link_cable)->link_type = LINK_TPU; if(!strcmp(q, "ugl")) (options.link_cable)->link_type = LINK_UGL; if(!strcmp(q, "vtl")) (options.link_cable)->link_type = LINK_VTL; } if(strstr (msg, "dev_port=" )) strcpy((options.link_cable)->device, msg+9); if(strstr (msg, "adr_port=" )) (options.link_cable)->io_addr = (int) strtol(msg+9, &q, 16); if(strstr (msg, "timeout=" )) (options.link_cable)->timeout = (int) atol(&msg[8]); if(strstr (msg, "delay=" )) (options.link_cable)->delay = (int) atol(&msg[6]); if(strstr (msg, "code_lines=")) options.code_lines = (int) atol(&msg[11]); if(strstr (msg, "stack_lines=")) options.stack_lines = (int) atol(&msg[12]); if(strstr (msg, "mem_lines=")) options.mem_lines = (int) atol(&msg[10]); if(strexact(msg, "-help" )) help(); if(strexact(msg, "-version" )) { version(); exit(0); } } return 0; }
/* Scan the command line, extract arguments and init variables */ int scan_cmdline(int argc, char **argv) { int cnt; char *p; char msg[80]; int import = 0; char *rom = NULL; char *tib = NULL; char *sav = NULL; char *fn = NULL; //for(cnt = 0; cnt < argc; cnt++) // fprintf(stdout, "%i: [%s]\n", cnt, argv[cnt]); /* Parses list of arguments */ for(cnt=1; cnt<argc; cnt++) { p = argv[cnt]; #ifdef __WIN32__ if(!stricmp(p, "/RegServer") || !stricmp(p, "-RegServer") || !stricmp(p, "--RegServer")) { char *p; ITypeLib *tlb; char szModule[512]; wchar_t tlbname[512]; HMODULE hModule = GetModuleHandle(NULL); DWORD dwResult = GetModuleFileName(hModule, szModule, sizeof(szModule)); if (!dwResult) exit(1); p = szModule + strlen(szModule) - 4; if (stricmp(p,".exe")) exit(1); strcpy(++p,"tlb"); mbstowcs(tlbname, szModule, strlen(szModule)+1); if (RegisterServer(&CLSID_TiEmuOLE, "TiEmu OLE Interface", "TiEmu.TiEmuOLE", "TiEmu.TiEmuOLE.1", NULL) || LoadTypeLib(tlbname, &tlb)) exit(1); else { if (RegisterTypeLib(tlb, tlbname, NULL)) { tlb->lpVtbl->Release(tlb); exit(1); } else { tlb->lpVtbl->Release(tlb); fprintf(stdout, "TiEmu OLE Interface successfully registered."); exit(0); } } } if(!stricmp(p, "/UnregServer") || !stricmp(p, "-UnregServer") || !stricmp(p, "--UnregServer")) { if (UnregisterServer(&CLSID_TiEmuOLE, "TiEmu.TiEmuOLE", "TiEmu.TiEmuOLE.1") || UnRegisterTypeLib(&LIBID_TiEmuOLELib, 1, 0, 0, SYS_WIN32)) exit(1); else { fprintf(stdout, "TiEmu OLE Interface successfully unregistered."); exit(0); } } if(!stricmp(p, "/Embedding") || !stricmp(p, "-Embedding") || !stricmp(p, "--Embedding")) { // VB runs it with this option. continue; } #endif if(*p == '-') { // a long option (like --help) p++; } else { fn = g_strdup(p); // a filename //g_free(params.rom_file); //params.rom_file = g_strdup(p); } strcpy(msg, p); if(strexact(msg, "-import")) import = !0; if(strstr(msg, "rom=")) rom = g_strdup(msg + 4); if(strstr(msg, "tib=")) tib = g_strdup(msg + 4); if(strstr(msg, "sav=")) sav = g_strdup(msg + 4); if(strstr(msg, "send=")) file_to_send = g_strdup(msg + 5); if(strexact(msg, "-help") || strexact(msg, "h")) help(); if(strexact(msg, "-version") || strexact(msg, "v")) exit(0); } /* */ if(fn && ti68k_is_a_rom_file(fn)) rom = fn; else if(fn && ti68k_is_a_tib_file(fn)) tib = fn; else if(fn && ti68k_is_a_sav_file(fn)) sav = fn; /* And process them */ if(rom && ti68k_is_a_rom_file(rom)) { gchar *dstname; int err = ti68k_convert_rom_to_image(rom, inst_paths.img_dir, &dstname); if(err) { tiemu_err(err, NULL); exit(-1); } if(import) exit(0); g_free(params.rom_file); params.rom_file = dstname; g_free(params.sav_file); params.sav_file = g_strdup(""); } if(tib && ti68k_is_a_tib_file(tib)) { gchar *dstname; int err = ti68k_convert_tib_to_image(tib, inst_paths.img_dir, &dstname, -1); if(err) { tiemu_err(err, NULL); exit(-1); } if(import) exit(0); g_free(params.rom_file); params.rom_file = dstname; g_free(params.sav_file); params.sav_file = g_strdup(""); } if(sav && !fn) // for compatibility { g_free(params.sav_file); params.sav_file = g_strdup(sav); } if(sav && ti68k_is_a_sav_file(sav) && fn) { gchar *rf, *tf; ti68k_state_parse(sav, &rf, &tf); if(!ti68k_is_a_img_file(rf)) return 0; g_free(params.rom_file); params.rom_file = rf; g_free(params.tib_file); params.tib_file = tf; g_free(params.sav_file); params.sav_file = g_strdup(sav); } return 0; }
/* Scan the command line, extract arguments and init variables */ int scan_cmdline(int argc, char **argv) { int cnt; char *p; char *q; char msg[80]; gchar *dstname; int import = 0; for(cnt=1; cnt<argc; cnt++) { p = argv[cnt]; if(*p == '-' ) { // a long option (like --help) p++; } else { // an image to load g_free(params.rom_file); params.rom_file = g_strdup(p); } strcpy(msg, p); if(strexact(msg, "-import")) import = !0; if(strstr(msg, "rom=") || strstr(msg, "tib=")) { q=msg+4; if(ti68k_is_a_rom_file(q)) { int err = ti68k_convert_rom_to_image(q, inst_paths.img_dir, &dstname); if(err) { tiemu_error(err, NULL); exit(-1); } if(import) exit(0); g_free(params.rom_file); params.rom_file = dstname; g_free(params.sav_file); params.sav_file = g_strdup(""); } else if(ti68k_is_a_tib_file(q)) { int err = ti68k_convert_tib_to_image(q, inst_paths.img_dir, &dstname); if(err) { tiemu_error(err, NULL); exit(-1); } if(import) exit(0); g_free(params.rom_file); params.rom_file = dstname; g_free(params.sav_file); params.sav_file = g_strdup(""); } else exit(-1); } if(strstr(msg, "sav=")) { q=msg+4; g_free(params.sav_file); params.sav_file = g_strdup(p); } if(strexact(msg, "-help") || strexact(msg, "h")) help(); if(strexact(msg, "-version") || strexact(msg, "v")) { //version(); exit(0); } } return 0; }
int main (int argc, char *argv[]) { int cnt; const char *p; char arg[128]; #ifdef __WIN32__ HMODULE hModule; char *sBuffer; DWORD dWord; char *dirname; char *base_dir; char *pixmap_dir; char *locale_dir; // Init the path for the Windows version by getting the // executable location. hModule = GetModuleHandle("skinedit.exe"); sBuffer = (char *) malloc(4096 * sizeof(char)); dWord = GetModuleFileName(hModule, sBuffer, 4096); dirname = g_dirname(sBuffer); base_dir = g_strconcat(dirname, "\\", NULL); g_free(dirname); free(sBuffer); pixmap_dir = g_strconcat(base_dir, "pixmaps\\", NULL); locale_dir = g_strconcat(base_dir, "locale\\", NULL); #endif #ifdef ENABLE_NLS #ifndef __WIN32__ bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #else bindtextdomain(PACKAGE, locale_dir); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif #endif gtk_set_locale (); gtk_init (&argc, &argv); #ifndef __WIN32__ add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps"); #else add_pixmap_directory (pixmap_dir); #endif signal(SIGINT, signal_handler); fprintf(stdout, _("SkinEdit v%s, (C) 2002-2003 Julien BLACHE <*****@*****.**>\n"), VERSION); fprintf(stdout, _(" 2004-2005 Romain Lievin <*****@*****.**>\n")); fprintf(stdout, "\n"); fprintf(stdout, _("This program is free software; you can redistribute it and/or modify\n")); fprintf(stdout, _("it under the terms of the GNU General Public License as published by\n")); fprintf(stdout, _("the Free Software Foundation; version 2 of the License\n")); fprintf(stdout, _("This program is distributed in the hope that it will be useful,\n")); fprintf(stdout, _("but WITHOUT ANY WARRANTY; without even the implied warranty of\n")); fprintf(stdout, _("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n")); fprintf(stdout, _("GNU General Public License for more details.\n")); gtk_widget_show (main_wnd = create_main_window()); sbar_print(_("Skinedit v%s -- Supported formats : TiEmu v2.00 (R/W), VTiv2.1 (R/W), VTiv2.5 (R/W)"), VERSION); // scan command line for (cnt = 1; cnt < argc; cnt++) { // get argument p = argv[cnt]; if (*p == '-') { // argument p++; } else { // filename if(load_skin(p) == 0) skin_infos.changed = 1; } strcpy(arg, p); if (strexact(arg, "-help") || strexact(arg, "h")) help(); if (strexact(arg, "-version") || strexact(arg, "v")) exit(0); } gtk_main (); return 0; }