int main(int argn, char *argc[]) { int i, j, title = 1; long int with_cfg = 1, reconfig = 0; char buffer[128]; char* load_file_name = NULL; signal(SIGFPE, my_abort); signal(SIGILL, my_abort); signal(SIGSEGV, my_abort); signal(SIGTERM, my_abort); printf("Devil %s%s\nCompiler: %s\nCompiled: %s %s\n", VERSION, LC_VERSION, SYS_COMPILER_NAME, __DATE__, __TIME__); if (sizeof(float) != 4 || sizeof(long int) != 4 || sizeof(short int) != 2 || sizeof(int) != 4 || sizeof(char) != 1) { printf("Wrong float/int size. Check your compiler flags.\n"); exit(2); } errf = stdout; for (j = 1; j < argn; j++) { sscanf(argc[j], " %s", buffer); for (i = 0; i < strlen(buffer); i++) { buffer[i] = toupper(buffer[i]); } if (buffer[0] == '/') { for (i = 0; i < num_cmdlineparams; i++) { if (strcmp(&buffer[1], cmdline_switches[i]) == 0) { switch (i) { case clp_new: with_cfg = 0; break; case clp_notitle: printf("Devil is sponsored by PC Player!\n"); title = 0; break; case clp_config: reconfig = 1; break; } break; } } if (i == num_cmdlineparams) { printf(TXT_CMDUNKNOWNPARAM, &buffer[1]); for (i = 0; i < num_cmdlineparams; i++) { printf("%s -- %s\n", cmdline_switches[i], cmdline_txts[i]); } exit(1); } } else { load_file_name = argc[j]; } } initeditor(INIFILE, title); if ( !readconfig() ) { writeconfig(0); } else if (reconfig) { writeconfig(1); } initgrph(title); ws_disablectrlc(); l = NULL; if (with_cfg) { readstatus(load_file_name); } else { printmsg(TXT_NOCFGFILE); } /* if(strlen(load_file_name)) { for(n=view.levels.head;n->next!=NULL;n=n->next) closelevel(n->d.lev,1); openlevel(load_file_name); } */ w_handleuser(0, NULL, 0, NULL, view.num_keycodes, view.ec_keycodes, do_event); return 1; }
static void GeanyPy_start_interpreter(void) { gchar *init_code; gchar *py_dir = NULL; #ifndef GEANYPY_WINDOWS { /* Prevents a crash in the dynload thingy TODO: is this or the old dlopen version even needed? */ GModule *mod = g_module_open(GEANYPY_PYTHON_LIBRARY, G_MODULE_BIND_LAZY); if (!mod) { g_warning(_("Unable to pre-load Python library: %s."), g_module_error()); return; } g_module_close(mod); } #endif Py_Initialize(); /* Import the C modules */ initapp(); initdialogs(); initdocument(); initeditor(); initencoding(); initfiletypes(); inithighlighting(); initmain(); initmsgwin(); initnavqueue(); initprefs(); initproject(); initscintilla(); initsearch(); inittemplates(); initui_utils(); #ifdef GEANYPY_WINDOWS { /* On windows, get path at runtime since we don't really know where * Geany is installed ahead of time. */ gchar *geany_base_dir; geany_base_dir = g_win32_get_package_installation_directory_of_module(NULL); if (geany_base_dir) { py_dir = g_build_filename(geany_base_dir, "lib", "geanypy", NULL); g_free(geany_base_dir); } if (!g_file_test(py_dir, G_FILE_TEST_EXISTS)) { g_critical("The path to the `geany' module was not found: %s", py_dir); g_free(py_dir); py_dir = g_strdup(""); /* will put current dir on path? */ } } #else py_dir = g_strdup(GEANYPY_PYTHON_DIR); #endif /* Adjust Python path to find wrapper package (geany) */ init_code = g_strdup_printf( "import os, sys\n" "path = '%s'.replace('~', os.path.expanduser('~'))\n" "sys.path.append(path)\n" "import geany\n", py_dir); g_free(py_dir); PyRun_SimpleString(init_code); g_free(init_code); }