shithub: sox

Download patch

ref: 6a4089121199cdf117c097f80a4404c14e158fa2
parent: e30f496ce4e358faf9598b94f8c6ea1b6c79a306
author: cbagwell <cbagwell>
date: Sun Dec 12 23:33:51 EST 1999

Added support for C++ programs using the libst.

--- a/cut.c
+++ b/cut.c
@@ -62,7 +62,7 @@
 void cut_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	cut_t cut = (cut_t) effp->priv;
 	int len, done;
@@ -98,7 +98,7 @@
 void cut_drain(effp, obuf, osamp)
 eff_t effp;
 LONG *obuf;
-int *osamp;
+LONG *osamp;
 {
 	*osamp = 0;
 }
--- a/dyn.c
+++ b/dyn.c
@@ -55,7 +55,7 @@
 void dyn_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	int len, done;
 	
@@ -93,7 +93,7 @@
 
 void dyn_drain(effp, obuf, osamp)
 LONG *obuf;
-int *osamp;
+LONG *osamp;
 {
 	*osamp = 0;
 }
--- a/pick.c
+++ b/pick.c
@@ -99,7 +99,7 @@
 void pick_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	pick_t pick = (pick_t) effp->priv;
 	int len, done;
--- a/split.c
+++ b/split.c
@@ -70,7 +70,7 @@
 void split_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	int len, done;
 
--- a/src/auto.c
+++ b/src/auto.c
@@ -73,7 +73,7 @@
                 }
 	report("Type AUTO changed to %s", type);
 	ft->filetype = type;
-	gettype(ft); /* Change ft->h to the new format */
+	st_gettype(ft); /* Change ft->h to the new format */
 	(* ft->h->startread)(ft);
 }
 
--- a/src/avg.c
+++ b/src/avg.c
@@ -103,7 +103,7 @@
 void avg_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	avg_t avg = (avg_t) effp->priv;
 	int len, done;
--- a/src/band.c
+++ b/src/band.c
@@ -108,7 +108,7 @@
 void band_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	band_t band = (band_t) effp->priv;
 	int len, done;
--- a/src/btrworth.c
+++ b/src/btrworth.c
@@ -56,7 +56,7 @@
 butterworth_flow (effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
   butterworth_t butterworth = (butterworth_t) effp->priv;
 
--- a/src/btrworth.h
+++ b/src/btrworth.h
@@ -33,7 +33,7 @@
 
 void butterworth_start (P1 (eff_t effp));
 void butterworth_flow (P5 (eff_t effp, LONG *ibuf, LONG *obuf,
-                       int *isamp, int *osamp));
+                           LONG *isamp, LONG *osamp));
 
 typedef struct butterworth {
   double x [2];
--- a/src/chorus.c
+++ b/src/chorus.c
@@ -210,7 +210,7 @@
 void chorus_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	chorus_t chorus = (chorus_t) effp->priv;
 	int len, done;
@@ -250,7 +250,7 @@
 void chorus_drain(effp, obuf, osamp)
 eff_t effp;
 LONG *obuf;
-int *osamp;
+LONG *osamp;
 {
 	chorus_t chorus = (chorus_t) effp->priv;
 	int done;
--- a/src/copy.c
+++ b/src/copy.c
@@ -45,7 +45,7 @@
 void copy_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	int done;
 	
--- a/src/deemphas.c
+++ b/src/deemphas.c
@@ -159,7 +159,7 @@
 void deemph_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
      deemph_t deemph = (deemph_t) effp->priv;
      int len, done;
@@ -182,7 +182,7 @@
 
 void deemph_drain(effp, obuf, osamp)
 LONG *obuf;
-int *osamp;
+LONG *osamp;
 {
      /* nothing to do */
 }
--- a/src/echo.c
+++ b/src/echo.c
@@ -161,7 +161,7 @@
 void echo_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	echo_t echo = (echo_t) effp->priv;
 	int len, done;
@@ -199,7 +199,7 @@
 void echo_drain(effp, obuf, osamp)
 eff_t effp;
 LONG *obuf;
-int *osamp;
+LONG *osamp;
 {
 	echo_t echo = (echo_t) effp->priv;
 	double d_in, d_out;
--- a/src/echos.c
+++ b/src/echos.c
@@ -150,7 +150,7 @@
 void echos_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	echos_t echos = (echos_t) effp->priv;
 	int len, done;
@@ -194,7 +194,7 @@
 void echos_drain(effp, obuf, osamp)
 eff_t effp;
 LONG *obuf;
-int *osamp;
+LONG *osamp;
 {
 	echos_t echos = (echos_t) effp->priv;
 	double d_in, d_out;
--- a/src/flanger.c
+++ b/src/flanger.c
@@ -172,7 +172,7 @@
 void flanger_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	flanger_t flanger = (flanger_t) effp->priv;
 	int len, done;
@@ -208,7 +208,7 @@
 void flanger_drain(effp, obuf, osamp)
 eff_t effp;
 LONG *obuf;
-int *osamp;
+LONG *osamp;
 {
 	flanger_t flanger = (flanger_t) effp->priv;
 	int done;
--- a/src/highp.c
+++ b/src/highp.c
@@ -1,4 +1,3 @@
-
 /*
  * July 5, 1991
  * Copyright 1991 Lance Norskog And Sundry Contributors
@@ -69,7 +68,7 @@
 void highp_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	highp_t highp = (highp_t) effp->priv;
 	int len, done;
--- a/src/lowp.c
+++ b/src/lowp.c
@@ -67,7 +67,7 @@
 void lowp_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	lowp_t lowp = (lowp_t) effp->priv;
 	int len, done;
--- a/src/map.c
+++ b/src/map.c
@@ -62,6 +62,6 @@
 void map_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 }
--- a/src/mask.c
+++ b/src/mask.c
@@ -48,7 +48,7 @@
 void mask_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	int len, done;
 	
--- a/src/phaser.c
+++ b/src/phaser.c
@@ -169,7 +169,7 @@
 void phaser_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	phaser_t phaser = (phaser_t) effp->priv;
 	int len, done;
@@ -205,7 +205,7 @@
 void phaser_drain(effp, obuf, osamp)
 eff_t effp;
 LONG *obuf;
-int *osamp;
+LONG *osamp;
 {
 	phaser_t phaser = (phaser_t) effp->priv;
 	int done;
--- a/src/polyphas.c
+++ b/src/polyphas.c
@@ -49,11 +49,11 @@
 
 typedef struct polyphase {
 
-  unsigned long lcmrate;         /* least common multiple of rates */
-  unsigned long inskip, outskip; /* LCM increments for I & O rates */
+  ULONG lcmrate;       		 /* least common multiple of rates */
+  ULONG inskip, outskip;	 /* LCM increments for I & O rates */
   double Factor;                 /* out_rate/in_rate               */
-  unsigned long total;           /* number of filter stages        */
-  unsigned long oskip;           /* output samples to skip at start*/
+  ULONG total;          	 /* number of filter stages        */
+  ULONG oskip;   	         /* output samples to skip at start*/
   double inpipe;                 /* output samples 'in the pipe'   */
   polystage *stage[MF];          /* array of pointers to polystage structs */
 
@@ -383,7 +383,7 @@
 
     st_initrand();
 
-    rate->lcmrate = st_lcm((long)effp->ininfo.rate, (long)effp->outinfo.rate);
+    rate->lcmrate = st_lcm((LONG)effp->ininfo.rate, (LONG)effp->outinfo.rate);
 
     /* Cursory check for LCM overflow.  
      * If both rate are below 65k, there should be no problem.
@@ -519,7 +519,7 @@
 
 }
 
-void poly_flow(eff_t effp, long *ibuf, long *obuf, long *isamp, long *osamp)
+void poly_flow(eff_t effp, LONG *ibuf, LONG *obuf, LONG *isamp, LONG *osamp)
 {
   poly_t rate = (poly_t) effp->priv;
   polystage *s0,*s1;
@@ -578,9 +578,9 @@
   }
 
   {
-    long *q;
-    long out_size;
-    long oskip;
+    LONG *q;
+    LONG out_size;
+    LONG oskip;
     Float *out_buf;
     int k;
 
@@ -615,9 +615,9 @@
 /*
  * Process tail of input samples.
  */
-void poly_drain(eff_t effp, long *obuf, long *osamp)
+void poly_drain(eff_t effp, LONG *obuf, LONG *osamp)
 {
-  long in_size;
+  LONG in_size;
   /* Call "flow" with NULL input. */
   poly_flow(effp, NULL, obuf, &in_size, osamp);
 }
--- a/src/rate.c
+++ b/src/rate.c
@@ -99,7 +99,7 @@
 void rate_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	rate_t rate = (rate_t) effp->priv;
 	LONG *istart,*iend;
--- a/src/reverb.c
+++ b/src/reverb.c
@@ -192,7 +192,7 @@
 void reverb_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	reverb_t reverb = (reverb_t) effp->priv;
 	int len, done;
@@ -228,7 +228,7 @@
 void reverb_drain(effp, obuf, osamp)
 eff_t effp;
 LONG *obuf;
-int *osamp;
+LONG *osamp;
 {
 	reverb_t reverb = (reverb_t) effp->priv;
 	float d_in, d_out;
--- a/src/reverse.c
+++ b/src/reverse.c
@@ -66,7 +66,7 @@
 void reverse_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	reverse_t reverse = (reverse_t) effp->priv;
 
@@ -85,7 +85,7 @@
 void reverse_drain(effp, obuf, osamp)
 eff_t effp;
 LONG *obuf;
-int *osamp;
+LONG *osamp;
 {
 	reverse_t reverse = (reverse_t) effp->priv;
 	int len, nbytes;
--- a/src/silence.c
+++ b/src/silence.c
@@ -68,7 +68,7 @@
 void silence_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	silence_t silence = (silence_t) effp->priv;
 	int len, done;
@@ -94,7 +94,7 @@
 
 void skel_drain(effp, obuf, osamp)
 LONG *obuf;
-int *osamp;
+LONG *osamp;
 {
 	*osamp = 0;
 }
--- a/src/skeleff.c
+++ b/src/skeleff.c
@@ -59,7 +59,7 @@
 void skeleff_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
     skeleff_t skeleff = (skeleff_t) effp->priv;
     int len, done;
@@ -94,7 +94,7 @@
 
 void skeleff_drain(effp, obuf, osamp)
 LONG *obuf;
-int *osamp;
+LONG *osamp;
 {
 	*osamp = 0;
 }
--- a/src/sox.c
+++ b/src/sox.c
@@ -56,7 +56,13 @@
 #endif
 #endif
 
+#if defined(VMS)
+#define LASTCHAR	']'
+#elif defined(DOS) || defined(WIN32)
+#define LASTCHAR	'\\'
+#else
 #define LASTCHAR        '/'
+#endif
 
 /*
  * SOX main program.
@@ -172,11 +178,11 @@
 	if (optind < argc) {
 		eff.name = argv[optind];
 		optind++;
-		geteffect(&eff);
+		st_geteffect(&eff);
 		(* eff.h->getopts)(&eff, argc - optind, &argv[optind]);
 	} else {
 		eff.name = "null";
-		geteffect(&eff);
+		st_geteffect(&eff);
 	}
 
 	/* Check global arguments */
@@ -394,13 +400,13 @@
     LONG i;
     int e, f, havedata;
 
-    gettype(&informat);
+    st_gettype(&informat);
     if (writing)
-	gettype(&outformat);
+	st_gettype(&outformat);
     
     /* Read and write starters can change their formats. */
     (* informat.h->startread)(&informat);
-    checkformat(&informat);
+    st_checkformat(&informat);
     
     if (informat.info.dovol)
 	report("Volume factor: %f\n", informat.info.vol);
@@ -454,10 +460,10 @@
 	outformat.seekable  = (filetype(fileno(informat.fp)) == S_IFREG);
 #endif
 
-	copyformat(&informat, &outformat);
+	st_copyformat(&informat, &outformat);
 	(* outformat.h->startwrite)(&outformat);
-	checkformat(&outformat);
-	cmpformats(&informat, &outformat);
+	st_checkformat(&outformat);
+	st_cmpformats(&informat, &outformat);
 	report("Output file: using sample rate %lu\n\tsize %s, style %s, %d %s",
 	       outformat.info.rate, sizes[outformat.info.size], 
 	       styles[outformat.info.style], outformat.info.channels, 
@@ -860,8 +866,8 @@
 			    memcpy(&efftabR[i], &eff, sizeof(struct effect));
 		} else {
 			/* set up & give default opts for added effects */
-			geteffect(&efftab[i]);
-			(* efftab[i].h->getopts)(&efftab[i],0,(char *)0);
+			st_geteffect(&efftab[i]);
+			(* efftab[i].h->getopts)(&efftab[i],(int)0,(char **)0);
 			if (efftabR[i].name) 
 			    memcpy(&efftabR[i], &efftab[i], 
 				sizeof(struct effect));
--- a/src/st.h
+++ b/src/st.h
@@ -11,6 +11,10 @@
  * the consequences of using this software.
  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #ifdef HAVE_MALLOC_H
@@ -53,24 +57,33 @@
 #define REGPARM(n)
 #endif
 
-/*
- * Handler structure for each format.
- */
+/* FIXME: Move to internal st header */
+#if	defined(__STDC__) || defined(__cplusplus)
+#define	P0 void
+#define	P1(a) a
+#define	P2(a,b) a, b
+#define	P3(a,b,c) a, b, c
+#define	P4(a,b,c,d) a, b, c, d
+#define	P5(a,b,c,d,e) a, b, c, d, e
+#define	P6(a,b,c,d,e,f) a, b, c, d, e, f
+#define	P7(a,b,c,d,e,f,g) a, b, c, d, e, f, g
+#define	P8(a,b,c,d,e,f,g,h) a, b, c, d, e, f, g, h
+#define	P9(a,b,c,d,e,f,g,h,i) a, b, c, d, e, f, g, h, i
+#define	P10(a,b,c,d,e,f,g,h,i,j) a, b, c, d, e, f, g, h, i, j
+#else
+#define	P0
+#define	P1(a)
+#define	P2(a,b)
+#define	P3(a,b,c)
+#define	P4(a,b,c,d)
+#define	P5(a,b,c,d,e)
+#define	P6(a,b,c,d,e,f)
+#define	P7(a,b,c,d,e,f,g)
+#define	P8(a,b,c,d,e,f,g,h)
+#define	P9(a,b,c,d,e,f,g,h,i)
+#define	P10(a,b,c,d,e,f,g,h,i,j)
+#endif
 
-typedef struct format {
-	char	**names;	/* file type names */
-	int	flags;		/* details about file type */
-	void	(*startread)();			
-	LONG	(*read)();			
-	void	(*stopread)();		
-	void	(*startwrite)();			
-	void	(*write)();
-	void	(*stopwrite)();		
-} format_t;
-
-/* FIXME: Does this need to be here? */ 
-extern format_t formats[];
-
 /* Signal parameters */
 
 /* FIXME: Change to typedef */
@@ -142,6 +155,23 @@
 
 #define NLOOPS		8
 
+/*
+ * Handler structure for each format.
+ */
+
+typedef struct soundstream *ft_t;
+
+typedef struct format {
+	char	**names;	/* file type names */
+	int	flags;		/* details about file type */
+	void	(*startread)(P1(ft_t ft));			
+	LONG	(*read)(P3(ft_t ft, LONG *buf, LONG len));			
+	void	(*stopread)(P1(ft_t ft));		
+	void	(*startwrite)(P1(ft_t ft));			
+	void	(*write)(P3(ft_t ft, LONG *buf, LONG len));
+	void	(*stopwrite)(P1(ft_t ft));		
+} format_t;
+
 struct soundstream {
 	struct	signalinfo info;	/* signal specifications */
 	struct  instrinfo instr;	/* instrument specification */
@@ -158,7 +188,8 @@
 	double	priv[PRIVSIZE/8];	/* format's private data area */
 };
 
-typedef struct soundstream *ft_t;
+/* FIXME: Does this need to be here? */ 
+extern format_t formats[];
 
 /* FIXME: Prefix all #defines with ST_ */
 /* flags field */
@@ -190,27 +221,32 @@
 extern const char *sizes[];
 extern const char *styles[];
 
+#define	EFF_CHAN	1		/* Effect can mix channels up/down */
+#define EFF_RATE	2		/* Effect can alter data rate */
+#define EFF_MCHAN	4		/* Effect can handle multi-channel */
+#define EFF_REPORT	8		/* Effect does nothing */
+
 /*
  * Handler structure for each effect.
  */
 
+typedef struct effect *eff_t;
+
 typedef struct {
 	char	*name;			/* effect name */
 	int	flags;			/* this and that */
-	void	(*getopts)();		/* process arguments */
-	void	(*start)();		/* start off effect */
-	void	(*flow)();		/* do a buffer */
-	void	(*drain)();		/* drain out at end */
-	void	(*stop)();		/* finish up effect */
+					/* process arguments */
+	void	(*getopts)(P3(eff_t effp, int argc, char **argv));
+					/* start off effect */
+	void	(*start)(P1(eff_t effp));
+					/* do a buffer */
+	void	(*flow)(P5(eff_t effp, LONG *ibuf, LONG *obuf,
+			   LONG *isamp, LONG *osamp));
+					/* drain out at end */
+	void	(*drain)(P3(eff_t effp, LONG *obuf, LONG *osamp));
+	void	(*stop)(P1(eff_t effp));/* finish up effect */
 } effect_t;
 
-extern effect_t effects[]; /* declared in handlers.c */
-
-#define	EFF_CHAN	1		/* Effect can mix channels up/down */
-#define EFF_RATE	2		/* Effect can alter data rate */
-#define EFF_MCHAN	4		/* Effect can handle multi-channel */
-#define EFF_REPORT	8		/* Effect does nothing */
-
 struct effect {
 	char		*name;		/* effect name */
 	struct signalinfo ininfo;	/* input signal specifications */
@@ -223,35 +259,8 @@
 	double		priv[PRIVSIZE];	/* private area for effect */
 };
 
-typedef struct effect *eff_t;
+extern effect_t effects[]; /* declared in handlers.c */
 
-/* FIXME: Move to internal st header */
-#if	defined(__STDC__)
-#define	P0 void
-#define	P1(a) a
-#define	P2(a,b) a, b
-#define	P3(a,b,c) a, b, c
-#define	P4(a,b,c,d) a, b, c, d
-#define	P5(a,b,c,d,e) a, b, c, d, e
-#define	P6(a,b,c,d,e,f) a, b, c, d, e, f
-#define	P7(a,b,c,d,e,f,g) a, b, c, d, e, f, g
-#define	P8(a,b,c,d,e,f,g,h) a, b, c, d, e, f, g, h
-#define	P9(a,b,c,d,e,f,g,h,i) a, b, c, d, e, f, g, h, i
-#define	P10(a,b,c,d,e,f,g,h,i,j) a, b, c, d, e, f, g, h, i, j
-#else
-#define	P0
-#define	P1(a)
-#define	P2(a,b)
-#define	P3(a,b,c)
-#define	P4(a,b,c,d)
-#define	P5(a,b,c,d,e)
-#define	P6(a,b,c,d,e,f)
-#define	P7(a,b,c,d,e,f,g)
-#define	P8(a,b,c,d,e,f,g,h)
-#define	P9(a,b,c,d,e,f,g,h,i)
-#define	P10(a,b,c,d,e,f,g,h,i,j)
-#endif
-
 /* declared in misc.c */
 extern LONG st_clip24(P1(LONG)) REGPARM(1);
 extern void st_sine(P4(int *, LONG, int, int));
@@ -259,10 +268,14 @@
 
 extern LONG st_gcd(P2(LONG,LONG)) REGPARM(2);
 extern LONG st_lcm(P2(LONG,LONG)) REGPARM(2);
+
 /****************************************************/
 /* Prototypes for internal cross-platform functions */
 /****************************************************/
 /* SJB: shouldn't these be elsewhere, exported from misc.c */
+/* CB: Yep, we need to create something like a "platform.h" file for
+ * these type functions.
+ */
 #ifndef HAVE_RAND
 extern int rand(P0);
 extern void srand(P1(ULONG seed));
@@ -315,11 +328,11 @@
 void warn(P2(const char *, ...));
 void fail(P2(const char *, ...))NORET;
 
-void geteffect(P1(eff_t));
-void gettype(P1(ft_t));
-void checkformat(P1(ft_t));
-void copyformat(P2(ft_t, ft_t));
-void cmpformats(P2(ft_t, ft_t));
+void st_geteffect(P1(eff_t));
+void st_gettype(P1(ft_t));
+void st_checkformat(P1(ft_t));
+void st_copyformat(P2(ft_t, ft_t));
+void st_cmpformats(P2(ft_t, ft_t));
 
 /* FIXME: Recording hacks shouldn't display a "sigint" style interface.
  * Instead we should provide a function to call when done playing/recording.
@@ -349,5 +362,9 @@
 #define REMOVE unlink
 
 const char *version(P0);			/* return version number */
+
+#ifdef __cplusplus
+} /* end of extern "C" */
+#endif
 
 #endif
--- a/src/stat.c
+++ b/src/stat.c
@@ -117,7 +117,7 @@
 void stat_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	stat_t stat = (stat_t) effp->priv;
 	int len, done;
--- a/src/util.c
+++ b/src/util.c
@@ -93,7 +93,7 @@
  * Check that we have a known format suffix string.
  */
 void
-gettype(formp)
+st_gettype(formp)
 ft_t formp;
 {
 	char **list;
@@ -133,7 +133,7 @@
  * Check that we have a known effect name.
  */
 void
-geteffect(effp)
+st_geteffect(effp)
 eff_t effp;
 {
 	int i;
@@ -160,7 +160,7 @@
  * File format routines 
  */
 
-void copyformat(ft, ft2)
+void st_copyformat(ft, ft2)
 ft_t ft, ft2;
 {
 	int noise = 0, i;
@@ -201,13 +201,13 @@
 	ft2->instr = ft->instr;
 }
 
-void cmpformats(ft, ft2)
+void st_cmpformats(ft, ft2)
 ft_t ft, ft2;
 {
 }
 
 /* check that all settings have been given */
-void checkformat(ft) 
+void st_checkformat(ft) 
 ft_t ft;
 {
 	if (ft->info.rate == 0)
--- a/src/vibro.c
+++ b/src/vibro.c
@@ -100,7 +100,7 @@
 void vibro_flow(effp, ibuf, obuf, isamp, osamp)
 eff_t effp;
 LONG *ibuf, *obuf;
-int *isamp, *osamp;
+LONG *isamp, *osamp;
 {
 	vibro_t vibro = (vibro_t) effp->priv;
 	register int counter, tablen;