shithub: sox

Download patch

ref: 2930fcf465fb4bd6e3b0be37efde952492cc6d17
parent: 834fda64b93fb0e96c2c4bc7b4263cdbe4b5dbf3
author: cbagwell <cbagwell>
date: Mon Nov 5 12:16:36 EST 2001

Changes to get compiling on Solaris

--- a/src/8svx.c
+++ b/src/8svx.c
@@ -16,7 +16,7 @@
 
 /* Private data used by writer */
 typedef struct svxpriv {
-	u_int32_t nsamples;
+	uint32_t nsamples;
 	FILE *ch[4];
 }*svx_t;
 
@@ -33,10 +33,10 @@
 	char buf[12];
 	char *chunk_buf;
  
-	u_int32_t totalsize;
-	u_int32_t chunksize;
+	uint32_t totalsize;
+	uint32_t chunksize;
 
-	u_int32_t channels;
+	uint32_t channels;
 	unsigned short rate;
 	int i;
 
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -86,18 +86,18 @@
 {
 	aiff_t aiff = (aiff_t ) ft->priv;
 	char buf[5];
-	u_int32_t totalsize;
-	u_int32_t chunksize;
+	uint32_t totalsize;
+	uint32_t chunksize;
 	unsigned short channels = 0;
-	u_int32_t frames;
+	uint32_t frames;
 	unsigned short bits = 0;
 	double rate = 0.0;
-	u_int32_t offset = 0;
-	u_int32_t blocksize = 0;
+	uint32_t offset = 0;
+	uint32_t blocksize = 0;
 	int foundcomm = 0, foundmark = 0, foundinstr = 0;
 	struct mark {
 		unsigned short id;
-		u_int32_t position;
+		uint32_t position;
 		char name[40]; 
 	} marks[32];
 	unsigned short looptype;
@@ -110,9 +110,9 @@
 	char *copyright;
 	char *nametext;
 
-	u_int8_t trash8;
-	u_int16_t trash16;
-	u_int32_t trash32;
+	uint8_t trash8;
+	uint16_t trash16;
+	uint32_t trash32;
 
 	int rc;
 
@@ -490,7 +490,7 @@
 /* Process a text chunk, allocate memory, display it if verbose and return */
 static int textChunk(char **text, char *chunkDescription, ft_t ft) 
 {
-  u_int32_t chunksize;
+  uint32_t chunksize;
   st_readdw(ft, &chunksize);
   /* allocate enough memory to hold the text including a terminating \0 */
   *text = (char *) malloc((size_t) chunksize + 1);
@@ -524,9 +524,9 @@
  */
 static int commentChunk(char **text, char *chunkDescription, ft_t ft)
 {
-  u_int32_t chunksize;
+  uint32_t chunksize;
   unsigned short numComments;
-  u_int32_t timeStamp;
+  uint32_t timeStamp;
   unsigned short markerId;
   unsigned short totalCommentLength = 0;
   unsigned int commentIndex;
@@ -588,7 +588,7 @@
 int st_aiffstopread(ft_t ft) 
 {
 	char buf[5];
-	u_int32_t chunksize;
+	uint32_t chunksize;
 	ULONG trash;
 
 	if (!ft->seekable)
--- a/src/au.c
+++ b/src/au.c
@@ -118,12 +118,12 @@
 	   Any extra bytes (totalling hdr_size - 24) are an
 	   "info" field of unspecified nature, usually a string.
 	   By convention the header size is a multiple of 4. */
-	u_int32_t magic;
-	u_int32_t hdr_size;
-	u_int32_t data_size;
-	u_int32_t encoding;
-	u_int32_t sample_rate;
-	u_int32_t channels;
+	uint32_t magic;
+	uint32_t hdr_size;
+	uint32_t data_size;
+	uint32_t encoding;
+	uint32_t sample_rate;
+	uint32_t channels;
 
 	register int i;
 	char *buf;
--- a/src/avr.c
+++ b/src/avr.c
@@ -38,11 +38,11 @@
   unsigned short midi; /* 0xffff = no MIDI note assigned,
 			  0xffXX = single key note assignment
 			  0xLLHH = key split, low/hi note */
-  u_int32_t rate;       /* sample frequency in hertz */
-  u_int32_t size;       /* sample length in bytes or words (see rez) */
-  u_int32_t lbeg;       /* offset to start of loop in bytes or words.
+  uint32_t rate;       /* sample frequency in hertz */
+  uint32_t size;       /* sample length in bytes or words (see rez) */
+  uint32_t lbeg;       /* offset to start of loop in bytes or words.
 			  set to zero if unused. */
-  u_int32_t lend;       /* offset to end of loop in bytes or words.
+  uint32_t lend;       /* offset to end of loop in bytes or words.
 			  set to sample length if unused. */
   unsigned short res1; /* Reserved, MIDI keyboard split */
   unsigned short res2; /* Reserved, sample compression */
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -44,7 +44,7 @@
 	LONG cksum;
 	int dictentry;
 	int nrbits;
-	u_int32_t current;
+	uint32_t current;
 	short sample;
 };
 
@@ -55,8 +55,8 @@
 	struct readpriv *p = (struct readpriv *) ft->priv;
 	int i;
 	char buf[5];
-	u_int32_t datasize, rsrcsize;
-	u_int32_t huffcount, checksum, compresstype, divisor;
+	uint32_t datasize, rsrcsize;
+	uint32_t huffcount, checksum, compresstype, divisor;
 	unsigned short dictsize;
 	int rc;
 
--- a/src/maud.c
+++ b/src/maud.c
@@ -29,7 +29,7 @@
 
 /* Private data for MAUD file */
 struct maudstuff { /* max. 100 bytes!!!! */
-	u_int32_t nsamples;
+	uint32_t nsamples;
 };
 
 static void maudwriteheader(ft_t);
@@ -49,12 +49,12 @@
 	char *chunk_buf;
 	
 	unsigned short bitpersam;
-	u_int32_t nom;
+	uint32_t nom;
 	unsigned short denom;
 	unsigned short chaninf;
 	
-	u_int32_t chunksize;
-	u_int32_t trash32;
+	uint32_t chunksize;
+	uint32_t trash32;
 	int rc;
 
 	/* Needed for rawread() */
--- a/src/misc.c
+++ b/src/misc.c
@@ -2,8 +2,8 @@
  * July 5, 1991
  * Copyright 1991 Lance Norskog And Sundry Contributors
  * This source code is freely redistributable and may be used for
- * any purpose.  This copyright notice must be maintained. 
- * Lance Norskog And Sundry Contributors are not responsible for 
+ * any purpose.  This copyright notice must be maintained.
+ * Lance Norskog And Sundry Contributors are not responsible for
  * the consequences of using this software.
  */
 
@@ -30,25 +30,25 @@
 #endif
 
 const char *st_sizes_str[] = {
-	"NONSENSE!",
-	"bytes",
-	"shorts",
-	"NONSENSE",
-	"longs",
-	"32-bit floats",
-	"64-bit floats",
-	"IEEE floats",
+        "NONSENSE!",
+        "bytes",
+        "shorts",
+        "NONSENSE",
+        "longs",
+        "32-bit floats",
+        "64-bit floats",
+        "IEEE floats",
 };
 
 const char *st_encodings_str[] = {
-	"NONSENSE!",
-	"unsigned",
-	"signed (2's complement)",
-	"u-law",
-	"a-law",
-	"adpcm",
-	"ima_adpcm",
-	"gsm",
+        "NONSENSE!",
+        "unsigned",
+        "signed (2's complement)",
+        "u-law",
+        "a-law",
+        "adpcm",
+        "ima_adpcm",
+        "gsm",
 };
 
 static const char readerr[] = "Premature EOF while reading sample file.";
@@ -77,8 +77,8 @@
 /* Read and write known datatypes in "machine format".  Swap if indicated.
  * They all return ST_EOF on error and ST_SUCCESS on success.
  */
-/* Read n-char string (and possibly null-terminating). 
- * Stop reading and null-terminate string if either a 0 or \n is reached. 
+/* Read n-char string (and possibly null-terminating).
+ * Stop reading and null-terminate string if either a 0 or \n is reached.
  */
 int st_reads(ft_t ft, char *c, st_ssize_t len)
 {
@@ -88,19 +88,19 @@
     sc = c;
     do
     {
-	if (fread(&in, 1, 1, ft->fp) != 1)
-	{
-	    *sc = 0;
-		st_fail_errno(ft,errno,readerr);
-	    return (ST_EOF);
-	}
-	if (in == 0 || in == '\n')
-	{
-	    break;
-	}
+        if (fread(&in, 1, 1, ft->fp) != 1)
+        {
+            *sc = 0;
+                st_fail_errno(ft,errno,readerr);
+            return (ST_EOF);
+        }
+        if (in == 0 || in == '\n')
+        {
+            break;
+        }
 
-	*sc = in;
-	sc++;
+        *sc = in;
+        sc++;
     } while (sc - c < len);
     *sc = 0;
     return(ST_SUCCESS);
@@ -109,147 +109,147 @@
 /* Write null-terminated string (without \0). */
 int st_writes(ft_t ft, char *c)
 {
-	if (fwrite(c, 1, strlen(c), ft->fp) != strlen(c))
-	{
-		st_fail_errno(ft,errno,writerr);
-		return(ST_EOF);
-	}
-	return(ST_SUCCESS);
+        if (fwrite(c, 1, strlen(c), ft->fp) != strlen(c))
+        {
+                st_fail_errno(ft,errno,writerr);
+                return(ST_EOF);
+        }
+        return(ST_SUCCESS);
 }
 
 /* Read byte. */
-int st_readb(ft_t ft, u_int8_t *ub)
+int st_readb(ft_t ft, uint8_t *ub)
 {
-	if (fread(ub, 1, 1, ft->fp) != 1)
-	{
-		st_fail_errno(ft,errno,readerr);
-	    return(ST_EOF);
-	}
-	return ST_SUCCESS;
+        if (fread(ub, 1, 1, ft->fp) != 1)
+        {
+                st_fail_errno(ft,errno,readerr);
+            return(ST_EOF);
+        }
+        return ST_SUCCESS;
 }
 
 /* Write byte. */
-int st_writeb(ft_t ft, u_int8_t ub)
+int st_writeb(ft_t ft, uint8_t ub)
 {
-	if (fwrite(&ub, 1, 1, ft->fp) != 1)
-	{
-		st_fail_errno(ft,errno,writerr);
-		return(ST_EOF);
-	}
-	return(ST_SUCCESS);
+        if (fwrite(&ub, 1, 1, ft->fp) != 1)
+        {
+                st_fail_errno(ft,errno,writerr);
+                return(ST_EOF);
+        }
+        return(ST_SUCCESS);
 }
 
 /* Read word. */
-int st_readw(ft_t ft, u_int16_t *uw)
+int st_readw(ft_t ft, uint16_t *uw)
 {
-	if (fread(uw, 2, 1, ft->fp) != 1)
-	{
-		st_fail_errno(ft,errno,readerr);
-	    return (ST_EOF);
-	}
-	if (ft->swap)
-		*uw = st_swapw(*uw);
-	return ST_SUCCESS;
+        if (fread(uw, 2, 1, ft->fp) != 1)
+        {
+                st_fail_errno(ft,errno,readerr);
+            return (ST_EOF);
+        }
+        if (ft->swap)
+                *uw = st_swapw(*uw);
+        return ST_SUCCESS;
 }
 
 /* Write word. */
-int st_writew(ft_t ft, u_int16_t uw)
+int st_writew(ft_t ft, uint16_t uw)
 {
-	if (ft->swap)
-		uw = st_swapw(uw);
-	if (fwrite(&uw, 2, 1, ft->fp) != 1)
-	{
-		st_fail_errno(ft,errno,writerr);
-		return (ST_EOF);
-	}
-	return(ST_SUCCESS);
+        if (ft->swap)
+                uw = st_swapw(uw);
+        if (fwrite(&uw, 2, 1, ft->fp) != 1)
+        {
+                st_fail_errno(ft,errno,writerr);
+                return (ST_EOF);
+        }
+        return(ST_SUCCESS);
 }
 
 /* Read double word. */
-int st_readdw(ft_t ft, u_int32_t *udw)
+int st_readdw(ft_t ft, uint32_t *udw)
 {
-	if (fread(udw, 4, 1, ft->fp) != 1)
-	{
-		st_fail_errno(ft,errno,readerr);
-	    return (ST_EOF);
-	}
-	if (ft->swap)
-		*udw = st_swapl(*udw);
-	return ST_SUCCESS;
+        if (fread(udw, 4, 1, ft->fp) != 1)
+        {
+                st_fail_errno(ft,errno,readerr);
+            return (ST_EOF);
+        }
+        if (ft->swap)
+                *udw = st_swapdw(*udw);
+        return ST_SUCCESS;
 }
 
 /* Write double word. */
-int st_writedw(ft_t ft, u_int32_t udw)
+int st_writedw(ft_t ft, uint32_t udw)
 {
-	if (ft->swap)
-		udw = st_swapl(udw);
-	if (fwrite(&udw, 4, 1, ft->fp) != 1)
-	{
-		st_fail_errno(ft,errno,writerr);
-		return (ST_EOF);
-	}
-	return(ST_SUCCESS);
+        if (ft->swap)
+                udw = st_swapdw(udw);
+        if (fwrite(&udw, 4, 1, ft->fp) != 1)
+        {
+                st_fail_errno(ft,errno,writerr);
+                return (ST_EOF);
+        }
+        return(ST_SUCCESS);
 }
 
 /* Read float. */
 int st_readf(ft_t ft, float *f)
 {
-	if (fread(f, sizeof(float), 1, ft->fp) != 1)
-	{
-	    return(ST_EOF);
-	}
-	if (ft->swap)
-		*f = st_swapf(*f);
-	return ST_SUCCESS;
+        if (fread(f, sizeof(float), 1, ft->fp) != 1)
+        {
+            return(ST_EOF);
+        }
+        if (ft->swap)
+                *f = st_swapf(*f);
+        return ST_SUCCESS;
 }
 
 /* Write float. */
 int st_writef(ft_t ft, float f)
 {
-	float t = f;
+        float t = f;
 
-	if (ft->swap)
-		t = st_swapf(t);
-	if (fwrite(&t, sizeof(float), 1, ft->fp) != 1)
-	{
-		st_fail_errno(ft,errno,writerr);
-		return (ST_EOF);
-	}
-	return (ST_SUCCESS);
+        if (ft->swap)
+                t = st_swapf(t);
+        if (fwrite(&t, sizeof(float), 1, ft->fp) != 1)
+        {
+                st_fail_errno(ft,errno,writerr);
+                return (ST_EOF);
+        }
+        return (ST_SUCCESS);
 }
 
 /* Read double. */
 int st_readdf(ft_t ft, double *d)
 {
-	if (fread(d, sizeof(double), 1, ft->fp) != 1)
-	{
-	    return(ST_EOF);
-	}
-	if (ft->swap)
-		*d = st_swapd(*d);
-	return ST_SUCCESS;
+        if (fread(d, sizeof(double), 1, ft->fp) != 1)
+        {
+            return(ST_EOF);
+        }
+        if (ft->swap)
+                *d = st_swapd(*d);
+        return ST_SUCCESS;
 }
 
 /* Write double. */
 int st_writedf(ft_t ft, double d)
 {
-	if (ft->swap)
-		d = st_swapd(d);
-	if (fwrite(&d, sizeof(double), 1, ft->fp) != 1)
-	{
-		st_fail_errno(ft,errno,writerr);
-		return (ST_EOF);
-	}
-	return (ST_SUCCESS);
+        if (ft->swap)
+                d = st_swapd(d);
+        if (fwrite(&d, sizeof(double), 1, ft->fp) != 1)
+        {
+                st_fail_errno(ft,errno,writerr);
+                return (ST_EOF);
+        }
+        return (ST_SUCCESS);
 }
 
 /* generic swap routine. Swap l and place in to f (datatype length = n) */
 void st_swapb(char *l, char *f, int n)
-{    
+{
     register int i;
 
     for (i= 0; i< n; i++)
-	f[i]= l[n-i-1];
+        f[i]= l[n-i-1];
 }
 
 
@@ -256,12 +256,12 @@
 /* Byte swappers, use libc optimized macro's if possible */
 #ifndef HAVE_BYTESWAP_H
 
-u_int16_t st_swapw(u_int16_t uw)
+uint16_t st_swapw(uint16_t uw)
 {
     return ((uw >> 8) | (uw << 8)) & 0xffff;
 }
 
-u_int32_t st_swapdw(u_int32_t udw)
+uint32_t st_swapdw(uint32_t udw)
 {
     return (udw >> 24) | ((udw >> 8) & 0xff00) | ((udw << 8) & 0xff0000L) | (udw << 24);
 }
@@ -270,8 +270,8 @@
 float st_swapf(float f)
 {
     union {
-	u_int32_t dw;
-	float f;
+        uint32_t dw;
+        float f;
     } u;
 
     u.f= f;
@@ -299,12 +299,12 @@
 int st_effect_nothing_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp) { *osamp = 0; return(ST_SUCCESS); }
 
 /* here for linear interp.  might be useful for other things */
-st_sample_t st_gcd(st_sample_t a, st_sample_t b) 
+st_sample_t st_gcd(st_sample_t a, st_sample_t b)
 {
-	if (b == 0)
-		return a;
-	else
-		return st_gcd(b, a % b);
+        if (b == 0)
+                return a;
+        else
+                return st_gcd(b, a % b);
 }
 
 st_sample_t st_lcm(st_sample_t a, st_sample_t b)
@@ -314,7 +314,7 @@
 }
 
 #ifndef HAVE_RAND
-/* 
+/*
  * Portable random generator as defined by ANSI C Standard.
  * Don't ask me why not all C libraries include it.
  */
@@ -326,7 +326,7 @@
     return ((unsigned int)(rand_seed/65536L) % 32768L);
 }
 
-void srand(unsigned int seed) 
+void srand(unsigned int seed)
 {
     rand_seed = seed;
 }
@@ -343,7 +343,7 @@
 st_sample_t st_clip24(st_sample_t l)
 {
     if (l >= ((st_sample_t)1 << 23))
-	return ((st_sample_t)1 << 23) - 1;
+        return ((st_sample_t)1 << 23) - 1;
     else if (l <= -((st_sample_t)1 << 23))
         return -((st_sample_t)1 << 23) + 1;
     else
@@ -360,8 +360,8 @@
 
     offset = max - depth;
     for (i = 0; i < len; i++) {
-	val = sin((double)i/(double)len * 2.0 * M_PI);
-	buf[i] = (int) ((1.0 + val) * depth / 2.0);
+        val = sin((double)i/(double)len * 2.0 * M_PI);
+        buf[i] = (int) ((1.0 + val) * depth / 2.0);
     }
 }
 
@@ -373,12 +373,12 @@
 
     offset = max - 2 * depth;
     for (i = 0; i < len / 2; i++) {
-	val = i * 2.0 / len;
-	buf[i] = offset + (int) (val * 2.0 * (double)depth);
+        val = i * 2.0 / len;
+        buf[i] = offset + (int) (val * 2.0 * (double)depth);
     }
     for (i = len / 2; i < len ; i++) {
-	val = (len - i) * 2.0 / len;
-	buf[i] = offset + (int) (val * 2.0 * (double)depth);
+        val = (len - i) * 2.0 / len;
+        buf[i] = offset + (int) (val * 2.0 * (double)depth);
     }
 }
 
@@ -386,71 +386,71 @@
 {
     static char versionstr[20];
 
-    sprintf(versionstr, "Version %d.%d.%d", 
-	    (ST_LIB_VERSION_CODE & 0xff0000) >> 16, 
-	    (ST_LIB_VERSION_CODE & 0x00ff00) >> 8,
-	    (ST_LIB_VERSION_CODE & 0x0000ff));
+    sprintf(versionstr, "Version %d.%d.%d",
+            (ST_LIB_VERSION_CODE & 0xff0000) >> 16,
+            (ST_LIB_VERSION_CODE & 0x00ff00) >> 8,
+            (ST_LIB_VERSION_CODE & 0x0000ff));
     return(versionstr);
 }
 
 
-#ifndef	HAVE_STRERROR
+#ifndef HAVE_STRERROR
 /* strerror function */
 char *strerror(int errcode)
 {
-	static char  nomesg[30];
-	extern int sys_nerr;
-	extern char *sys_errlist[];
+        static char  nomesg[30];
+        extern int sys_nerr;
+        extern char *sys_errlist[];
 
-	if (errcode < sys_nerr)
-		return (sys_errlist[errcode]);
-	else
-	{
-		sprintf (nomesg, "Undocumented error %d", errcode);
-		return (nomesg);
-	}
+        if (errcode < sys_nerr)
+                return (sys_errlist[errcode]);
+        else
+        {
+                sprintf (nomesg, "Undocumented error %d", errcode);
+                return (nomesg);
+        }
 }
 #endif
 
 /* Sets file offset
- * offset in bytes 
+ * offset in bytes
  */
-int st_seek(ft_t ft, st_size_t offset, int whence) 
+int st_seek(ft_t ft, st_size_t offset, int whence)
 {
     if( ft->seekable == 0 ){
-	/* 
-	 * If a stream peel off chars else 
-	 * EPERM 	"Operation not permitted" 
-	 */
-	if(whence == SEEK_CUR ){
-	    if( offset < 0 ){
-		st_fail_errno(ft,ST_EINVAL,"Can't seek backwards in pipe");
-	    } else {
-		while ( offset > 0 && !feof(ft->fp) )
-		{
-		    getc(ft->fp);
-		    offset--;
-		}
-		if(offset)
-		    st_fail_errno(ft,ST_EOF,"offset past eof");
-		else 
-		    ft->st_errno = ST_SUCCESS;
-	    }
-	} else {
-	    st_fail_errno(ft,ST_EPERM,"File not seekable");
-	}
+        /*
+         * If a stream peel off chars else
+         * EPERM        "Operation not permitted"
+         */
+        if(whence == SEEK_CUR ){
+            if( offset < 0 ){
+                st_fail_errno(ft,ST_EINVAL,"Can't seek backwards in pipe");
+            } else {
+                while ( offset > 0 && !feof(ft->fp) )
+                {
+                    getc(ft->fp);
+                    offset--;
+                }
+                if(offset)
+                    st_fail_errno(ft,ST_EOF,"offset past eof");
+                else
+                    ft->st_errno = ST_SUCCESS;
+            }
+        } else {
+            st_fail_errno(ft,ST_EPERM,"File not seekable");
+        }
     } else {
-	if( fseek(ft->fp,offset,whence) == -1 )
-	    st_fail_errno(ft,errno,strerror(errno));
-	else
-	    ft->st_errno = ST_SUCCESS;
-    }	
+        if( fseek(ft->fp,offset,whence) == -1 )
+            st_fail_errno(ft,errno,strerror(errno));
+        else
+            ft->st_errno = ST_SUCCESS;
+    }
 
     /* Empty the st file buffer */
     if( ft->st_errno == ST_SUCCESS ){
-	ft->file.count = 0;
-	ft->file.pos = 0;
-	ft->file.eof = 0;
+        ft->file.count = 0;
+        ft->file.pos = 0;
+        ft->file.eof = 0;
     }
 
     return(ft->st_errno);
--- a/src/raw.c
+++ b/src/raw.c
@@ -2,8 +2,8 @@
  * July 5, 1991
  * Copyright 1991 Lance Norskog And Sundry Contributors
  * This source code is freely redistributable and may be used for
- * any purpose.  This copyright notice must be maintained. 
- * Lance Norskog And Sundry Contributors are not responsible for 
+ * any purpose.  This copyright notice must be maintained.
+ * Lance Norskog And Sundry Contributors are not responsible for
  * the consequences of using this software.
  */
 
@@ -15,7 +15,7 @@
 
 /*
  * Notes: most of the headerless formats set their handlers to raw
- * in their startread/write routines.  
+ * in their startread/write routines.
  *
  */
 
@@ -38,62 +38,62 @@
 
 static void rawdefaults(ft_t ft);
 
-int st_rawseek(ft_t ft, st_size_t offset) 
+int st_rawseek(ft_t ft, st_size_t offset)
 {
-	int sample_size = 0;
+        int sample_size = 0;
 
-	switch(ft->info.size) {
-		case ST_SIZE_BYTE:
-			sample_size = 1;
-		        break;
-		case ST_SIZE_WORD:
-			sample_size = 2;
-		        break;
-		case ST_SIZE_DWORD:
-			sample_size = 4;
-		        break;
-		case ST_SIZE_DDWORD:
-			sample_size = 8;
-		        break;
-		default:
-			st_fail_errno(ft,ST_ENOTSUP,"Can't seek this data size");
-			return(ft->st_errno);
-	}
+        switch(ft->info.size) {
+                case ST_SIZE_BYTE:
+                        sample_size = 1;
+                        break;
+                case ST_SIZE_WORD:
+                        sample_size = 2;
+                        break;
+                case ST_SIZE_DWORD:
+                        sample_size = 4;
+                        break;
+                case ST_SIZE_DDWORD:
+                        sample_size = 8;
+                        break;
+                default:
+                        st_fail_errno(ft,ST_ENOTSUP,"Can't seek this data size");
+                        return(ft->st_errno);
+        }
 
-	ft->st_errno = st_seek(ft,offset*sample_size,SEEK_SET);
+        ft->st_errno = st_seek(ft,offset*sample_size,SEEK_SET);
 
-	return(ft->st_errno);
+        return(ft->st_errno);
 }
 
-int st_rawstartread(ft_t ft) 
+int st_rawstartread(ft_t ft)
 {
-	ft->file.buf = malloc(BUFSIZ);
-	if (!ft->file.buf)
-	{
-	    st_fail_errno(ft,ST_ENOMEM,"Unable to alloc resources");
-	    return(ST_EOF);
-	}
-	ft->file.size = BUFSIZ;
-	ft->file.count = 0;
-	ft->file.pos = 0;
-	ft->file.eof = 0;
+        ft->file.buf = malloc(BUFSIZ);
+        if (!ft->file.buf)
+        {
+            st_fail_errno(ft,ST_ENOMEM,"Unable to alloc resources");
+            return(ST_EOF);
+        }
+        ft->file.size = BUFSIZ;
+        ft->file.count = 0;
+        ft->file.pos = 0;
+        ft->file.eof = 0;
 
-	return(ST_SUCCESS);
+        return(ST_SUCCESS);
 }
 
-int st_rawstartwrite(ft_t ft) 
+int st_rawstartwrite(ft_t ft)
 {
-	ft->file.buf = malloc(BUFSIZ);
-	if (!ft->file.buf)
-	{
-	    st_fail_errno(ft,ST_ENOMEM,"Unable to alloc resources");
-	    return(ST_EOF);
-	}
-	ft->file.size = BUFSIZ;
-	ft->file.pos = 0;
-	ft->file.eof = 0;
+        ft->file.buf = malloc(BUFSIZ);
+        if (!ft->file.buf)
+        {
+            st_fail_errno(ft,ST_ENOMEM,"Unable to alloc resources");
+            return(ST_EOF);
+        }
+        ft->file.size = BUFSIZ;
+        ft->file.pos = 0;
+        ft->file.eof = 0;
 
-	return(ST_SUCCESS);
+        return(ST_SUCCESS);
 }
 
 /* Util to reverse the n chars starting at p. */
@@ -100,28 +100,28 @@
 /* FIXME: This is already in misc.c */
 static void swapn(char *p, int n)
 {
-	char *q;
-	if (n>1) {
-		q = p+n-1;
-		while (q>p) {
-			char t = *q;
-			*q-- = *p;
-			*p++ = t;
-		}
-	}
-}
+        char *q;
+        if (n>1) {
+                q = p+n-1;
+                while (q>p) {
+                        char t = *q;
+                        *q-- = *p;
+                        *p++ = t;
+                }
+        }
+}
 
 void st_ub_copy_buf(LONG *buf1, char *buf2, ULONG len, char swap)
 {
     while (len)
     {
-	unsigned char datum;
+        unsigned char datum;
 
-	datum = *((unsigned char *)buf2);
+        datum = *((unsigned char *)buf2);
         buf2++;
 
-	*buf1++ = ST_UNSIGNED_BYTE_TO_SAMPLE(datum);
-	len--;
+        *buf1++ = ST_UNSIGNED_BYTE_TO_SAMPLE(datum);
+        len--;
     }
 }
 
@@ -129,13 +129,13 @@
 {
     while (len)
     {
-	unsigned char datum;
+        unsigned char datum;
 
-	datum = *((unsigned char *)buf2);
+        datum = *((unsigned char *)buf2);
         buf2++;
 
-	*buf1++ = ST_SIGNED_BYTE_TO_SAMPLE(datum);
-	len--;
+        *buf1++ = ST_SIGNED_BYTE_TO_SAMPLE(datum);
+        len--;
     }
 }
 
@@ -143,13 +143,13 @@
 {
     while (len)
     {
-	unsigned char datum;
+        unsigned char datum;
 
-	datum = *((unsigned char *)buf2);
+        datum = *((unsigned char *)buf2);
         buf2++;
 
-	*buf1++ = ST_ULAW_BYTE_TO_SAMPLE(datum);
-	len--;
+        *buf1++ = ST_ULAW_BYTE_TO_SAMPLE(datum);
+        len--;
     }
 }
 
@@ -157,13 +157,13 @@
 {
     while (len)
     {
-	unsigned char datum;
+        unsigned char datum;
 
-	datum = *((unsigned char *)buf2);
+        datum = *((unsigned char *)buf2);
         buf2++;
 
-	*buf1++ = ST_ALAW_BYTE_TO_SAMPLE(datum);
-	len--;
+        *buf1++ = ST_ALAW_BYTE_TO_SAMPLE(datum);
+        len--;
     }
 }
 
@@ -171,15 +171,15 @@
 {
     while (len)
     {
-	unsigned short datum;
+        unsigned short datum;
 
-	datum = *((unsigned short *)buf2);
+        datum = *((unsigned short *)buf2);
         buf2++; buf2++;
-	if (swap)
-	    datum = st_swapw(datum);
+        if (swap)
+            datum = st_swapw(datum);
 
-	*buf1++ = ST_UNSIGNED_WORD_TO_SAMPLE(datum);
-	len--;
+        *buf1++ = ST_UNSIGNED_WORD_TO_SAMPLE(datum);
+        len--;
     }
 }
 
@@ -187,15 +187,15 @@
 {
     while (len)
     {
-	unsigned short datum;
+        unsigned short datum;
 
-	datum = *((unsigned short *)buf2);
+        datum = *((unsigned short *)buf2);
         buf2++; buf2++;
-	if (swap)
-	    datum = st_swapw(datum);
+        if (swap)
+            datum = st_swapw(datum);
 
-	*buf1++ = ST_SIGNED_WORD_TO_SAMPLE(datum);
-	len--;
+        *buf1++ = ST_SIGNED_WORD_TO_SAMPLE(datum);
+        len--;
     }
 }
 
@@ -203,15 +203,15 @@
 {
     while (len)
     {
-	ULONG datum;
+        ULONG datum;
 
-	datum = *((ULONG *)buf2);
+        datum = *((ULONG *)buf2);
         buf2++; buf2++; buf2++; buf2++;
-	if (swap)
-	    datum = st_swapl(datum);
+        if (swap)
+            datum = st_swapdw(datum);
 
-	*buf1++ = ST_UNSIGNED_DWORD_TO_SAMPLE(datum);
-	len--;
+        *buf1++ = ST_UNSIGNED_DWORD_TO_SAMPLE(datum);
+        len--;
     }
 }
 
@@ -219,15 +219,15 @@
 {
     while (len)
     {
-	ULONG datum;
+        ULONG datum;
 
-	datum = *((ULONG *)buf2);
+        datum = *((ULONG *)buf2);
         buf2++; buf2++; buf2++; buf2++;
-	if (swap)
-	    datum = st_swapl(datum);
+        if (swap)
+            datum = st_swapdw(datum);
 
-	*buf1++ = ST_SIGNED_DWORD_TO_SAMPLE(datum);
-	len--;
+        *buf1++ = ST_SIGNED_DWORD_TO_SAMPLE(datum);
+        len--;
     }
 }
 
@@ -235,15 +235,15 @@
 {
     while (len)
     {
-	float datum;
+        float datum;
 
-	datum = *((float *)buf2);
+        datum = *((float *)buf2);
         buf2++; buf2++; buf2++; buf2++;
-	if (swap)
-	    datum = st_swapf(datum);
+        if (swap)
+            datum = st_swapf(datum);
 
-	*buf1++ = ST_FLOAT_DWORD_TO_SAMPLE(datum);
-	len--;
+        *buf1++ = ST_FLOAT_DWORD_TO_SAMPLE(datum);
+        len--;
     }
 }
 
@@ -251,16 +251,16 @@
 {
     while (len)
     {
-	double datum;
+        double datum;
 
-	datum = *((double *)buf2);
+        datum = *((double *)buf2);
         buf2++; buf2++; buf2++; buf2++;
         buf2++; buf2++; buf2++; buf2++;
-	if (swap)
-	    datum = st_swapd(datum);
+        if (swap)
+            datum = st_swapd(datum);
 
-	*buf1++ = ST_FLOAT_DDWORD_TO_SAMPLE(datum);
-	len--;
+        *buf1++ = ST_FLOAT_DDWORD_TO_SAMPLE(datum);
+        len--;
     }
 }
 
@@ -279,122 +279,122 @@
     int i;
 
     switch(size) {
-	case ST_SIZE_BYTE:
-	    switch(encoding)
-	    {
-		case ST_ENCODING_SIGN2:
-		    copy_buf = st_sb_copy_buf;
-		    break;
-		case ST_ENCODING_UNSIGNED:
-		    copy_buf = st_ub_copy_buf;
-		    break;
-		case ST_ENCODING_ULAW:
-		    copy_buf = st_ulaw_copy_buf;
-		    break;
-		case ST_ENCODING_ALAW:
-		    copy_buf = st_alaw_copy_buf;
-		    break;
-		default:
-		    st_fail_errno(ft,ST_EFMT,"Do not support this encoding for this data size");
-		    return(0);
-	    }
-	    break;
+        case ST_SIZE_BYTE:
+            switch(encoding)
+            {
+                case ST_ENCODING_SIGN2:
+                    copy_buf = st_sb_copy_buf;
+                    break;
+                case ST_ENCODING_UNSIGNED:
+                    copy_buf = st_ub_copy_buf;
+                    break;
+                case ST_ENCODING_ULAW:
+                    copy_buf = st_ulaw_copy_buf;
+                    break;
+                case ST_ENCODING_ALAW:
+                    copy_buf = st_alaw_copy_buf;
+                    break;
+                default:
+                    st_fail_errno(ft,ST_EFMT,"Do not support this encoding for this data size");
+                    return(0);
+            }
+            break;
 
-	case ST_SIZE_WORD:
-	    switch(encoding)
-	    {
-		case ST_ENCODING_SIGN2:
-		    copy_buf = st_sw_copy_buf;
-		    break;
-		case ST_ENCODING_UNSIGNED:
-		    copy_buf = st_uw_copy_buf;
-		    break;
-		default:
-		    st_fail_errno(ft,ST_EFMT,"Do not support this encoding for this data size");
-		    return(0);
-	    }
-	    break;
+        case ST_SIZE_WORD:
+            switch(encoding)
+            {
+                case ST_ENCODING_SIGN2:
+                    copy_buf = st_sw_copy_buf;
+                    break;
+                case ST_ENCODING_UNSIGNED:
+                    copy_buf = st_uw_copy_buf;
+                    break;
+                default:
+                    st_fail_errno(ft,ST_EFMT,"Do not support this encoding for this data size");
+                    return(0);
+            }
+            break;
 
-	case ST_SIZE_DWORD:
-	    switch(encoding)
-	    {
-		case ST_ENCODING_SIGN2:
-		    copy_buf = st_sl_copy_buf;
-		    break;
-		case ST_ENCODING_UNSIGNED:
-		    copy_buf = st_udw_copy_buf;
-		    break;
-		case ST_ENCODING_FLOAT:
-		    copy_buf = st_f32_copy_buf;
-		default:
-		    st_fail_errno(ft,ST_EFMT,"Do not support this encoding for this data size");
-		    return(0);
-	    }
-	    break;
+        case ST_SIZE_DWORD:
+            switch(encoding)
+            {
+                case ST_ENCODING_SIGN2:
+                    copy_buf = st_sl_copy_buf;
+                    break;
+                case ST_ENCODING_UNSIGNED:
+                    copy_buf = st_udw_copy_buf;
+                    break;
+                case ST_ENCODING_FLOAT:
+                    copy_buf = st_f32_copy_buf;
+                default:
+                    st_fail_errno(ft,ST_EFMT,"Do not support this encoding for this data size");
+                    return(0);
+            }
+            break;
 
-	case ST_SIZE_DDWORD:
-	    switch(encoding)
-	    {
-		case ST_ENCODING_FLOAT:
-		    copy_buf = st_f64_copy_buf;
-		    break;
-		default:
-		    st_fail_errno(ft,ST_EFMT,"Do not support this encoding for this data size");
-	    }
-	    break;
+        case ST_SIZE_DDWORD:
+            switch(encoding)
+            {
+                case ST_ENCODING_FLOAT:
+                    copy_buf = st_f64_copy_buf;
+                    break;
+                default:
+                    st_fail_errno(ft,ST_EFMT,"Do not support this encoding for this data size");
+            }
+            break;
 
-	default:
-	    st_fail_errno(ft,ST_EFMT,"Do not support this data size for this handler");
-	    return (0);
+        default:
+            st_fail_errno(ft,ST_EFMT,"Do not support this data size for this handler");
+            return (0);
     }
 
-    
+
     len = MIN(n,(ft->file.count-ft->file.pos)/size);
     if (len)
     {
-	copy_buf(p + done, ft->file.buf + ft->file.pos, len, ft->swap);
+        copy_buf(p + done, ft->file.buf + ft->file.pos, len, ft->swap);
         ft->file.pos += (len*size);
-	done += len;
+        done += len;
     }
 
     while (done < n)
     {
-	/* See if there is not enough data in buffer for any more reads
-	 * or if there is no data in the buffer at all.
-	 * If not then shift any remaining data down to the beginning
-	 * and attempt to fill up the rest of the buffer.  
-	 */
-	if (!ft->file.eof && (ft->file.count == 0 ||
-		              ft->file.pos >= (ft->file.count-size+1)))
-	{
-	    for (i = 0; i < (ft->file.count-ft->file.pos); i++)
-		ft->file.buf[i] = ft->file.buf[ft->file.pos+i];
+        /* See if there is not enough data in buffer for any more reads
+         * or if there is no data in the buffer at all.
+         * If not then shift any remaining data down to the beginning
+         * and attempt to fill up the rest of the buffer.
+         */
+        if (!ft->file.eof && (ft->file.count == 0 ||
+                              ft->file.pos >= (ft->file.count-size+1)))
+        {
+            for (i = 0; i < (ft->file.count-ft->file.pos); i++)
+                ft->file.buf[i] = ft->file.buf[ft->file.pos+i];
 
-	    i = ft->file.count-ft->file.pos;
-	    ft->file.pos = 0;
+            i = ft->file.count-ft->file.pos;
+            ft->file.pos = 0;
 
-	    ft->file.count = fread(ft->file.buf+i, 1, ft->file.size-i, ft->fp) ;
-	    if (ft->file.count == 0)
-	    {
-		ft->file.eof = 1;
-	    }
-	    ft->file.count += i;
-	}
+            ft->file.count = fread(ft->file.buf+i, 1, ft->file.size-i, ft->fp) ;
+            if (ft->file.count == 0)
+            {
+                ft->file.eof = 1;
+            }
+            ft->file.count += i;
+        }
 
         len = MIN(n - done,(ft->file.count-ft->file.pos)/size);
         if (len)
         {
-	    copy_buf(p + done, ft->file.buf + ft->file.pos, len, ft->swap);
+            copy_buf(p + done, ft->file.buf + ft->file.pos, len, ft->swap);
             ft->file.pos += (len*size);
-	    done += len;
+            done += len;
         }
-	if (ft->file.eof)
-	    break;
+        if (ft->file.eof)
+            break;
     }
     return done;
 }
 
-LONG st_rawread(ft, buf, nsamp) 
+LONG st_rawread(ft, buf, nsamp)
 ft_t ft;
 LONG *buf, nsamp;
 {
@@ -404,19 +404,19 @@
 int st_rawstopread(ft)
 ft_t ft;
 {
-	free(ft->file.buf);
+        free(ft->file.buf);
 
-	return(ST_SUCCESS);
+        return(ST_SUCCESS);
 }
 
 static void blockflush(ft)
 ft_t ft;
 {
-	if (fwrite(ft->file.buf, 1, ft->file.pos, ft->fp) != ft->file.pos)
-	{
-		st_fail_errno(ft,errno,"Error writing data to file");
-	}
-	ft->file.pos = 0;
+        if (fwrite(ft->file.buf, 1, ft->file.pos, ft->fp) != ft->file.pos)
+        {
+                st_fail_errno(ft,errno,"Error writing data to file");
+        }
+        ft->file.pos = 0;
 }
 
 static void blockputc(ft,c)
@@ -423,9 +423,9 @@
 ft_t ft;
 int c;
 {
-	if (ft->file.pos == ft->file.size) blockflush(ft);
-	*(ft->file.buf + ft->file.pos) = c;
-	ft->file.pos++;
+        if (ft->file.pos == ft->file.size) blockflush(ft);
+        *(ft->file.buf + ft->file.pos) = c;
+        ft->file.pos++;
 }
 
 static void blockw(p0, n, ft)
@@ -433,15 +433,15 @@
 int n;
 ft_t ft;
 {
-	if (ft->file.pos > ft->file.size-n) blockflush(ft);
-	memcpy(ft->file.buf + ft->file.pos, p0, n);
-	/* FIXME: Should be a version for every data type.  This
-	 * is because swap is an expensive operation.  We should
-	 * only swap the buffer after its full.
-	 */
-	if (ft->swap)
-		swapn(ft->file.buf + ft->file.pos, n);
-	ft->file.pos += n;
+        if (ft->file.pos > ft->file.size-n) blockflush(ft);
+        memcpy(ft->file.buf + ft->file.pos, p0, n);
+        /* FIXME: Should be a version for every data type.  This
+         * is because swap is an expensive operation.  We should
+         * only swap the buffer after its full.
+         */
+        if (ft->swap)
+                swapn(ft->file.buf + ft->file.pos, n);
+        ft->file.pos += n;
 }
 
 static LONG blockw_sw(ft, buf, nsamp)
@@ -448,172 +448,172 @@
 ft_t ft;
 LONG *buf, nsamp;
 {
-	short *top;
-	LONG save_nsamp = nsamp;
+        short *top;
+        LONG save_nsamp = nsamp;
 
-	top = (short*)(ft->file.buf + ft->file.size);
-	while (nsamp) {
-		short *p, *q;
-		p = (short*)(ft->file.buf + ft->file.pos);
-		if (p >= top) {
-			blockflush(ft);
-			continue;
-		}
-		q = p+nsamp; if (q>top) q = top;
-		ft->file.pos += (q-p)*sizeof(short);
-		nsamp -= (q-p);
-		if (ft->swap) {
-#	ifdef MAXWSPEED
-			q -= 4;
-			while (p<q) {
-				p[0] = st_swapw(buf[0] >> 16); 
-				p[1] = st_swapw(buf[1] >> 16); 
-				p[2] = st_swapw(buf[2] >> 16); 
-				p[3] = st_swapw(buf[3] >> 16); 
-				p += 4; buf += 4;
-			}
-			q += 4;
-#	endif
-			while (p<q) {
-				*p++ = st_swapw((*buf++) >> 16); 
-			}
-		} else {
-#	ifdef MAXWSPEED
-			q -= 4;
-			while (p<q) {
-				p[0] = buf[0] >> 16; 
-				p[1] = buf[1] >> 16; 
-				p[2] = buf[2] >> 16; 
-				p[3] = buf[3] >> 16; 
-				p += 4; buf += 4;
-			}
-			q += 4;
-#	endif
-			while (p<q) {
-				*p++ = (*buf++) >> 16; 
-			}
-		}
-	}
-	return(save_nsamp - nsamp);
-}
+        top = (short*)(ft->file.buf + ft->file.size);
+        while (nsamp) {
+                short *p, *q;
+                p = (short*)(ft->file.buf + ft->file.pos);
+                if (p >= top) {
+                        blockflush(ft);
+                        continue;
+                }
+                q = p+nsamp; if (q>top) q = top;
+                ft->file.pos += (q-p)*sizeof(short);
+                nsamp -= (q-p);
+                if (ft->swap) {
+#       ifdef MAXWSPEED
+                        q -= 4;
+                        while (p<q) {
+                                p[0] = st_swapw(buf[0] >> 16);
+                                p[1] = st_swapw(buf[1] >> 16);
+                                p[2] = st_swapw(buf[2] >> 16);
+                                p[3] = st_swapw(buf[3] >> 16);
+                                p += 4; buf += 4;
+                        }
+                        q += 4;
+#       endif
+                        while (p<q) {
+                                *p++ = st_swapw((*buf++) >> 16);
+                        }
+                } else {
+#       ifdef MAXWSPEED
+                        q -= 4;
+                        while (p<q) {
+                                p[0] = buf[0] >> 16;
+                                p[1] = buf[1] >> 16;
+                                p[2] = buf[2] >> 16;
+                                p[3] = buf[3] >> 16;
+                                p += 4; buf += 4;
+                        }
+                        q += 4;
+#       endif
+                        while (p<q) {
+                                *p++ = (*buf++) >> 16;
+                        }
+                }
+        }
+        return(save_nsamp - nsamp);
+}
 
 /* Convert the sox internal signed long format */
 /* to the raw file data, and write it. */
 
-LONG st_rawwrite(ft, buf, nsamp) 
+LONG st_rawwrite(ft, buf, nsamp)
 ft_t ft;
 LONG *buf, nsamp;
 {
-	int done = 0;
+        int done = 0;
 
-	switch(ft->info.size) {
-		case ST_SIZE_BYTE:
-		    switch(ft->info.encoding)
-		    {
-			case ST_ENCODING_SIGN2:
-				while(done < nsamp) {
-					int datum;
-					/* scale signed up to long's range */
-					datum = 
-					    ST_SAMPLE_TO_SIGNED_BYTE(*buf++);
-					blockputc(ft, datum);
-					done++;
-				}
-				return done;
-			case ST_ENCODING_UNSIGNED:
-				while(done < nsamp) {
-					int datum;
-					/* scale signed up to long's range */
-					datum = 
-					    ST_SAMPLE_TO_UNSIGNED_BYTE(*buf++);
-					/* Convert to unsigned */
-					blockputc(ft, datum);
-					done++;
-				}
-				return done;
-			case ST_ENCODING_ULAW:
-				while(done < nsamp) {
-					short datum;
-					/* scale signed up to long's range */
-					datum = 
-					    ST_SAMPLE_TO_ULAW_BYTE(*buf++);
-					blockputc(ft, datum);
-					done++;
-				}
-				return done;
-			case ST_ENCODING_ALAW:
-				while(done < nsamp) {
-					int datum;
-					/* scale signed up to long's range */
-					datum =
-					    ST_SAMPLE_TO_ALAW_BYTE(*buf++);
-					blockputc(ft, datum);
-					done++;
-				}
-				return done;
-		    }
-		    break;
-		case ST_SIZE_WORD:
-		    switch(ft->info.encoding)
-		    {
-			case ST_ENCODING_SIGN2:
-				return blockw_sw(ft,buf,nsamp);
-			case ST_ENCODING_UNSIGNED:
-				while(done < nsamp) {
-					u_int16_t s;
-					/* scale signed up to long's range */
-					s = ST_SAMPLE_TO_UNSIGNED_WORD(*buf++);
-					/* Convert to unsigned */
-					blockw(&s, sizeof(u_int16_t),ft);
-					done++;
-				}
-				return done;
-			case ST_ENCODING_ULAW:
-				st_fail_errno(ft,ST_EFMT,"No U-Law support for shorts");
-				return 0;
-			case ST_ENCODING_ALAW:
-				st_fail_errno(ft,ST_EFMT,"No A-Law support for shorts");
-				return 0;
-		    }
-		    break;
-		case ST_SIZE_DWORD:
-		    switch(ft->info.encoding)
-		    {
-			case ST_ENCODING_SIGN2:
-				while(done < nsamp) {
-					/* scale signed up to long's range */
-					blockw(buf, sizeof(u_int32_t), ft);
-					buf++;
-					done++;
-				}
-				return done;
-			case ST_ENCODING_FLOAT:
-				while(done < nsamp) {
-				    float f;
-				    /* scale signed up to long's range */
-				    f = (float)*buf++ / 0x10000;
-				    blockw(&f, sizeof(float), ft);
-				    done++;
-				}
-				return done;
-		    }
-		    break;
-		default:
-			break;
-	}
-	/* Possible overflow */
-	st_fail_errno(ft,ST_EFMT,"Sorry, don't have code to write %s, %s",
-		st_encodings_str[(unsigned char)ft->info.encoding],
-     		st_sizes_str[(unsigned char)ft->info.size]);
-	return 0;
-}
+        switch(ft->info.size) {
+                case ST_SIZE_BYTE:
+                    switch(ft->info.encoding)
+                    {
+                        case ST_ENCODING_SIGN2:
+                                while(done < nsamp) {
+                                        int datum;
+                                        /* scale signed up to long's range */
+                                        datum =
+                                            ST_SAMPLE_TO_SIGNED_BYTE(*buf++);
+                                        blockputc(ft, datum);
+                                        done++;
+                                }
+                                return done;
+                        case ST_ENCODING_UNSIGNED:
+                                while(done < nsamp) {
+                                        int datum;
+                                        /* scale signed up to long's range */
+                                        datum =
+                                            ST_SAMPLE_TO_UNSIGNED_BYTE(*buf++);
+                                        /* Convert to unsigned */
+                                        blockputc(ft, datum);
+                                        done++;
+                                }
+                                return done;
+                        case ST_ENCODING_ULAW:
+                                while(done < nsamp) {
+                                        short datum;
+                                        /* scale signed up to long's range */
+                                        datum =
+                                            ST_SAMPLE_TO_ULAW_BYTE(*buf++);
+                                        blockputc(ft, datum);
+                                        done++;
+                                }
+                                return done;
+                        case ST_ENCODING_ALAW:
+                                while(done < nsamp) {
+                                        int datum;
+                                        /* scale signed up to long's range */
+                                        datum =
+                                            ST_SAMPLE_TO_ALAW_BYTE(*buf++);
+                                        blockputc(ft, datum);
+                                        done++;
+                                }
+                                return done;
+                    }
+                    break;
+                case ST_SIZE_WORD:
+                    switch(ft->info.encoding)
+                    {
+                        case ST_ENCODING_SIGN2:
+                                return blockw_sw(ft,buf,nsamp);
+                        case ST_ENCODING_UNSIGNED:
+                                while(done < nsamp) {
+                                        uint16_t s;
+                                        /* scale signed up to long's range */
+                                        s = ST_SAMPLE_TO_UNSIGNED_WORD(*buf++);
+                                        /* Convert to unsigned */
+                                        blockw(&s, sizeof(uint16_t),ft);
+                                        done++;
+                                }
+                                return done;
+                        case ST_ENCODING_ULAW:
+                                st_fail_errno(ft,ST_EFMT,"No U-Law support for shorts");
+                                return 0;
+                        case ST_ENCODING_ALAW:
+                                st_fail_errno(ft,ST_EFMT,"No A-Law support for shorts");
+                                return 0;
+                    }
+                    break;
+                case ST_SIZE_DWORD:
+                    switch(ft->info.encoding)
+                    {
+                        case ST_ENCODING_SIGN2:
+                                while(done < nsamp) {
+                                        /* scale signed up to long's range */
+                                        blockw(buf, sizeof(uint32_t), ft);
+                                        buf++;
+                                        done++;
+                                }
+                                return done;
+                        case ST_ENCODING_FLOAT:
+                                while(done < nsamp) {
+                                    float f;
+                                    /* scale signed up to long's range */
+                                    f = (float)*buf++ / 0x10000;
+                                    blockw(&f, sizeof(float), ft);
+                                    done++;
+                                }
+                                return done;
+                    }
+                    break;
+                default:
+                        break;
+        }
+        /* Possible overflow */
+        st_fail_errno(ft,ST_EFMT,"Sorry, don't have code to write %s, %s",
+                st_encodings_str[(unsigned char)ft->info.encoding],
+                st_sizes_str[(unsigned char)ft->info.size]);
+        return 0;
+}
 
 int st_rawstopwrite(ft)
 ft_t ft;
 {
-	blockflush(ft);
-	free(ft->file.buf);
-	return(ST_SUCCESS);
+        blockflush(ft);
+        free(ft->file.buf);
+        return(ST_SUCCESS);
 }
 
 /*
@@ -625,10 +625,10 @@
 int NAME(ft) \
 ft_t ft; \
 { \
-	ft->info.size = SIZE; \
-	ft->info.encoding = STYLE; \
-	rawdefaults(ft); \
-	return st_rawstartread(ft); \
+        ft->info.size = SIZE; \
+        ft->info.encoding = STYLE; \
+        rawdefaults(ft); \
+        return st_rawstartread(ft); \
 }
 
 #define STARTWRITE(NAME,SIZE,STYLE)\
@@ -635,39 +635,39 @@
 int NAME(ft) \
 ft_t ft; \
 { \
-	ft->info.size = SIZE; \
-	ft->info.encoding = STYLE; \
-	rawdefaults(ft); \
-	return st_rawstartwrite(ft); \
+        ft->info.size = SIZE; \
+        ft->info.encoding = STYLE; \
+        rawdefaults(ft); \
+        return st_rawstartwrite(ft); \
 }
 
-STARTREAD(st_sbstartread,ST_SIZE_BYTE,ST_ENCODING_SIGN2) 
-STARTWRITE(st_sbstartwrite,ST_SIZE_BYTE,ST_ENCODING_SIGN2) 
+STARTREAD(st_sbstartread,ST_SIZE_BYTE,ST_ENCODING_SIGN2)
+STARTWRITE(st_sbstartwrite,ST_SIZE_BYTE,ST_ENCODING_SIGN2)
 
-STARTREAD(st_ubstartread,ST_SIZE_BYTE,ST_ENCODING_UNSIGNED) 
-STARTWRITE(st_ubstartwrite,ST_SIZE_BYTE,ST_ENCODING_UNSIGNED) 
+STARTREAD(st_ubstartread,ST_SIZE_BYTE,ST_ENCODING_UNSIGNED)
+STARTWRITE(st_ubstartwrite,ST_SIZE_BYTE,ST_ENCODING_UNSIGNED)
 
-STARTREAD(st_uwstartread,ST_SIZE_WORD,ST_ENCODING_UNSIGNED) 
-STARTWRITE(st_uwstartwrite,ST_SIZE_WORD,ST_ENCODING_UNSIGNED) 
+STARTREAD(st_uwstartread,ST_SIZE_WORD,ST_ENCODING_UNSIGNED)
+STARTWRITE(st_uwstartwrite,ST_SIZE_WORD,ST_ENCODING_UNSIGNED)
 
-STARTREAD(st_swstartread,ST_SIZE_WORD,ST_ENCODING_SIGN2) 
-STARTWRITE(st_swstartwrite,ST_SIZE_WORD,ST_ENCODING_SIGN2) 
+STARTREAD(st_swstartread,ST_SIZE_WORD,ST_ENCODING_SIGN2)
+STARTWRITE(st_swstartwrite,ST_SIZE_WORD,ST_ENCODING_SIGN2)
 
-STARTREAD(st_slstartread,ST_SIZE_DWORD,ST_ENCODING_SIGN2) 
-STARTWRITE(st_slstartwrite,ST_SIZE_DWORD,ST_ENCODING_SIGN2) 
+STARTREAD(st_slstartread,ST_SIZE_DWORD,ST_ENCODING_SIGN2)
+STARTWRITE(st_slstartwrite,ST_SIZE_DWORD,ST_ENCODING_SIGN2)
 
-STARTREAD(st_ulstartread,ST_SIZE_BYTE,ST_ENCODING_ULAW) 
-STARTWRITE(st_ulstartwrite,ST_SIZE_BYTE,ST_ENCODING_ULAW) 
+STARTREAD(st_ulstartread,ST_SIZE_BYTE,ST_ENCODING_ULAW)
+STARTWRITE(st_ulstartwrite,ST_SIZE_BYTE,ST_ENCODING_ULAW)
 
-STARTREAD(st_alstartread,ST_SIZE_BYTE,ST_ENCODING_ALAW) 
-STARTWRITE(st_alstartwrite,ST_SIZE_BYTE,ST_ENCODING_ALAW) 
+STARTREAD(st_alstartread,ST_SIZE_BYTE,ST_ENCODING_ALAW)
+STARTWRITE(st_alstartwrite,ST_SIZE_BYTE,ST_ENCODING_ALAW)
 
 void rawdefaults(ft)
 ft_t ft;
 {
-	if (ft->info.rate == 0)
-		ft->info.rate = 8000;
-	if (ft->info.channels == -1)
-		ft->info.channels = 1;
+        if (ft->info.rate == 0)
+                ft->info.rate = 8000;
+        if (ft->info.channels == -1)
+                ft->info.channels = 1;
 }
 
--- a/src/sf.c
+++ b/src/sf.c
@@ -2,14 +2,14 @@
  * July 5, 1991
  * Copyright 1991 Lance Norskog And Sundry Contributors
  * This source code is freely redistributable and may be used for
- * any purpose.  This copyright notice must be maintained. 
- * Lance Norskog And Sundry Contributors are not responsible for 
+ * any purpose.  This copyright notice must be maintained.
+ * Lance Norskog And Sundry Contributors are not responsible for
  * the consequences of using this software.
  */
 
 /*
  * Sound Tools IRCAM SoundFile format handler.
- * 
+ *
  * Derived from: Sound Tools skeleton handler file.
  */
 
@@ -25,9 +25,9 @@
 
 /* Private data for SF file */
 typedef struct sfstuff {
-	struct sfinfo info;
-	/* needed for seek */
-	LONG dataStart;
+        struct sfinfo info;
+        /* needed for seek */
+        LONG dataStart;
 } *sf_t;
 
 /*
@@ -36,177 +36,177 @@
  */
 static void readcodes(ft_t ft, SFHEADER *sfhead)
 {
-	char *commentbuf = NULL, *sfcharp, *newline;
-	short bsize, finished = 0;
-	SFCODE *sfcodep;
+        char *commentbuf = NULL, *sfcharp, *newline;
+        short bsize, finished = 0;
+        SFCODE *sfcodep;
 
-	sfcodep = (SFCODE *) &sfcodes(sfhead);
-	do {
-		sfcharp = (char *) sfcodep + sizeof(SFCODE);
-		if (ft->swap) {
-			sfcodep->bsize = st_swapl(sfcodep->bsize);
-			sfcodep->code = st_swapl(sfcodep->code);
-		}
-		bsize = sfcodep->bsize - sizeof(SFCODE);
-		switch(sfcodep->code) {
-		case SF_END:
-			finished = 1;
-			break;
-		case SF_COMMENT:
-			if((commentbuf = (char *) malloc(bsize + 1)) != NULL) {
-				memcpy(commentbuf, sfcharp, bsize);
-				st_report("IRCAM comment: %s", sfcharp);
-				commentbuf[bsize] = '\0';
-				if((newline = strchr(commentbuf, '\n')) != NULL)
-					*newline = '\0';
-			}
-			break;
-		}
-		sfcodep = (SFCODE *) (sfcharp + bsize);
-	} while(!finished);
-	if(commentbuf != NULL)	/* handles out of memory condition as well */
-		ft->comment = commentbuf;
-}
+        sfcodep = (SFCODE *) &sfcodes(sfhead);
+        do {
+                sfcharp = (char *) sfcodep + sizeof(SFCODE);
+                if (ft->swap) {
+                        sfcodep->bsize = st_swapdw(sfcodep->bsize);
+                        sfcodep->code = st_swapdw(sfcodep->code);
+                }
+                bsize = sfcodep->bsize - sizeof(SFCODE);
+                switch(sfcodep->code) {
+                case SF_END:
+                        finished = 1;
+                        break;
+                case SF_COMMENT:
+                        if((commentbuf = (char *) malloc(bsize + 1)) != NULL) {
+                                memcpy(commentbuf, sfcharp, bsize);
+                                st_report("IRCAM comment: %s", sfcharp);
+                                commentbuf[bsize] = '\0';
+                                if((newline = strchr(commentbuf, '\n')) != NULL)
+                                        *newline = '\0';
+                        }
+                        break;
+                }
+                sfcodep = (SFCODE *) (sfcharp + bsize);
+        } while(!finished);
+        if(commentbuf != NULL)  /* handles out of memory condition as well */
+                ft->comment = commentbuf;
+}
 
-int st_sfseek(ft_t ft, st_size_t offset) 
+int st_sfseek(ft_t ft, st_size_t offset)
 {
-	sf_t sf = (sf_t ) ft->priv;
+        sf_t sf = (sf_t ) ft->priv;
 
-	return st_seek(ft,offset*ft->info.size + sf->dataStart,SEEK_SET);
+        return st_seek(ft,offset*ft->info.size + sf->dataStart,SEEK_SET);
 
 }
 
 /*
  * Do anything required before you start reading samples.
- * Read file header. 
- *	Find out sampling rate, 
- *	size and encoding of samples, 
- *	mono/stereo/quad.
+ * Read file header.
+ *      Find out sampling rate,
+ *      size and encoding of samples,
+ *      mono/stereo/quad.
  */
-int st_sfstartread(ft_t ft) 
+int st_sfstartread(ft_t ft)
 {
-	sf_t sf = (sf_t) ft->priv;
-	SFHEADER sfhead;
-	int rc;
-	int samplesize = 0;	
+        sf_t sf = (sf_t) ft->priv;
+        SFHEADER sfhead;
+        int rc;
+        int samplesize = 0;
 
-	if (fread(&sfhead, 1, sizeof(sfhead), ft->fp) != sizeof(sfhead))
-	{
-		st_fail("unexpected EOF in SF header");
-		return(ST_EOF);
-	}
-	memcpy(&sf->info, &sfhead.sfinfo, sizeof(struct sfinfo));
-	if (ft->swap) {
-		sf->info.sf_srate = st_swapf(sf->info.sf_srate);
-		sf->info.sf_packmode = st_swapl(sf->info.sf_packmode);
-		sf->info.sf_chans = st_swapl(sf->info.sf_chans);
-	}
-	if ((sfmagic1(&sfhead) != SF_MAGIC1) ||
-	    (sfmagic2(&sfhead) != SF_MAGIC2))
-		st_fail(
-"SF %s file: can't read, it is byte-swapped or it is not an IRCAM SoundFile", 
-			ft->filename);
+        if (fread(&sfhead, 1, sizeof(sfhead), ft->fp) != sizeof(sfhead))
+        {
+                st_fail("unexpected EOF in SF header");
+                return(ST_EOF);
+        }
+        memcpy(&sf->info, &sfhead.sfinfo, sizeof(struct sfinfo));
+        if (ft->swap) {
+                sf->info.sf_srate = st_swapf(sf->info.sf_srate);
+                sf->info.sf_packmode = st_swapdw(sf->info.sf_packmode);
+                sf->info.sf_chans = st_swapdw(sf->info.sf_chans);
+        }
+        if ((sfmagic1(&sfhead) != SF_MAGIC1) ||
+            (sfmagic2(&sfhead) != SF_MAGIC2))
+                st_fail(
+"SF %s file: can't read, it is byte-swapped or it is not an IRCAM SoundFile",
+                        ft->filename);
 
 
-	/*
-	 * If your format specifies or your file header contains
-	 * any of the following information. 
-	 */
-	ft->info.rate = sf->info.sf_srate;
-	switch(sf->info.sf_packmode) {
-		case SF_SHORT:
-			ft->info.size = ST_SIZE_WORD;
-			ft->info.encoding = ST_ENCODING_SIGN2;
-			samplesize = ft->info.size;
-			break;
-		case SF_FLOAT:
-			ft->info.size = ST_SIZE_DWORD;
-			ft->info.encoding = ST_ENCODING_FLOAT;
-			samplesize = sizeof(float);
-			break;
-		default:
-			st_fail("Soundfile input: unknown format 0x%x\n",
-				sf->info.sf_packmode);
-			return(ST_EOF);
-	}
-	ft->info.channels = (int) sf->info.sf_chans;
+        /*
+         * If your format specifies or your file header contains
+         * any of the following information.
+         */
+        ft->info.rate = sf->info.sf_srate;
+        switch(sf->info.sf_packmode) {
+                case SF_SHORT:
+                        ft->info.size = ST_SIZE_WORD;
+                        ft->info.encoding = ST_ENCODING_SIGN2;
+                        samplesize = ft->info.size;
+                        break;
+                case SF_FLOAT:
+                        ft->info.size = ST_SIZE_DWORD;
+                        ft->info.encoding = ST_ENCODING_FLOAT;
+                        samplesize = sizeof(float);
+                        break;
+                default:
+                        st_fail("Soundfile input: unknown format 0x%x\n",
+                                sf->info.sf_packmode);
+                        return(ST_EOF);
+        }
+        ft->info.channels = (int) sf->info.sf_chans;
 
-	if (ft->info.channels == -1)
-	    ft->info.channels = 1;
+        if (ft->info.channels == -1)
+            ft->info.channels = 1;
 
-	/* Read codes and print as comments. */
-	readcodes(ft, &sfhead);
+        /* Read codes and print as comments. */
+        readcodes(ft, &sfhead);
 
-	/* Needed for rawread() */
-	rc = st_rawstartread(ft);
+        /* Needed for rawread() */
+        rc = st_rawstartread(ft);
 
 /* Need length for seeking */
-	if(ft->seekable){
-		ft->length = st_filelength(ft)/samplesize;
-		sf->dataStart = ftell(ft->fp);
-	} else {
-		ft->length = 0;
-	}
-	
-	return(rc);
+        if(ft->seekable){
+                ft->length = st_filelength(ft)/samplesize;
+                sf->dataStart = ftell(ft->fp);
+        } else {
+                ft->length = 0;
+        }
+
+        return(rc);
 }
 
-int st_sfstartwrite(ft_t ft) 
+int st_sfstartwrite(ft_t ft)
 {
-	sf_t sf = (sf_t) ft->priv;
-	SFHEADER sfhead;
-	SFCODE *sfcodep;
-	char *sfcharp;
-	int rc;
+        sf_t sf = (sf_t) ft->priv;
+        SFHEADER sfhead;
+        SFCODE *sfcodep;
+        char *sfcharp;
+        int rc;
 
-	/* Needed for rawwrite() */
-	rc = st_rawstartwrite(ft);
-	if (rc)
-	    return rc;
+        /* Needed for rawwrite() */
+        rc = st_rawstartwrite(ft);
+        if (rc)
+            return rc;
 
-	sf->info.magic_union._magic_bytes.sf_magic1 = SF_MAGIC1;
-	sf->info.magic_union._magic_bytes.sf_magic2 = SF_MAGIC2;
-	sf->info.magic_union._magic_bytes.sf_param = 0;
+        sf->info.magic_union._magic_bytes.sf_magic1 = SF_MAGIC1;
+        sf->info.magic_union._magic_bytes.sf_magic2 = SF_MAGIC2;
+        sf->info.magic_union._magic_bytes.sf_param = 0;
 
-	/* This file handler can handle both big and little endian data */
-	if (ST_IS_LITTLEENDIAN)
-	    sf->info.magic_union._magic_bytes.sf_machine = SF_VAX;
-	else
-	    sf->info.magic_union._magic_bytes.sf_machine = SF_SUN;
+        /* This file handler can handle both big and little endian data */
+        if (ST_IS_LITTLEENDIAN)
+            sf->info.magic_union._magic_bytes.sf_machine = SF_VAX;
+        else
+            sf->info.magic_union._magic_bytes.sf_machine = SF_SUN;
 
-	sf->info.sf_srate = ft->info.rate;
-	if (ft->info.size == ST_SIZE_DWORD && 
-	    ft->info.encoding == ST_ENCODING_FLOAT) {
-		sf->info.sf_packmode = SF_FLOAT;
-	} else {
-		sf->info.sf_packmode = SF_SHORT;
-		/* Default to signed words */
-		ft->info.size = ST_SIZE_WORD;
-		ft->info.encoding = ST_ENCODING_SIGN2;
-	}
+        sf->info.sf_srate = ft->info.rate;
+        if (ft->info.size == ST_SIZE_DWORD &&
+            ft->info.encoding == ST_ENCODING_FLOAT) {
+                sf->info.sf_packmode = SF_FLOAT;
+        } else {
+                sf->info.sf_packmode = SF_SHORT;
+                /* Default to signed words */
+                ft->info.size = ST_SIZE_WORD;
+                ft->info.encoding = ST_ENCODING_SIGN2;
+        }
 
-	sf->info.sf_chans = ft->info.channels;
+        sf->info.sf_chans = ft->info.channels;
 
-	/* Clean out structure so unused areas will remain constain  */
-	/* between different coverts and not rely on memory contents */
-	memset (&sfhead, 0, sizeof(SFHEADER));
-	memcpy(&sfhead.sfinfo, &sf->info, sizeof(struct sfinfo));
-	sfcodep = (SFCODE *) &sfcodes(&sfhead);
-	sfcodep->code = SF_COMMENT;
-	sfcodep->bsize = strlen(ft->comment) + sizeof(SFCODE);
-	while (sfcodep->bsize % 4)
-		sfcodep->bsize++;
-	sfcharp = (char *) sfcodep;
-	strcpy(sfcharp + sizeof(SFCODE), ft->comment);
-	sfcodep = (SFCODE *) (sfcharp + sfcodep->bsize);
-	sfcodep->code = SF_END;
-	sfcodep->bsize = sizeof(SFCODE);
-	sfcharp = (char *) sfcodep + sizeof(SFCODE);
-	while(sfcharp < (char *) &sfhead + SIZEOF_BSD_HEADER)
-		*sfcharp++ = '\0';
-	fwrite(&sfhead, 1, sizeof(SFHEADER), ft->fp);
+        /* Clean out structure so unused areas will remain constain  */
+        /* between different coverts and not rely on memory contents */
+        memset (&sfhead, 0, sizeof(SFHEADER));
+        memcpy(&sfhead.sfinfo, &sf->info, sizeof(struct sfinfo));
+        sfcodep = (SFCODE *) &sfcodes(&sfhead);
+        sfcodep->code = SF_COMMENT;
+        sfcodep->bsize = strlen(ft->comment) + sizeof(SFCODE);
+        while (sfcodep->bsize % 4)
+                sfcodep->bsize++;
+        sfcharp = (char *) sfcodep;
+        strcpy(sfcharp + sizeof(SFCODE), ft->comment);
+        sfcodep = (SFCODE *) (sfcharp + sfcodep->bsize);
+        sfcodep->code = SF_END;
+        sfcodep->bsize = sizeof(SFCODE);
+        sfcharp = (char *) sfcodep + sizeof(SFCODE);
+        while(sfcharp < (char *) &sfhead + SIZEOF_BSD_HEADER)
+                *sfcharp++ = '\0';
+        fwrite(&sfhead, 1, sizeof(SFHEADER), ft->fp);
 
-	return(ST_SUCCESS);
+        return(ST_SUCCESS);
 }
 
 /* Read and write are supplied by raw.c */
--- a/src/smp.c
+++ b/src/smp.c
@@ -35,8 +35,8 @@
 
 /* Samplevision loop definition structure */
 struct loop {
-	u_int32_t start; /* Sample count into sample data, not byte count */
-	u_int32_t end;   /* end point */
+	uint32_t start; /* Sample count into sample data, not byte count */
+	uint32_t end;   /* end point */
 	char type;   /* 0 = loop off, 1 = forward, 2 = forw/back */
 	short count;	     /* No of times to loop */
 };
@@ -44,7 +44,7 @@
 /* Samplevision marker definition structure */
 struct marker {
 	char name[10];		/* Ascii Marker name */
-	u_int32_t position;	/* Sample Number, not byte number */
+	uint32_t position;	/* Sample Number, not byte number */
 };
 
 /* The trailer following the sample data */
@@ -52,15 +52,15 @@
 	struct loop loops[8];		/* loops */
 	struct marker markers[8];	/* markers */
 	char MIDInote;			/* for unity pitch playback */
-	u_int32_t rate;			/* in hertz */
-	u_int32_t SMPTEoffset;		/* in subframes - huh? */
-	u_int32_t CycleSize;		/* sample count in one cycle of the */
+	uint32_t rate;			/* in hertz */
+	uint32_t SMPTEoffset;		/* in subframes - huh? */
+	uint32_t CycleSize;		/* sample count in one cycle of the */
 					/* sampled sound -1 if unknown */
 };
 
 /* Private data for SMP file */
 typedef struct smpstuff {
-  u_int32_t NoOfSamps;		/* Sample data count in words */
+  uint32_t NoOfSamps;		/* Sample data count in words */
   LONG dataStart;
   /* comment memory resides in private data because it's small */
   char comment[COMMENTLEN + NAMELEN + 3];
--- a/src/st.h
+++ b/src/st.h
@@ -87,7 +87,7 @@
 
 /* Signal parameters */
 
-typedef struct  st_signalinfo 
+typedef struct  st_signalinfo
 {
     st_rate_t rate;      /* sampling rate */
     char size;           /* word length of data */
@@ -97,7 +97,7 @@
 
 /* Loop parameters */
 
-typedef struct  st_loopinfo 
+typedef struct  st_loopinfo
 {
     st_size_t    start;          /* first sample */
     st_size_t    length;         /* length */
@@ -109,7 +109,7 @@
 
 /* vague attempt at generic information for sampler-specific info */
 
-typedef struct  st_instrinfo 
+typedef struct  st_instrinfo
 {
     char MIDInote;       /* for unity pitch playback */
     char MIDIlow, MIDIhi;/* MIDI pitch-bend range */
@@ -127,7 +127,7 @@
  * File buffer info.  Holds info so that data can be read in blocks.
  */
 
-typedef struct st_fileinfo 
+typedef struct st_fileinfo
 {
     char          *buf;                 /* Pointer to data buffer */
     size_t        size;                 /* Size of buffer */
@@ -206,7 +206,7 @@
 #define ST_SIZE_32BIT   4
 #define ST_SIZE_DDWORD  8
 #define ST_SIZE_64BIT   8
-#define ST_SIZE_MAX     8
+#define ST_INFO_SIZE_MAX     8
 
 /* Style field */
 #define ST_ENCODING_UNSIGNED    1 /* unsigned linear: Sound Blaster */
@@ -217,7 +217,7 @@
 #define ST_ENCODING_ADPCM       6 /* Compressed PCM */
 #define ST_ENCODING_IMA_ADPCM   7 /* Compressed PCM */
 #define ST_ENCODING_GSM         8 /* GSM 6.10 33byte frame lossy compression */
-#define ST_ENCODING_MAX         8 
+#define ST_ENCODING_MAX         8
 
 /* declared in misc.c */
 extern const char *st_sizes_str[];
@@ -234,7 +234,7 @@
 
 typedef struct st_effect *eff_t;
 
-typedef struct 
+typedef struct
 {
     char    *name;                  /* effect name */
     unsigned int flags;
@@ -242,12 +242,12 @@
     int (*getopts)(eff_t effp, int argc, char **argv);
     int (*start)(eff_t effp);
     int (*flow)(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
-	        st_size_t *isamp, st_size_t *osamp);
+                st_size_t *isamp, st_size_t *osamp);
     int (*drain)(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
     int (*stop)(eff_t effp);
 } st_effect_t;
 
-struct st_effect 
+struct st_effect
 {
     char            *name;          /* effect name */
     struct st_signalinfo ininfo;    /* input signal specifications */
--- a/src/st_i.h
+++ b/src/st_i.h
@@ -14,6 +14,7 @@
  */
 
 #include "st.h"
+#include <sys/types.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -64,12 +65,12 @@
 st_ssize_t st_write(ft_t ft, void *buf, size_t size, st_ssize_t len);
 int st_reads(ft_t ft, char *c, st_ssize_t len);
 int st_writes(ft_t ft, char *c);
-int st_readb(ft_t ft, u_int8_t *ub);
-int st_writeb(ft_t ft, u_int8_t ub);
-int st_readw(ft_t ft, u_int16_t *uw);
-int st_writew(ft_t ft, u_int16_t uw);
-int st_readdw(ft_t ft, u_int32_t *udw);
-int st_writedw(ft_t ft, u_int32_t udw);
+int st_readb(ft_t ft, uint8_t *ub);
+int st_writeb(ft_t ft, uint8_t ub);
+int st_readw(ft_t ft, uint16_t *uw);
+int st_writew(ft_t ft, uint16_t uw);
+int st_readdw(ft_t ft, uint32_t *udw);
+int st_writedw(ft_t ft, uint32_t udw);
 int st_readf(ft_t ft, float *f);
 int st_writef(ft_t ft, float f);
 int st_readdf(ft_t ft, double *d);
@@ -80,11 +81,11 @@
 /* Utilities to byte-swap values, use libc optimized macro's if possible  */
 #ifdef HAVE_BYTESWAP_H
 #define st_swapw(x) bswap_16(x)
-#define st_swapl(x) bswap_32(x)
+#define st_swapdw(x) bswap_32(x)
 #define st_swapf(x) (float)bswap_32((ULONG)(x))
 #else
-u_int16_t st_swapw(u_int16_t uw);
-u_int32_t st_swapdw(u_int32_t udw);
+uint16_t st_swapw(uint16_t uw);
+uint32_t st_swapdw(uint32_t udw);
 float st_swapf(float f);
 #endif
 double st_swapd(double d);
@@ -333,15 +334,15 @@
  */
 int st_avg_getopts(eff_t effp, int argc, char **argv);
 int st_avg_start(eff_t effp);
-int st_avg_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	        st_size_t *isamp, st_size_t *osamp);
+int st_avg_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                st_size_t *isamp, st_size_t *osamp);
 int st_avg_stop(eff_t effp);
 
 int st_band_getopts(eff_t effp, int argc, char **argv);
 int st_band_start(eff_t effp);
-int st_band_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	         st_size_t *isamp, st_size_t *osamp);
-int st_band_stop(eff_t effp); 
+int st_band_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                 st_size_t *isamp, st_size_t *osamp);
+int st_band_stop(eff_t effp);
 int st_bandpass_getopts(eff_t effp, int argc, char **argv);
 int st_bandpass_start(eff_t effp);
 
@@ -350,82 +351,82 @@
 
 int st_chorus_getopts(eff_t effp, int argc, char **argv);
 int st_chorus_start(eff_t effp);
-int st_chorus_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	           st_size_t *isamp, st_size_t *osamp);
+int st_chorus_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                   st_size_t *isamp, st_size_t *osamp);
 int st_chorus_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_chorus_stop(eff_t effp);
 
 int st_compand_getopts(eff_t effp, int argc, char **argv);
 int st_compand_start(eff_t effp);
-int st_compand_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	            st_size_t *isamp, st_size_t *osamp);
+int st_compand_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                    st_size_t *isamp, st_size_t *osamp);
 int st_compand_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_compand_stop(eff_t effp);
 
-int st_copy_getopts(eff_t effp, int argc, char **argv); 
+int st_copy_getopts(eff_t effp, int argc, char **argv);
 int st_copy_start(eff_t effp);
-int st_copy_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	         st_size_t *isamp, st_size_t *osamp);
+int st_copy_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                 st_size_t *isamp, st_size_t *osamp);
 int st_copy_stop(eff_t effp);
 
 int st_dcshift_getopts(eff_t effp, int argc, char **argv);
 int st_dcshift_start(eff_t effp);
-int st_dcshift_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	            st_size_t *isamp, st_size_t *osamp);
+int st_dcshift_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                    st_size_t *isamp, st_size_t *osamp);
 int st_dcshift_stop(eff_t effp);
 
 int st_deemph_getopts(eff_t effp, int argc, char **argv);
 int st_deemph_start(eff_t effp);
 int st_deemph_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
-	           st_size_t *isamp, st_size_t *osamp);
+                   st_size_t *isamp, st_size_t *osamp);
 int st_deemph_stop(eff_t effp);
 
 int st_earwax_getopts(eff_t effp, int argc, char **argv);
 int st_earwax_start(eff_t effp);
-int st_earwax_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	           st_size_t *isamp, st_size_t *osamp);
+int st_earwax_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                   st_size_t *isamp, st_size_t *osamp);
 int st_earwax_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_earwax_stop(eff_t effp);
 
 int st_echo_getopts(eff_t effp, int argc, char **argv);
 int st_echo_start(eff_t effp);
-int st_echo_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	         st_size_t *isamp, st_size_t *osamp);
+int st_echo_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                 st_size_t *isamp, st_size_t *osamp);
 int st_echo_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_echo_stop(eff_t effp);
 
 int st_echos_getopts(eff_t effp, int argc, char **argv);
 int st_echos_start(eff_t effp);
-int st_echos_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	          st_size_t *isamp, st_size_t *osamp);
+int st_echos_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                  st_size_t *isamp, st_size_t *osamp);
 int st_echos_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_echos_stop(eff_t effp);
 
 int st_fade_getopts(eff_t effp, int argc, char **argv);
 int st_fade_start(eff_t effp);
-int st_fade_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	         st_size_t *isamp, st_size_t *osamp);
+int st_fade_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                 st_size_t *isamp, st_size_t *osamp);
 int st_fade_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_fade_stop(eff_t effp);
 
 int st_filter_getopts(eff_t effp, int argc, char **argv);
 int st_filter_start(eff_t effp);
-int st_filter_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	           st_size_t *isamp, st_size_t *osamp);
+int st_filter_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                   st_size_t *isamp, st_size_t *osamp);
 int st_filter_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_filter_stop(eff_t effp);
 
 int st_flanger_getopts(eff_t effp, int argc, char **argv);
 int st_flanger_start(eff_t effp);
-int st_flanger_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	            st_size_t *isamp, st_size_t *osamp);
+int st_flanger_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                    st_size_t *isamp, st_size_t *osamp);
 int st_flanger_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_flanger_stop(eff_t effp);
 
 int st_highp_getopts(eff_t effp, int argc, char **argv);
 int st_highp_start(eff_t effp);
-int st_highp_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	          st_size_t *isamp, st_size_t *osamp);
+int st_highp_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                  st_size_t *isamp, st_size_t *osamp);
 int st_highp_stop(eff_t effp);
 
 int st_highpass_getopts(eff_t effp, int argc, char **argv);
@@ -433,8 +434,8 @@
 
 int st_lowp_getopts(eff_t effp, int argc, char **argv);
 int st_lowp_start(eff_t effp);
-int st_lowp_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	         st_size_t *isamp, st_size_t *osamp);
+int st_lowp_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                 st_size_t *isamp, st_size_t *osamp);
 int st_lowp_stop(eff_t effp);
 
 int st_lowpass_getopts(eff_t effp, int argc, char **argv);
@@ -442,63 +443,63 @@
 
 int st_map_getopts(eff_t effp, int argc, char **argv);
 int st_map_start(eff_t effp);
-int st_map_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	        st_size_t *isamp, st_size_t *osamp);
+int st_map_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                st_size_t *isamp, st_size_t *osamp);
 
 int st_mask_getopts(eff_t effp, int argc, char **argv);
-int st_mask_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	         st_size_t *isamp, st_size_t *osamp);
+int st_mask_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                 st_size_t *isamp, st_size_t *osamp);
 
 int st_pan_getopts(eff_t effp, int argc, char **argv);
 int st_pan_start(eff_t effp);
-int st_pan_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	        st_size_t *isamp, st_size_t *osamp);
+int st_pan_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                st_size_t *isamp, st_size_t *osamp);
 int st_pan_stop(eff_t effp);
 
 int st_phaser_getopts(eff_t effp, int argc, char **argv);
 int st_phaser_start(eff_t effp);
-int st_phaser_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	           st_size_t *isamp, st_size_t *osamp);
+int st_phaser_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                   st_size_t *isamp, st_size_t *osamp);
 int st_phaser_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_phaser_stop(eff_t effp);
 
 int st_pick_getopts(eff_t effp, int argc, char **argv);
 int st_pick_start(eff_t effp);
-int st_pick_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	         st_size_t *isamp, st_size_t *osamp);
+int st_pick_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                 st_size_t *isamp, st_size_t *osamp);
 int st_pick_stop(eff_t effp);
 
 int st_pitch_getopts(eff_t effp, int argc, char **argv);
 int st_pitch_start(eff_t effp);
-int st_pitch_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	          st_size_t *isamp, st_size_t *osamp);
+int st_pitch_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                  st_size_t *isamp, st_size_t *osamp);
 int st_pitch_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_pitch_stop(eff_t effp);
 
 int st_poly_getopts(eff_t effp, int argc, char **argv);
 int st_poly_start(eff_t effp);
-int st_poly_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	         st_size_t *isamp, st_size_t *osamp);
+int st_poly_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                 st_size_t *isamp, st_size_t *osamp);
 int st_poly_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_poly_stop(eff_t effp);
 
 int st_rate_getopts(eff_t effp, int argc, char **argv);
 int st_rate_start(eff_t effp);
-int st_rate_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	         st_size_t *isamp, st_size_t *osamp);
+int st_rate_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                 st_size_t *isamp, st_size_t *osamp);
 int st_rate_stop(eff_t effp);
 
 int st_resample_getopts(eff_t effp, int argc, char **argv);
 int st_resample_start(eff_t effp);
-int st_resample_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	             st_size_t *isamp, st_size_t *osamp);
+int st_resample_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                     st_size_t *isamp, st_size_t *osamp);
 int st_resample_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_resample_stop(eff_t effp);
 
 int st_reverb_getopts(eff_t effp, int argc, char **argv);
 int st_reverb_start(eff_t effp);
-int st_reverb_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	           st_size_t *isamp, st_size_t *osamp);
+int st_reverb_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                   st_size_t *isamp, st_size_t *osamp);
 int st_reverb_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_reverb_stop(eff_t effp);
 
@@ -505,74 +506,74 @@
 int st_reverse_getopts(eff_t effp, int argc, char **argv);
 int st_reverse_start(eff_t effp);
 int st_reverse_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
-	            st_size_t *isamp, st_size_t *osamp);
+                    st_size_t *isamp, st_size_t *osamp);
 int st_reverse_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_reverse_stop(eff_t effp);
 
 int st_silence_getopts(eff_t effp, int argc, char **argv);
 int st_silence_start(eff_t effp);
-int st_silence_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	            st_size_t *isamp, st_size_t *osamp);
+int st_silence_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                    st_size_t *isamp, st_size_t *osamp);
 int st_silence_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_silence_stop(eff_t effp);
 
 int st_speed_getopts(eff_t effp, int argc, char **argv);
 int st_speed_start(eff_t effp);
-int st_speed_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	          st_size_t *isamp, st_size_t *osamp);
+int st_speed_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                  st_size_t *isamp, st_size_t *osamp);
 int st_speed_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_speed_stop(eff_t effp);
 
 int st_split_getopts(eff_t effp, int argc, char **argv);
 int st_split_start(eff_t effp);
-int st_split_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	          st_size_t *isamp, st_size_t *osamp);
+int st_split_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                  st_size_t *isamp, st_size_t *osamp);
 int st_split_stop(eff_t effp);
 
 int st_stat_getopts(eff_t effp, int argc, char **argv);
 int st_stat_start(eff_t effp);
-int st_stat_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	         st_size_t *isamp, st_size_t *osamp);
+int st_stat_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                 st_size_t *isamp, st_size_t *osamp);
 int st_stat_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_stat_stop(eff_t effp);
 
 int st_stretch_getopts(eff_t effp, int argc, char **argv);
 int st_stretch_start(eff_t effp);
-int st_stretch_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	            st_size_t *isamp, st_size_t *osamp);
+int st_stretch_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                    st_size_t *isamp, st_size_t *osamp);
 int st_stretch_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_stretch_stop(eff_t effp);
 
 int st_swap_getopts(eff_t effp, int argc, char **argv);
 int st_swap_start(eff_t effp);
-int st_swap_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	         st_size_t *isamp, st_size_t *osamp);
+int st_swap_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                 st_size_t *isamp, st_size_t *osamp);
 int st_swap_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_swap_stop(eff_t effp);
 
-int st_synth_getopts(eff_t effp, int argc, char **argv); 
+int st_synth_getopts(eff_t effp, int argc, char **argv);
 int st_synth_start(eff_t effp);
-int st_synth_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	          st_size_t *isamp, st_size_t *osamp);
+int st_synth_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                  st_size_t *isamp, st_size_t *osamp);
 int st_synth_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp);
 int st_synth_stop(eff_t effp);
 
-int st_trim_getopts(eff_t effp, int argc, char **argv); 
+int st_trim_getopts(eff_t effp, int argc, char **argv);
 int st_trim_start(eff_t effp);
-int st_trim_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	         st_size_t *isamp, st_size_t *osamp);
+int st_trim_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                 st_size_t *isamp, st_size_t *osamp);
 int st_trim_stop(eff_t effp);
 
 int st_vibro_getopts(eff_t effp, int argc, char **argv);
 int st_vibro_start(eff_t effp);
-int st_vibro_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	          st_size_t *isamp, st_size_t *osamp);
+int st_vibro_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                  st_size_t *isamp, st_size_t *osamp);
 int st_vibro_stop(eff_t effp);
 
 int st_vol_getopts(eff_t effp, int argc, char **argv);
 int st_vol_start(eff_t effp);
-int st_vol_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf, 
-	        st_size_t *isamp, st_size_t *osamp);
+int st_vol_flow(eff_t effp, st_sample_t *ibuf, st_sample_t *obuf,
+                st_size_t *isamp, st_size_t *osamp);
 int st_vol_stop(eff_t effp);
 
 #ifdef __cplusplus
--- a/src/sunaudio.c
+++ b/src/sunaudio.c
@@ -1,4 +1,4 @@
-#if	defined(SUNAUDIO_PLAYER)
+#if     defined(SUNAUDIO_PLAYER)
 /*
  * Copyright 1997 Chris Bagwell And Sundry Contributors
  * This source code is freely redistributable and may be used for
@@ -26,6 +26,7 @@
 #include <sun/audioio.h>
 #endif
 
+#include <errno.h>
 #include <stropts.h>
 #include <malloc.h>
 #include <unistd.h>
@@ -36,9 +37,9 @@
 /*
  * Do anything required before you start reading samples.
  * Read file header.
- *	Find out sampling rate,
- *	size and encoding of samples,
- *	mono/stereo/quad.
+ *      Find out sampling rate,
+ *      size and encoding of samples,
+ *      mono/stereo/quad.
  */
 int st_sunstartread(ft_t ft)
 {
@@ -55,8 +56,8 @@
     ft->file.eof = 0;
     ft->file.size = 1024;
     if ((ft->file.buf = malloc (ft->file.size)) == NULL) {
-	st_fail_errno(ft,ST_ENOMEM,"unable to allocate input buffer of size %d", ft->file.size);
-	return ST_EOF;
+        st_fail_errno(ft,ST_ENOMEM,"unable to allocate input buffer of size %d", ft->file.size);
+        return ST_EOF;
     }
 
     if (ft->info.rate == 0.0) ft->info.rate = 8000;
@@ -66,13 +67,13 @@
 #ifdef __SVR4
     /* Read in old values, change to what we need and then send back */
     if (ioctl(fileno(ft->fp), AUDIO_GETDEV, &audio_dev) < 0) {
-	st_fail_errno(ft,errno,"Unable to get device information.");
-	return(ST_EOF);
+        st_fail_errno(ft,errno,"Unable to get device information.");
+        return(ST_EOF);
     }
     st_report("Hardware detected:  %s\n",audio_dev.name);
     if (strcmp("SUNW,am79c30",audio_dev.name) == 0)
     {
-	simple_hw = 1;
+        simple_hw = 1;
     }
 #endif
 
@@ -79,98 +80,98 @@
     // If simple hardware detected in force data to ulaw.
     if (simple_hw)
     {
-	if (ft->info.size == ST_SIZE_BYTE)
-	{
-	    if (ft->info.encoding != ST_ENCODING_ULAW && 
-		ft->info.encoding != ST_ENCODING_ALAW)
-	    {
-		st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
-		ft->info.encoding = ST_ENCODING_ULAW;
-	    }
-	}
-	else if (ft->info.size == ST_SIZE_WORD)
-	{
-	    st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
-	    ft->info.size = ST_SIZE_BYTE;
-	    ft->info.encoding = ST_ENCODING_ULAW;
-	}
+        if (ft->info.size == ST_SIZE_BYTE)
+        {
+            if (ft->info.encoding != ST_ENCODING_ULAW &&
+                ft->info.encoding != ST_ENCODING_ALAW)
+            {
+                st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
+                ft->info.encoding = ST_ENCODING_ULAW;
+            }
+        }
+        else if (ft->info.size == ST_SIZE_WORD)
+        {
+            st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
+            ft->info.size = ST_SIZE_BYTE;
+            ft->info.encoding = ST_ENCODING_ULAW;
+        }
     }
-   
+
     if (ft->info.size == ST_SIZE_BYTE) {
-	samplesize = 8;
-	if (ft->info.encoding != ST_ENCODING_ULAW &&
-	    ft->info.encoding != ST_ENCODING_ALAW &&
-	    ft->info.encoding != ST_ENCODING_SIGN2) {
-	    st_fail_errno(ft,ST_EFMT,"Sun Audio driver only supports ULAW, ALAW, and Signed Linear for bytes.");
-		return (ST_EOF);
-	}
-	if ((ft->info.encoding == ST_ENCODING_ULAW || 
-	     ft->info.encoding == ST_ENCODING_ALAW) && ft->info.channels == 2)
-	{
-	    st_report("Warning: only support mono for ULAW and ALAW data.  Forcing to mono");
-	    ft->info.channels = 2;
-	}
+        samplesize = 8;
+        if (ft->info.encoding != ST_ENCODING_ULAW &&
+            ft->info.encoding != ST_ENCODING_ALAW &&
+            ft->info.encoding != ST_ENCODING_SIGN2) {
+            st_fail_errno(ft,ST_EFMT,"Sun Audio driver only supports ULAW, ALAW, and Signed Linear for bytes.");
+                return (ST_EOF);
+        }
+        if ((ft->info.encoding == ST_ENCODING_ULAW ||
+             ft->info.encoding == ST_ENCODING_ALAW) && ft->info.channels == 2)
+        {
+            st_report("Warning: only support mono for ULAW and ALAW data.  Forcing to mono");
+            ft->info.channels = 2;
+        }
     }
     else if (ft->info.size == ST_SIZE_WORD) {
-	samplesize = 16;
-	if (ft->info.encoding != ST_ENCODING_SIGN2) {
-	    st_fail_errno(ft,ST_EFMT,"Sun Audio driver only supports Signed Linear for words.");
-	    return(ST_EOF);
-	}
+        samplesize = 16;
+        if (ft->info.encoding != ST_ENCODING_SIGN2) {
+            st_fail_errno(ft,ST_EFMT,"Sun Audio driver only supports Signed Linear for words.");
+            return(ST_EOF);
+        }
     }
     else {
-	st_fail_errno(ft,ST_EFMT,"Sun Audio driver only supports bytes and words");
-	return(ST_EOF);
+        st_fail_errno(ft,ST_EFMT,"Sun Audio driver only supports bytes and words");
+        return(ST_EOF);
     }
 
     if (ft->info.channels == -1) ft->info.channels = 1;
     else if (ft->info.channels > 1) {
-	st_report("Warning: some sun audio devices can not play stereo");
-	st_report("at all or sometime only with signed words.  If the");
-	st_report("sound seems sluggish then this is probably the case.");
-	st_report("Try forcing output to signed words or use the avg");
-	st_report("filter to reduce the number of channels.");
-	ft->info.channels = 2;
+        st_report("Warning: some sun audio devices can not play stereo");
+        st_report("at all or sometime only with signed words.  If the");
+        st_report("sound seems sluggish then this is probably the case.");
+        st_report("Try forcing output to signed words or use the avg");
+        st_report("filter to reduce the number of channels.");
+        ft->info.channels = 2;
     }
 
     /* Read in old values, change to what we need and then send back */
     if (ioctl(fileno(ft->fp), AUDIO_GETINFO, &audio_if) < 0) {
-	st_fail_errno(ft,errno,"Unable to initialize /dev/audio");
-	return(ST_EOF);
+        st_fail_errno(ft,errno,"Unable to initialize /dev/audio");
+        return(ST_EOF);
     }
     audio_if.record.precision = samplesize;
     audio_if.record.channels = ft->info.channels;
     audio_if.record.sample_rate = ft->info.rate;
     if (ft->info.encoding == ST_ENCODING_ULAW)
-	encoding = AUDIO_ENCODING_ULAW;
+        encoding = AUDIO_ENCODING_ULAW;
     else if (ft->info.encoding == ST_ENCODING_ALAW)
-	encoding = AUDIO_ENCODING_ALAW;
+        encoding = AUDIO_ENCODING_ALAW;
     else
-	encoding = AUDIO_ENCODING_LINEAR;
+        encoding = AUDIO_ENCODING_LINEAR;
     audio_if.record.encoding = encoding;
-    
+
     ioctl(fileno(ft->fp), AUDIO_SETINFO, &audio_if);
     if (audio_if.record.precision != samplesize) {
         st_fail_errno(ft,errno,"Unable to initialize sample size for /dev/audio");
-	return(ST_EOF);
+        return(ST_EOF);
     }
     if (audio_if.record.channels != ft->info.channels) {
-	st_fail_errno(ft,errno,"Unable to initialize number of channels for /dev/audio");
-	return(ST_EOF);
+        st_fail_errno(ft,errno,"Unable to initialize number of channels for /dev/audio");
+        return(ST_EOF);
     }
     if (audio_if.record.sample_rate != ft->info.rate) {
-	st_fail_errno(ft,errno,"Unable to initialize rate for /dev/audio");
-	return(ST_EOF);
+        st_fail_errno(ft,errno,"Unable to initialize rate for /dev/audio");
+        return(ST_EOF);
     }
     if (audio_if.record.encoding != encoding) {
-	st_fail_errno(ft,errno,"Unable to initialize encoding for /dev/audio");
-	return(ST_EOF);
+        st_fail_errno(ft,errno,"Unable to initialize encoding for /dev/audio");
+        return(ST_EOF);
     }
     /* Flush any data in the buffers - its probably in the wrong format */
     ioctl(fileno(ft->fp), I_FLUSH, FLUSHR);
     /* Change to non-buffered I/O*/
     setvbuf(ft->fp, NULL, _IONBF, sizeof(char) * ft->file.size);
-    sigintreg(ft);	/* Prepare to catch SIGINT */
+    sigintreg(ft);      /* Prepare to catch SIGINT */
 
     return (ST_SUCCESS);
 }
@@ -190,75 +191,75 @@
     ft->file.eof = 0;
     ft->file.size = 1024;
     if ((ft->file.buf = malloc (ft->file.size)) == NULL) {
-	st_fail_errno(ft,ST_ENOMEM,"unable to allocate output buffer of size %d", ft->file.size);
-	return(ST_EOF);
+        st_fail_errno(ft,ST_ENOMEM,"unable to allocate output buffer of size %d", ft->file.size);
+        return(ST_EOF);
     }
 
 #ifdef __SVR4
     /* Read in old values, change to what we need and then send back */
     if (ioctl(fileno(ft->fp), AUDIO_GETDEV, &audio_dev) < 0) {
-	st_fail_errno(ft,errno,"Unable to get device information.");
-	return(ST_EOF);
+        st_fail_errno(ft,errno,"Unable to get device information.");
+        return(ST_EOF);
     }
     st_report("Hardware detected:  %s\n",audio_dev.name);
     if (strcmp("SUNW,am79c30",audio_dev.name) == 0)
     {
-	simple_hw = 1;
+        simple_hw = 1;
     }
 #endif
 
     if (simple_hw)
     {
-	if (ft->info.size == ST_SIZE_BYTE)
-	{
-	    if (ft->info.encoding != ST_ENCODING_ULAW && 
-		ft->info.encoding != ST_ENCODING_ALAW)
-	    {
-		st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
-		ft->info.encoding = ST_ENCODING_ULAW;
-	    }
-	}
-	else if (ft->info.size == ST_SIZE_WORD)
-	{
-	    st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
-	    ft->info.size = ST_SIZE_BYTE;
-	    ft->info.encoding = ST_ENCODING_ULAW;
-	}
+        if (ft->info.size == ST_SIZE_BYTE)
+        {
+            if (ft->info.encoding != ST_ENCODING_ULAW &&
+                ft->info.encoding != ST_ENCODING_ALAW)
+            {
+                st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
+                ft->info.encoding = ST_ENCODING_ULAW;
+            }
+        }
+        else if (ft->info.size == ST_SIZE_WORD)
+        {
+            st_report("Warning: Detected simple hardware.  Forcing output to ULAW");
+            ft->info.size = ST_SIZE_BYTE;
+            ft->info.encoding = ST_ENCODING_ULAW;
+        }
     }
- 
+
     if (ft->info.rate == 0.0) ft->info.rate = 8000;
     if (ft->info.size == -1) ft->info.size = ST_SIZE_BYTE;
     if (ft->info.encoding == -1) ft->info.encoding = ST_ENCODING_ULAW;
 
     if (ft->info.size == ST_SIZE_BYTE) {
-	samplesize = 8;
-	if (ft->info.encoding != ST_ENCODING_ULAW &&
-	    ft->info.encoding != ST_ENCODING_ALAW &&
-	    ft->info.encoding != ST_ENCODING_SIGN2) {
-	    st_report("Sun Audio driver only supports ULAW, ALAW, and Signed Linear for bytes.");
-	    st_report("Forcing to ULAW");
-	    ft->info.encoding = ST_ENCODING_ULAW;
-	}
-	if ((ft->info.encoding == ST_ENCODING_ULAW || 
-	     ft->info.encoding == ST_ENCODING_ALAW) && ft->info.channels == 2)
-	{
-	    st_report("Warning: only support mono for ULAW and ALAW data.  Forcing to mono");
-	    ft->info.channels = 2;
-	}
+        samplesize = 8;
+        if (ft->info.encoding != ST_ENCODING_ULAW &&
+            ft->info.encoding != ST_ENCODING_ALAW &&
+            ft->info.encoding != ST_ENCODING_SIGN2) {
+            st_report("Sun Audio driver only supports ULAW, ALAW, and Signed Linear for bytes.");
+            st_report("Forcing to ULAW");
+            ft->info.encoding = ST_ENCODING_ULAW;
+        }
+        if ((ft->info.encoding == ST_ENCODING_ULAW ||
+             ft->info.encoding == ST_ENCODING_ALAW) && ft->info.channels == 2)
+        {
+            st_report("Warning: only support mono for ULAW and ALAW data.  Forcing to mono");
+            ft->info.channels = 2;
+        }
 
     }
     else if (ft->info.size == ST_SIZE_WORD) {
-	samplesize = 16;
-	if (ft->info.encoding != ST_ENCODING_SIGN2) {
-	    st_report("Sun Audio driver only supports Signed Linear for words.");
-	    st_report("Forcing to Signed Linear");
-	    ft->info.encoding = ST_ENCODING_SIGN2;
-	}
+        samplesize = 16;
+        if (ft->info.encoding != ST_ENCODING_SIGN2) {
+            st_report("Sun Audio driver only supports Signed Linear for words.");
+            st_report("Forcing to Signed Linear");
+            ft->info.encoding = ST_ENCODING_SIGN2;
+        }
     }
     else {
-	st_report("Sun Audio driver only supports bytes and words");
-	ft->info.size = ST_SIZE_WORD;
-	samplesize = 16;
+        st_report("Sun Audio driver only supports bytes and words");
+        ft->info.size = ST_SIZE_WORD;
+        samplesize = 16;
     }
 
     if (ft->info.channels == -1) ft->info.channels = 1;
@@ -266,36 +267,36 @@
 
     /* Read in old values, change to what we need and then send back */
     if (ioctl(fileno(ft->fp), AUDIO_GETINFO, &audio_if) < 0) {
-	st_fail_errno(ft,errno,"Unable to initialize /dev/audio");
-	return(ST_EOF);
+        st_fail_errno(ft,errno,"Unable to initialize /dev/audio");
+        return(ST_EOF);
     }
     audio_if.play.precision = samplesize;
     audio_if.play.channels = ft->info.channels;
     audio_if.play.sample_rate = ft->info.rate;
     if (ft->info.encoding == ST_ENCODING_ULAW)
-	encoding = AUDIO_ENCODING_ULAW;
+        encoding = AUDIO_ENCODING_ULAW;
     else if (ft->info.encoding == ST_ENCODING_ALAW)
-	encoding = AUDIO_ENCODING_ALAW;
+        encoding = AUDIO_ENCODING_ALAW;
     else
-	encoding = AUDIO_ENCODING_LINEAR;
+        encoding = AUDIO_ENCODING_LINEAR;
     audio_if.play.encoding = encoding;
-    
+
     ioctl(fileno(ft->fp), AUDIO_SETINFO, &audio_if);
     if (audio_if.play.precision != samplesize) {
-	st_fail_errno(ft,errno,"Unable to initialize sample size for /dev/audio");
-	return(ST_EOF);
+        st_fail_errno(ft,errno,"Unable to initialize sample size for /dev/audio");
+        return(ST_EOF);
     }
     if (audio_if.play.channels != ft->info.channels) {
-	st_fail_errno(ft,errno,"Unable to initialize number of channels for /dev/audio");
-	return(ST_EOF);
+        st_fail_errno(ft,errno,"Unable to initialize number of channels for /dev/audio");
+        return(ST_EOF);
     }
     if (audio_if.play.sample_rate != ft->info.rate) {
-	st_fail_errno(ft,errno,"Unable to initialize rate for /dev/audio");
-	return(ST_EOF);
+        st_fail_errno(ft,errno,"Unable to initialize rate for /dev/audio");
+        return(ST_EOF);
     }
     if (audio_if.play.encoding != encoding) {
-	st_fail_errno(ft,errno,"Unable to initialize encoding for /dev/audio");
-	return(ST_EOF);
+        st_fail_errno(ft,errno,"Unable to initialize encoding for /dev/audio");
+        return(ST_EOF);
     }
     /* Change to non-buffered I/O */
     setvbuf(ft->fp, NULL, _IONBF, sizeof(char) * ft->file.size);
--- a/src/util.c
+++ b/src/util.c
@@ -421,7 +421,7 @@
                 return ST_EOF;
         }
 
-        if ((ft->info.size <= 0) || (ft->info.size > ST_SIZE_MAX))
+        if ((ft->info.size <= 0) || (ft->info.size > ST_INFO_SIZE_MAX))
         {
                 st_fail_errno(ft,ST_EFMT,"data size %i is invalid");
                 return ST_EOF;
--- a/src/voc.c
+++ b/src/voc.c
@@ -373,8 +373,8 @@
         vs_t v = (vs_t) ft->priv;
         unsigned char uc, block;
         ULONG sblen;
-        u_int16_t new_rate_16;
-        u_int32_t new_rate_32;
+        uint16_t new_rate_16;
+        uint32_t new_rate_32;
         int i;
         ULONG trash;
 
--- a/src/wav.c
+++ b/src/wav.c
@@ -394,10 +394,10 @@
 /* General Sox WAV file code                                                */
 /****************************************************************************/
 
-static u_int32_t findChunk(ft_t ft, const char *Label)
+static uint32_t findChunk(ft_t ft, const char *Label)
 {
     char magic[5];
-    u_int32_t len;
+    uint32_t len;
     for (;;)
     {
 	if (st_reads(ft, magic, 4) == ST_EOF)
@@ -427,23 +427,23 @@
 {
     wav_t	wav = (wav_t) ft->priv;
     char	magic[5];
-    u_int32_t	len;
+    uint32_t	len;
     int		rc;
 
     /* wave file characteristics */
-    u_int32_t      dwRiffLength;
+    uint32_t      dwRiffLength;
     unsigned short wChannels;	    /* number of channels */
-    u_int32_t      dwSamplesPerSecond; /* samples per second per channel */
-    u_int32_t      dwAvgBytesPerSec;/* estimate of bytes per second needed */
+    uint32_t      dwSamplesPerSecond; /* samples per second per channel */
+    uint32_t      dwAvgBytesPerSec;/* estimate of bytes per second needed */
     unsigned short wBitsPerSample;  /* bits per sample */
     unsigned short wFmtSize;
     unsigned short wExtSize = 0;    /* extended field for non-PCM */
 
-    u_int32_t      dwDataLength;    /* length of sound data in bytes */
+    uint32_t      dwDataLength;    /* length of sound data in bytes */
     ULONG    bytesPerBlock = 0;
     ULONG    bytespersample;	    /* bytes per sample (per channel */
     char text[256];
-    u_int32_t      dwLoopPos;
+    uint32_t      dwLoopPos;
 
 	ft->st_errno = ST_SUCCESS;
 
@@ -1218,7 +1218,7 @@
 	unsigned short wFormatTag = 0;      /* data format */
 	unsigned short wChannels;           /* number of channels */
 	ULONG  dwSamplesPerSecond;          /* samples per second per channel*/
-	u_int32_t dwAvgBytesPerSec=0;       /* estimate of bytes per second needed */
+	uint32_t dwAvgBytesPerSec=0;       /* estimate of bytes per second needed */
 	unsigned short wBlockAlign=0;       /* byte alignment of a basic sample block */
 	unsigned short wBitsPerSample=0;    /* bits per sample */
 	/* fmt chunk extension (not PCM) */
@@ -1231,7 +1231,7 @@
 	ULONG wSamplesWritten=0;	/* windows doesnt seem to use this*/
 
 	/* data chunk */
-	u_int32_t  dwDataLength=0x7ffff000L;	/* length of sound data in bytes */
+	uint32_t  dwDataLength=0x7ffff000L;	/* length of sound data in bytes */
 	/* end of variables written to header */
 
 	/* internal variables, intermediate values etc */
--- a/src/wve.c
+++ b/src/wve.c
@@ -16,7 +16,7 @@
 
 typedef struct wvepriv
     {
-    u_int32_t length;
+    uint32_t length;
     short padding;
     short repeats;
 /* For seeking */