[Olsr-cvs] olsrd-current/lib/dot_draw/src olsrd_dot_draw.c, 1.22, 1.23 olsrd_plugin.c, 1.13, 1.14
Bernd Petrovitsch
(spam-protected)
Fri Apr 20 16:06:20 CEST 2007
Update of /cvsroot/olsrd/olsrd-current/lib/dot_draw/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv7046/lib/dot_draw/src
Modified Files:
olsrd_dot_draw.c olsrd_plugin.c
Log Message:
cleanup, 1. step (to get some local changes away):
* killed lots of warnings
* added __attribure__((unused)) and __attribure__((format(printf, ..., ...)))
* added "const"
* moved declarations of static functions into .c files
* added "static" declarations
* removed all "inline" declarations. Usually the compiler knows better anyways.
* removed emtpy "return" statements at the end of functions
* localized declarations
* avoided unnecessary data copies
* removed lots of empty lines
There is much more to do.
Index: olsrd_dot_draw.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/dot_draw/src/olsrd_dot_draw.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** olsrd_dot_draw.c 11 Apr 2006 18:43:12 -0000 1.22
--- olsrd_dot_draw.c 20 Apr 2007 14:06:18 -0000 1.23
***************
*** 99,123 ****
ipc_action(int);
! static void inline
ipc_print_neigh_link(struct neighbor_entry *neighbor);
! static void inline
ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry);
! static void inline
ipc_print_net(union olsr_ip_addr *, union olsr_ip_addr *, union hna_netmask *);
static int
! ipc_send(char *, int);
static int
! ipc_send_str(char *);
static double
calc_etx(double, double);
- static void inline
- ipc_print_neigh_link(struct neighbor_entry *);
-
/**
--- 99,120 ----
ipc_action(int);
! static void
ipc_print_neigh_link(struct neighbor_entry *neighbor);
! static void
ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry);
! static void
ipc_print_net(union olsr_ip_addr *, union olsr_ip_addr *, union hna_netmask *);
static int
! ipc_send(const char *, int);
static int
! ipc_send_str(const char *);
static double
calc_etx(double, double);
/**
***************
*** 128,136 ****
*/
int
! olsrd_plugin_init()
{
/* Initial IPC value */
ipc_open = 0;
ipc_socket_up = 0;
/* Register the "ProcessChanges" function */
--- 125,135 ----
*/
int
! olsrd_plugin_init(void)
{
/* Initial IPC value */
ipc_open = 0;
ipc_socket_up = 0;
+ ipc_socket = -1;
+ ipc_connection = -1;
/* Register the "ProcessChanges" function */
***************
*** 147,151 ****
*/
void
! olsr_plugin_exit()
{
if(ipc_open)
--- 146,150 ----
*/
void
! olsr_plugin_exit(void)
{
if(ipc_open)
***************
*** 154,163 ****
! static void inline
ipc_print_neigh_link(struct neighbor_entry *neighbor)
{
char buf[256];
! char* adr;
! double etx=0.0;
char* style = "solid";
struct link_entry* link;
--- 153,162 ----
! static void
ipc_print_neigh_link(struct neighbor_entry *neighbor)
{
char buf[256];
! const char* adr;
! double etx = 0.0;
char* style = "solid";
struct link_entry* link;
***************
*** 189,193 ****
static int
! plugin_ipc_init()
{
struct sockaddr_in sin;
--- 188,192 ----
static int
! plugin_ipc_init(void)
{
struct sockaddr_in sin;
***************
*** 250,271 ****
static void
! ipc_action(int fd)
{
struct sockaddr_in pin;
! socklen_t addrlen;
! char *addr;
!
! addrlen = sizeof(struct sockaddr_in);
if (ipc_open)
{
! while(close(ipc_connection) == -1)
! {
! olsr_printf(1, "(DOT DRAW) Error on closing previously active TCP connection on fd %d: %s\n", ipc_connection, strerror(errno));
! if (errno != EINTR)
! {
! break;
! }
! }
ipc_open = 0;
}
--- 249,266 ----
static void
! ipc_action(int fd __attribute__((unused)))
{
struct sockaddr_in pin;
! socklen_t addrlen = sizeof(struct sockaddr_in);
if (ipc_open)
{
! int rc;
! do {
! rc = close(ipc_connection);
! } while (rc == -1 && (errno == EINTR || errno == EAGAIN));
! if (rc == -1) {
! olsr_printf(1, "(DOT DRAW) Error on closing previously active TCP connection on fd %d: %s\n", ipc_connection, strerror(errno));
! }
ipc_open = 0;
}
***************
*** 274,287 ****
{
olsr_printf(1, "(DOT DRAW)IPC accept: %s\n", strerror(errno));
- exit(1);
}
else
{
! addr = inet_ntoa(pin.sin_addr);
if(ntohl(pin.sin_addr.s_addr) != ntohl(ipc_accept_ip.s_addr))
{
olsr_printf(1, "Front end-connection from foregin host(%s) not allowed!\n", addr);
close(ipc_connection);
! return;
}
else
--- 269,281 ----
{
olsr_printf(1, "(DOT DRAW)IPC accept: %s\n", strerror(errno));
}
else
{
! char *addr = inet_ntoa(pin.sin_addr);
if(ntohl(pin.sin_addr.s_addr) != ntohl(ipc_accept_ip.s_addr))
{
olsr_printf(1, "Front end-connection from foregin host(%s) not allowed!\n", addr);
close(ipc_connection);
! ipc_connection = -1;
}
else
***************
*** 396,404 ****
! static void inline
ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry)
{
char buf[256];
! char* adr;
double etx = calc_etx( dst_entry->link_quality, dst_entry->inverse_link_quality );
--- 390,398 ----
! static void
ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry)
{
char buf[256];
! const char* adr;
double etx = calc_etx( dst_entry->link_quality, dst_entry->inverse_link_quality );
***************
*** 413,420 ****
! static void inline
ipc_print_net(union olsr_ip_addr *gw, union olsr_ip_addr *net, union hna_netmask *mask)
{
! char *adr;
adr = olsr_ip_to_string(gw);
--- 407,414 ----
! static void
ipc_print_net(union olsr_ip_addr *gw, union olsr_ip_addr *net, union hna_netmask *mask)
{
! const char *adr;
adr = olsr_ip_to_string(gw);
***************
*** 439,443 ****
static int
! ipc_send_str(char *data)
{
if(!ipc_open)
--- 433,437 ----
static int
! ipc_send_str(const char *data)
{
if(!ipc_open)
***************
*** 448,452 ****
static int
! ipc_send(char *data, int size)
{
if(!ipc_open)
--- 442,446 ----
static int
! ipc_send(const char *data, int size)
{
if(!ipc_open)
***************
*** 454,461 ****
#if defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined __MacOSX__
! if (send(ipc_connection, data, size, 0) < 0)
#else
! if (send(ipc_connection, data, size, MSG_NOSIGNAL) < 0)
#endif
{
olsr_printf(1, "(DOT DRAW)IPC connection lost!\n");
--- 448,456 ----
#if defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined __MacOSX__
! #define FLAGS 0
#else
! #define FLAGS MSG_NOSIGNAL
#endif
+ if (send(ipc_connection, data, size, FLAGS) == -1)
{
olsr_printf(1, "(DOT DRAW)IPC connection lost!\n");
Index: olsrd_plugin.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/dot_draw/src/olsrd_plugin.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** olsrd_plugin.c 2 Apr 2007 22:23:09 -0000 1.13
--- olsrd_plugin.c 20 Apr 2007 14:06:18 -0000 1.14
***************
*** 79,83 ****
*/
static void
! my_init()
{
/* Print plugin info to stdout */
--- 79,83 ----
*/
static void
! my_init(void)
{
/* Print plugin info to stdout */
***************
*** 94,98 ****
*/
static void
! my_fini()
{
/* Calls the destruction function
--- 94,98 ----
*/
static void
! my_fini(void)
{
/* Calls the destruction function
***************
*** 107,111 ****
int
! olsrd_plugin_interface_version()
{
return PLUGIN_INTERFACE_VERSION;
--- 107,111 ----
int
! olsrd_plugin_interface_version(void)
{
return PLUGIN_INTERFACE_VERSION;
More information about the Olsr-cvs
mailing list