root/src/noit_console.c

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

renaming something before it becomes crazy painful

  • 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_console.h"
15
16 void
17 noit_console_init() {
18   eventer_name_callback("noit_console", noit_console_handler);
19 }
20
21 int
22 noit_console_handler(eventer_t e, int mask, void *closure,
23                      struct timeval *now) {
24   int newmask = EVENTER_READ;
25   if(mask & EVENTER_EXCEPTION) {
26     eventer_remove_fd(e->fd);
27     close(e->fd);
28     return 0;
29   }
30   if(mask & EVENTER_READ) {
31     int len;
32     char buffer[4096];
33     len = e->opset->read(e->fd, buffer, sizeof(buffer)-1, &newmask, e);
34     if(len <= 0) {
35       eventer_remove_fd(e->fd);
36       close(e->fd);
37       return 0;
38     }
39     printf("IN: %.*s", len, buffer);
40   }
41   return newmask | EVENTER_EXCEPTION;
42 }
43
Note: See TracBrowser for help on using the browser.