Show
Ignore:
Timestamp:
01/16/08 04:57:05 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1200459425 +0000
git-parent:

[7212f9de44a1f04707e822e3337100a80f707cb3]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1200459425 +0000
Message:

make this work on Mac OS X

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noitd.c

    r7212f9d rf235ad4  
    1212#include "noit_console.h" 
    1313 
    14 int stdin_handler(eventer_t e, int mask, void *closure, struct timeval *now) { 
    15   fprintf(stderr, "in stdin_handler:\n"); 
    16   while(1) { 
    17     int len; 
    18     char buffer[1024]; 
    19     len = e->opset->read(e->fd, buffer, sizeof(buffer)-1, &mask, NULL); 
    20     printf("read() => %d\n", len); 
    21     if(len < 0 && errno == EINTR) continue; 
    22     if(len < 0 && errno == EAGAIN) break; 
    23     if(len > 0) { 
    24       buffer[len] = '\0'; 
    25       printf("read: '%s'\n", buffer); 
    26     } 
    27   } 
    28   return mask; 
    29 
    30 void stdin_sample() { 
    31   socklen_t salen; 
    32   eventer_t e; 
     14int main(int argc, char **argv) { 
    3315 
    34   salen = 1; 
    35   if(ioctl(0, FIONBIO, &salen)) { 
    36     fprintf(stderr, "Cannot unlock stdin\n"); 
    37   } 
    38   e = eventer_alloc(); 
    39   e->fd = 0; 
    40   e->mask = EVENTER_READ; 
    41   e->callback = stdin_handler; 
    42   eventer_add(e); 
    43 } 
    44 int main(int argc, char **argv) { 
    4516  noit_log_init(); 
     17  noit_log_stream_add_stream(noit_debug, noit_stderr); 
     18  noit_log_stream_add_stream(noit_error, noit_stderr); 
     19 
    4620  if(eventer_choose("kqueue") == -1) { 
    4721    fprintf(stderr, "Cannot choose kqueue\n"); 
     
    5327  } 
    5428 
    55   stdin_sample(); 
    5629  noit_listener("127.0.0.1", 23123, SOCK_STREAM, 5, noit_console_handler, NULL); 
    5730  eventer_loop();