---
 include/s3/s3io.h                    |    4 ++--
 src/libs/libcommon/lexicon.c         |    1 +
 src/libs/libcommon/mk_phone_seq.c    |    1 +
 src/libs/libio/corpus.c              |    1 +
 src/libs/libio/s3lamb_io.c           |    6 ++++--
 src/libs/libio/s3map_io.c            |    6 ++++--
 src/libs/libio/s3mixw_io.c           |    1 +
 src/libs/libio/segdmp.c              |   21 +++++++++++----------
 src/programs/agg_seg/agg_all_seg.c   |    1 +
 src/programs/agg_seg/agg_phn_seg.c   |    2 ++
 src/programs/bw/next_utt_states.c    |    1 +
 src/programs/cdcn_norm/main.c        |    2 ++
 src/programs/init_gau/init_gau.c     |    1 +
 src/programs/kmeans_init/main.c      |    1 +
 src/programs/map_adapt/main.c        |    1 +
 src/programs/param_cnt/enum_corpus.h |    1 +
 16 files changed, 35 insertions(+), 16 deletions(-)

--- a/src/libs/libcommon/lexicon.c
+++ b/src/libs/libcommon/lexicon.c
@@ -47,6 +47,7 @@
 #include <sphinxbase/ckd_alloc.h>
 #include <sphinxbase/hash_table.h>
 #include <sphinxbase/pio.h>
+#include <sphinxbase/strfuncs.h>
 
 #include <s3/s3.h>
 
--- a/src/libs/libcommon/mk_phone_seq.c
+++ b/src/libs/libcommon/mk_phone_seq.c
@@ -45,6 +45,7 @@
 
 #include <sphinxbase/ckd_alloc.h>
 #include <sphinxbase/err.h>
+#include <sphinxbase/strfuncs.h>
 
 #include <s3/mk_phone_seq.h>
 #include <s3/mk_phone_list.h>
--- a/src/libs/libio/corpus.c
+++ b/src/libs/libio/corpus.c
@@ -75,6 +75,7 @@
 #include <s3/mllr_io.h>
 #include <s3/acmod_set.h>
 #include <s3/s3.h>
+#include <s3/s3io.h>
 
 #include <stdio.h>
 #include <string.h>
--- a/src/libs/libio/s3lamb_io.c
+++ b/src/libs/libio/s3lamb_io.c
@@ -44,6 +44,8 @@
  *    Eric Thayer (eht@cs.cmu.edu)
  *********************************************************************/
 
+#include <sphinxbase/bio.h>
+
 #include <s3/s3lamb_io.h>
 #include <s3/s3io.h>
 #include <s3/s3.h>
@@ -138,7 +140,7 @@ s3lamb_write(const char *fn,
 	return S3_ERROR;
     }
 
-    if (bio_fwrite(&chksum, sizeof(uint32), 1, fp, &ignore) != 1) {
+    if (bio_fwrite(&chksum, sizeof(uint32), 1, fp, 0, &ignore) != 1) {
 	s3close(fp);
 
 	return S3_ERROR;
@@ -239,7 +241,7 @@ s3lambcnt_write(const char *fn,
 	return S3_ERROR;
     }
 
-    if (bio_fwrite(&chksum, sizeof(uint32), 1, fp, &ignore) != 1) {
+    if (bio_fwrite(&chksum, sizeof(uint32), 1, fp, 0, &ignore) != 1) {
 	s3close(fp);
 
 	return S3_ERROR;
--- a/src/libs/libio/s3map_io.c
+++ b/src/libs/libio/s3map_io.c
@@ -43,6 +43,8 @@
  * 
  *********************************************************************/
 
+#include <sphinxbase/bio.h>
+
 #include <s3/s3map_io.h>
 #include <s3/s3io.h>
 
@@ -143,7 +145,7 @@ s3map_write(const char *fn,
     if (fp == NULL)
 	return S3_ERROR;
 
-    if (bio_fwrite(&n_rng, sizeof(uint32), 1, fp, &chksum) != 1) {
+    if (bio_fwrite(&n_rng, sizeof(uint32), 1, fp, 0, &chksum) != 1) {
 	s3close(fp);
 
 	return S3_ERROR;
@@ -159,7 +161,7 @@ s3map_write(const char *fn,
 	return S3_ERROR;
     }
 
-    if (bio_fwrite(&chksum, sizeof(uint32), 1, fp, &ignore) != 1) {
+    if (bio_fwrite(&chksum, sizeof(uint32), 1, fp, 0, &ignore) != 1) {
 	s3close(fp);
 
 	return S3_ERROR;
--- a/src/libs/libio/s3mixw_io.c
+++ b/src/libs/libio/s3mixw_io.c
@@ -45,6 +45,7 @@
 
 #include <s3/s3mixw_io.h>
 #include <sphinxbase/matrix.h>
+#include <sphinxbase/bio.h>
 #include <s3/s3io.h>
 #include <s3/s3.h>
 
--- a/src/libs/libio/segdmp.c
+++ b/src/libs/libio/segdmp.c
@@ -49,6 +49,7 @@
 #include <sphinxbase/ckd_alloc.h>
 #include <sphinxbase/cmd_ln.h>
 #include <sphinxbase/err.h>
+#include <sphinxbase/bio.h>
 
 #include <s3/segdmp.h>
 #include <s3/s3io.h>
@@ -132,7 +133,7 @@ write_seg_inorder(FILE *fp,
 
     for (cur = s; cur;) {
 	l = frame_sz * cur->len;
-	if (bio_fwrite((void *)&frm_buf[cur->idx], 1, l, fp, &ignore) != l) {
+	if (bio_fwrite((void *)&frm_buf[cur->idx], 1, l, fp, 0, &ignore) != l) {
 	    E_ERROR_SYSTEM("Unable to write to dump file\n");
 	    
 	    return S3_ERROR;
@@ -294,7 +295,7 @@ write_idx(uint32 part)
     uint32 onefrm;
     uint32 i, j, ttt, n;
 
-    if (bio_fwrite(&n_id, sizeof(uint32), 1, idx_fp[part], &ignore) != 1) {
+    if (bio_fwrite(&n_id, sizeof(uint32), 1, idx_fp[part], 0, &ignore) != 1) {
 	E_FATAL_SYSTEM("Unable to write index file");
 
 	return S3_ERROR;
@@ -306,13 +307,13 @@ write_idx(uint32 part)
 	onefrm = FALSE;
 
     /* Write one frame per segment flag */
-    if (bio_fwrite(&onefrm, sizeof(uint32), 1, idx_fp[part], &ignore) != 1) {
+    if (bio_fwrite(&onefrm, sizeof(uint32), 1, idx_fp[part], 0, &ignore) != 1) {
 	E_FATAL_SYSTEM("Unable to write index file");
 
 	return S3_ERROR;
     }
 
-    if (bio_fwrite(&frame_sz, sizeof(uint32), 1, idx_fp[part], &ignore) != 1) {
+    if (bio_fwrite(&frame_sz, sizeof(uint32), 1, idx_fp[part], 0, &ignore) != 1) {
 	E_FATAL_SYSTEM("Unable to write index file");
 
 	return S3_ERROR;
@@ -328,31 +329,31 @@ write_idx(uint32 part)
 
     i = ttt;
 
-    if (bio_fwrite(&i, sizeof(uint32), 1, idx_fp[part], &ignore) != 1) {
+    if (bio_fwrite(&i, sizeof(uint32), 1, idx_fp[part], 0, &ignore) != 1) {
 	E_FATAL_SYSTEM("Unable to write index file");
 
 	return S3_ERROR;
     }
-    if (bio_fwrite(&n, sizeof(uint32), 1, idx_fp[part], &ignore) != 1) {
+    if (bio_fwrite(&n, sizeof(uint32), 1, idx_fp[part], 0, &ignore) != 1) {
 	E_FATAL_SYSTEM("Unable to write index file");
 
 	return S3_ERROR;
     }
 
     for (; (i < n_id) && (id_part[i] == part); i++) {
-	if (bio_fwrite(&n_seg[i], sizeof(uint32), 1, idx_fp[part], &ignore) != 1) {
+	if (bio_fwrite(&n_seg[i], sizeof(uint32), 1, idx_fp[part], 0, &ignore) != 1) {
 	    E_FATAL_SYSTEM("Unable to write index file");
 	    
 	    return S3_ERROR;
 	}
-	if (bio_fwrite(&id_off[i], sizeof(uint32), 1, idx_fp[part], &ignore) != 1) {
+	if (bio_fwrite(&id_off[i], sizeof(uint32), 1, idx_fp[part], 0, &ignore) != 1) {
 	    E_FATAL_SYSTEM("Unable to write index file");
 	    
 	    return S3_ERROR;
 	}
 	if (!onefrm) {
 	    for (j = 0; j < n_seg[i]; j++) {
-		if (bio_fwrite(&n_frame[i][j], sizeof(uint32), 1, idx_fp[part], &ignore) != 1) {
+		if (bio_fwrite(&n_frame[i][j], sizeof(uint32), 1, idx_fp[part], 0, &ignore) != 1) {
 		    E_FATAL_SYSTEM("Unable to write index file");
 		    
 		    return S3_ERROR;
@@ -589,7 +590,7 @@ segdmp_open_write(const char **dirs,		/*
 	    
 	    idx_fp[i] = s3open(idx_fn, "wb", NULL);
 	    
-	    if (bio_fwrite((int *)&data_type, sizeof(int), 1, idx_fp[i], &ignore) != 1) {
+	    if (bio_fwrite((int *)&data_type, sizeof(int), 1, idx_fp[i], 0, &ignore) != 1) {
 		E_FATAL_SYSTEM("unable to write seg dmp file");
 	    }
 	    if (write_idx(i) == S3_SUCCESS) {
--- a/src/programs/agg_seg/agg_phn_seg.c
+++ b/src/programs/agg_seg/agg_phn_seg.c
@@ -54,6 +54,8 @@
 
 #include <sphinxbase/ckd_alloc.h>
 #include <sphinxbase/feat.h>
+#include <sphinxbase/strfuncs.h>
+#include <sphinxbase/bio.h>
 
 #include <stdio.h>
 #include <assert.h>
--- a/src/programs/bw/next_utt_states.c
+++ b/src/programs/bw/next_utt_states.c
@@ -48,6 +48,7 @@
 #include <s3/lexicon.h>
 #include <s3/model_inventory.h>
 #include <sphinxbase/ckd_alloc.h>
+#include <sphinxbase/strfuncs.h>
 #include <s3/mk_phone_list.h>
 #include <s3/cvt2triphone.h>
 
--- a/src/programs/cdcn_norm/main.c
+++ b/src/programs/cdcn_norm/main.c
@@ -45,6 +45,8 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include <s3/s3io.h>
+
 #include "header.h"
 
 #define DESCRIPTION "\nProgram to compensate speech cepstra files for the effect of noise and channel\nPerforms normalization on a bunch of noisy files given clean speech statistics\n(CDCN style statistics). The routine reads the noisy files from the input path\nand dumps the compensated files in the output path. The control files should\nNOT contain file extensions.\nNOTE: The program assumes that the dimension of the CDCN statistics and the\n    data are the same. If your cepstral files and the distribution have \n    different dimensionality the program will die a horrible death!!\n"
--- a/src/programs/init_gau/init_gau.c
+++ b/src/programs/init_gau/init_gau.c
@@ -66,6 +66,7 @@
 #include <sphinxbase/ckd_alloc.h>
 #include <sphinxbase/cmd_ln.h>
 #include <sphinxbase/feat.h>
+#include <sphinxbase/strfuncs.h>
 
 
 int
--- a/src/programs/kmeans_init/main.c
+++ b/src/programs/kmeans_init/main.c
@@ -51,6 +51,7 @@
 #include <sphinxbase/feat.h>
 #include <sphinxbase/err.h>
 #include <sphinxbase/profile.h>
+#include <sphinxbase/bio.h>
 
 #include <s3/lexicon.h>
 #include <s3/model_def_io.h>
--- a/src/programs/map_adapt/main.c
+++ b/src/programs/map_adapt/main.c
@@ -34,6 +34,7 @@
 #include <s3/s3acc_io.h>
 #include <s3/s3.h>
 #include <s3/ts2cb.h>
+#include <s3/s3ts2cb_io.h>
 
 #include <sphinxbase/matrix.h>
 #include <sphinxbase/err.h>
--- a/src/programs/param_cnt/enum_corpus.h
+++ b/src/programs/param_cnt/enum_corpus.h
@@ -49,6 +49,7 @@
 #include <s3/lexicon.h>
 #include <s3/model_def_io.h>
 #include <sphinxbase/prim_type.h>
+#include <sphinxbase/strfuncs.h>
 #include "cnt_fn.h"
 
 int
--- a/src/programs/agg_seg/agg_all_seg.c
+++ b/src/programs/agg_seg/agg_all_seg.c
@@ -55,6 +55,7 @@
 #include <sphinxbase/cmd_ln.h>
 #include <sphinxbase/ckd_alloc.h>
 #include <sphinxbase/feat.h>
+#include <sphinxbase/bio.h>
 
 #include <sys_compat/misc.h>
 
--- a/include/s3/s3io.h
+++ b/include/s3/s3io.h
@@ -82,8 +82,8 @@ s3add_fattr(char *attrib,
 int
 s3close(FILE *fp);
 
-int32
-s3read_intv_3d(void ****arr,
+int
+bio_fread_intv_3d(void ****arr,
 	       size_t e_sz,
 	       uint32 s,
 	       uint32 e,
