root/src/noit_console.c

Revision f235ad41b286a70c1f8e40c8e56eebc9b051508a, 0.7 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 7 years ago)

make this work on Mac OS X

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