SmaugWizard/Backup/
SmaugWizard/Backup/L/
SmaugWizard/Boards/
SmaugWizard/Building/
SmaugWizard/Corpses/
SmaugWizard/Councils/
SmaugWizard/Deity/
SmaugWizard/Gods/
SmaugWizard/MudProgs/
SmaugWizard/Player/L/
SmaugWizard/Src/
SmaugWizard/Src/res/
/****************************************************************************
 * [S]imulated [M]edieval [A]dventure multi[U]ser [G]ame      |				*
 * -----------------------------------------------------------|   \\._.//	*
 * SmaugWiz (C) 1998 by Russ Pillsbury (Windows NT version)   |   (0...0)	*
 * -----------------------------------------------------------|    ).:.(	*
 * SMAUG (C) 1994, 1995, 1996 by Derek Snider                 |    {o o}	*
 * -----------------------------------------------------------|   / ' ' \	*
 * SMAUG code team: Thoric, Altrag, Blodkai, Narn, Haus,      |~'~.VxvxV.~'~*
 * Scryn, Swordbearer, Rennard, Tricops, and Gorog.           |				*
 * ------------------------------------------------------------------------ *
 * Merc 2.1 Diku Mud improvments copyright (C) 1992, 1993 by Michael        *
 * Chastain, Michael Quan, and Mitchell Tse.                                *
 * Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,          *
 * Michael Seifert, Hans Henrik Staerfeldt, Tom Madsen, and Katja Nyboe.    *
 * ------------------------------------------------------------------------ *
 *			    Special requests module									    *
 * ------------------------------------------------------------------------ *
 * - Only handles who requests currently, but will hopefully support much   *
 *   more in the future.  Including: reboot/shutdown etc.				    *
 ****************************************************************************/

#include	"stdafx.h"
#include	"smaug.h"

int REQ;

void init_request_pipe ()
{
#ifdef REQUESTS
  if ((REQ = open (REQUEST_PIPE, O_RDONLY | O_NONBLOCK)) == -1)
  {
    bug ("REQUEST pipe not found", 0);
    ThrowSmaugException (SE_BOOT);
  }
#endif
}

void check_requests ()
{
#ifdef REQUESTS
  char buf[MAX_STRING_LENGTH];
  char buf2[MAX_STRING_LENGTH];
  int  c;
  if (read (REQ, buf, sizeof (buf)) != -1)
  {
     close (REQ);
     init_request_pipe ();
     for (c = 0; c < MAX_STRING_LENGTH; c++)
	if (buf[c] == '\n' || buf[c] == '\r')
	{
	   buf[c] = '\0';
	   break;
	}
     sprintf (buf2, "REQUEST: %s", buf);
     gpDoc->LogString (buf2);
     if (strcmp (buf, "who") == 0)
	do_who (NULL, "");
     else
     if (strcmp (buf, "webwho") == 0)
	do_who (NULL, "www");
  }
#endif
}