summaryrefslogtreecommitdiffstats
path: root/gnu/usr.sbin/isdn/load
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1995-02-15 00:46:26 +0000
committerjkh <jkh@FreeBSD.org>1995-02-15 00:46:26 +0000
commit0cb129cc755064f31fb42abf2c721a8605381511 (patch)
tree87521af8f33d69817699aec072374bf2d3734e3e /gnu/usr.sbin/isdn/load
downloadFreeBSD-src-0cb129cc755064f31fb42abf2c721a8605381511.zip
FreeBSD-src-0cb129cc755064f31fb42abf2c721a8605381511.tar.gz
Import the ISDN userland utilities. Just about ready to start shaking
this baby out in earnest..
Diffstat (limited to 'gnu/usr.sbin/isdn/load')
-rw-r--r--gnu/usr.sbin/isdn/load/Makefile5
-rw-r--r--gnu/usr.sbin/isdn/load/load.c117
2 files changed, 122 insertions, 0 deletions
diff --git a/gnu/usr.sbin/isdn/load/Makefile b/gnu/usr.sbin/isdn/load/Makefile
new file mode 100644
index 0000000..31bc381
--- /dev/null
+++ b/gnu/usr.sbin/isdn/load/Makefile
@@ -0,0 +1,5 @@
+PROG= load
+CFLAGS+= -DBSD -O
+NOMAN= yes
+
+.include <bsd.prog.mk>
diff --git a/gnu/usr.sbin/isdn/load/load.c b/gnu/usr.sbin/isdn/load/load.c
new file mode 100644
index 0000000..fa9e600
--- /dev/null
+++ b/gnu/usr.sbin/isdn/load/load.c
@@ -0,0 +1,117 @@
+static char rcsid[] = "@(#)$Id: load.c,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $";
+/*******************************************************************************
+ * II - Version 0.1 $Revision: 1.1 $ $State: Exp $
+ *
+ * Copyright 1994 Dietmar Friede
+ *******************************************************************************
+ * Bug reports, patches, comments, suggestions should be sent to:
+ *
+ * jkr@saarlink.de or jkrause@guug.de
+ *
+ *******************************************************************************
+ * $Log: load.c,v $
+ *
+ ******************************************************************************/
+
+#include <sys/types.h>
+#undef BSD
+#include <sys/param.h>
+#include <machine/endian.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/file.h>
+#include <time.h>
+#include "../../../../sys/gnu/i386/isa/niccyreg.h"
+
+struct head head;
+char buf[64 * 1024];
+
+void
+main(int argc, char **argv)
+{
+ FILE *f;
+ int n;
+ argv++;
+
+ if ((n = open("/dev/nic0", O_RDWR)) < 0)
+ {
+ perror("open");
+ exit(1);
+ }
+ if (!*argv)
+ {
+ process(stdin, n);
+ } else
+ while (*argv)
+ {
+ if ((f = fopen(*argv, "r")) == NULL)
+ {
+ perror(*argv);
+ exit(1);
+ } else
+ {
+ process(f, n);
+ fclose(f);
+ }
+ argv++;
+ }
+ exit(0);
+}
+
+stime(int f)
+{
+ struct tm *t;
+ time_t tt;
+ char buf[16];
+
+ tt = time(NULL);
+ t = localtime(&tt);
+ sprintf(buf, "%.2d%.2d%.2d%.2d%.2d19%.2d", t->tm_hour,
+ t->tm_min, t->tm_sec, t->tm_mday, t->tm_mon + 1, t->tm_year);
+
+ if (ioctl(f, NICCY_SET_CLOCK, buf) < 0)
+ {
+ perror("ioctl");
+ }
+}
+
+
+process(FILE * f, int n)
+{
+ long size;
+ int len;
+ int no = 0;
+
+ while ((len = fread(buf, 1, 0x16, f)) == 0x16)
+ {
+ bcopy(buf, (char *) &head, 0x16);
+ head.data = buf;
+ size = ntohl(head.len);
+ if ((len = fread(&buf[0x16], 1, size - 0x16, f)) != (size - 0x16))
+ {
+ fprintf(stderr, "Cannot read modul %.8s of length %d\n",
+ head.nam, size);
+ exit(1);
+ }
+ printf("%d\t %x %.8s %.5s %x\n",
+ size, head.sig, head.nam, head.ver, head.typ);
+
+ head.d_len = size;
+ head.status = no++;
+
+ if (ioctl(n, NICCY_LOAD, &head) < 0)
+ {
+ perror("load");
+ exit(1);
+ }
+ if (head.status)
+ {
+ fprintf(stderr, "Error loading %d\n", head.status);
+ exit(1);
+ }
+ }
+ printf("done\n");
+
+ stime(n);
+}
OpenPOWER on IntegriCloud