lib update & gpl changes
This commit is contained in:
parent
3e6e3d814c
commit
e7715ea1d3
18
brarpwatch.c
18
brarpwatch.c
@ -1,3 +1,21 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 07/2007 by Olaf Rempel *
|
||||||
|
* razzor@kopf-tisch.de *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; version 2 of the License *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
***************************************************************************/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 06/2006 by Olaf Rempel *
|
* Copyright (C) 07/2007 by Olaf Rempel *
|
||||||
* razzor@kopf-tisch.de *
|
* razzor@kopf-tisch.de *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
* the Free Software Foundation; version 2 of the License *
|
||||||
* (at your option) any later version. *
|
|
||||||
* *
|
* *
|
||||||
* This program is distributed in the hope that it will be useful, *
|
* This program is distributed in the hope that it will be useful, *
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
18
datastore.c
18
datastore.c
@ -1,3 +1,21 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 07/2007 by Olaf Rempel *
|
||||||
|
* razzor@kopf-tisch.de *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; version 2 of the License *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
***************************************************************************/
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
81
event.c
81
event.c
@ -1,11 +1,10 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 10/2006 by Olaf Rempel *
|
* Copyright (C) 07/2007 by Olaf Rempel *
|
||||||
* razzor@kopf-tisch.de *
|
* razzor@kopf-tisch.de *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
* the Free Software Foundation; version 2 of the License *
|
||||||
* (at your option) any later version. *
|
|
||||||
* *
|
* *
|
||||||
* This program is distributed in the hope that it will be useful, *
|
* This program is distributed in the hope that it will be useful, *
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
@ -79,6 +78,7 @@ struct event_fd * event_add_fd(
|
|||||||
}
|
}
|
||||||
|
|
||||||
memset(entry, 0, sizeof(struct event_fd));
|
memset(entry, 0, sizeof(struct event_fd));
|
||||||
|
entry->flags |= EVENT_NEW;
|
||||||
entry->fd = fd;
|
entry->fd = fd;
|
||||||
|
|
||||||
/* put it on the list */
|
/* put it on the list */
|
||||||
@ -86,17 +86,16 @@ struct event_fd * event_add_fd(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type & FD_READ) {
|
if (type & FD_READ) {
|
||||||
entry->flags = (callback != NULL) ? (entry->flags | FD_READ) : (entry->flags & ~FD_READ);
|
entry->flags = (callback != NULL) ? (entry->flags | FD_READ | EVENT_NEW) : (entry->flags & ~FD_READ);
|
||||||
entry->read_cb = callback;
|
entry->read_cb = callback;
|
||||||
entry->read_priv = privdata;
|
entry->read_priv = privdata;
|
||||||
|
|
||||||
} else if (type & FD_WRITE) {
|
} else if (type & FD_WRITE) {
|
||||||
entry->flags = (callback != NULL) ? (entry->flags | FD_WRITE) : (entry->flags & ~FD_WRITE);
|
entry->flags = (callback != NULL) ? (entry->flags | FD_WRITE | EVENT_NEW) : (entry->flags & ~FD_WRITE);
|
||||||
entry->write_cb = callback;
|
entry->write_cb = callback;
|
||||||
entry->write_priv = privdata;
|
entry->write_priv = privdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry->flags |= EVENT_NEW;
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,32 +207,6 @@ int event_loop(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
fd_set *readfds = NULL, *writefds = NULL;
|
|
||||||
struct event_fd *entry, *tmp;
|
|
||||||
|
|
||||||
list_for_each_entry_safe(entry, tmp, &event_fd_list, list) {
|
|
||||||
entry->flags &= ~EVENT_NEW;
|
|
||||||
|
|
||||||
if (entry->flags & EVENT_DELETE) {
|
|
||||||
list_del(&entry->list);
|
|
||||||
free(entry);
|
|
||||||
|
|
||||||
} else if (entry->flags & FD_READ) {
|
|
||||||
if (readfds == NULL) {
|
|
||||||
readfds = &fdsets[0];
|
|
||||||
FD_ZERO(readfds);
|
|
||||||
}
|
|
||||||
FD_SET(entry->fd, readfds);
|
|
||||||
|
|
||||||
} else if (entry->flags & FD_WRITE) {
|
|
||||||
if (writefds == NULL) {
|
|
||||||
writefds = &fdsets[1];
|
|
||||||
FD_ZERO(writefds);
|
|
||||||
}
|
|
||||||
FD_SET(entry->fd, writefds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct timeval timeout, *timeout_p = NULL;
|
struct timeval timeout, *timeout_p = NULL;
|
||||||
if (!list_empty(&event_timeout_list)) {
|
if (!list_empty(&event_timeout_list)) {
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
@ -247,7 +220,7 @@ int event_loop(void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* timeout not elapsed, exit search (since list is sorted) */
|
/* first timeout not elapsed, exit search (since list is sorted) */
|
||||||
if (cmp_timeval(&entry->nextrun, &now) == -1)
|
if (cmp_timeval(&entry->nextrun, &now) == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -272,6 +245,36 @@ int event_loop(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fd_set *readfds = NULL, *writefds = NULL;
|
||||||
|
struct event_fd *entry, *tmp;
|
||||||
|
|
||||||
|
list_for_each_entry_safe(entry, tmp, &event_fd_list, list) {
|
||||||
|
entry->flags &= ~EVENT_NEW;
|
||||||
|
|
||||||
|
if (entry->flags & EVENT_DELETE) {
|
||||||
|
list_del(&entry->list);
|
||||||
|
free(entry);
|
||||||
|
continue;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry->flags & FD_READ) {
|
||||||
|
if (readfds == NULL) {
|
||||||
|
readfds = &fdsets[0];
|
||||||
|
FD_ZERO(readfds);
|
||||||
|
}
|
||||||
|
FD_SET(entry->fd, readfds);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry->flags & FD_WRITE) {
|
||||||
|
if (writefds == NULL) {
|
||||||
|
writefds = &fdsets[1];
|
||||||
|
FD_ZERO(writefds);
|
||||||
|
}
|
||||||
|
FD_SET(entry->fd, writefds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int i = select(FD_SETSIZE, readfds, writefds, NULL, timeout_p);
|
int i = select(FD_SETSIZE, readfds, writefds, NULL, timeout_p);
|
||||||
if (i <= 0) {
|
if (i <= 0) {
|
||||||
/* On error, -1 is returned, and errno is set
|
/* On error, -1 is returned, and errno is set
|
||||||
@ -280,23 +283,17 @@ int event_loop(void)
|
|||||||
* after an error.
|
* after an error.
|
||||||
*/
|
*/
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else {
|
|
||||||
list_for_each_entry(entry, &event_fd_list, list) {
|
|
||||||
if ((entry->flags & EVENT_NEW) != 0) {
|
|
||||||
/* entry has just been added, execute it next round */
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((entry->flags & FD_READ) && FD_ISSET(entry->fd, readfds))
|
list_for_each_entry(entry, &event_fd_list, list) {
|
||||||
|
if (((entry->flags & (FD_READ | EVENT_NEW)) == FD_READ) && FD_ISSET(entry->fd, readfds))
|
||||||
if (entry->read_cb(entry->fd, entry->read_priv) != 0)
|
if (entry->read_cb(entry->fd, entry->read_priv) != 0)
|
||||||
entry->flags |= EVENT_DELETE;
|
entry->flags |= EVENT_DELETE;
|
||||||
|
|
||||||
if ((entry->flags & FD_WRITE) && FD_ISSET(entry->fd, writefds))
|
if (((entry->flags & (FD_WRITE | EVENT_NEW)) == FD_WRITE) && FD_ISSET(entry->fd, writefds))
|
||||||
if (entry->write_cb(entry->fd, entry->write_priv) != 0)
|
if (entry->write_cb(entry->fd, entry->write_priv) != 0)
|
||||||
entry->flags |= EVENT_DELETE;
|
entry->flags |= EVENT_DELETE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
free(fdsets);
|
free(fdsets);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 06/2006 by Olaf Rempel *
|
* Copyright (C) 07/2007 by Olaf Rempel *
|
||||||
* razzor@kopf-tisch.de *
|
* razzor@kopf-tisch.de *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
* the Free Software Foundation; version 2 of the License *
|
||||||
* (at your option) any later version. *
|
|
||||||
* *
|
* *
|
||||||
* This program is distributed in the hope that it will be useful, *
|
* This program is distributed in the hope that it will be useful, *
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
18
netlink.c
18
netlink.c
@ -1,3 +1,21 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 07/2007 by Olaf Rempel *
|
||||||
|
* razzor@kopf-tisch.de *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; version 2 of the License *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
***************************************************************************/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
18
ulogparse.c
18
ulogparse.c
@ -1,3 +1,21 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 07/2007 by Olaf Rempel *
|
||||||
|
* razzor@kopf-tisch.de *
|
||||||
|
* *
|
||||||
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; version 2 of the License *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with this program; if not, write to the *
|
||||||
|
* Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
***************************************************************************/
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user