-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqotdservice.js
59 lines (49 loc) · 940 Bytes
/
qotdservice.js
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
// qotdservice.js
// Synchronet Service for the Quote of The Day protocol (RFC 865)
// $Id: qotdservice.js,v 1.1 2007/08/13 04:25:41 deuce Exp $
const REVISION = "$Revision: 1.1 $".split(' ')[1];
var output_buf = "";
// Write a string to the client socket
function write(str)
{
output_buf += str;
}
// Write all the output at once
function flush()
{
client.socket.send(output_buf);
}
function done()
{
flush();
exit();
}
automsg=new File(system.data_dir+"msgs/auto.msg");
if(!automsg.open("r",true)) {
log("Error opening "+system.data_dir+"msgs/auto.msg for read");
write("No AutoMessage set\r\n");
done();
}
while(1) {
if(!client.socket.is_connected)
done();
b=automsg.readBin(1);
if(automsg.eof)
done();
if(b==1) { // CTRL-A... eat it
b=automsg.readBin(1);
if(b!=1)
continue;
}
if(b < 32) {
switch(b) {
case 9:
case 10:
case 13:
break;
default:
continue;
}
}
write(ascii(b));
}