*** main.c Thu Mar 8 18:29:23 1990 --- main.c.new Thu Mar 8 18:29:24 1990 *************** *** 18,23 **** --- 18,24 ---- int msglevel = 7; char *term, *getenv(); char *outfile; + int outfd; /* sound output file descriptor, if "-N -" given */ extern char errmsg[]; main(argc,argv) *************** *** 61,66 **** --- 62,76 ---- break; case 'N': outfile = s; /* soundfile name */ while (*++s); + if (strcmp(outfile, "-") == 0) { + /* Do it now before any output */ + /* Divert all future writes to fd1 to + * stderr; send sound output to the + * stream inherited as fd 1 */ + outfd = dup(1); + if (outfd < 0) die("too many open files"); + dup2(2,1); /* point stdout at stderr */ + } break; default: fprintf(stderr,"illegal char %c\n",c); die("unknown orch flag"); *** soundio.c Thu Mar 8 18:29:26 1990 --- soundio.c.new Thu Mar 8 18:29:27 1990 *************** *** 27,37 **** register char *sfname, *wherecolon; extern char *outfile, *malloc(); ! sfname = buildsfname((outfile != NULL) ? outfile : DEFAULT_NAME); ! if (index(sfname,':') != NULL) /* if : in name, */ ! sfd = rsfopen(sfname,'>'); /* open remote file */ ! else if ((sfd = open(sfname,O_TRUNC|O_CREAT|O_RDWR,PMODE)) < 0) ! dies("sfinit: cannot open %s", sfname); if ((outbuf = malloc((unsigned) BUFSIZE)) == NULL) die("sfinit: cannot allocate outbuf"); #ifdef SFIRCAM /* for soundfiles w. headers */ --- 27,44 ---- register char *sfname, *wherecolon; extern char *outfile, *malloc(); ! if (outfile != NULL && strcmp(outfile, "-") == 0) { ! extern int outfd; ! /* Send sound output to what used to be stdout */ ! sfd = outfd; ! sfname = "stdout"; ! } else { ! sfname = buildsfname((outfile != NULL) ? outfile : DEFAULT_NAME); ! if (index(sfname,':') != NULL) /* if : in name, */ ! sfd = rsfopen(sfname,'>'); /* open remote file */ ! else if ((sfd = open(sfname,O_TRUNC|O_CREAT|O_RDWR,PMODE)) < 0) ! dies("sfinit: cannot open %s", sfname); ! } if ((outbuf = malloc((unsigned) BUFSIZE)) == NULL) die("sfinit: cannot allocate outbuf"); #ifdef SFIRCAM /* for soundfiles w. headers */