-
Notifications
You must be signed in to change notification settings - Fork 0
/
requests.cpp
executable file
·67 lines (59 loc) · 1.9 KB
/
requests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/****************************************************************************
* [S]imulated [M]edieval [A]dventure multi[U]ser [G]ame | \\._.// *
* -----------------------------------------------------------| (0...0) *
* SMAUG 1.0 (C) 1994, 1995, 1996 by Derek Snider | ).:.( *
* -----------------------------------------------------------| {o o} *
* SMAUG code team: Thoric, Altrag, Blodkai, Narn, Haus, | / ' ' \ *
* Scryn, Rennard, Swordbearer, Gorog, Grishnakh and Tricops |~'~.VxvxV.~'~*
* ------------------------------------------------------------------------ *
* Special requests module *
* ------------------------------------------------------------------------ *
* - Only handles who requests currently, but will hopefully support much *
* more in the future. Including: reboot/shutdown etc. *
****************************************************************************/
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "mud.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 );
exit(1);
}
#endif
}
void check_requests( )
{
#ifdef REQUESTS
char buf[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 );
log_string( buf2 );*/
if ( !strcmp(buf, "reboot") ) {
extern bool mud_down;
extern bool shell_shutdown;
mud_down = shell_shutdown = TRUE;
} else if ( !strcmp(buf, "copyover") ) {
do_copyover(NULL, NULL);
}
}
#endif
}