Beispiel #1
0
int API
main ()
{
    struct routeup rtc;
    if (routeup_setup (&rtc))
        return 1;
    while (!routeup_once (&rtc, 0))
        printf ("n\n");
    routeup_teardown (&rtc);
    return 0;
}
Beispiel #2
0
/*
 * Wait for a single event to happen. If should_netlink is true, we ask the
 * supplied routeup context to wait for an event; otherwise, we wait for a byte
 * of input on stdin. Semantics (for return value) are the same as for
 * routeup_once().
 */
int
wait_for_event (struct routeup *rtc, int should_netlink, int timeout)
{
  char buf[1];
  fd_set fds;
  struct timeval tv;
  int r;

  if (should_netlink)
    return routeup_once (rtc, timeout);

  tv.tv_sec = timeout;
  tv.tv_usec = 0;
  FD_ZERO (&fds);
  FD_SET (STDIN_FILENO, &fds);
  r = select (STDIN_FILENO + 1, &fds, NULL, NULL, &tv);
  if (r > 0)
    return read (STDIN_FILENO, buf, sizeof (buf)) != 1;
  return r == 0 ? 1 : -1;
}
Beispiel #3
0
static void _routeup(void *arg, int fd)
{
  struct routeup *rtup = arg;
  while (!routeup_once(rtup, 0))
    _subproc_signal(fd);
}