changeset 306:8136fb5eb292

fc-fsio: write_buf_to_file() function made global in prep for upload-rf-table
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 21 Nov 2017 06:09:35 +0000
parents 3d79116be312
children 67d57375e3ad
files rvinterf/etmsync/fswrite.c rvinterf/etmsync/pirmagnetite.c
diffstat 2 files changed, 26 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/etmsync/fswrite.c	Mon Nov 20 17:51:23 2017 +0000
+++ b/rvinterf/etmsync/fswrite.c	Tue Nov 21 06:09:35 2017 +0000
@@ -161,3 +161,29 @@
 		return(ERROR_USAGE);
 	}
 }
+
+write_buf_to_file(pathname, data, datalen)
+	char *pathname;
+	u_char *data;
+{
+	int tfd, rc, chunk, remain;
+
+	if (datalen <= max_short_file_write(pathname))
+		return do_short_fwrite(pathname, data, datalen);
+	/* do it the long way */
+	rc = fd_open(pathname, FFS_O_WRONLY | FFS_O_CREATE | FFS_O_TRUNC, &tfd);
+	if (rc)
+		return(rc);
+	for (remain = datalen; remain; remain -= chunk) {
+		chunk = remain;
+		if (chunk > 240)
+			chunk = 240;
+		rc = fd_write(tfd, data, chunk);
+		if (rc) {
+			fd_close(tfd);
+			return(rc);
+		}
+		data += chunk;
+	}
+	return fd_close(tfd);
+}
--- a/rvinterf/etmsync/pirmagnetite.c	Mon Nov 20 17:51:23 2017 +0000
+++ b/rvinterf/etmsync/pirmagnetite.c	Tue Nov 21 06:09:35 2017 +0000
@@ -56,33 +56,6 @@
 }
 
 static
-write_buf_to_file(pathname, data, datalen)
-	char *pathname;
-	u_char *data;
-{
-	int tfd, rc, chunk, remain;
-
-	if (datalen <= max_short_file_write(pathname))
-		return do_short_fwrite(pathname, data, datalen);
-	/* do it the long way */
-	rc = fd_open(pathname, FFS_O_WRONLY | FFS_O_CREATE | FFS_O_TRUNC, &tfd);
-	if (rc)
-		return(rc);
-	for (remain = datalen; remain; remain -= chunk) {
-		chunk = remain;
-		if (chunk > 240)
-			chunk = 240;
-		rc = fd_write(tfd, data, chunk);
-		if (rc) {
-			fd_close(tfd);
-			return(rc);
-		}
-		data += chunk;
-	}
-	return fd_close(tfd);
-}
-
-static
 copy_calib_record(memaddr, pathname, size)
 	u32 memaddr;
 	char *pathname;