root/src/noit_console.c

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

poller structure... is it that simple? can't be

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