source: trunk/minix/commands/talkd/talkd.c@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.0 KB
Line 
1/* talkd.c Copyright Michael Temari 07/22/1996 All Rights Reserved */
2
3#include <sys/types.h>
4#include <stdio.h>
5#include <string.h>
6#include <unistd.h>
7#include <net/gen/in.h>
8
9#include "talk.h"
10#include "talkd.h"
11#include "net.h"
12#include "process.h"
13
14_PROTOTYPE(int main, (int argc, char *argv[]));
15
16int opt_d = 0;
17char myhostname[HOST_SIZE+1];
18
19int main(argc, argv)
20int argc;
21char *argv[];
22{
23struct talk_request request;
24struct talk_reply reply;
25
26 if(argc > 1)
27 if(strcmp(argv[1], "-d") || argc > 2) {
28 fprintf(stderr, "Usage: talkd [-d]\n");
29 return(-1);
30 } else
31 opt_d = 1;
32
33 if(getuid() != 0) {
34 fprintf(stderr, "talkd: Must be run as super user\n");
35 return(-1);
36 }
37
38 if(gethostname(myhostname, HOST_SIZE) < 0) {
39 fprintf(stderr, "talkd: Error getting hostname\n");
40 return(-1);
41 }
42
43 if(NetInit()) {
44 fprintf(stderr, "talkd: Error in NetInit\n");
45 return(-1);
46 }
47
48 while(getrequest(&request) == 0) {
49 if(processrequest(&request, &reply)) break;
50 if(sendreply(&request, &reply)) break;
51 }
52
53 return(-1);
54}
Note: See TracBrowser for help on using the repository browser.