Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13765
Modified Files: Tag: desiredata s_main.c Log Message: a new style of parsing options, much more concise
Index: s_main.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_main.c,v retrieving revision 1.7.4.17.2.22.2.1 retrieving revision 1.7.4.17.2.22.2.2 diff -C2 -d -r1.7.4.17.2.22.2.1 -r1.7.4.17.2.22.2.2 *** s_main.c 30 Nov 2006 03:55:48 -0000 1.7.4.17.2.22.2.1 --- s_main.c 30 Nov 2006 17:54:21 -0000 1.7.4.17.2.22.2.2 *************** *** 5,12 **** /* IOhannes : * hacked the code to add advanced multidevice-support ! * 1311:forum::fr::uml�te:2001 */
! char pd_version[] = "Pd version 0.39-1test1 devel\n"; char pd_compiletime[] = __TIME__; char pd_compiledate[] = __DATE__; --- 5,12 ---- /* IOhannes : * hacked the code to add advanced multidevice-support ! * 1311:forum::für::umläute:2001 */
! char pd_version[] = "DesireData 0.39.A.pre4\n"; char pd_compiletime[] = __TIME__; char pd_compiledate[] = __DATE__; *************** *** 178,185 **** }
- /* in DesireData you *shouldn't* use sys_fontwidth nor sys_fontheight */ - int sys_fontwidth(int fontsize) {return -666;} - int sys_fontheight(int fontsize) {return -666;} - int sys_defaultfont; #ifdef MSW --- 178,181 ---- *************** *** 469,482 **** }
- static int sys_getmultidevchannels(int n, int *devlist) - { - int sum = 0; - if (n<0)return(-1); - if (n==0)return 0; - while(n--)sum+=*devlist++; - return sum; - } - - /* this routine tries to figure out where to find the auxilliary files Pd will need to run. This is either done by looking at the command line --- 465,468 ---- *************** *** 584,679 **** #define NOT_HERE fprintf(stderr,"option %s not compiled into this pd\n", *argv)
! int sys_argparse(int argc, char **argv) ! { char sbuf[MAXPDSTRING]; int i; ! while ((argc > 0) && **argv == '-') ! { ! if (!strcmp(*argv, "-r") && argc > 1 && ! sscanf(argv[1], "%d", &sys_main_srate) >= 1) ! { ! argc -= 2; ! argv += 2; } ! else if (!strcmp(*argv, "-inchannels")) ! { /* IOhannes */ ! sys_parsedevlist(&sys_nchin, ! sys_chinlist, MAXAUDIOINDEV, argv[1]); ! ! if (!sys_nchin) ! goto usage; ! ! argc -= 2; argv += 2; } ! else if (!strcmp(*argv, "-outchannels")) ! { /* IOhannes */ ! sys_parsedevlist(&sys_nchout, sys_choutlist, ! MAXAUDIOOUTDEV, argv[1]); ! ! if (!sys_nchout) ! goto usage; ! ! argc -= 2; argv += 2; } ! else if (!strcmp(*argv, "-channels")) ! { ! sys_parsedevlist(&sys_nchin, sys_chinlist,MAXAUDIOINDEV, ! argv[1]); ! sys_parsedevlist(&sys_nchout, sys_choutlist,MAXAUDIOOUTDEV, ! argv[1]); ! ! if (!sys_nchout) ! goto usage; ! ! argc -= 2; argv += 2; } ! else if (!strcmp(*argv, "-soundbuf") || !strcmp(*argv, "-audiobuf")) ! { sys_main_advance = atoi(argv[1]); ! argc -= 2; argv += 2; ! } ! else if (!strcmp(*argv, "-blocksize")) ! { ! sys_setblocksize(atoi(argv[1])); ! argc -= 2; argv += 2; ! } ! else if (!strcmp(*argv, "-dacblocksize") && argc > 1 && ! sscanf(argv[1], "%d", &sys_main_dacblocksize) >= 1) ! { ! argc -= 2; ! argv += 2; ! } ! else if (!strcmp(*argv, "-sleepgrain")) ! { ! sys_sleepgrain = 1000 * atof(argv[1]); ! argc -= 2; argv += 2; ! } ! /* tb: callback-based scheduling { */ ! else if (!strcmp(*argv, "-cb_scheduler")) ! { ! sys_setscheduler(1); ! argc--; argv++; ! } ! /* tb } */ ! else if (!strcmp(*argv, "-nodac")) ! { /* IOhannes */ ! sys_nsoundout=0; ! sys_nchout = 0; ! argc--; argv++; ! } ! else if (!strcmp(*argv, "-noadc")) ! { /* IOhannes */ ! sys_nsoundin=0; ! sys_nchin = 0; ! argc--; argv++; } ! else if (!strcmp(*argv, "-nosound") || !strcmp(*argv, "-noaudio")) ! { /* IOhannes */ sys_nsoundin=sys_nsoundout = 0; sys_nchin = sys_nchout = 0; ! argc--; argv++; } ! else if (!strcmp(*argv, "-oss")) ! { #ifdef USEAPI_OSS sys_set_audio_api(API_OSS); --- 570,621 ---- #define NOT_HERE fprintf(stderr,"option %s not compiled into this pd\n", *argv)
! #define ARG(name,count) (!strcmp(*argv,(name)) && argc>=(count)) ! #define NEXT(count) argc -= (count), argv += (count); continue; ! ! int sys_argparse(int argc, char **argv) { char sbuf[MAXPDSTRING]; int i; ! while ((argc > 0) && **argv == '-') { ! if (ARG("-r",2) && sscanf(argv[1], "%d", &sys_main_srate) >= 1) { ! NEXT(2); } ! if (ARG("-inchannels",2)) { /* IOhannes */ ! sys_parsedevlist(&sys_nchin, sys_chinlist, MAXAUDIOINDEV, argv[1]); ! if (!sys_nchin) goto usage; ! NEXT(2); } ! if (ARG("-outchannels",2)) { /* IOhannes */ ! sys_parsedevlist(&sys_nchout, sys_choutlist, MAXAUDIOOUTDEV, argv[1]); ! if (!sys_nchout) goto usage; ! NEXT(2); } ! if (ARG("-channels",2)) { ! sys_parsedevlist(&sys_nchin, sys_chinlist,MAXAUDIOINDEV, argv[1]); ! sys_parsedevlist(&sys_nchout, sys_choutlist,MAXAUDIOOUTDEV, argv[1]); ! if (!sys_nchout) goto usage; ! NEXT(2); } ! if (ARG("-soundbuf",2) || ARG("-audiobuf",2)) { sys_main_advance = atoi(argv[1]); ! NEXT(2); } ! if (ARG("-blocksize",2)) {sys_setblocksize(atoi(argv[1])); NEXT(2);} ! if (ARG("-dacblocksize",2) && sscanf(argv[1], "%d", &sys_main_dacblocksize) >= 1) NEXT(2); ! if (ARG("-sleepgrain",2)) {sys_sleepgrain = 1000 * atof(argv[1]); NEXT(2);} ! ! /* from tim */ ! if (ARG("-cb_scheduler",1)) {sys_setscheduler(1); NEXT(1);} ! ! /* IOhannes */ ! if (ARG("-nodac",1)) {sys_nsoundout= sys_nchout = 0; NEXT(1);} ! if (ARG("-noadc",1)) {sys_nsoundin = sys_nchin = 0; NEXT(1);} ! if (ARG("-nosound",1) || ARG("-noaudio",1)) { sys_nsoundin=sys_nsoundout = 0; sys_nchin = sys_nchout = 0; ! NEXT(1); } ! ! /* many options for selecting audio api */ ! if (ARG("-oss",1)) { #ifdef USEAPI_OSS sys_set_audio_api(API_OSS); *************** *** 681,688 **** NOT_HERE; #endif ! argc--; argv++; } ! else if (!strcmp(*argv, "-32bit")) ! { #ifdef USEAPI_OSS sys_set_audio_api(API_OSS); --- 623,629 ---- NOT_HERE; #endif ! NEXT(1); } ! if (ARG("-32bit",1)) { #ifdef USEAPI_OSS sys_set_audio_api(API_OSS); *************** *** 691,698 **** NOT_HERE; #endif ! argc--; argv++; } ! else if (!strcmp(*argv, "-alsa")) ! { #ifdef USEAPI_ALSA sys_set_audio_api(API_ALSA); --- 632,638 ---- NOT_HERE; #endif ! NEXT(1); } ! if (ARG("-alsa",1)) { #ifdef USEAPI_ALSA sys_set_audio_api(API_ALSA); *************** *** 700,707 **** NOT_HERE; #endif ! argc--; argv++; } ! else if (!strcmp(*argv, "-alsaadd")) ! { #ifdef USEAPI_ALSA if (argc > 1) --- 640,646 ---- NOT_HERE; #endif ! NEXT(1); } ! if (ARG("-alsaadd",2)) { #ifdef USEAPI_ALSA if (argc > 1) *************** *** 711,718 **** NOT_HERE; #endif ! argc -= 2; argv +=2; } ! else if (!strcmp(*argv, "-alsamidi")) ! { #ifdef USEAPI_ALSA sys_set_midi_api(API_ALSA); --- 650,656 ---- NOT_HERE; #endif ! NEXT(2); } ! if (ARG("-alsamidi",1)) { #ifdef USEAPI_ALSA sys_set_midi_api(API_ALSA); *************** *** 720,727 **** NOT_HERE; #endif ! argc--; argv++; } ! else if (!strcmp(*argv, "-jack")) ! { #ifdef USEAPI_JACK sys_set_audio_api(API_JACK); --- 658,664 ---- NOT_HERE; #endif ! NEXT(1); } ! if (ARG("-jack",1)) { #ifdef USEAPI_JACK sys_set_audio_api(API_JACK); *************** *** 729,737 **** NOT_HERE; #endif ! argc--; argv++; } ! else if (!strcmp(*argv, "-pa") || !strcmp(*argv, "-portaudio") || !strcmp(*argv, "-asio") ! ) ! { #ifdef USEAPI_PORTAUDIO sys_set_audio_api(API_PORTAUDIO); --- 666,672 ---- NOT_HERE; #endif ! NEXT(1); } ! if (ARG("-pa",1) || ARG("-portaudio",1) || ARG("-asio",1)) { #ifdef USEAPI_PORTAUDIO sys_set_audio_api(API_PORTAUDIO); *************** *** 742,747 **** argc--; argv++; } ! else if (!strcmp(*argv, "-asio_native")) ! { #ifdef USEAPI_ASIO sys_set_audio_api(API_ASIO); --- 677,681 ---- argc--; argv++; } ! if (ARG("-asio_native",1)) { #ifdef USEAPI_ASIO sys_set_audio_api(API_ASIO); *************** *** 752,757 **** argc--; argv++; } ! else if (!strcmp(*argv, "-mmio")) ! { #ifdef USEAPI_MMIO sys_set_audio_api(API_MMIO); --- 686,690 ---- argc--; argv++; } ! if (ARG("-mmio",1)) { #ifdef USEAPI_MMIO sys_set_audio_api(API_MMIO); *************** *** 760,989 **** #endif sys_mmio = 1; ! argc--; argv++; ! } ! else if (!strcmp(*argv, "-nomidiin")) ! { ! sys_nmidiin = 0; ! argc--; argv++; ! } ! else if (!strcmp(*argv, "-nomidiout")) ! { ! sys_nmidiout = 0; ! argc--; argv++; ! } ! else if (!strcmp(*argv, "-nomidi")) ! { ! sys_nmidiin = sys_nmidiout = 0; ! argc--; argv++; } ! else if (!strcmp(*argv, "-midiindev")) ! { ! sys_parsedevlist(&sys_nmidiin, sys_midiindevlist, MAXMIDIINDEV, ! argv[1]); ! if (!sys_nmidiin) ! goto usage; ! argc -= 2; argv += 2; } ! else if (!strcmp(*argv, "-midioutdev")) ! { ! sys_parsedevlist(&sys_nmidiout, sys_midioutdevlist, MAXMIDIOUTDEV, ! argv[1]); ! if (!sys_nmidiout) ! goto usage; ! argc -= 2; argv += 2; } ! else if (!strcmp(*argv, "-mididev")) ! { ! sys_parsedevlist(&sys_nmidiin, sys_midiindevlist, MAXMIDIINDEV, ! argv[1]); ! sys_parsedevlist(&sys_nmidiout, sys_midioutdevlist, MAXMIDIOUTDEV, ! argv[1]); ! if (!sys_nmidiout) ! goto usage; ! argc -= 2; argv += 2; } ! else if (!strcmp(*argv, "-path")) ! { sys_searchpath = namelist_append_files(sys_searchpath, argv[1]); ! argc -= 2; argv += 2; ! } ! else if (!strcmp(*argv, "-nostdpath")) ! { ! sys_usestdpath = 0; ! argc--; argv++; ! } ! else if (!strcmp(*argv, "-stdpath")) ! { ! sys_usestdpath = 1; ! argc--; argv++; ! } ! else if (!strcmp(*argv, "-helppath")) ! { ! sys_helppath = namelist_append_files(sys_helppath, argv[1]); ! argc -= 2; argv += 2; ! } ! else if (!strcmp(*argv, "-open") && argc > 1) ! { ! sys_openlist = namelist_append_files(sys_openlist, argv[1]); ! argc -= 2; argv += 2; ! } ! else if (!strcmp(*argv, "-lib") && argc > 1) ! { ! sys_externlist = namelist_append_files(sys_externlist, argv[1]); ! argc -= 2; argv += 2; ! } ! else if (!strcmp(*argv, "-font") && argc > 1) ! { ! sys_defaultfont = sys_nearestfontsize(atoi(argv[1])); ! argc -= 2; ! argv += 2; ! } ! /* tb: font name { */ ! else if (!strcmp(*argv, "-typeface") && argc > 1) ! { ! strncpy(sys_font,*(argv+1),sizeof sys_font-1); ! sys_font[sizeof(sys_font)-1] = 0; /* set trailing 0 in case of space exhaustion */ ! argc -= 2; ! argv += 2; ! } ! /* tb: skip flag, we already parsed it */ ! else if (!strcmp(*argv, "-no-prefs")) ! { ! argc -= 1; ! argv += 1; ! } ! /* } tb */ ! /* jmz: read an alternative rcfile { */ ! else if (!strcmp(*argv, "-rcfile")) ! { ! sys_parsercfile(*(argv+1)); ! argc -= 2; ! argv += 2; ! } ! /* } jmz */ ! else if (!strcmp(*argv, "-verbose")) ! { ! sys_verbose++; ! argc--; argv++; ! } ! else if (!strcmp(*argv, "-version")) ! { ! sys_version = 1; ! argc--; argv++; ! } ! else if (!strcmp(*argv, "-d") && argc > 1 && ! sscanf(argv[1], "%d", &sys_debuglevel) >= 1) ! { ! argc -= 2; ! argv += 2; ! } ! else if (!strcmp(*argv, "-noloadbang")) ! { ! sys_noloadbang = 1; ! argc--; argv++; ! } ! else if (!strcmp(*argv, "-nogui")) ! { ! sys_printtostderr = sys_nogui = 1; ! argc--; argv++; ! } ! else if (!strcmp(*argv, "-guiport") && argc > 1 && ! sscanf(argv[1], "%d", &sys_guisetportnumber) >= 1) ! { ! argc -= 2; ! argv += 2; ! } ! else if (!strcmp(*argv, "-stderr")) ! { ! sys_printtostderr = 1; ! argc--; argv++; } ! else if (!strcmp(*argv, "-guicmd") && argc > 1) ! { ! sys_guicmd = argv[1]; ! argc -= 2; argv += 2; } ! else if (!strcmp(*argv, "-send") && argc > 1) ! { sys_messagelist = namelist_append(sys_messagelist, argv[1], 1); ! argc -= 2; argv += 2; ! } ! else if (!strcmp(*argv, "-listdev")) ! { ! sys_listdevs(); ! argc--; argv++; } /* jsarlo { */ ! else if (!strcmp(*argv, "-schedlib")) ! { sys_externalschedlib = 1; strcpy(sys_externalschedlibname, argv[1]); ! argv += 2; ! argc -= 2; } ! else if (!strcmp(*argv, "-extraflags")) ! { sys_extraflags = 1; strcpy(sys_extraflagsstring, argv[1]); ! argv += 2; ! argc -= 2; } /* } jsarlo */ #ifdef UNISTD ! else if (!strcmp(*argv, "-rt") || !strcmp(*argv, "-realtime")) ! { ! sys_hipriority = 1; ! argc--; argv++; ! } ! else if (!strcmp(*argv, "-nrt")) ! { ! sys_hipriority = 0; ! argc--; argv++; ! } #endif ! else if (!strcmp(*argv, "-soundindev") || ! !strcmp(*argv, "-audioindev")) ! { /* IOhannes */ ! sys_parsedevlist(&sys_nsoundin, sys_soundindevlist, ! MAXAUDIOINDEV, argv[1]); ! if (!sys_nsoundin) ! goto usage; ! argc -= 2; argv += 2; } ! else if (!strcmp(*argv, "-soundoutdev") || ! !strcmp(*argv, "-audiooutdev")) ! { /* IOhannes */ ! sys_parsedevlist(&sys_nsoundout, sys_soundoutdevlist, ! MAXAUDIOOUTDEV, argv[1]); ! if (!sys_nsoundout) ! goto usage; ! argc -= 2; argv += 2; } ! else if (!strcmp(*argv, "-sounddev") || !strcmp(*argv, "-audiodev")) ! { ! sys_parsedevlist(&sys_nsoundin, sys_soundindevlist, ! MAXAUDIOINDEV, argv[1]); ! sys_parsedevlist(&sys_nsoundout, sys_soundoutdevlist, ! MAXAUDIOOUTDEV, argv[1]); ! if (!sys_nsoundout) ! goto usage; ! argc -= 2; argv += 2; } - else - { - unsigned int i; usage: for (i = 0; i < sizeof(usagemessage)/sizeof(*usagemessage); i++) fprintf(stderr, "%s", usagemessage[i]); ! return (1); ! } } ! if (!sys_defaultfont) ! sys_defaultfont = DEFAULTFONT; ! for (; argc > 0; argc--, argv++) sys_openlist = namelist_append_files(sys_openlist, *argv); ! ! ! return (0); }
--- 693,794 ---- #endif sys_mmio = 1; ! NEXT(1); } ! ! if (ARG("-nomidiin", 1)) {sys_nmidiin = 0; NEXT(1);} ! if (ARG("-nomidiout",1)) {sys_nmidiout = 0; NEXT(1);} ! if (ARG("-nomidi",1)) {sys_nmidiin = sys_nmidiout = 0; NEXT(1);} ! if (ARG("-midiindev",1)) { ! sys_parsedevlist(&sys_nmidiin, sys_midiindevlist, MAXMIDIINDEV, argv[1]); ! if (!sys_nmidiin) goto usage; ! NEXT(2); } ! if (ARG("-midioutdev",1)) { ! sys_parsedevlist(&sys_nmidiout, sys_midioutdevlist, MAXMIDIOUTDEV, argv[1]); ! if (!sys_nmidiout) goto usage; ! NEXT(2); } ! if (ARG("-mididev",1)) { ! sys_parsedevlist(&sys_nmidiin, sys_midiindevlist, MAXMIDIINDEV, argv[1]); ! sys_parsedevlist(&sys_nmidiout, sys_midioutdevlist, MAXMIDIOUTDEV, argv[1]); ! if (!sys_nmidiout) goto usage; ! NEXT(2); } ! if (ARG("-path",2)) { sys_searchpath = namelist_append_files(sys_searchpath, argv[1]); ! NEXT(2); } ! if (ARG("-nostdpath",1)) {sys_usestdpath = 0; NEXT(1);} ! if (ARG("-stdpath",1)) {sys_usestdpath = 1; NEXT(1);} ! if (ARG("-helppath",1)) {sys_helppath = namelist_append_files(sys_helppath, argv[1]); NEXT(2);} ! if (ARG("-open",2)) {sys_openlist = namelist_append_files(sys_openlist, argv[1]); NEXT(2);} ! if (ARG("-lib",2)) {sys_externlist = namelist_append_files(sys_externlist, argv[1]); NEXT(2);} ! if (ARG("-font",2)) { ! fprintf(stderr,"Warning: -font ignored by DesireData; use .ddrc instead\n"); ! //sys_defaultfont = sys_nearestfontsize(atoi(argv[1])); ! NEXT(2); } ! if (ARG("-typeface",2)) { /* tim */ ! fprintf(stderr,"Warning: -typeface ignored by DesireData; use .ddrc instead\n"); ! NEXT(2); ! } ! if (ARG("-no-prefs",1)) NEXT(1); /* tim: skip flag, we already parsed it */ ! /* jmz: read an alternative rcfile { */ ! if (ARG("-rcfile",2)) {sys_parsercfile(argv[1]); NEXT(2);} /* recursively */ ! /* } jmz */ ! if (ARG("-verbose",1)) {sys_verbose++; NEXT(1);} ! if (ARG("-version",1)) {sys_version = 1; NEXT(1);} ! if (ARG("-d",2) && sscanf(argv[1], "%d", &sys_debuglevel) >= 1) NEXT(2); ! if (ARG("-noloadbang",1)) {sys_noloadbang = 1; NEXT(1);} ! if (ARG("-nogui",1)) {sys_printtostderr = sys_nogui = 1; NEXT(1);} ! if (ARG("-guiport",2) && sscanf(argv[1], "%d", &sys_guisetportnumber) >= 1) NEXT(2); ! if (ARG("-stderr",1)) {sys_printtostderr = 1; NEXT(1);} ! if (ARG("-guicmd",2)) {sys_guicmd = argv[1]; NEXT(2);} ! if (ARG("-send",2)) { sys_messagelist = namelist_append(sys_messagelist, argv[1], 1); ! NEXT(2); } + if (ARG("-listdev",1)) {sys_listdevs(); NEXT(1);} /* jsarlo { */ ! if (ARG("-schedlib",2)) { sys_externalschedlib = 1; strcpy(sys_externalschedlibname, argv[1]); ! NEXT(2); } ! if (ARG("-extraflags",2)) { sys_extraflags = 1; strcpy(sys_extraflagsstring, argv[1]); ! NEXT(2); } /* } jsarlo */ #ifdef UNISTD ! if (ARG("-rt",1) || ARG("-realtime",1)) {sys_hipriority = 1; NEXT(1);} ! if (ARG("-nrt",1)) {sys_hipriority = 0; NEXT(1);} #endif ! if (ARG("-soundindev",2) || ARG("-audioindev",2)) { /* IOhannes */ ! sys_parsedevlist(&sys_nsoundin, sys_soundindevlist, MAXAUDIOINDEV, argv[1]); ! if (!sys_nsoundin) goto usage; ! NEXT(2); } ! if (ARG("-soundoutdev",2) || ARG("-audiooutdev",2)) { /* IOhannes */ ! sys_parsedevlist(&sys_nsoundout, sys_soundoutdevlist, MAXAUDIOOUTDEV, argv[1]); ! if (!sys_nsoundout) goto usage; ! NEXT(2); } ! if (ARG("-sounddev",2) || ARG("-audiodev",2)) { ! sys_parsedevlist(&sys_nsoundin, sys_soundindevlist, MAXAUDIOINDEV, argv[1]); ! sys_parsedevlist(&sys_nsoundout, sys_soundoutdevlist, MAXAUDIOOUTDEV, argv[1]); ! if (!sys_nsoundout) goto usage; ! NEXT(2); } usage: for (i = 0; i < sizeof(usagemessage)/sizeof(*usagemessage); i++) fprintf(stderr, "%s", usagemessage[i]); ! return 1; } ! if (!sys_defaultfont) sys_defaultfont = DEFAULTFONT; ! for (; argc > 0; argc--, argv++) sys_openlist = namelist_append_files(sys_openlist, *argv); ! return 0; }
*************** *** 1086,1092 **** sys_open_midi(nmidiindev, midiindev, nmidioutdev, midioutdev, 0); } - - static void sys_addreferencepath(void) - { - char sbuf[MAXPDSTRING]; - } --- 891,892 ----