Internet Relay Chat (IRC) Part 4/6

david bleckmann bleckmd at jacobs.cs.orst.edu
Tue Jun 20 13:33:50 AEST 1989


---- Cut Here and unpack ----
#!/bin/sh
# this is part 4 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file help.c continued
#
CurArch=4
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file help.c"
sed 's/^X//' << 'SHAR_EOF' >> help.c
X    putline(helpbuf);
X    for (count = 0; count < 5; count++)
X      if (hptr->explanation[count] && *(hptr->explanation[count])) {
X	sprintf(helpbuf, "          %s", hptr->explanation[count]);
X	putline(helpbuf);
X      }
X    putline("*** End Help");
X  }
X  return(0);
X}
X
SHAR_EOF
echo "File help.c is complete"
chmod 0600 help.c || echo "restore of help.c fails"
set `wc -c help.c`;Sum=$1
if test "$Sum" != "2192"
then echo original size 2192, current size $Sum;fi
echo "x - extracting help.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > help.h &&
X/*************************************************************************
X ** help.h  Beta v2.0    (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author:           Jarkko Oikarinen
X **         Internet: jto at tolsun.oulu.fi
X **             UUCP: ...!mcvax!tut!oulu!jto
X **           BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X
Xstruct Help {
X  char *command, *syntax, *explanation[5];
X};
X
X#define NULL ((char *) 0)
X
Xstruct Help helplist[] = {
X  { "HELP", "/help <command>",
X    "Query help for specific command",
X    "If called without parameter, lists all commands", "", "", "" },
X  { "SIGNOFF", "/signoff",
X    "The correct way of logging out from IRC.", "", "", "", "" },
X  { "WHO", "/who <channel>",
X    "Lists users on a specific channel",
X    "If <channel> parameter is left out, lists all users",
X    "(you cannot see users on other negative channels though)",
X    "If called '/who *' then lists all users on the same channel as you", "" },
X  { "WHOIS", "/whois <nick>",
X    "Query information about nickname",
X    "Users name, host and server are listed to you", "", "", "" },
X  { "LIST", "/list",
X    "Lists all channels and their topics", "", "", "" },
X  { "TOPIC", "/topic <topic>",
X    "Sets a new topic for the channel you're on.", "", "", "", "" },
X  { "JOIN", "/join <channel>",
X    "Joins a new channel.",
X    "You are automatically removed from your current channel",
X    "This command is exactly the same as /channel command", "", "" },
X  { "CHANNEL", "/channel <channel>",
X    "Joins a new channel.",
X    "You are automatically removed from your current channel",
X    "This command is exactly the same as /join command", "", "" },
X  { "LINKS", "/links",
X    "List all Internet Relay Chat links currently up", "", "", "", "" },
X  { "MSG", "/msg <nicknamelist> <xxx>",
X    "Send private message to <nicknamelist>.",
X    "<nicknamelist> can contain one or more nicknames or channel numbers",
X    "separated by commas (,). For example /m joe,7 Hello! sends message",
X    "Hello! to user joe and channel 7. nicknames and channels must exist",
X    "on ircnet, otherwise an error is returned." },
X  { "INVITE", "/invite <nick>",
X    "Invite user to your channel.",
X    "Nick must be a nickname currently logged on some ircserver", "", "", "" },
X  { "SUMMON", "/summon <user>",
X    "Summon user from operating system level to IRC. User is eg.",
X    "guest at tolsun, where guest is user's username on that host, and tolsun",
X    "is the name of the host user is currently logged in. Host must be",
X    "running irc-daemon before you can summon anyone from there. Do NOT",
X    "use this command unless you really have something important to say"
X    },
X  { "USERS", "/users <host>",
X    "List all users logged on <host>.",
X    "Host must be running irc-daemon before you can list it's users",
X    "If parameter host is omitted, users on the server you're logged on,",
X    "are listed", "" },
X  { "STATS", "/stats",
X    "Show some stats. This command is not much use for ordinary user",
X    "", "", "", "" },
X  { "NICK", "/nick <nick>",
X    "Change your nickname. You cannot choose nickname already in use",
X    "Also some special characters are not allowed in nicknames",
X    "Do not change your nickname too often, it causes unnecessary",
X    "load to IRCnet", "" },
X  { "AWAY", "/away <msg>",
X    "Mark yourself as being away. With msg parameter you can specify",
X    "a message to be sent to all users trying to send private",
X    "messages to you", "", "" },
X  { "INFO", "/info",
X    "Short info of Internet Relay Chat", "", "", "", "" },
X  { "CLEAR", "/clear",
X    "Clears screen.", "", "", "", "" },
X  { "QUERY", "/query <nicknamelist>",
X    "Begins a private chat with <nicknamelist>. All normal messages you",
X    "send from now on are forwarded only to <nicknamelist>.",
X    "You can remove query just by calling query without any parameters,",
X    "e.g. /query", 
X    "/ without any parameters overrides /query's effect, like / blaah" },
X  { "CMDCH", "/cmdch c",
X    "Changes your command prefix character to c. For example, if you",
X    "type '/cmdch .', then you must prefix all commands from now on",
X    "with '.', like .who or .links", "", "" },
X  { "DATE", "/date [daemon]",
X    "Tells you the date in given daemon. If daemon parameter is not given,",
X    "default daemon is current daemon you're logged on", "", "", "" },
X  { "NAMES", "/names [channel]",
X    "List you all users on channel in compressed format. If channel is",
X    "omitted, lists all users on all channels", "", "", "" },
X  { "IGNORE", "/ignore [+|-]<nicknamelist>",
X    "Ignore toggles ignoreflags of given users on and off. Ignore without",
X    "parameters displays current ignorelist. If '+' is specified before",
X    "given nickname, all PUBLIC messages from given nickname are ignored",
X    "'-' respectively ignores all PRIVATE messages. Default is that both",
X    "public and private messages are ignored." },
X  { NULL, NULL, NULL, NULL, NULL, NULL, NULL }
X};
X
SHAR_EOF
chmod 0600 help.h || echo "restore of help.h fails"
set `wc -c help.h`;Sum=$1
if test "$Sum" != "5204"
then echo original size 5204, current size $Sum;fi
echo "x - extracting ignore.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ignore.c &&
X/*************************************************************************
X ** ignore.c  Beta v2.01.6    (09 May 1989)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author:           Jarkko Oikarinen
X **         Internet: jto at tolsun.oulu.fi
X **             UUCP: ...!mcvax!tut!oulu!jto
X **           BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X
Xchar ignore_id[]="ignore.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include "struct.h"
X#include "sys.h"
X
Xstruct Ignore *ignore = (struct Ignore *) 0;
Xchar ibuf[80];
Xextern struct Ignore *find_ignore();
X
Xdo_ignore(user)
Xchar *user;
X{
X  char *ch;
X  struct Ignore *iptr;
X  char *apu = user;
X  int status;
X  if ((user == (char *) 0) || (*user == '\0')) {
X    iptr = ignore;
X    putline("*** Current ignore list entries:");
X    while (iptr) {
X      sprintf(ibuf,"    Ignoring %s messages from user %s", 
X	      (iptr->flags == IGNORE_TOTAL) ? "all" :
X	      (iptr->flags == IGNORE_PRIVATE) ? "private" : "public", 
X	      iptr->user);
X      putline(ibuf);
X      iptr = iptr->next;
X    }
X    putline("*** End of ignore list entries");
X    return (0);
X  }
X  while (apu && *apu) {
X    ch = apu;
X    if (*ch == '+') {
X      ch++;
X      status = IGNORE_PUBLIC;
X    }
X    else if (*ch == '-') {
X      ch++;
X      status = IGNORE_PRIVATE;
X    }
X    else 
X      status = IGNORE_TOTAL;
X    if (apu = index(ch, ','))
X      *(apu++) = '\0';
X    if (iptr = find_ignore(ch, (struct Ignore *) 0)) {
X      sprintf(ibuf,"*** Ignore removed: user %s", iptr->user);
X      putline(ibuf);
X      kill_ignore(iptr);
X    } else {
X      if (strlen(ch) > NICKLEN)
X	ch[NICKLEN] = '\0';
X      if (add_ignore(ch, status) >= 0) {
X	sprintf(ibuf,"*** Ignore %s messages from user %s", 
X		(status == IGNORE_TOTAL) ? "all" :
X		(status == IGNORE_PRIVATE) ? "private" : "public", ch);
X	putline(ibuf);
X      } else
X	putline("Fatal Error: Cannot allocate memory for ignore buffer");
X    }
X  }
X}    
X
Xstruct Ignore *
Xfind_ignore(user, para)
Xchar *user;
Xstruct Ignore *para;
X{
X  struct Ignore *iptr = ignore;
X  while (iptr) {
X    if (myncmp(iptr->user, user, NICKLEN) == 0)
X      break;
X    iptr = iptr->next;
X  }
X  if (iptr)
X    return iptr;
X  else
X    return para;
X}
X
Xint
Xkill_ignore(iptr)
Xstruct Ignore *iptr;
X{
X  struct Ignore *i2ptr = ignore, *i3ptr = (struct Ignore *) 0;
X  while (i2ptr) {
X    if (i2ptr == iptr)
X      break;
X    i3ptr = i2ptr;
X    i2ptr = i2ptr->next;
X  }
X  if (i2ptr) {
X    if (i3ptr)
X      i3ptr->next = i2ptr->next;
X    else
X      ignore = i2ptr->next;
X    free(i2ptr);
X    return (1);
X  }
X  return (-1);
X}
X
Xint add_ignore(ch, status)
Xchar *ch;
Xint status;
X{
X  struct Ignore *iptr;
X  iptr = (struct Ignore *) malloc(sizeof (struct Ignore));
X  if (iptr == (struct Ignore *) 0)
X    return(-1);
X  strncpy(iptr->user, ch, NICKLEN);
X  iptr->user[NICKLEN] = '\0';
X  iptr->next = ignore;
X  ignore = iptr;
X  iptr->flags = status;
X  return(1);
X}
SHAR_EOF
chmod 0600 ignore.c || echo "restore of ignore.c fails"
set `wc -c ignore.c`;Sum=$1
if test "$Sum" != "3111"
then echo original size 3111, current size $Sum;fi
echo "x - extracting irc.1 (Text)"
sed 's/^X//' << 'SHAR_EOF' > irc.1 &&
X.\" @(#)irc.1 2.0 (beta version) 21 Oct 88 
X.TH Irc 1 "21 October 1988"
X.SH NAME
Xirc \- User Interface to Internet Relay Chat Protocol
X.SH SYNOPSIS
X\fBirc\fP [-pportnum] [ \fBnickname\fP [ \fBhost\fP ]]
X.SH DESCRIPTION
X.LP
X\fIIrc\fP is an user interface to Internet Relay Chat. It connects to
Xhost (if host is not given, default is the same host irc is running).
Xif nickname is not given, default is your login name.
XIf portnum is given, irc tries to connect that port on given host.
X.LP
XInside \fIIrc\fP you can get more help by writing /help in the beginning of
Xline.
X.SH EXAMPLE
X.RS
X.nf
Xtolmoon% \fBirc -p6667 Wizard tolsun\fP
X.fi
X.RE
X.LP
Xconnects you to irc server in host tolsun (port 6667) with nickname Wizard
X.SH COPYRIGHT
XCopyright (c) 1988 University of Oulu, Computing Center, Finland.
XAll rights reserved.
XFor full COPYRIGHT see COPYRIGHT file with IRC package.
X.SH "SEE ALSO"
Xircd(8)
X.SH BUGS
XSometimes users get logged off when some server dies. Reason unknown.
XIrc should never be stopped with CTRL-Z, with time buffers fill up and
Xserver may hang.
X.SH AUTHOR
XJarkko Oikarinen, currently jto at tolsun.oulu.fi
SHAR_EOF
chmod 0640 irc.1 || echo "restore of irc.1 fails"
set `wc -c irc.1`;Sum=$1
if test "$Sum" != "1122"
then echo original size 1122, current size $Sum;fi
echo "x - extracting irc.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > irc.c &&
X/*************************************************************************
X ** irc.c  Beta v2.0    (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author:           Jarkko Oikarinen
X **         Internet: jto at tolsun.oulu.fi
X **             UUCP: ...!mcvax!tut!oulu!jto
X **           BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X
Xchar irc_id[]="irc.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include <sys/types.h>
X#include <stdio.h>
X#include <curses.h>
X#include <signal.h>
X
X#define MAIN
X#define DEPTH 10
X#include "struct.h"
X#include "msg.h"
X#include "sys.h"
X#undef MAIN
X
Xchar *makeclientbuf();
X
Xint timeout();
Xchar buf[BUFSIZE];
Xchar *mycncmp(), *real_name();
Xstruct Client me;
Xstruct Client *client = &me;
Xint portnum;
Xint debuglevel;
X
Xmain(argc, argv)
X     int argc;
X     char *argv[];
X{
X  int sock, length;
X  struct passwd *userdata;
X  char *argv0=argv[0], *nickptr, *servptr, *getenv();
X  extern int exit();
X  portnum = PORTNUM;
X/*  signal(SIGTSTP, SIG_IGN); */
X  buf[0] = '\0';
X  initconf(buf, me.passwd, me.host, &me.channel);
X  while (argc > 1 && argv[1][0] == '-') {
X    switch(argv[1][1]) {
X      case 'p':
X        if ((length = atoi(&argv[1][2])) > 0)
X          portnum = length;
X        break;
X    }
X    argv++; argc--;
X  }
X  me.buffer[0] = '\0'; me.next = NULL;
X  me.status = STAT_ME;
X  if (servptr = getenv("IRCSERVER")) {
X    strncpy(buf, servptr, HOSTLEN);
X    buf[HOSTLEN] = '\0';
X  }
X  sock = client_init((argc > 2) ? argv[2] : ((buf[0]) ? buf : me.host),
X		     (me.channel > 0) ? me.channel : portnum);
X  userdata = getpwuid(getuid());
X  if (strlen(userdata->pw_name) >= USERLEN) {
X    userdata->pw_name[USERLEN-1] = '\0';
X  }
X  if (strlen(userdata->pw_gecos) >= REALLEN) {
X    userdata->pw_gecos[REALLEN-1] = '\0';
X  }
X  /* FIX:    jtrim at orion.cair.du.edu -- 3/14/88 
X           & jto at tolsun.oulu.fi */
X  if (argc >= 2) {
X    strncpy(me.nickname, argv[1], NICKLEN);
X  } else if (nickptr = getenv("IRCNICK")) {
X    strncpy(me.nickname, nickptr, NICKLEN);
X  } else
X    strncpy(me.nickname,userdata->pw_name,NICKLEN);
X
X  me.nickname[NICKLEN] = '\0';
X  /* END FIX */
X
X  if (argv0[0] == ':') {
X    strcpy(me.host,"OuluBox");
X    strncpy(me.realname, &argv0[1], REALLEN);
X    strncpy(me.username, argv[1], USERLEN);
X  }
X  else {
X    strncpy(me.realname,real_name(userdata),REALLEN);
X    strncpy(me.username,userdata->pw_name,USERLEN);
X  }
X  strcpy(me.server,me.host);
X  me.username[USERLEN] = '\0';
X  me.realname[REALLEN] = '\0';
X  me.fd = sock;
X  if (me.passwd[0])
X    sendto_one(&me, "PASS %s", me.passwd);
X  sendto_one(&me, "NICK %s", me.nickname);
X  sendto_one(&me, "USER %s %s %s %s", me.username, me.host,
X	     me.server, me.realname);
X  initscr();
X  noecho();
X  crmode();
X  clear();
X  refresh();
X/*  signal(SIGTSTP, SIG_IGN); */
X  myloop(sock);
X  echo();
X  nocrmode();
X  clear();
X  refresh();
X  endwin();
X  exit(0);
X}
X
Xmyloop(sock)
Xint sock;
X{
X  char header[HEADERLEN];
X  sprintf(header,HEADER,version);
X  standout();
X  mvaddstr(LINES - 2, 0, header);
X  standend();
X  client_loop(sock);
X}
X
X
Xsendit(sock,line)
Xint sock;
Xchar *line;
X{
X  static char queryuser[NICKLEN+2];
X  static char cmdch = '/';
X  char *ptr, *ptr2;
X  if (line[0] != cmdch) {
X    if (*queryuser) {
X      m_myprivate(NULL, NULL, NULL, queryuser, line);
X      sendto_one(&me, "PRIVMSG %s :%s", queryuser, line);
X    }
X    else {
X      sendto_one(&me, "MSG :%s", line);
X      m_mytext(NULL, NULL, NULL, line);
X    }
X  }
X  else {
X    if (line[1] == ' ') {
X      sendto_one(&me, "MSG :%s", &line[2]);
X      m_mytext(NULL, NULL, NULL, &line[2]);
X    }
X    else if (mycncmp(&line[1],"SIGNOFF", 1))
X      sendto_one(&me, "QUIT");
X    else if (mycncmp(&line[1],"BYE", 1))
X      sendto_one(&me, "QUIT");
X    else if (mycncmp(&line[1],"EXIT", 1))
X      sendto_one(&me, "QUIT");
X    else if (mycncmp(&line[1],"QUIT", 1))
X      sendto_one(&me, "QUIT");
X    else if (ptr=mycncmp(&line[1],"KILL", 2)) {
X      if (unixuser())
X	sendto_one(&me, "KILL %s", ptr);
X      else
X	putline("`tis is no game for mere mortal souls...");
X    }
X    else if (ptr=mycncmp(&line[1],"SUMMON", 2)) {
X/*      if (unixuser()) */
X	sendto_one(&me, "SUMMON %s", ptr);
X/*      else
X	putline("'tis is no game for mere mortal souls..."); */
X    }
X    else if (ptr=mycncmp(&line[1],"STATS", 2)) 
X      sendto_one(&me, "STATS %s", ptr);
X    else if (ptr=mycncmp(&line[1],"USERS", 1)) 
X      sendto_one(&me, "USERS %s", ptr);
X    else if (ptr=mycncmp(&line[1],"TIME", 1))
X      sendto_one(&me, "TIME %s", ptr);
X    else if (ptr=mycncmp(&line[1],"DATE", 1))
X      sendto_one(&me, "TIME %s", ptr);
X    else if (ptr=mycncmp(&line[1],"NAMES", 1)) 
X      sendto_one(&me, "NAMES %s", ptr);
X    else if (ptr=mycncmp(&line[1],"NICK", 2)) 
X      sendto_one(&me, "NICK %s", ptr);
X    else if (ptr=mycncmp(&line[1],"WHOIS", 4)) 
X      sendto_one(&me, "WHOIS %s", ptr);
X    else if (ptr=mycncmp(&line[1],"WHO", 1)) 
X      sendto_one(&me, "WHO %s", ptr);
X    else if (ptr=mycncmp(&line[1],"JOIN", 1))
X      sendto_one(&me, "CHANNEL %s", ptr);
X    else if (ptr=mycncmp(&line[1],"WALL", 2))
X      sendto_one(&me, "WALL %s", ptr);
X    else if (ptr=mycncmp(&line[1],"CHANNEL", 1))
X      sendto_one(&me, "CHANNEL %s", ptr);
X    else if (ptr=mycncmp(&line[1],"AWAY", 1))
X      sendto_one(&me, "AWAY %s", ptr);
X    else if (ptr=mycncmp(&line[1],"MSG", 1)) {
X      if ((ptr2 = index(ptr, ' ')) == (char *) 0)
X	putline("ERROR: No message");
X      else {
X	*ptr2 = '\0';
X	sendto_one(&me, "PRIVMSG %s :%s", ptr, ++ptr2);
X	m_myprivate(NULL, NULL, NULL, ptr, ptr2);
X      }
X    }
X    else if (ptr=mycncmp(&line[1],"TOPIC", 1))
X      sendto_one(&me, "TOPIC :%s", ptr);
X    else if (ptr=mycncmp(&line[1],"CMDCH", 2)) {
X      if (ptr && *ptr) {
X	sprintf(buf, "*** Command character changed from '%c' to '%c'",
X		cmdch, *ptr);
X	cmdch = *ptr;
X	putline(buf);
X      } else {
X	putline("*** Error: Command character not changed");
X      }
X    }
X    else if (ptr=mycncmp(&line[1],"INVITE", 2))
X      sendto_one(&me, "INVITE %s", ptr);
X    else if (ptr=mycncmp(&line[1],"INFO", 2))
X      sendto_one(&me, "INFO");
X    else if (ptr=mycncmp(&line[1],"LIST", 1))
X      sendto_one(&me, "LIST %s",ptr);
X    else if (ptr=mycncmp(&line[1],"KILL", 1))
X      sendto_one(&me, "KILL %s",ptr);
X    else if (ptr=mycncmp(&line[1],"OPER", 1))
X      sendto_one(&me, "OPER %s",ptr);
X    else if (ptr=mycncmp(&line[1],"QUOTE", 1))
X      sendto_one(&me, "%s",ptr);
X    else if (ptr=mycncmp(&line[1],"LINKS", 2)) 
X      sendto_one(&me, "LINKS %s", ptr);
X    else if (ptr=mycncmp(&line[1],"ADMIN", 1)) 
X      sendto_one(&me, "ADMIN %s", ptr);
X    else if (ptr=mycncmp(&line[1],"IGNORE", 1))
X      do_ignore(ptr);
X    else if (ptr=mycncmp(&line[1],"TRACE", 1)) 
X      sendto_one(&me, "TRACE %s", ptr);
X    else if (ptr=mycncmp(&line[1],"HELP", 1))
X      help(ptr);
X    else if (mycncmp(&line[1],"VERSION", 1))
X      sendto_one(&me, "VERSION");
X    else if (mycncmp(&line[1],"CLEAR", 1))
X      doclear();
X    else if (mycncmp(&line[1],"REHASH", 1))
X      sendto_one(&me, "REHASH");
X    else if (ptr=mycncmp(&line[1],"QUERY", 2)) {
X      if (ptr == NULL || *ptr == '\0') {
X	sprintf(buf,"*** Note: Finished chatting with %s",queryuser);
X	putline(buf);
X        queryuser[0] = '\0';
X      }
X      else {
X	strncpy(queryuser,ptr,NICKLEN);
X	queryuser[NICKLEN] = '\0';
X	if (ptr = index(queryuser,' ')) *ptr = '\0';
X	sprintf(buf,"*** Note: Beginning private chat with %s",queryuser);
X	putline(buf);
X      }
X    }
X    else
X      putline("* Illegal Command *");
X  }
X}
X
Xchar *mycncmp(str1, str2, len)
Xchar *str1, *str2;
Xint len;
X{
X  int flag = 0;
X  char *s1;
X  for (s1 = str1; *s1 != ' ' && *s1 && *str2; s1++, str2++) {
X    if (!isascii(*s1)) return 0;
X    if (islower(*s1)) *s1 = toupper(*s1);
X    if (*s1 != *str2) flag = 1;
X  }
X  if (*s1 && *s1 != ' ' && *str2 == '\0')
X    return 0;
X  if (flag) return 0;
X  if (len != 0 && s1 - str1 < len)
X    return 0;
X  if (*s1) return s1 + 1;
X  else return s1;
X}
X
Xstatic int apu = 0;
X
Xdoclear()
X{
X  char header[HEADERLEN];
X  apu = 0;
X  sprintf(header,HEADER,version);
X  clear();
X  standout();
X  mvaddstr(LINES - 2, 0, header);
X  standend();
X  refresh();
X}
X
Xputline(line)
Xchar *line;
X{
X  char *ptr = line, *ptr2 = NULL;
X  char ch='\0';
X  static char blanko[] = "                                        ";
X  while (ptr) {
X    if (strlen(ptr) > COLS) {
X      ch = ptr[COLS];
X      ptr[COLS] = '\0';
X      ptr2 = &ptr[COLS-1];
X    } 
X    else
X      ptr2 = NULL;
X    move(apu++,0);
X    if (apu > LINES - 4) apu = 0;
X    addstr(ptr);
X    if (apu == 0) 
X      mvaddstr(0,0,"\n\n");
X    else if (apu == LINES - 4) {
X      mvaddstr(LINES - 4, 0, "\n");
X      mvaddstr(0,0,"\n");
X    }
X    else {
X      addstr(blanko); addstr(blanko);
X      addstr("\n");
X      addstr(blanko); addstr(blanko);
X    }
X    ptr = ptr2;
X    if (ptr2) {
X      *ptr2++ = '+';
X      *ptr2 = ch;
X    }
X  }
X  refresh();
X}
X
Xint
Xunixuser()
X{
X  return(strcmp(me.host,"OuluBox"));
X}
X
Xstruct Client *
Xmake_client()
X{
X  return(NULL);
X}
SHAR_EOF
chmod 0600 irc.c || echo "restore of irc.c fails"
set `wc -c irc.c`;Sum=$1
if test "$Sum" != "9158"
then echo original size 9158, current size $Sum;fi
echo "x - extracting ircd.8 (Text)"
sed 's/^X//' << 'SHAR_EOF' > ircd.8 &&
X.\" @(#)ircd.8 2.0 (beta version) 29 Mar 1989 
X.TH IRCD 8 "29 March 1989"
X.SH NAME
Xircd \- The Internet Relay Chat Program Server 
X.SH SYNOPSIS
X\fBircd\fP [-hhostname] [-pportnum] 
X.SH DESCRIPTION
X.LP
X\fIircd\fP is the server (daemon) program for the Internet Relay Chat
XProgram.  The \fIircd\fP is a server in that its function is to "serve"
Xthe client program \fIirc(1)\fP with messages and commands.  All commands
Xand user messages are passed directly to the \fIircd\fP for processing
Xand relaying to other UNIX sites.  The \fIirc(1)\fP program depends upon
Xthere being an \fIircd\fP server running somewhere (either on your local
XUNIX site or a remote UNIX site) so that it will have somewhere to connect
Xto and thus allow the user to begin talking to other users. 
X.LP
XIf you plan to connect your \fIircd\fP server to an existing Irc-Network,
Xyou will need to alter your local IRC CONFIGURATION FILE (typically named
X"irc.conf") so that it will accept and make connections to other \fIircd\fP
Xservers.  This file contains the hostnames, Network Addresses, and sometimes
Xpasswords for connections to other UNIXES around the world.  Because 
Xdescription of the actual file format of the "irc.conf" file is beyond the
Xscope of this document, please refer to the file README in the IRC source
Xfiles directory.
X.LP
XBOOTING THE SERVER:  The \fIircd\fP server can be started as part of the
XUNIX boot procedure or just by placing the server into Unix Background.
XKeep in mind that if it is *not* part of your UNIXES Boot-up procedure 
Xthen you will have to manually start the \fIircd\fP server each time your
XUNIX is rebooted.  This means if your UNIX is prone to crashing
Xor going for for repairs a lot it would make sense to start the \fIircd\fP
Xserver as part of your UNIX bootup procedure.  In some cases the \fIirc(1)\fP
Xwill automatically attempt to boot the \fIircd\fP server if the user is
Xon the SAME UNIX that the \fIircd\fP is supposed to be running on.  If the
X\fIirc(1)\fP cannot connect to the \fIircd\fP server it will try to start
Xthe server on it's own and will then try to reconnect to the newly booted
X\fIircd\fP server.
X.SH EXAMPLE
X.RS
X.nf
Xtolsun% \fBircd\fP
X.fi
X.RE
X.LP
XPlaces \fIircd\fP into UNIX Background and starts up the server for use.
XNote:  You do not have to add the "&" to this command, the program will
Xautomatically place itself into UNIX Background after it has been executed.
X.SH COPYRIGHT
XCopyright (c) 1988 University of Oulu, Computing Center, Finland.
XAll rights reserved.
XFor full COPYRIGHT see COPYRIGHT file with IRC package.
X.SH FILES
X /etc/utmp
X "irc.conf"
X.SH "SEE ALSO"
Xirc(1)
X.SH BUGS
XNone... ;-) if somebody finds one, please inform author
X.SH AUTHOR
XJarkko Oikarinen, currently jto at tolsun.oulu.fi,
Xmanual page written by Jeff Trim, jtrim at orion.cair.du.edu.
SHAR_EOF
chmod 0600 ircd.8 || echo "restore of ircd.8 fails"
set `wc -c ircd.8`;Sum=$1
if test "$Sum" != "2804"
then echo original size 2804, current size $Sum;fi
echo "x - extracting ircd.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ircd.c &&
X/*************************************************************************
X ** ircd.c  Beta  v2.0    (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author:           Jarkko Oikarinen 
X **         Internet: jto at tolsun.oulu.fi
X **             UUCP: ...!mcvax!tut!oulu!jto
X **           BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X ** 
X *************************************************************************/
X
Xchar ircd_id[] = "ircd.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include <sys/types.h>
X#include <sys/file.h>
X#include <stdio.h>
X#include <signal.h>
X#define MAIN
X#include "struct.h"
X#undef MAIN
X#define TRUE 1
X
Xextern int dummy();
Xextern struct Client *make_client();
Xstruct Client me;                /* That's me */
Xstruct Client *client = &me;    /* Pointer to beginning of Client list */
Xextern struct Confitem *conf;
Xextern struct Confitem *find_me();
Xchar *uphost;
Xchar **myargv;
Xint portnum;
Xint debuglevel;
Xint maxusersperchannel = MAXUSERSPERCHANNEL;
X
Xrestart()
X{
X  int i;
X  debug(DEBUG_NOTICE,"Restarting server...");
X#ifdef NOTTY
X  for (i=0; i<MAXFD; i++) 
X#else
X  for (i=3; i<MAXFD; i++)
X#endif
X    close(i);
X  execv(MYNAME, myargv);
X  debug(DEBUG_FATAL,"Couldn't restart server !!!!!!!!");
X  exit(-1);
X}
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X  struct Client *cptr;
X  struct Confitem *aconf;
X  int length;                      /* Length of message received from client */
X  char buffer[BUFSIZE];
X  int counter;
X  long lasttime, lastconnecttry;
X  myargv = argv;
X  signal(SIGPIPE, SIG_IGN);
X  signal(SIGHUP, restart);
X  signal(SIGALRM, dummy);
X  setuid(geteuid());
X  if (getuid() == 0) {
X    setgid(-2);
X    setuid(-2);
X  } 
X  getmyname(myhostname,HOSTLEN-1);
X  portnum = PORTNUM;
X  debuglevel = -1;
X  while (argc > 1 && argv[1][0] == '-') {
X    switch (argv[1][1]) {
X      case 'h':
X        strncpy(myhostname, &argv[1][2], HOSTLEN-1);
X        myhostname[HOSTLEN] = '\0';
X        break;
X      case 'p':
X        if ((length = atoi(&argv[1][2])) > 0 )
X          portnum = length;
X        break;
X      case 'x':
X        debuglevel = atoi(&argv[1][2]);
X        break;
X/*      case 'c':
X	maxusersperchannel = atoi(&argv[1][2]);
X	break; */
X      default:
X	printf("Illegal option\n");
X	break;
X    }
X    argv++; argc--;
X  }
X  if (argc > 1 && argv[1][0] > '9')
X    uphost = argv[1];
X  else
X    uphost = NULL;
X  init_sys();
X  openlog();
X  initconf();
X  if (aconf = find_me())
X    strcpy(me.server, aconf->name);
X  else
X    me.server[0] = '\0';
X  me.next = NULL;
X  strcpy(me.host,myhostname);
X  me.fromhost[0] = me.nickname[0] = me.realname[0] = '\0';
X  me.fd = open_port(portnum);
X  me.status = STAT_ME;
X  lastconnecttry = getlongtime();
X  aconf = conf;
X  while (aconf) {
X    if (aconf->status == CONF_CONNECT_SERVER && aconf->port > 0) {
X      if (connect_server(aconf) == 0)
X	break;
X    }
X    aconf = aconf->next;
X  }
X  debug(DEBUG_DEBUG,"Server ready...");
X  
X  for (;;) {
X    if ((length = read_msg(buffer, BUFSIZE, &cptr)) > 0) {
X      cptr->lasttime = getlongtime();
X      cptr->flags &= ~FLAGS_PINGSENT;
X      dopacket(cptr, buffer, length);
X    } 
X
X    debug(DEBUG_DEBUG,"Got message");
X
X    lasttime = getlongtime();
X    if (lasttime - lastconnecttry > CONNECTFREQUENCY) {
X      lastconnecttry = lasttime;
X      aconf = conf;
X      while (aconf) {
X	if (aconf->status == CONF_CONNECT_SERVER) {
X	  cptr = client;
X	  while (cptr) {
X	    if ((cptr->status == STAT_SERVER || cptr->status == STAT_ME) &&
X		strcmp(cptr->host, aconf->name) == 0)
X	      break;
X	    cptr = cptr->next;
X	  }
X	  if (cptr == NULL && aconf->port > 0) 
X	    if (connect_server(aconf) == 0)
X	      break;
X	}
X	aconf = aconf->next;
X      }
X      lasttime = getlongtime();
X    }
X
X    cptr = client;
X    while (cptr) {
X      if (cptr->status != STAT_ME && cptr->fd >= 0 &&
X	  (lasttime - cptr->lasttime) > PINGFREQUENCY) {
X	if ((lasttime - cptr->lasttime) > 2 * PINGFREQUENCY) {
X	  m_bye(cptr, cptr);
X	  cptr = client;
X	}
X	else if ((cptr->flags & FLAGS_PINGSENT) == 0) {
X	  cptr->flags |= FLAGS_PINGSENT;
X	  sendto_one(cptr, "PING %s", myhostname);
X	}
X      }
X      cptr = cptr->next;
X    }
X  }
X}
SHAR_EOF
chmod 0600 ircd.c || echo "restore of ircd.c fails"
set `wc -c ircd.c`;Sum=$1
if test "$Sum" != "4264"
then echo original size 4264, current size $Sum;fi
echo "x - extracting list.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > list.c &&
X/*************************************************************************
X ** list.c  Beta  v2.0    (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author:           Jarkko Oikarinen 
X **         Internet: jto at tolsun.oulu.fi
X **             UUCP: ...!mcvax!tut!oulu!jto
X **           BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X ** 
X *************************************************************************/
X
Xchar list_id[] = "list.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include "struct.h"
X#define NULL ((char *) 0)
X
Xextern struct Client *client;
Xextern struct Confitem *conf;
Xextern int maxusersperchannel;
X
Xstruct Client *
Xmake_client()
X{
X  struct Client *cptr;
X  if ((cptr = (struct Client *) malloc(sizeof (struct Client))) == 
X      (struct Client *) 0)
X    {
X      perror("malloc");
X      debug(DEBUG_FATAL, "Out of memory: restarting server...");
X      restart();
X    }
X  else {
X    cptr->next = client;
X    cptr->away = NULL;
X    cptr->host[0] = cptr->nickname[0] = cptr->username[0] = '\0';
X    cptr->realname[0] = cptr->server[0] = cptr->buffer[0] = '\0';
X    cptr->passwd[0] = cptr->sockhost[0] = '\0';
X    cptr->status = STAT_UNKNOWN; cptr->channel = 0; cptr->fd = -1;
X    cptr->lasttime = getlongtime(); cptr->flags = 0;
X  }
X  return (cptr);
X}
X
Xint
Xis_full(channel, users)
Xint channel, users;
X{
X  if (channel > 0 && channel < 10)
X    return(0);
X  if (users >= maxusersperchannel)
X    return(1);
X  return(0);
X}
X
SHAR_EOF
chmod 0600 list.c || echo "restore of list.c fails"
set `wc -c list.c`;Sum=$1
if test "$Sum" != "1608"
then echo original size 1608, current size $Sum;fi
echo "x - extracting main.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > main.c &&
Xmain()
X{
X  printf("date = %s\n",date());
X}
SHAR_EOF
chmod 0600 main.c || echo "restore of main.c fails"
set `wc -c main.c`;Sum=$1
if test "$Sum" != "43"
then echo original size 43, current size $Sum;fi
echo "x - extracting msg.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > msg.h &&
X/*************************************************************************
X ** msg.h  Beta  v2.0    (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author:           Jarkko Oikarinen 
X **         Internet: jto at tolsun.oulu.fi
X **             UUCP: ...!mcvax!tut!oulu!jto
X **           BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X ** 
X *************************************************************************/
X
X#define MSG_TEXT     "MSG"
X#define MSG_PRIVATE  "PRIVMSG"
X#define MSG_WHO      "WHO"
X#define MSG_WHOIS    "WHOIS"
X#define MSG_USER     "USER"
X#define MSG_NICK     "NICK"
X#define MSG_SERVER   "SERVER"
X#define MSG_LIST     "LIST"
X#define MSG_TOPIC    "TOPIC"
X#define MSG_INVITE   "INVITE"
X#define MSG_CHANNEL  "CHANNEL"
X#define MSG_VERSION  "VERSION"
X#define MSG_QUIT     "QUIT"
X#define MSG_SQUIT    "SQUIT"
X#define MSG_KILL     "KILL"
X#define MSG_INFO     "INFO"
X#define MSG_LINKS    "LINKS"
X#define MSG_SUMMON   "SUMMON"
X#define MSG_STATS    "STATS"
X#define MSG_USERS    "USERS"
X#define MSG_RESTART  "RESTART"
X#define MSG_HELP     "HELP"
X#define MSG_WHOREPLY "WHOREPLY"
X#define MSG_ERROR    "ERROR"
X#define MSG_AWAY     "AWAY"
X#define MSG_DIE      "DIE"
X#define MSG_CONNECT  "CONNECT"
X#define MSG_PING     "PING"
X#define MSG_PONG     "PONG"
X#define MSG_OPER     "OPER"
X#define MSG_PASS     "PASS"
X#define MSG_WALL     "WALL"
X#define MSG_TIME     "TIME"
X#define MSG_REHASH   "REHASH"
X#define MSG_NAMES    "NAMES"
X#define MSG_NAMREPLY "NAMREPLY"
X#define MSG_ADMIN    "ADMIN"
X#define MSG_TRACE    "TRACE"
X#define MSG_LINREPLY "LINREPLY"
X
X#define MAXPARA    10 
X
Xextern int m_text(), m_private(), m_who(), m_whois(), m_user(), m_list();
Xextern int m_topic(), m_invite(), m_channel(), m_version(), m_quit();
Xextern int m_server(), m_kill(), m_info(), m_links(), m_summon(), m_stats();
Xextern int m_users(), m_nick(), m_error(), m_help(), m_whoreply();
Xextern int m_squit(), m_restart(), m_away(), m_die(), m_connect();
Xextern int m_ping(), m_pong(), m_oper(), m_pass(), m_wall(), m_trace();
Xextern int m_time(), m_rehash(), m_names(), m_namreply(), m_admin();
Xextern int m_linreply();
X
Xstruct Message {
X  char *cmd;
X  int (* func)();
X  int count;
X  int parameters;
X};
X
X#ifdef MSGTAB
Xstruct Message msgtab[] = {
X  { MSG_NICK,    m_nick,     0, 1 },
X  { MSG_TEXT,    m_text,     0, 1 },
X  { MSG_PRIVATE, m_private,  0, 2 },
X  { MSG_WHO,     m_who,      0, 1 },
X  { MSG_WHOIS,   m_whois,    0, 1 },
X  { MSG_USER,    m_user,     0, 4 },
X  { MSG_SERVER,  m_server,   0, 2 },
X  { MSG_LIST,    m_list,     0, 1 },
X  { MSG_TOPIC,   m_topic,    0, 1 },
X  { MSG_INVITE,  m_invite,   0, 2 },
X  { MSG_CHANNEL, m_channel,  0, 1 },
X  { MSG_VERSION, m_version,  0, 1 },
X  { MSG_QUIT,    m_quit,     0, 1 },
X  { MSG_SQUIT,   m_squit,    0, 1 },
X  { MSG_KILL,    m_kill,     0, 2 },
X  { MSG_INFO,    m_info,     0, 1 },
X  { MSG_LINKS,   m_links,    0, 1 },
X  { MSG_SUMMON,  m_summon,   0, 1 },
X  { MSG_STATS,   m_stats,    0, 1 },
X  { MSG_USERS,   m_users,    0, 1 },
X  { MSG_RESTART, m_restart,  0, 1 },
X  { MSG_WHOREPLY,m_whoreply, 0, 7 },
X  { MSG_HELP,    m_help,     0, 2 },
X  { MSG_ERROR,   m_error,    0, 1 },
X  { MSG_AWAY,    m_away,     0, 1 },
X  { MSG_DIE,     m_die,      0, 1 },
X  { MSG_CONNECT, m_connect,  0, 3 },
X  { MSG_PING,    m_ping,     0, 2 },
X  { MSG_PONG,    m_pong,     0, 3 },
X  { MSG_OPER,    m_oper,     0, 3 },
X  { MSG_PASS,    m_pass,     0, 2 },
X  { MSG_WALL,    m_wall,     0, 1 },
X  { MSG_TIME,    m_time,     0, 1 },
X  { MSG_REHASH,  m_rehash,   0, 1 },
X  { MSG_NAMES,   m_names,    0, 1 },
X  { MSG_NAMREPLY,m_namreply, 0, 3 },
X  { MSG_ADMIN,   m_admin,    0, 1 },
X  { MSG_TRACE,   m_trace,    0, 1 },
X  { MSG_LINREPLY,m_linreply, 0, 2 },
X  { (char *) 0, (int (*)()) 0 }  
X};
X#else
Xextern struct Message msgtab[];
X#endif
SHAR_EOF
chmod 0600 msg.h || echo "restore of msg.h fails"
set `wc -c msg.h`;Sum=$1
if test "$Sum" != "3905"
then echo original size 3905, current size $Sum;fi
echo "x - extracting packet.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > packet.c &&
X/*************************************************************************
X ** packet.c  Beta  v2.0    (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author:           Jarkko Oikarinen
X **         Internet: jto at tolsun.oulu.fi
X **             UUCP: ...!mcvax!tut!oulu!jto
X **           BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X 
Xchar packet_id[]="packet.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include "struct.h"
X#include "msg.h"
X
Xdopacket(cptr, buffer, length)
Xstruct Client *cptr;
Xchar *buffer;
Xint length;
X{
X  char *ch1, *ch2, *ch3;
X  strncat(cptr->buffer, buffer, length);
X  ch1 = ch2 = cptr->buffer;
X  while (*ch2) {
X    if (*ch2 == '\r' || *ch2 == '\n') {
X      if (ch2 != ch1) {
X	ch1[ch2-ch1] = '\0';
X	if (parse(cptr, ch1, ch2 - ch1, msgtab) == FLUSH_BUFFER) 
X	  return(0);
X      }
X      if (*(ch2+1) == '\r' || *(ch2+1) == '\n')
X	ch2++;
X      ch1 = ch2+1;
X    }
X    ch2++;
X  }
X  for (ch3 = cptr->buffer; *ch1; ch1++, ch3++)
X    *ch3 = *ch1;
X  *ch3 = '\0';
X}
SHAR_EOF
chmod 0600 packet.c || echo "restore of packet.c fails"
set `wc -c packet.c`;Sum=$1
if test "$Sum" != "1230"
then echo original size 1230, current size $Sum;fi
echo "x - extracting parse.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > parse.c &&
X/*************************************************************************
X ** parse.c  Beta  v2.0    (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author:           Jarkko Oikarinen
X **         Internet: jto at tolsun.oulu.fi
X **             UUCP: ...!mcvax!tut!oulu!jto
X **           BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X 
Xchar parse_id[] = "parse.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include <ctype.h>
X#define MSGTAB
X#include "msg.h"
X#undef MSGTAB
X#include "struct.h"
X#include "sys.h"
X
X#define NULL ((char *) 0)
X
Xint msgcount[40];
Xextern struct Client *client;
Xchar sender[20];
X
Xint
Xmyncmp(str1, str2, n)
Xchar *str1, *str2;
Xint n;
X{
X  while ((islower(*str1) ? toupper(*str1) : *str1) ==
X	 (islower(*str2) ? toupper(*str2) : *str2)) {
X    str1++; str2++; n--;
X    if (n == 0 || (*str1 == '\0' && *str2 == '\0'))
X      return(0);
X  }
X  return(1);
X}
X
Xstruct Client *
Xfind_client(ch, cptr)
Xchar *ch;
Xstruct Client *cptr;
X{
X  struct Client *c2ptr=client;
X  int len;
X  char *ch2 = index(ch,' ');
X  if (ch2)
X    len = ch2 - ch;
X  else
X    len = strlen(ch);
X  while (c2ptr) {
X    if (strlen(c2ptr->nickname) == len &&
X	myncmp(ch, c2ptr->nickname, len) == 0)
X      break;
X    c2ptr = c2ptr->next;
X  }
X  return ((c2ptr) ? c2ptr : cptr);
X}
X
Xstruct Client *
Xfind_server(ch, cptr)
Xchar *ch;
Xstruct Client *cptr;
X{
X  struct Client *c2ptr=client;
X  int len;
X  char *ch2;
X  if (ch == NULL)
X    return(cptr);
X  ch2 = index(ch,' ');
X  if (ch2)
X    len = ch2 - ch;
X  else
X    len = strlen(ch);
X  while (c2ptr) {
X    if ((c2ptr->status == STAT_SERVER || c2ptr->status == STAT_ME) &&
X        strlen(c2ptr->host) == len && myncmp(ch, c2ptr->host, len) == 0)
X      break;
X    c2ptr = c2ptr->next;
X  }
X  return ((c2ptr) ? c2ptr : cptr);
X}
X
Xparse(cptr, buffer, length, mptr)
Xstruct Client *cptr;
Xchar *buffer;
Xint length;
Xstruct Message *mptr;
X{
X  struct Client *from = cptr;
X  char *ch, *ch2, *para[MAXPARA+1];
X  int len,i=0;
X  int (*func)();
X  *sender = '\0';
X  for (i=0; i<length; i++)
X    if (buffer[i] && buffer[i] != '\007' &&
X	(buffer[i] < 32 || buffer[i] > 126))
X      buffer[i] = ' '; 
X  for (ch = buffer; *ch == ' '; ch++);
X  if (*ch >= '0' && *ch <= '9') {
X    return(0);     /* Add numeric command parsing here... */
X  }
X  if (*ch == ':') {
X    ch++;
X    if (cptr->status != STAT_OPER && cptr->status != STAT_SERVER)
X      from = cptr;
X    else
X      from = find_client(ch, cptr);
X    strncpy(sender, ch, 15);
X    for (ch2 = sender; (ch2 < &sender[15]) && *ch2 > 32 && *ch2 < 126; ch2++);
X    *ch2 = '\0';
X    ch = index(ch, ' ');
X  }
X  if (ch == NULL) {
X    debug(DEBUG_NOTICE, "Empty message from %s:%s (host %s)",
X	  cptr->nickname,from->nickname, cptr->host);
X    return(-1);
X  }
X  while (*ch == ' ') ch++;
X  ch2 = index(ch, ' ');
X  len = (ch2) ? (ch2 - ch) : strlen(ch);
X  while (mptr->cmd) {
X    if (myncmp(mptr->cmd, ch, len) == 0 && strlen(mptr->cmd) == len)
X      break;
X    mptr++;
X  }
X  if (mptr->cmd == NULL) {
X    if (buffer[0] != '0')
X      sendto_one(from, "ERROR Illegal command %s", ch);
X    return(-1);
X  }
X  i = 0;
X  while (ch2 && *ch2 && i < MAXPARA-1 && i < mptr->parameters) {
X    for (; *ch2 == ' '; ch2++);
X    *(ch2-1) = '\0';
X    if (*ch2 == '\0')
X      para[i++] = NULL;
X    else {
X      para[i] = ch2;
X      if (*ch2 == ':') {
X	para[i] = ch2 + 1;
X	ch2 = NULL;
X      }
X      else 
X	for (; *ch2 != ' ' && *ch2; ch2++);
X      i++;
X    }
X  }
X  mptr->count++;
X  for (; i <= MAXPARA; i++) para[i] = NULL;
X  func = mptr->func;
X  return (*func)(cptr, from, sender,
X		       para[0], para[1], para[2], para[3], para[4], para[5],
X		       para[6], para[7], para[8]);
X}
SHAR_EOF
chmod 0600 parse.c || echo "restore of parse.c fails"
set `wc -c parse.c`;Sum=$1
if test "$Sum" != "3847"
then echo original size 3847, current size $Sum;fi
echo "x - extracting r_bsd.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > r_bsd.c &&
X/*************************************************************************
X ** r_bsd.c  Beta  v2.0    (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author:           Jarkko Oikarinen 
X **         Internet: jto at tolsun.oulu.fi
X **             UUCP: ...!mcvax!tut!oulu!jto
X **           BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X ** 
X *************************************************************************/
X
Xchar r_bsd_id[] = "r_bsd.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include <sys/time.h>
X#include <sys/types.h>
X#include <sys/socket.h>
X#include <sys/file.h>
X#include <sys/ioctl.h>
X#include <netinet/in.h>
X#include <netdb.h>
X#include <stdio.h>
X#include <signal.h>
X#include <fcntl.h>
X#include "struct.h"
X#if BSD42 || ULTRIX
X#include "sock.h"
X#endif
X#include "sys.h"
X
Xextern struct Client me;
Xint
Xclient_init(host, portnum)
Xchar *host;
Xint portnum;
X{
X  int sock, tryagain = 1;
X  static struct hostent *hp;
X  static struct sockaddr_in server;
X
X  gethostname(me.host,HOSTLEN);
X
X  /* FIX:  jtrim at duorion.cair.du.edu -- 3/4/89 
X     and jto at tolsun.oulu.fi -- 3/7/89 */
X
X    sock = socket(AF_INET, SOCK_STREAM, 0);
X    if (sock < 0) {
X      perror("opening stream socket");
X      exit(1);
X    }
X    server.sin_family = AF_INET;
X    
X    /* MY FIX -- jtrim at duorion.cair.du.edu   (2/10/89) */
X    if ( isdigit(*host))
X      {
X	server.sin_addr.s_addr = inet_addr(host);
X      }
X    else
X      { 
X	hp = gethostbyname(host);
X	if (hp == 0) {
X	  fprintf(stderr, "%s: unknown host", host);
X	  exit(2);
X	}
X	bcopy(hp->h_addr, &server.sin_addr, hp->h_length);
X      }
X    server.sin_port = htons(portnum);
X    /* End Fix */
X    
X    if (connect(sock, (struct sockaddr *) &server, sizeof(server)) < 0) {
X      perror("irc");
X      exit(1);
X    }
X  return(sock);
X}
X/* End Fix */
X
Xclient_loop(sock)
Xint sock;
X{
X  int i = 0, size;
X  char apubuf[101], ch;
X  fd_set ready;
X  do {
X    ready.fds_bits[0] = (1 << sock);
X    if (select(sock+1, &ready, 0, 0, NULL) < 0) {
X/*      perror("select"); */
X      continue;
X    }
X    if (ready.fds_bits[0] & (1 << sock)) {
X      if ((size = read(sock, apubuf, 100)) < 0)
X	perror("receiving stream packet");
X      if (size == 0) return(-1);
X      dopacket(&me, apubuf, size);
X    }
X/*    if (ready.fds_bits[0] & 1) {
X      if ((ch = getchar()) == -1) {
X	move(0,0);
X	addstr("\rFATAL ERROR: End of stdin file !\n\r");
X	refresh();
X	return;
X      }
X      i=do_char(ch);
X    } */
X  } while (1);
X}
SHAR_EOF
chmod 0600 r_bsd.c || echo "restore of r_bsd.c fails"
set `wc -c r_bsd.c`;Sum=$1
if test "$Sum" != "2594"
then echo original size 2594, current size $Sum;fi
echo "x - extracting r_msg.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > r_msg.c &&
X/*************************************************************************
X ** r_msg.c    Beta v2.0    (22 Aug 1988)
X **
X ** This file is part of Internet Relay Chat v2.0
X **
X ** Author:           Jarkko Oikarinen
X **         Internet: jto at tolsun.oulu.fi
X **             UUCP: ...!mcvax!tut!oulu!jto
X **           BITNET: toljto at finou
X **
X ** Copyright (c) 1988 University of Oulu, Computing Center
X **
X ** All rights reserved.
X **
X ** See file COPYRIGHT in this package for full copyright.
X **
X *************************************************************************/
X 
Xchar r_msg_id[] = "r_msg.c v2.0 (c) 1988 University of Oulu, Computing Center";
X
X#include "struct.h"
X#include "msg.h"
X
Xchar mybuf[513];
Xchar abuf1[20], abuf2[20], abuf3[20], abuf4[20];
X
Xextern char *center(), *mycncmp();
Xextern struct Client *client;
X
Xm_restart() {
X  putline("*** Oh boy... somebody wants *me* to restart... exiting...\n");
X  sleep(5);
X  exit(0);
X}
X
Xm_time() {
X  putline("*** Received time message..!");
X}
X
Xm_rehash() {
X  putline("*** Received rehash message..!");
X}
X
Xm_die() {
X  exit(-1);
X}
X
Xm_pass() {
X  putline("*** Received Pass message !");
X}
X
Xm_oper() {
X  putline("*** Received Oper message !");
X}
X
Xm_names() {
X  putline("*** Received Names message !");
X}
X
Xm_wall(sptr, cptr, sender, message) 
Xstruct Client *sptr, *cptr;
Xchar *sender, *message;
X{
X  sprintf(abuf1, "*** #%s# %s", sender, message);
X  putline(abuf1);
X}
X
Xm_connect() {
X  putline("*** Received Connect message !");
X}
X
Xm_ping(sptr, cptr, sender, para1, para2) 
Xstruct Client *sptr, *cptr;
Xchar *sender, *para1, *para2;
X{
X  if (para2 && *para2)
X    sendto_one(client, "PONG %s@%s %s", client->username, client->host, para2);
X  else
X    sendto_one(client, "PONG %s@%s", client->username, client->host);
X}
X
Xm_pong(sptr, cptr, sender, para1, para2)
Xstruct Client *sptr, *cptr;
Xchar *sender, *para1, *para2;
X{
X  putline("*** Received PONG message: %s %s", para1, (para2) ? para2 : "");
X}
X
Xm_nick(sptr, cptr, sender, nickname)
Xstruct Client *sptr, *cptr;
Xchar *sender, *nickname;
X{
X  sprintf(mybuf,"*** Change: %s is now known as %s", sender, nickname);
X  putline(mybuf);
X}
X
Xm_away(sptr, cptr, sender, text)
Xstruct Client *sptr, *cptr;
Xchar *sender, *text;
X{
X  sprintf(mybuf,"*** %s is away: \"%s\"",sender,text);
X  putline(mybuf);
X}
X
Xm_who() { 
X  putline("*** Oh boy... server asking who from client... exiting...");
X}
X
Xm_whois() {
X  putline("*** Oh boy... server asking whois from client... exiting...");
X}
X
Xm_user() {
X  putline("*** Oh boy... server telling me user messages... exiting...");
X}
X
Xm_server(sptr, cptr, sender, serv) 
Xstruct Client *cptr, *sptr;
Xchar *sender, *serv;
X{
X  sprintf(mybuf,"*** New server: %s", serv);
X  putline(mybuf);
X}
X
Xm_list() {
X  putline("*** Oh boy... server asking me channel lists... exiting...");
X}
X
Xm_topic(sptr, cptr, sender, topic)
Xstruct Client *sptr, *cptr;
Xchar *sender, *topic;
X{
X  putline("*** Oh boy... server telling me the topic... exiting...");
X}
X
Xm_channel(sptr, cptr, sender, ch)
Xstruct Client *cptr, *sptr;
Xchar *sender, *ch;
X{
X  if (ch == (char *) 0 || *ch == '\0' || atoi(ch) == 0)
X    sprintf(mybuf,"*** Change: %s has left this Channel", sender);
X  else
X    sprintf(mybuf,"*** Change: %s has joined this Channel (%d)", 
X	    sender, atoi(ch));
X  putline(mybuf);
X}
X
Xm_version(sptr, cptr, sender, version)
Xstruct Client *cptr, *sptr;
Xchar *sender, *version;
X{
X  sprintf(mybuf,"*** Version: %s", version);
X  putline(mybuf);
X}
X
Xm_bye()
X{
X  exit(-1);    
X}
X
Xm_quit(sptr, cptr, sender)
Xstruct Client *sptr, *cptr;
Xchar *sender;
X{
X  sprintf(mybuf,"*** Signoff: %s", sender);
X  putline(mybuf);
X}
X
Xm_kill() {
X  putline("*** Received KILL message");
X}
X
Xm_info(sptr, cptr, sender, info)
Xstruct Client *cptr, *sptr;
Xchar *sender, *info;
X{
X  sprintf(mybuf,"*** Info: %s", info);
X  putline(mybuf);
X}
X
Xm_links() { 
X  putline("*** Received LINKS message");
X}
X
Xm_summon() {
X  putline("*** Received SUMMON message");
X}
X
Xm_stats() {
X  putline("*** Received STATS message");
X}
X
Xm_users() {
X  putline("*** Received USERS message");
X}
X
Xm_help() {
X  putline("*** Received HELP message");
X}
X
Xm_squit(sptr, cptr, sender, server)
Xstruct Client *cptr, *sptr;
Xchar *sender, *server;
X{
X  sprintf(mybuf,"*** Server %s has died. Snif.", server);
X  putline(mybuf);
X}
X
Xm_whoreply(sptr, cptr, sender, channel, username, host, server,
X	   nickname, away, realname)
Xstruct Client *sptr, *cptr;
Xchar *sender, *channel, *username, *host, *server, *nickname, *away;
Xchar *realname;
X{
X  int i = atoi(channel);
X  if (username)
X    center(abuf1, username, 8);
X  else
X    abuf1[0] = '\0';
X  if (host)
X    center(abuf2, host, 8);
X  else
X    abuf2[0] = '\0';
X  if (server)
X    center(abuf3, server, 8);
X  else
X    abuf3[0] = '\0';
X  if (nickname)
X    center(abuf4, nickname, 8);
X  else
X    abuf4[0] = '\0';
X  if (i != 0)
X    sprintf(mybuf,"Channel %3d: %8s@%8s %8s (%8s) %s %s",i ,abuf1, abuf2,
X	    abuf3, abuf4, away, realname);
X  else
X    sprintf(mybuf,"* Private *: %8s@%8s %8s (%8s) %s %s", abuf1, abuf2,
X	    abuf3, abuf4, away, realname);
X  putline(mybuf);
X}
X
Xm_mytext(sptr, cptr, sender, buf)
Xstruct Client *sptr, *cptr;
Xchar *sender, *buf;
X{
X  if (sender)
X    sprintf(mybuf,"<%s> %s", sender, buf);
X  else
X    sprintf(mybuf,"> %s",buf);
X  putline(mybuf);
X}
X
Xm_text(sptr, cptr, sender, buf)
Xstruct Client *sptr, *cptr;
Xchar *buf, *sender;
X{
X  if (sender && sender[0]) {
X    sprintf(mybuf,"<%s> %s", sender, buf);
X    putline(mybuf);
X  } else
X    putline(buf);
X}
X
Xm_myprivate(sptr, cptr, sender, buf, buf2)
Xstruct Client *sptr, *cptr;
Xchar *buf, *buf2, *sender;
X{
X  sprintf(mybuf,"-> *%s* %s",buf,buf2);
SHAR_EOF
echo "End of part 4"
echo "File r_msg.c is continued in part 5"
echo "5" > s2_seq_.tmp
exit 0



More information about the Alt.sources mailing list