summaryrefslogtreecommitdiff
path: root/src/common/long.c
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2013-01-27 23:51:56 +0000
committerIgor Pashev <pashev.igor@gmail.com>2013-01-27 23:51:56 +0000
commit6ab0c0f5bf14ed9c15370407b9ee7e0b4b089ae1 (patch)
tree926065cf45450116098db664e3c61dced9e1f21a /src/common/long.c
downloadicon-6ab0c0f5bf14ed9c15370407b9ee7e0b4b089ae1.tar.gz
Initial upstream version 9.4.3upstream/9.4.3
Diffstat (limited to 'src/common/long.c')
-rw-r--r--src/common/long.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/common/long.c b/src/common/long.c
new file mode 100644
index 0000000..071a944
--- /dev/null
+++ b/src/common/long.c
@@ -0,0 +1,34 @@
+/*
+ * long.c -- functions for handling long values on 16-bit computers.
+ */
+
+#include "../h/gsupport.h"
+
+/*
+ * Write a long string in int-sized chunks.
+ */
+
+long longwrite(s,len,file)
+FILE *file;
+char *s;
+long len;
+{
+ long tally = 0;
+ int n = 0;
+ int leftover, loopnum;
+ char *p;
+
+ leftover = (int)(len % (long)MaxInt);
+ for (p = s, loopnum = (int)(len / (long)MaxInt); loopnum; loopnum--) {
+ n = fwrite(p,sizeof(char),MaxInt,file);
+ tally += (long)n;
+ p += MaxInt;
+ }
+ if (leftover) {
+ n = fwrite(p,sizeof(char),leftover,file);
+ tally += (long)n;
+ }
+ if (tally != len)
+ return -1;
+ else return tally;
+ }