/* this is called from main() in s_entry.c */ int sys_main(int argc, char **argv) { int i, noprefs; sys_externalschedlib = 0; sys_extraflags = 0; #ifdef PD_DEBUG fprintf(stderr, "Pd: COMPILED FOR DEBUGGING\n"); #endif /* use Win32 "binary" mode by default since we don't want the * translation that Win32 does by default */ #ifdef _WIN32 # ifdef _MSC_VER /* MS Visual Studio */ _set_fmode( _O_BINARY ); # else /* MinGW */ { extern int _fmode; _fmode = _O_BINARY; } # endif /* _MSC_VER */ #endif /* WIN32 */ pd_init(); /* start the message system */ sys_findprogdir(argv[0]); /* set sys_progname, guipath */ for (i = noprefs = 0; i < argc; i++) /* prescan args for noprefs */ if (!strcmp(argv[i], "-noprefs")) noprefs = 1; if (!noprefs) sys_loadpreferences(); /* load default settings */ #ifndef _WIN32 if (!noprefs) sys_rcfile(); /* parse the startup file */ #endif if (sys_argparse(argc-1, argv+1)) /* parse cmd line */ return (1); sys_afterargparse(); /* post-argparse settings */ if (sys_verbose || sys_version) fprintf(stderr, "%s compiled %s %s\n", pd_version, pd_compiletime, pd_compiledate); if (sys_version) /* if we were just asked our version, exit here. */ return (0); sys_setsignalhandlers(); if (sys_startgui(sys_libdir->s_name)) /* start the gui */ return (1); if (sys_externalschedlib) return (sys_run_scheduler(sys_externalschedlibname, sys_extraflagsstring)); else if (sys_batch) return (m_batchmain()); else { /* open audio and MIDI */ sys_reopen_midi(); if (audio_shouldkeepopen()) sys_reopen_audio(); /* run scheduler until it quits */ return (m_mainloop()); } }
/* this is called from main() in s_entry.c */ int sys_main(int argc, char **argv) { int i, noprefs; sys_externalschedlib = 0; sys_extraflags = 0; #ifdef PD_DEBUG fprintf(stderr, "Pd: COMPILED FOR DEBUGGING\n"); #endif pd_init(); /* start the message system */ logpost(NULL, 2, "PD_FLOATPRECISION = %lu bits", sizeof(t_float)*8); sys_findprogdir(argv[0]); /* set sys_progname, guipath */ for (i = noprefs = 0; i < argc; i++) /* prescan args for noprefs */ if (!strcmp(argv[i], "-noprefs")) noprefs = 1; if (!noprefs) sys_loadpreferences(); /* load default settings */ #ifndef MSW if (!noprefs) sys_rcfile(); /* parse the startup file */ #endif if (sys_argparse(argc-1, argv+1)) /* parse cmd line */ return (1); sys_afterargparse(); /* post-argparse settings */ if (sys_verbose || sys_version) fprintf(stderr, "%s compiled %s %s\n", pd_version, pd_compiletime, pd_compiledate); if (sys_version) /* if we were just asked our version, exit here. */ return (0); if (sys_startgui(sys_libdir->s_name)) /* start the gui */ return(1); if (sys_externalschedlib) return (sys_run_scheduler(sys_externalschedlibname, sys_extraflagsstring)); else if (sys_batch) return (m_batchmain()); else { /* open audio and MIDI */ sys_reopen_midi(); sys_reopen_audio(); /* run scheduler until it quits */ return (m_mainloop()); } }
/* this is called from main() in s_entry.c */ int sys_main(int argc, char **argv) { int i, noprefs; sys_externalschedlib = 0; sys_extraflags = 0; char * filenames; #ifdef PD_DEBUG fprintf(stderr, "Pd-L2Ork: COMPILED FOR DEBUGGING\n"); #endif pd_init(); /* start the message system */ sys_findprogdir(argv[0]); /* set sys_progname, guipath */ for (i = noprefs = 0; i < argc; i++) /* prescan args for noprefs */ if (!strcmp(argv[i], "-noprefs")) noprefs = 1; if (!noprefs) sys_loadpreferences(); /* load default settings */ #ifndef MSW if (!noprefs) sys_rcfile(); /* parse the startup file */ #endif if (sys_argparse(argc-1, argv+1)) /* parse cmd line */ return (1); sys_afterargparse(); /* post-argparse settings */ /* build version string from defines in m_pd.h */ pd_makeversion(); if (sys_verbose || sys_version) fprintf(stderr, "%scompiled %s %s\n", pd_version, pd_compiletime, pd_compiledate); if (sys_version) /* if we were just asked our version, exit here. */ return (0); if (sys_startgui(sys_guidir->s_name)) /* start the gui */ return(1); /* check if we are unique, otherwise, just focus existing instance, and if necessary open file inside it */\ if (sys_openlist) { // let's create one continuous string from all files int length = 0; t_namelist *nl; for (nl = sys_openlist; nl; nl = nl->nl_next) length = length + strlen(nl->nl_string) + 1; if((filenames = malloc(length)) != NULL) { filenames[0] = '\0'; // ensures the memory is an empty string if (sys_openlist) { for (nl = sys_openlist; nl; nl = nl->nl_next) { strcat(filenames,nl->nl_string); if (nl->nl_next) strcat(filenames," "); } } //fprintf(stderr,"final list: <%s>\n", filenames); } else { error("filelist malloc failed!\n"); return(1); } } sys_vgui("pdtk_check_unique %d %s\n", sys_unique, (filenames ? filenames : "0")); if (sys_externalschedlib) return (sys_run_scheduler(sys_externalschedlibname, sys_extraflagsstring)); else if (sys_batch) return (m_batchmain()); else { /* open audio and MIDI */ sys_reopen_midi(); sys_reopen_audio(); if (sys_console) sys_vgui("pdtk_toggle_console 1\n"); if (sys_k12_mode) { t_namelist *path = pd_extrapath; while (path->nl_next) path = path->nl_next; sys_vgui("pdtk_enable_k12_mode %s\n", path->nl_string); } /* run scheduler until it quits */ return (m_mainloop()); } }