| 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 |
|
|---|
| 16 | int opt_d = 0;
|
|---|
| 17 | char myhostname[HOST_SIZE+1];
|
|---|
| 18 |
|
|---|
| 19 | int main(argc, argv)
|
|---|
| 20 | int argc;
|
|---|
| 21 | char *argv[];
|
|---|
| 22 | {
|
|---|
| 23 | struct talk_request request;
|
|---|
| 24 | struct 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.