summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Lucien Van Elsen <lwvanels@mit.edu>1992-08-14 08:28:33 +0000
committerGravatar Lucien Van Elsen <lwvanels@mit.edu>1992-08-14 08:28:33 +0000
commit45fe5b454e190de8a805bc52a14658e69075cb44 (patch)
treea410c71727eb7a85e22f9ca395cfcadbc54cf2cc /lib
parentecba71b29c9a172731209c07806abcbdc41cbeef (diff)
Initial revision
Diffstat (limited to 'lib')
-rw-r--r--lib/inet_ntoa.c36
-rw-r--r--lib/smwgc.c64
2 files changed, 100 insertions, 0 deletions
diff --git a/lib/inet_ntoa.c b/lib/inet_ntoa.c
new file mode 100644
index 0000000..df91da9
--- /dev/null
+++ b/lib/inet_ntoa.c
@@ -0,0 +1,36 @@
+/* This file is part of the Project Athena Zephyr Notification System.
+ * It contains a version of the standard inet_ntoa function, for use
+ * on a Sun 4 with gcc version 1.
+ *
+ * Created by: Ken Raeburn
+ *
+ * $Source$
+ * $Author$
+ *
+ * Copyright (c) 1991 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, see the file
+ * "mit-copyright.h".
+ */
+
+#include <zephyr/mit-copyright.h>
+
+#ifndef lint
+static char rcsid_inet_ntoa_c[] = "$Zephyr$";
+#endif
+
+#if defined (sparc) && __GNUC__ == 1
+/* GCC version 1 passes structures incorrectly on the Sparc.
+ This addition will cause things to work correctly if everything
+ using inet_ntoa is compiled with gcc. If not, you lose anyways. */
+char *inet_ntoa (addr)
+ struct in_addr addr;
+{
+ static char buf[16];
+ sprintf (buf, "%d.%d.%d.%d",
+ addr.S_un.S_un_b.s_b1,
+ addr.S_un.S_un_b.s_b2,
+ addr.S_un.S_un_b.s_b3,
+ addr.S_un.S_un_b.s_b4);
+ return buf;
+}
+#endif
diff --git a/lib/smwgc.c b/lib/smwgc.c
new file mode 100644
index 0000000..2289654
--- /dev/null
+++ b/lib/smwgc.c
@@ -0,0 +1,64 @@
+/* Copyright (c) 1988 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ */
+#include <zephyr/zephyr.h>
+
+main()
+{
+ FILE *fp;
+ char buf[512],*ptr;
+ int auth,retval;
+ u_short port;
+ ZNotice_t notice;
+ ZSubscription_t sub;
+ struct sockaddr_in from;
+
+ if ((retval = ZInitialize()) != ZERR_NONE) {
+ com_err("foo",retval,"initing");
+ exit(1);
+ }
+
+ port = 0;
+ if ((retval = ZOpenPort(&port)) != ZERR_NONE) {
+ com_err("foo",retval,"opening port");
+ exit(1);
+ }
+ printf("Using port %d\n",(int)port);
+ sprintf(buf,"/tmp/wg.%d",getuid());
+ fp = fopen(buf,"w");
+ if (!fp) {
+ com_err("foo",errno,"opening file");
+ exit(1);
+ }
+ fprintf(fp,"%d\n",(int)port);
+ fclose(fp);
+
+ printf("All ready...\n");
+
+ sub.class = "MESSAGE";
+ sub.classinst = "PERSONAL";
+ sub.recipient = ZGetSender();
+
+ if ((retval = ZSubscribeTo(&sub,1,port)) != ZERR_NONE) {
+ com_err("foo",retval,"subscribing");
+ exit(1);
+ }
+ for (;;) {
+ if ((retval = ZReceiveNotice(&notice,&from)) != ZERR_NONE) {
+ com_err("foo",retval,"receiving packet");
+ continue;
+ }
+ auth = ZCheckAuthentication(&notice,&from);
+ printf("Class = %s Instance = %s Sender = %s\nTime = %s Auth = %d\n",
+ notice.z_class,notice.z_class_inst,notice.z_sender,
+ ctime(&notice.z_time.tv_sec),auth);
+ printf("Len = %d\n",notice.z_message_len);
+/* ptr = notice.z_message;
+ for (;ptr<notice.z_message+notice.z_message_len;) {
+ printf("%s\n",ptr);
+ ptr += strlen(ptr)+1;
+ }
+ printf("\n");*/
+ ZFreeNotice(&notice);
+ }
+}