Diffstat (limited to 'noncore/net/wellenreiter/daemon/source/daemon.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/daemon.cc | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.cc b/noncore/net/wellenreiter/daemon/source/daemon.cc index 8724efa..b3a37b6 100644 --- a/noncore/net/wellenreiter/daemon/source/daemon.cc +++ b/noncore/net/wellenreiter/daemon/source/daemon.cc | |||
@@ -7,12 +7,10 @@ | |||
7 | #include "config.hh" | 7 | #include "config.hh" |
8 | #include "daemon.hh" | 8 | #include "daemon.hh" |
9 | #include "log.hh" | ||
10 | #include "sendgui.hh" | ||
11 | #include "getgui.hh" | ||
12 | 9 | ||
13 | /* Main function of wellenreiterd */ | 10 | /* Main function of wellenreiterd */ |
14 | int main(int argc, char **argv) | 11 | int main(int argc, char **argv) |
15 | { | 12 | { |
16 | int sock, maxfd; | 13 | int sock, maxfd, guiport=GUIPORT; |
14 | char guihost[]="127.0.0.1"; | ||
17 | struct sockaddr_in *cliaddr; | 15 | struct sockaddr_in *cliaddr; |
18 | socklen_t len=sizeof(struct sockaddr); | 16 | socklen_t len=sizeof(struct sockaddr); |
@@ -24,13 +22,15 @@ int main(int argc, char **argv) | |||
24 | 22 | ||
25 | /* Setup socket for incoming commands */ | 23 | /* Setup socket for incoming commands */ |
26 | if(!commsock(&sock)) | 24 | if((sock=commsock(DAEMONADDR, DAEMONPORT)) < 0) |
27 | return 0; | 25 | { |
28 | 26 | wl_logerr("Cannot setup socket"); | |
29 | log_info("Set up socket '%d' for GUI communication", sock); | 27 | exit(-1); |
28 | } | ||
29 | wl_loginfo("Set up socket '%d' for GUI communication", sock); | ||
30 | 30 | ||
31 | FD_ZERO(&rset); | 31 | FD_ZERO(&rset); |
32 | 32 | ||
33 | /* Start main loop */ | 33 | /* Start main loop */ |
34 | log_info("Starting main loop"); | 34 | wl_loginfo("Starting main loop"); |
35 | while(1) | 35 | while(1) |
36 | { | 36 | { |
@@ -41,5 +41,5 @@ int main(int argc, char **argv) | |||
41 | if(select(maxfd, &rset, NULL, NULL, NULL) < 0) | 41 | if(select(maxfd, &rset, NULL, NULL, NULL) < 0) |
42 | { | 42 | { |
43 | log_err("Error calling select: %s", strerror(errno)); | 43 | wl_logerr("Error calling select: %s", strerror(errno)); |
44 | break; | 44 | break; |
45 | } | 45 | } |
@@ -51,11 +51,11 @@ int main(int argc, char **argv) | |||
51 | if(recvfrom(sock, buffer, sizeof(buffer)-1, 0, (struct sockaddr *)cliaddr, &len) < 0) | 51 | if(recvfrom(sock, buffer, sizeof(buffer)-1, 0, (struct sockaddr *)cliaddr, &len) < 0) |
52 | { | 52 | { |
53 | log_err("Cannot read from socket: %s", strerror(errno)); | 53 | wl_logerr("Cannot read from socket: %s", strerror(errno)); |
54 | break; | 54 | break; |
55 | } | 55 | } |
56 | log_info("Received command from '%s': %s", inet_ntoa(cliaddr->sin_addr), buffer); | 56 | wl_loginfo("Received command from '%s': %s", inet_ntoa(cliaddr->sin_addr), buffer); |
57 | 57 | ||
58 | /* Pass string to analyze function */ | 58 | /* Pass string to analyze function */ |
59 | commstring(buffer); | 59 | // sendcomm(guihost, guiport, buffer); |
60 | 60 | ||
61 | } | 61 | } |
@@ -67,17 +67,15 @@ int main(int argc, char **argv) | |||
67 | if(fgets(buffer, sizeof(buffer) - 1, fp) == NULL) | 67 | if(fgets(buffer, sizeof(buffer) - 1, fp) == NULL) |
68 | { | 68 | { |
69 | log_err("Cannot read from stdin: %s", strerror(errno)); | 69 | wl_logerr("Cannot read from stdin: %s", strerror(errno)); |
70 | break; | 70 | break; |
71 | } | 71 | } |
72 | log_info("Sending command to '%s': %s", GUIADDR, buffer); | 72 | wl_loginfo("Sending command to '%s': %s", GUIADDR, buffer); |
73 | 73 | ||
74 | /* Send string to GUI */ | 74 | /* Send string to GUI */ |
75 | sendgui("%d: %s", 1234, buffer); | 75 | sendcomm(guihost, guiport, "%d: %s", 1234, buffer); |
76 | 76 | ||
77 | } | 77 | } |
78 | |||
79 | } | 78 | } |
80 | |||
81 | close(sock); | 79 | close(sock); |
82 | return 0; | 80 | exit(0); |
83 | } | 81 | } |