root/src/noit_console.c

Revision caa7b86e0a2913bf4f9e3254320a05dd636b2e06, 0.9 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 6 years ago)

glue up some actual XML

  • Property mode set to 100644
Line 
1 /*
2  * Copyright (c) 2007, OmniTI Computer Consulting, Inc.
3  * All rights reserved.
4  */
5
6 #include "noit_defines.h"
7
8 #include <stdio.h>
9 #include <unistd.h>
10
11 #include "eventer/eventer.h"
12 #include "utils/noit_log.h"
13 #include "noit_listener.h"
14 #include "noit_poller.h"
15 #include "noit_console.h"
16
17 void
18 noit_console_init() {
19   eventer_name_callback("noit_console", noit_console_handler);
20 }
21
22 int
23 noit_console_handler(eventer_t e, int mask, void *closure,
24                      struct timeval *now) {
25   int newmask = EVENTER_READ;
26   if(mask & EVENTER_EXCEPTION) {
27     eventer_remove_fd(e->fd);
28     close(e->fd);
29     return 0;
30   }
31   if(mask & EVENTER_READ) {
32     int len;
33     char buffer[4096];
34     len = e->opset->read(e->fd, buffer, sizeof(buffer)-1, &newmask, e);
35     if(len <= 0) {
36       eventer_remove_fd(e->fd);
37       close(e->fd);
38       return 0;
39     }
40     printf("IN: %.*s", len, buffer);
41   }
42   return newmask | EVENTER_EXCEPTION;
43 }
44
Note: See TracBrowser for help on using the browser.