summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/src/s_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/s_main.c')
-rw-r--r--apps/plugins/pdbox/PDa/src/s_main.c839
1 files changed, 0 insertions, 839 deletions
diff --git a/apps/plugins/pdbox/PDa/src/s_main.c b/apps/plugins/pdbox/PDa/src/s_main.c
deleted file mode 100644
index b77f804e9f..0000000000
--- a/apps/plugins/pdbox/PDa/src/s_main.c
+++ /dev/null
@@ -1,839 +0,0 @@
1/* Copyright (c) 1997-1999 Miller Puckette and others.
2* For information on usage and redistribution, and for a DISCLAIMER OF ALL
3* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
4
5/* IOhannes :
6 * hacked the code to add advanced multidevice-support
7 * 1311:forum::für::umläute:2001
8 */
9
10char pd_version[] = "Pd version 0.37.4\n";
11char pd_compiletime[] = __TIME__;
12char pd_compiledate[] = __DATE__;
13
14#include "m_pd.h"
15#include "m_imp.h"
16#include "s_stuff.h"
17#include <sys/types.h>
18#include <sys/stat.h>
19#include <limits.h>
20#include <string.h>
21#include <stdio.h>
22#include <fcntl.h>
23#include <stdlib.h>
24
25#ifdef UNIX
26#include <unistd.h>
27#endif
28#ifdef MSW
29#include <io.h>
30#include <windows.h>
31#include <winbase.h>
32#endif
33
34void pd_init(void);
35int sys_argparse(int argc, char **argv);
36void sys_findprogdir(char *progname);
37int sys_startgui(const char *guipath);
38int sys_rcfile(void);
39int m_scheduler(void);
40void sys_addhelppath(char *p);
41void alsa_adddev(char *name);
42
43int sys_debuglevel;
44int sys_verbose;
45int sys_noloadbang;
46int sys_nogui;
47int sys_stdin = 0;
48char *sys_guicmd;
49t_symbol *sys_libdir;
50static t_symbol *sys_guidir;
51static t_namelist *sys_externlist;
52static t_namelist *sys_openlist;
53static t_namelist *sys_messagelist;
54static int sys_version;
55int sys_oldtclversion; /* hack to warn g_rtext.c about old text sel */
56
57int sys_nmidiout = 1;
58#ifdef MSW
59int sys_nmidiin = 0;
60#else
61int sys_nmidiin = 1;
62#endif
63int sys_midiindevlist[MAXMIDIINDEV] = {1};
64int sys_midioutdevlist[MAXMIDIOUTDEV] = {1};
65
66static int sys_main_srate = DEFAULTSRATE;
67static int sys_main_advance = DEFAULTADVANCE;
68
69/* IOhannes { */
70
71 /* here the "-1" counts signify that the corresponding vector hasn't been
72 specified in command line arguments; sys_open_audio will detect this
73 and fill things in. */
74int sys_nsoundin = -1;
75int sys_nsoundout = -1;
76int sys_soundindevlist[MAXAUDIOINDEV];
77int sys_soundoutdevlist[MAXAUDIOOUTDEV];
78
79int sys_nchin = -1;
80int sys_nchout = -1;
81int sys_chinlist[MAXAUDIOINDEV];
82int sys_choutlist[MAXAUDIOOUTDEV];
83/* } IOhannes */
84
85
86typedef struct _fontinfo
87{
88 int fi_fontsize;
89 int fi_maxwidth;
90 int fi_maxheight;
91 int fi_hostfontsize;
92 int fi_width;
93 int fi_height;
94} t_fontinfo;
95
96 /* these give the nominal point size and maximum height of the characters
97 in the six fonts. */
98
99static t_fontinfo sys_fontlist[] = {
100 {8, 5, 9, 0, 0, 0}, {10, 7, 13, 0, 0, 0}, {12, 9, 16, 0, 0, 0},
101 {16, 10, 20, 0, 0, 0}, {24, 15, 25, 0, 0, 0}, {36, 25, 45, 0, 0, 0}};
102#define NFONT (sizeof(sys_fontlist)/sizeof(*sys_fontlist))
103
104/* here are the actual font size structs on msp's systems:
105MSW:
106font 8 5 9 8 5 11
107font 10 7 13 10 6 13
108font 12 9 16 14 8 16
109font 16 10 20 16 10 18
110font 24 15 25 16 10 18
111font 36 25 42 36 22 41
112
113linux:
114font 8 5 9 8 5 9
115font 10 7 13 12 7 13
116font 12 9 16 14 9 15
117font 16 10 20 16 10 19
118font 24 15 25 24 15 24
119font 36 25 42 36 22 41
120*/
121
122static t_fontinfo *sys_findfont(int fontsize)
123{
124 unsigned int i;
125 t_fontinfo *fi;
126 for (i = 0, fi = sys_fontlist; i < (NFONT-1); i++, fi++)
127 if (fontsize < fi[1].fi_fontsize) return (fi);
128 return (sys_fontlist + (NFONT-1));
129}
130
131int sys_nearestfontsize(int fontsize)
132{
133 return (sys_findfont(fontsize)->fi_fontsize);
134}
135
136int sys_hostfontsize(int fontsize)
137{
138 return (sys_findfont(fontsize)->fi_hostfontsize);
139}
140
141int sys_fontwidth(int fontsize)
142{
143 return (sys_findfont(fontsize)->fi_width);
144}
145
146int sys_fontheight(int fontsize)
147{
148 return (sys_findfont(fontsize)->fi_height);
149}
150
151int sys_defaultfont;
152#ifdef MSW
153#define DEFAULTFONT 12
154#else
155#define DEFAULTFONT 10
156#endif
157
158static void openit(const char *dirname, const char *filename)
159{
160 char dirbuf[MAXPDSTRING], *nameptr;
161 int fd = open_via_path(dirname, filename, "", dirbuf, &nameptr,
162 MAXPDSTRING, 0);
163 if (fd)
164 {
165 close (fd);
166 glob_evalfile(0, gensym(nameptr), gensym(dirbuf));
167 }
168 else
169 error("%s: can't open", filename);
170}
171
172#define NHOSTFONT 7
173
174/* this is called from the gui process. The first argument is the cwd, and
175succeeding args give the widths and heights of known fonts. We wait until
176these are known to open files and send messages specified on the command line.
177We ask the GUI to specify the "cwd" in case we don't have a local OS to get it
178from; for instance we could be some kind of RT embedded system. However, to
179really make this make sense we would have to implement
180open(), read(), etc, calls to be served somehow from the GUI too. */
181
182void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv)
183{
184 char *cwd = atom_getsymbolarg(0, argc, argv)->s_name;
185 t_namelist *nl;
186 unsigned int i, j;
187 if (argc != 2 + 3 * NHOSTFONT) bug("glob_initfromgui");
188 for (i = 0; i < NFONT; i++)
189 {
190 int wantheight = sys_fontlist[i].fi_maxheight;
191 for (j = 0; j < NHOSTFONT-1; j++)
192 {
193 if (atom_getintarg(3 * (j + 1) + 3, argc, argv) > wantheight)
194 break;
195 }
196 /* j is now the "real" font index for the desired font index i. */
197 sys_fontlist[i].fi_hostfontsize = atom_getintarg(3 * j + 1, argc, argv);
198 sys_fontlist[i].fi_width = atom_getintarg(3 * j + 2, argc, argv);
199 sys_fontlist[i].fi_height = atom_getintarg(3 * j + 3, argc, argv);
200 }
201#if 0
202 for (i = 0; i < 6; i++)
203 fprintf(stderr, "font %d %d %d %d %d\n",
204 sys_fontlist[i].fi_fontsize,
205 sys_fontlist[i].fi_maxheight,
206 sys_fontlist[i].fi_hostfontsize,
207 sys_fontlist[i].fi_width,
208 sys_fontlist[i].fi_height);
209#endif
210 /* load dynamic libraries specified with "-lib" args */
211 for (nl = sys_externlist; nl; nl = nl->nl_next)
212 if (!sys_load_lib(cwd, nl->nl_string))
213 post("%s: can't load library", nl->nl_string);
214 namelist_free(sys_externlist);
215 sys_externlist = 0;
216 /* open patches specifies with "-open" args */
217 for (nl = sys_openlist; nl; nl = nl->nl_next)
218 openit(cwd, nl->nl_string);
219 namelist_free(sys_openlist);
220 sys_openlist = 0;
221 /* send messages specified with "-send" args */
222 for (nl = sys_messagelist; nl; nl = nl->nl_next)
223 {
224 t_binbuf *b = binbuf_new();
225 binbuf_text(b, nl->nl_string, strlen(nl->nl_string));
226 binbuf_eval(b, 0, 0, 0);
227 binbuf_free(b);
228 }
229 namelist_free(sys_messagelist);
230 sys_messagelist = 0;
231 sys_oldtclversion = atom_getfloatarg(1 + 3 * NHOSTFONT, argc, argv);
232}
233
234static void sys_afterargparse(void);
235
236/* this is called from main() in s_entry.c */
237int sys_main(int argc, char **argv)
238{
239#ifdef PD_DEBUG
240 fprintf(stderr, "Pd: COMPILED FOR DEBUGGING\n");
241#endif
242 pd_init();
243 sys_findprogdir(argv[0]); /* set sys_progname, guipath */
244#ifdef UNIX
245 sys_rcfile(); /* parse the startup file */
246#endif
247 if (sys_argparse(argc, argv)) /* parse cmd line */
248 return (1);
249 sys_afterargparse(); /* post-argparse settings */
250 if (sys_verbose || sys_version) fprintf(stderr, "%scompiled %s %s\n",
251 pd_version, pd_compiletime, pd_compiledate);
252 if (sys_version) /* if we were just asked our version, exit here. */
253 return (0);
254 if (sys_startgui(sys_guidir->s_name)) /* start the gui */
255 return(1);
256 /* open audio and MIDI */
257 sys_open_midi(sys_nmidiin, sys_midiindevlist,
258 sys_nmidiout, sys_midioutdevlist);
259 sys_open_audio(sys_nsoundin, sys_soundindevlist, sys_nchin, sys_chinlist,
260 sys_nsoundout, sys_soundoutdevlist, sys_nchout, sys_choutlist,
261 sys_main_srate, sys_main_advance, 1);
262 /* run scheduler until it quits */
263
264 return (m_scheduler_pda());
265 return (m_scheduler());
266}
267
268static char *(usagemessage[]) = {
269"usage: pd [-flags] [file]...\n",
270"\naudio configuration flags:\n",
271"-r <n> -- specify sample rate\n",
272"-audioindev ... -- audio in devices; e.g., \"1,3\" for first and third\n",
273"-audiooutdev ... -- audio out devices (same)\n",
274"-audiodev ... -- specify input and output together\n",
275"-inchannels ... -- audio input channels (by device, like \"2\" or \"16,8\")\n",
276"-outchannels ... -- number of audio out channels (same)\n",
277"-channels ... -- specify both input and output channels\n",
278"-audiobuf <n> -- specify size of audio buffer in msec\n",
279"-blocksize <n> -- specify audio I/O block size in sample frames\n",
280"-sleepgrain <n> -- specify number of milliseconds to sleep when idle\n",
281"-nodac -- suppress audio output\n",
282"-noadc -- suppress audio input\n",
283"-noaudio -- suppress audio input and output (-nosound is synonym) \n",
284"-listdev -- list audio and MIDI devices\n",
285
286#ifdef USEAPI_OSS
287"-oss -- use OSS audio API\n",
288"-32bit ----- allow 32 bit OSS audio (for RME Hammerfall)\n",
289#endif
290
291#ifdef USEAPI_ALSA
292"-alsa -- use ALSA audio API\n",
293"-alsaadd <name> -- add an ALSA device name to list\n",
294"-alsadev <n> ----- obsolete: use -audiodev\n",
295#endif
296
297#ifdef USEAPI_JACK
298"-jack -- use JACK audio API\n",
299#endif
300
301#ifdef USEAPI_PORTAUDIO
302#ifdef MSW
303"-asio -- use ASIO audio driver (via Portaudio)\n",
304"-pa -- synonym for -asio\n",
305#else
306"-pa -- use Portaudio API\n",
307#endif
308#endif
309
310#ifdef USEAPI_MMIO
311"-mmio -- use MMIO audio API (default for Windows)\n",
312#endif
313" (default audio API for this platform: ", API_DEFSTRING, ")\n\n",
314
315"\nMIDI configuration flags:\n",
316"-midiindev ... -- midi in device list; e.g., \"1,3\" for first and third\n",
317"-midioutdev ... -- midi out device list, same format\n",
318"-mididev ... -- specify -midioutdev and -midiindev together\n",
319"-nomidiin -- suppress MIDI input\n",
320"-nomidiout -- suppress MIDI output\n",
321"-nomidi -- suppress MIDI input and output\n",
322
323"\nother flags:\n",
324"-path <path> -- add to file search path\n",
325"-helppath <path> -- add to help file search path\n",
326"-open <file> -- open file(s) on startup\n",
327"-lib <file> -- load object library(s)\n",
328"-font <n> -- specify default font size in points\n",
329"-verbose -- extra printout on startup and when searching for files\n",
330"-version -- don't run Pd; just print out which version it is \n",
331"-d <n> -- specify debug level\n",
332"-noloadbang -- suppress all loadbangs\n",
333"-nogui -- suppress starting the GUI\n",
334"-stdin -- scan stdin for keypresses\n",
335"-guicmd \"cmd...\" -- substitute another GUI program (e.g., rsh)\n",
336"-send \"msg...\" -- send a message at startup (after patches are loaded)\n",
337#ifdef UNIX
338"-rt or -realtime -- use real-time priority\n",
339"-nrt -- don't use real-time priority\n",
340#endif
341};
342
343static void sys_parsedevlist(int *np, int *vecp, int max, char *str)
344{
345 int n = 0;
346 while (n < max)
347 {
348 if (!*str) break;
349 else
350 {
351 char *endp;
352 vecp[n] = strtol(str, &endp, 10);
353 if (endp == str)
354 break;
355 n++;
356 if (!endp)
357 break;
358 str = endp + 1;
359 }
360 }
361 *np = n;
362}
363
364static int sys_getmultidevchannels(int n, int *devlist)
365{
366 int sum = 0;
367 if (n<0)return(-1);
368 if (n==0)return 0;
369 while(n--)sum+=*devlist++;
370 return sum;
371}
372
373
374 /* this routine tries to figure out where to find the auxilliary files
375 Pd will need to run. This is either done by looking at the command line
376 invokation for Pd, or if that fails, by consulting the variable
377 INSTALL_PREFIX. In MSW, we don't try to use INSTALL_PREFIX. */
378void sys_findprogdir(char *progname)
379{
380 char sbuf[MAXPDSTRING], sbuf2[MAXPDSTRING], *sp;
381 char *lastslash;
382#ifdef UNIX
383 struct stat statbuf;
384#endif
385
386 /* find out by what string Pd was invoked; put answer in "sbuf". */
387#ifdef MSW
388 GetModuleFileName(NULL, sbuf2, sizeof(sbuf2));
389 sbuf2[MAXPDSTRING-1] = 0;
390 sys_unbashfilename(sbuf2, sbuf);
391#endif /* MSW */
392#ifdef UNIX
393 strncpy(sbuf, progname, MAXPDSTRING);
394 sbuf[MAXPDSTRING-1] = 0;
395#endif
396 lastslash = strrchr(sbuf, '/');
397 if (lastslash)
398 {
399 /* bash last slash to zero so that sbuf is directory pd was in,
400 e.g., ~/pd/bin */
401 *lastslash = 0;
402 /* go back to the parent from there, e.g., ~/pd */
403 lastslash = strrchr(sbuf, '/');
404 if (lastslash)
405 {
406 strncpy(sbuf2, sbuf, lastslash-sbuf);
407 sbuf2[lastslash-sbuf] = 0;
408 }
409 else strcpy(sbuf2, "..");
410 }
411 else
412 {
413 /* no slashes found. Try INSTALL_PREFIX. */
414#ifdef INSTALL_PREFIX
415 strcpy(sbuf2, INSTALL_PREFIX);
416#else
417 strcpy(sbuf2, ".");
418#endif
419 }
420 /* now we believe sbuf2 holds the parent directory of the directory
421 pd was found in. We now want to infer the "lib" directory and the
422 "gui" directory. In "simple" UNIX installations, the layout is
423 .../bin/pd
424 .../bin/pd-gui
425 .../doc
426 and in "complicated" UNIX installations, it's:
427 .../bin/pd
428 .../lib/pd/bin/pd-gui
429 .../lib/pd/doc
430 To decide which, we stat .../lib/pd; if that exists, we assume it's
431 the complicated layout. In MSW, it's the "simple" layout, but
432 the gui program is straight wish80:
433 .../bin/pd
434 .../bin/wish80.exe
435 .../doc
436 */
437#ifdef UNIX
438 strncpy(sbuf, sbuf2, MAXPDSTRING-30);
439 sbuf[MAXPDSTRING-30] = 0;
440 strcat(sbuf, "/lib/pd");
441 if (stat(sbuf, &statbuf) >= 0)
442 {
443 /* complicated layout: lib dir is the one we just stat-ed above */
444 sys_libdir = gensym(sbuf);
445 /* gui lives in .../lib/pd/bin */
446 strncpy(sbuf, sbuf2, MAXPDSTRING-30);
447 sbuf[MAXPDSTRING-30] = 0;
448 strcat(sbuf, "/lib/pd/bin");
449 sys_guidir = gensym(sbuf);
450 }
451 else
452 {
453 /* simple layout: lib dir is the parent */
454 sys_libdir = gensym(sbuf2);
455 /* gui lives in .../bin */
456 strncpy(sbuf, sbuf2, MAXPDSTRING-30);
457 sbuf[MAXPDSTRING-30] = 0;
458 strcat(sbuf, "/bin");
459 sys_guidir = gensym(sbuf);
460 }
461#endif
462#ifdef MSW
463 sys_libdir = gensym(sbuf2);
464 sys_guidir = &s_; /* in MSW the guipath just depends on the libdir */
465#endif
466}
467
468#ifdef MSW
469static int sys_mmio = 1;
470#else
471static int sys_mmio = 0;
472#endif
473
474int sys_argparse(int argc, char **argv)
475{
476 char sbuf[MAXPDSTRING];
477 int i;
478 argc--; argv++;
479 while ((argc > 0) && **argv == '-')
480 {
481 if (!strcmp(*argv, "-r") && argc > 1 &&
482 sscanf(argv[1], "%d", &sys_main_srate) >= 1)
483 {
484 argc -= 2;
485 argv += 2;
486 }
487 else if (!strcmp(*argv, "-inchannels"))
488 { /* IOhannes */
489 sys_parsedevlist(&sys_nchin,
490 sys_chinlist, MAXAUDIOINDEV, argv[1]);
491
492 if (!sys_nchin)
493 goto usage;
494
495 argc -= 2; argv += 2;
496 }
497 else if (!strcmp(*argv, "-outchannels"))
498 { /* IOhannes */
499 sys_parsedevlist(&sys_nchout, sys_choutlist,
500 MAXAUDIOOUTDEV, argv[1]);
501
502 if (!sys_nchout)
503 goto usage;
504
505 argc -= 2; argv += 2;
506 }
507 else if (!strcmp(*argv, "-channels"))
508 {
509 sys_parsedevlist(&sys_nchin, sys_chinlist,MAXAUDIOINDEV,
510 argv[1]);
511 sys_parsedevlist(&sys_nchout, sys_choutlist,MAXAUDIOOUTDEV,
512 argv[1]);
513
514 if (!sys_nchout)
515 goto usage;
516
517 argc -= 2; argv += 2;
518 }
519 else if (!strcmp(*argv, "-soundbuf") || !strcmp(*argv, "-audiobuf"))
520 {
521 sys_main_advance = atoi(argv[1]);
522 argc -= 2; argv += 2;
523 }
524 else if (!strcmp(*argv, "-blocksize"))
525 {
526 sys_setblocksize(atoi(argv[1]));
527 argc -= 2; argv += 2;
528 }
529 else if (!strcmp(*argv, "-sleepgrain"))
530 {
531 sys_sleepgrain = 1000 * atoi(argv[1]);
532 argc -= 2; argv += 2;
533 }
534 else if (!strcmp(*argv, "-nodac"))
535 { /* IOhannes */
536 sys_nsoundout=0;
537 sys_nchout = 0;
538 argc--; argv++;
539 }
540 else if (!strcmp(*argv, "-noadc"))
541 { /* IOhannes */
542 sys_nsoundin=0;
543 sys_nchin = 0;
544 argc--; argv++;
545 }
546 else if (!strcmp(*argv, "-nosound") || !strcmp(*argv, "-noaudio"))
547 { /* IOhannes */
548 sys_nsoundin=sys_nsoundout = 0;
549 sys_nchin = sys_nchout = 0;
550 argc--; argv++;
551 }
552#ifdef USEAPI_OSS
553 else if (!strcmp(*argv, "-oss"))
554 {
555 sys_set_audio_api(API_OSS);
556 argc--; argv++;
557 }
558 else if (!strcmp(*argv, "-32bit"))
559 {
560 sys_set_audio_api(API_OSS);
561 oss_set32bit();
562 argc--; argv++;
563 }
564#endif
565#ifdef USEAPI_ALSA
566 else if (!strcmp(*argv, "-alsa"))
567 {
568 sys_set_audio_api(API_ALSA);
569 argc--; argv++;
570 }
571 else if (!strcmp(*argv, "-alsaadd"))
572 {
573 if (argc > 1)
574 alsa_adddev(argv[1]);
575 else goto usage;
576 argc -= 2; argv +=2;
577 }
578 /* obsolete flag for setting ALSA device number or name */
579 else if (!strcmp(*argv, "-alsadev"))
580 {
581 int devno = 0;
582 if (argv[1][0] >= '1' && argv[1][0] <= '9')
583 devno = 1 + 2 * (atoi(argv[1]) - 1);
584 else if (!strncmp(argv[1], "hw:", 3))
585 devno = 1 + 2 * atoi(argv[1]+3);
586 else if (!strncmp(argv[1], "plughw:", 7))
587 devno = 2 + 2 * atoi(argv[1]+7);
588 else goto usage;
589 sys_nsoundin = sys_nsoundout = 1;
590 sys_soundindevlist[0] = sys_soundoutdevlist[0] = devno;
591 sys_set_audio_api(API_ALSA);
592 argc -= 2; argv +=2;
593 }
594#endif
595#ifdef USEAPI_JACK
596 else if (!strcmp(*argv, "-jack"))
597 {
598 sys_set_audio_api(API_JACK);
599 argc--; argv++;
600 }
601#endif
602#ifdef USEAPI_PORTAUDIO
603 else if (!strcmp(*argv, "-pa") || !strcmp(*argv, "-portaudio")
604#ifdef MSW
605 || !strcmp(*argv, "-asio")
606#endif
607 )
608 {
609 sys_set_audio_api(API_PORTAUDIO);
610 sys_mmio = 0;
611 argc--; argv++;
612 }
613#endif
614#ifdef USEAPI_MMIO
615 else if (!strcmp(*argv, "-mmio"))
616 {
617 sys_set_audio_api(API_MMIO);
618 sys_mmio = 1;
619 argc--; argv++;
620 }
621#endif
622 else if (!strcmp(*argv, "-nomidiin"))
623 {
624 sys_nmidiin = 0;
625 argc--; argv++;
626 }
627 else if (!strcmp(*argv, "-nomidiout"))
628 {
629 sys_nmidiout = 0;
630 argc--; argv++;
631 }
632 else if (!strcmp(*argv, "-nomidi"))
633 {
634 sys_nmidiin = sys_nmidiout = 0;
635 argc--; argv++;
636 }
637 else if (!strcmp(*argv, "-midiindev"))
638 {
639 sys_parsedevlist(&sys_nmidiin, sys_midiindevlist, MAXMIDIINDEV,
640 argv[1]);
641 if (!sys_nmidiin)
642 goto usage;
643 argc -= 2; argv += 2;
644 }
645 else if (!strcmp(*argv, "-midioutdev"))
646 {
647 sys_parsedevlist(&sys_nmidiout, sys_midioutdevlist, MAXMIDIOUTDEV,
648 argv[1]);
649 if (!sys_nmidiout)
650 goto usage;
651 argc -= 2; argv += 2;
652 }
653 else if (!strcmp(*argv, "-mididev"))
654 {
655 sys_parsedevlist(&sys_nmidiin, sys_midiindevlist, MAXMIDIINDEV,
656 argv[1]);
657 sys_parsedevlist(&sys_nmidiout, sys_midioutdevlist, MAXMIDIOUTDEV,
658 argv[1]);
659 if (!sys_nmidiout)
660 goto usage;
661 argc -= 2; argv += 2;
662 }
663 else if (!strcmp(*argv, "-path"))
664 {
665 sys_addpath(argv[1]);
666 argc -= 2; argv += 2;
667 }
668 else if (!strcmp(*argv, "-helppath"))
669 {
670 sys_addhelppath(argv[1]);
671 argc -= 2; argv += 2;
672 }
673 else if (!strcmp(*argv, "-open") && argc > 1)
674 {
675 sys_openlist = namelist_append(sys_openlist, argv[1]);
676 argc -= 2; argv += 2;
677 }
678 else if (!strcmp(*argv, "-lib") && argc > 1)
679 {
680 sys_externlist = namelist_append(sys_externlist, argv[1]);
681 argc -= 2; argv += 2;
682 }
683 else if (!strcmp(*argv, "-font") && argc > 1)
684 {
685 sys_defaultfont = sys_nearestfontsize(atoi(argv[1]));
686 argc -= 2;
687 argv += 2;
688 }
689 else if (!strcmp(*argv, "-verbose"))
690 {
691 sys_verbose = 1;
692 argc--; argv++;
693 }
694 else if (!strcmp(*argv, "-version"))
695 {
696 sys_version = 1;
697 argc--; argv++;
698 }
699 else if (!strcmp(*argv, "-d") && argc > 1 &&
700 sscanf(argv[1], "%d", &sys_debuglevel) >= 1)
701 {
702 argc -= 2;
703 argv += 2;
704 }
705 else if (!strcmp(*argv, "-noloadbang"))
706 {
707 sys_noloadbang = 1;
708 argc--; argv++;
709 }
710 else if (!strcmp(*argv, "-nogui"))
711 {
712 sys_nogui = 1;
713 argc--; argv++;
714 }
715 else if (!strcmp(*argv, "-stdin"))
716 {
717 sys_stdin = 1;
718 argc--; argv++;
719 }
720 else if (!strcmp(*argv, "-guicmd") && argc > 1)
721 {
722 sys_guicmd = argv[1];
723 argc -= 2; argv += 2;
724 }
725 else if (!strcmp(*argv, "-send") && argc > 1)
726 {
727 sys_messagelist = namelist_append(sys_messagelist, argv[1]);
728 argc -= 2; argv += 2;
729 }
730 else if (!strcmp(*argv, "-listdev"))
731 {
732 sys_listdevs();
733 argc--; argv++;
734 }
735#ifdef UNIX
736 else if (!strcmp(*argv, "-rt") || !strcmp(*argv, "-realtime"))
737 {
738 sys_hipriority = 1;
739 argc--; argv++;
740 }
741 else if (!strcmp(*argv, "-nrt"))
742 {
743 sys_hipriority = 0;
744 argc--; argv++;
745 }
746#endif
747 else if (!strcmp(*argv, "-soundindev") ||
748 !strcmp(*argv, "-audioindev"))
749 { /* IOhannes */
750 sys_parsedevlist(&sys_nsoundin, sys_soundindevlist,
751 MAXAUDIOINDEV, argv[1]);
752 if (!sys_nsoundin)
753 goto usage;
754 argc -= 2; argv += 2;
755 }
756 else if (!strcmp(*argv, "-soundoutdev") ||
757 !strcmp(*argv, "-audiooutdev"))
758 { /* IOhannes */
759 sys_parsedevlist(&sys_nsoundout, sys_soundoutdevlist,
760 MAXAUDIOOUTDEV, argv[1]);
761 if (!sys_nsoundout)
762 goto usage;
763 argc -= 2; argv += 2;
764 }
765 else if (!strcmp(*argv, "-sounddev") || !strcmp(*argv, "-audiodev"))
766 {
767 sys_parsedevlist(&sys_nsoundin, sys_soundindevlist,
768 MAXAUDIOINDEV, argv[1]);
769 sys_parsedevlist(&sys_nsoundout, sys_soundoutdevlist,
770 MAXAUDIOOUTDEV, argv[1]);
771 if (!sys_nsoundout)
772 goto usage;
773 argc -= 2; argv += 2;
774 }
775 else
776 {
777 unsigned int i;
778 usage:
779 for (i = 0; i < sizeof(usagemessage)/sizeof(*usagemessage); i++)
780 fprintf(stderr, "%s", usagemessage[i]);
781 return (1);
782 }
783 }
784 if (!sys_defaultfont)
785 sys_defaultfont = DEFAULTFONT;
786 for (; argc > 0; argc--, argv++)
787 sys_openlist = namelist_append(sys_openlist, *argv);
788
789
790 return (0);
791}
792
793int sys_getblksize(void)
794{
795 return (DEFDACBLKSIZE);
796}
797
798 /* stuff to do, once, after calling sys_argparse() -- which may itself
799 be called twice because of the .pdrc hack. */
800static void sys_afterargparse(void)
801{
802 char sbuf[MAXPDSTRING];
803 int i;
804 /* add "extra" library to path */
805 strncpy(sbuf, sys_libdir->s_name, MAXPDSTRING-30);
806 sbuf[MAXPDSTRING-30] = 0;
807 strcat(sbuf, "/extra");
808 sys_addpath(sbuf);
809 strncpy(sbuf, sys_libdir->s_name, MAXPDSTRING-30);
810 sbuf[MAXPDSTRING-30] = 0;
811 strcat(sbuf, "/intern");
812 sys_addpath(sbuf);
813 /* add "doc/5.reference" library to helppath */
814 strncpy(sbuf, sys_libdir->s_name, MAXPDSTRING-30);
815 sbuf[MAXPDSTRING-30] = 0;
816 strcat(sbuf, "/doc/5.reference");
817 sys_addhelppath(sbuf);
818 /* correct to make audio and MIDI device lists zero based. On
819 MMIO, however, "1" really means the second device (the first one
820 is "mapper" which is was not included when the command args were
821 set up, so we leave it that way for compatibility. */
822 if (!sys_mmio)
823 {
824 for (i = 0; i < sys_nsoundin; i++)
825 sys_soundindevlist[i]--;
826 for (i = 0; i < sys_nsoundout; i++)
827 sys_soundoutdevlist[i]--;
828 }
829 for (i = 0; i < sys_nmidiin; i++)
830 sys_midiindevlist[i]--;
831 for (i = 0; i < sys_nmidiout; i++)
832 sys_midioutdevlist[i]--;
833}
834
835static void sys_addreferencepath(void)
836{
837 char sbuf[MAXPDSTRING];
838}
839