summaryrefslogtreecommitdiffstats
path: root/runtime/stpd/stp_dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/stpd/stp_dump.c')
-rw-r--r--runtime/stpd/stp_dump.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/runtime/stpd/stp_dump.c b/runtime/stpd/stp_dump.c
new file mode 100644
index 00000000..74dbc012
--- /dev/null
+++ b/runtime/stpd/stp_dump.c
@@ -0,0 +1,82 @@
+/*
+ * stp_dump.c - stp data dump program
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) Redhat Inc, 2005
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+static void usage (char *prog)
+{
+ fprintf(stderr, "%s input_file \n", prog);
+ exit(1);
+}
+
+#define TIMESTAMP_SIZE 11
+
+int main (int argc, char *argv[])
+{
+ char buf[32];
+ int c, seq, lastseq = 0;
+ FILE *fp;
+
+ if (argc != 2)
+ usage(argv[0]);
+
+ fp = fopen(argv[1], "r");
+ if (!fp) {
+ fprintf(stderr, "ERROR: couldn't open input file %s: errcode = %s\n",
+ argv[1], strerror(errno));
+ return -1;
+ }
+
+ while (1) {
+ int numbytes = 0;
+
+ if (fread (buf, TIMESTAMP_SIZE, 1, fp))
+ seq = strtoul (buf, NULL, 10);
+ else
+ break;
+
+ if (seq < lastseq)
+ fprintf(stderr, "WARNING: seq %d followed by %d\n", lastseq, seq);
+ lastseq = seq;
+
+ while (1) {
+ c = fgetc_unlocked(fp);
+ if (c == 0 || c == EOF)
+ break;
+ numbytes++;
+ }
+ printf ("<%d><%d BYTES>", seq, numbytes);
+ if (c == 0)
+ printf ("<0>\n");
+ else {
+ printf ("<EOF>\n");
+ break;
+ }
+ }
+
+ printf ("DONE\n");
+ fclose (fp);
+ return 0;
+}