summaryrefslogtreecommitdiff
path: root/userspace/checker.c
diff options
context:
space:
mode:
Diffstat (limited to 'userspace/checker.c')
-rw-r--r--userspace/checker.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/userspace/checker.c b/userspace/checker.c
new file mode 100644
index 0000000..e5352f6
--- /dev/null
+++ b/userspace/checker.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+
+int main()
+
+{
+FILE *fp; /* The file handle for input data */
+fp=stdin;
+int ch; /* Each character read. */
+int checksum = 0; /* The checksum mod 2^16. */
+int count=0;
+
+while ((ch = getc(fp)) != EOF) {
+ checksum = (checksum >> 1) + ((checksum & 1) << 15);
+ checksum +=(int) ch;
+ checksum &= 0xffff; /* Keep it within bounds. */
+ count++;
+}
+printf("checksum : 0x%08X for %i bytes\n",checksum,count);
+}