Patch file to update midirecv.c, diskin.c and wave.c from 
Dave Phillips Csound source release 3.482 of 1998 June 4
so it compiles and runs under glibc.  Note that the 
MIDI receive code has not been tested!

Robin Whittle   http://www.firstpr.com.au/csound/

1998 June 5



--- midirecv-pre-glibc.c	Thu Jun  4 10:27:56 1998
+++ midirecv.c	Fri Jun  5 00:44:35 1998
@@ -10,11 +10,35 @@
  *
  */
 
+/* Modified 1998 June 5 by Damien Miller & Robin Whittle    
+ * to compile under glibc, rather than the earlier C library.  
+ * Took out #include <bsd/sgtty.h> and used termios.h and 
+ * errno.h instead.  New code in MidiOpen.               
+ * Changes flagged with the text "glibc" and original code    
+ * is included in comments.   
+ * 
+ * Damien had been reading W. Richard Steven's "Advanced  
+ * Programming for the Unix Environment" and whipped up these 
+ * changes in a few minutes.                                  
+ *          
+ * Note!  We haven't tested this!!          
+ *
+ * Robin Whittle rw@firstpr.com.au          
+ */
+
+
 #include "cs.h"
 #include "midiops.h"
 #include "oload.h"
 #include <sys/time.h>
-#include <bsd/sgtty.h>
+
+					/* glibc changes.  Was:
+					 *
+					 * #include <bsd/sgtty.h>
+					 */
+#include <termios.h>
+#include <errno.h>
+
 
 #define INBAUD    EXTB
 #define MBUFSIZ   1024
@@ -22,7 +46,11 @@
 #define OFF       0
 #define MAXLONG   0x7FFFFFFFL
 
-static struct sgttyb tty;
+					/* glibc changes.  Was:
+					 *
+					 * static struct sgttyb tty;
+					 */
+static struct termios tty;
 
 static u_char *mbuf, *bufp, *bufend, *endatp;
 static u_char *sexbuf, *sexp, *sexend;
@@ -76,10 +104,22 @@
 
             if ((rtfd = open(O.Midiname, O_RDONLY | O_NDELAY, 0)) < 0)
                 dies("cannot open %s", O.Midiname);
-            ioctl(rtfd, TIOCGETP, &tty);           /* for other machines      */
-            tty.sg_ispeed = INBAUD;                /*   set baud rate         */
-            tty.sg_flags = RAW;                    /*   and no I/O processing */
-            ioctl(rtfd, TIOCSETP, &tty);
+
+		/* glibc changes.  Was:
+		 *   ioctl(rtfd, TIOCGETP, &tty);    for other machines      
+           	 *   tty.sg_ispeed = INBAUD;         set baud rate         
+		 *   tty.sg_flags = RAW;             and no I/O processing 
+		 *   ioctl(rtfd, TIOCSETP, &tty);
+		 */
+
+		if (tcgetattr(rtfd, &tty) < 0)
+			die("MIDI receive: Can't get termios info.");
+		cfmakeraw(&tty);
+		if (cfsetispeed(&tty, INBAUD) < 0)
+			die("MIDI receive: Can't set input baud rate.");
+		if (tcsetattr(rtfd, TCSANOW, &tty) < 0)
+			die("MIDI receive: Can't set termios.");
+
         }
 }
 



--- diskin-pre-glibc.c	Mon Apr  6 01:45:00 1998
+++ diskin.c	Fri Jun  5 00:45:16 1998
@@ -2,6 +2,12 @@
 /*							 	*/
 /*	diskin	-	a new soundin that shifts pitch		*/
 /*		based on the old soundin code			*/
+
+/* Modified 1998 June 5 by Damien Miller & Robin Whittle        */
+/* to compile under glibc, rather than the earlier C library.   */
+/* One change only - search for "glibc"                         */
+/* diskin.c and wave.c both used tell()                         */
+
 #include "cs.h"
 #include "soundio.h"
 #include "diskin.h"
@@ -205,7 +211,13 @@
 /*****   this next section looked kinda iffy, so rewrote it*********-matt*/
   {
     long nbytes = (long)(*p->iskptim * p->sr) * p->sampframsiz;
-    p->firstsampinfile = tell(sinfd); /* this might not work for all header types??? */
+    
+ 					/* The line below changed for 
+					 * compatibility with glibc.  
+					 * Previously "tell(sinfd)"
+				 	 */ 
+
+    p->firstsampinfile = lseek(sinfd, 0, SEEK_CUR); /* this might not work for all header types??? */
             	 	
     if ((p->audrem > 0) && (nbytes > p->audrem)) {
       warning("skip time larger than audio data,substituting zero.");





--- wave-pre-glibc.c	Sat Feb 28 02:55:46 1998
+++ wave.c	Fri Jun  5 00:10:29 1998
@@ -1,4 +1,10 @@
 #include        "cs.h"                            /*                WAVE.C   */
+
+/* Modified 1998 June 5 by Damien Miller & Robin Whittle        */
+/* to compile under glibc, rather than the earlier C library.   */
+/* One change only - search for "glibc"                         */
+/* diskin.c and wave.c both used tell()                         */
+
 #include        "soundio.h"
 #include        "wave.h"
 #include        "sfheader.h"
@@ -136,7 +142,14 @@
 void wavReWriteHdr(int fd,        /* Write proper sizes into WAV header  */
                    long datasize) /*        called before closing file   */
 {                                 /*        & optionally under -R        */
-    long  endpos = tell(fd);
+
+ 					/* The line below changed for 
+					 * compatibility with glibc.  
+					 * Previously "tell(fd)"
+				 	 */ 
+
+    long  endpos = lseek(fd, 0, SEEK_CUR);
+
     /* RWD.2.98: all changed to deal with variable headersize */
     long length = lenlong(endpos-8);
     long size = lenlong(datasize);



