1 /* Copyright (c) 1988 by the Massachusetts Institute of Technology.
4 #include <zephyr/zephyr.h>
14 struct sockaddr_in from;
16 if ((retval = ZInitialize()) != ZERR_NONE) {
17 com_err("foo",retval,"initing");
22 if ((retval = ZOpenPort(&port)) != ZERR_NONE) {
23 com_err("foo",retval,"opening port");
26 printf("Using port %d\n",(int)port);
27 sprintf(buf,"/tmp/wg.%d",getuid());
30 com_err("foo",errno,"opening file");
33 fprintf(fp,"%d\n",(int)port);
36 printf("All ready...\n");
38 sub.class = "MESSAGE";
39 sub.classinst = "PERSONAL";
40 sub.recipient = ZGetSender();
42 if ((retval = ZSubscribeTo(&sub,1,port)) != ZERR_NONE) {
43 com_err("foo",retval,"subscribing");
47 if ((retval = ZReceiveNotice(¬ice,&from)) != ZERR_NONE) {
48 com_err("foo",retval,"receiving packet");
51 auth = ZCheckAuthentication(¬ice,&from);
52 printf("Class = %s Instance = %s Sender = %s\nTime = %s Auth = %d\n",
53 notice.z_class,notice.z_class_inst,notice.z_sender,
54 ctime(¬ice.z_time.tv_sec),auth);
55 printf("Len = %d\n",notice.z_message_len);
56 /* ptr = notice.z_message;
57 for (;ptr<notice.z_message+notice.z_message_len;) {