forked from Stichting-MINIX-Research-Foundation/minix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtalkd.c
More file actions
executable file
·54 lines (43 loc) · 1.04 KB
/
Copy pathtalkd.c
File metadata and controls
executable file
·54 lines (43 loc) · 1.04 KB
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
/* talkd.c Copyright Michael Temari 07/22/1996 All Rights Reserved */
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <net/gen/in.h>
#include "talk.h"
#include "talkd.h"
#include "net.h"
#include "process.h"
_PROTOTYPE(int main, (int argc, char *argv[]));
int opt_d = 0;
char myhostname[HOST_SIZE+1];
int main(argc, argv)
int argc;
char *argv[];
{
struct talk_request request;
struct talk_reply reply;
if(argc > 1)
if(strcmp(argv[1], "-d") || argc > 2) {
fprintf(stderr, "Usage: talkd [-d]\n");
return(-1);
} else
opt_d = 1;
if(getuid() != 0) {
fprintf(stderr, "talkd: Must be run as super user\n");
return(-1);
}
if(gethostname(myhostname, HOST_SIZE) < 0) {
fprintf(stderr, "talkd: Error getting hostname\n");
return(-1);
}
if(NetInit()) {
fprintf(stderr, "talkd: Error in NetInit\n");
return(-1);
}
while(getrequest(&request) == 0) {
if(processrequest(&request, &reply)) break;
if(sendreply(&request, &reply)) break;
}
return(-1);
}