[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Reindent windows libevent file.



Update of /home/or/cvsroot/libevent/WIN32-Code
In directory moria.mit.edu:/tmp/cvs-serv8952/WIN32-Code

Modified Files:
	win32.c 
Log Message:
Reindent windows libevent file.

Index: win32.c
===================================================================
RCS file: /home/or/cvsroot/libevent/WIN32-Code/win32.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- win32.c	10 Mar 2005 19:32:05 -0000	1.3
+++ win32.c	10 Mar 2005 21:03:02 -0000	1.4
@@ -93,11 +93,13 @@
 
 #define FD_SET_ALLOC_SIZE(n) ((sizeof(struct win_fd_set) + ((n)-1)*sizeof(SOCKET)))
 
-static int realloc_fd_sets(struct win32op *op, size_t new_size)
+static int
+realloc_fd_sets(struct win32op *op, size_t new_size)
 {
 	size_t size;
 
-	assert(new_size >= op->readset_in->fd_count && new_size >= op->writeset_in->fd_count);
+	assert(new_size >= op->readset_in->fd_count &&
+	       new_size >= op->writeset_in->fd_count);
 	assert(new_size >= 1);
 
 	size = FD_SET_ALLOC_SIZE(new_size);
@@ -115,12 +117,14 @@
 	return (0);
 }
 
-static int timeval_to_ms(struct timeval *tv)
+static int
+timeval_to_ms(struct timeval *tv)
 {
 	return ((tv->tv_sec * 1000) + (tv->tv_usec / 1000));
 }
 
-static int do_fd_set(struct win32op *op, SOCKET s, int read)
+static int
+do_fd_set(struct win32op *op, SOCKET s, int read)
 {
 	unsigned int i;
 	struct win_fd_set *set = read ? op->readset_in : op->writeset_in;
@@ -136,7 +140,8 @@
 	return (set->fd_count++);
 }
 
-static int do_fd_clear(struct win32op *op, SOCKET s, int read)
+static int
+do_fd_clear(struct win32op *op, SOCKET s, int read)
 {
 	unsigned int i;
 	struct win_fd_set *set = read ? op->readset_in : op->writeset_in;
@@ -162,33 +167,33 @@
 	winop->fd_setsz = NEVENT;
 	size = FD_SET_ALLOC_SIZE(NEVENT);
 	if (!(winop->readset_in = malloc(size)))
-        goto err;
+		goto err;
 	if (!(winop->writeset_in = malloc(size)))
-        goto err;
+		goto err;
 	if (!(winop->readset_out = malloc(size)))
-        goto err;
+		goto err;
 	if (!(winop->writeset_out = malloc(size)))
-        goto err;
+		goto err;
 	if (!(winop->exset_out = malloc(size)))
-        goto err;
+		goto err;
 	winop->n_events = 0;
 	winop->n_events_alloc = NEVENT;
 	if (!(winop->events = malloc(NEVENT*sizeof(struct event*))))
-        goto err;
+		goto err;
 	winop->readset_in->fd_count = winop->writeset_in->fd_count = 0;
 	winop->readset_out->fd_count = winop->writeset_out->fd_count
 		= winop->exset_out->fd_count = 0;
 
 	return (winop);
-err:
-    XFREE(winop->readset_in);
-    XFREE(winop->writeset_in);
-    XFREE(winop->readset_out);
-    XFREE(winop->writeset_out);
-    XFREE(winop->exset_out);
-    XFREE(winop->events);
-    XFREE(winop);
-    return (NULL);
+ err:
+        XFREE(winop->readset_in);
+        XFREE(winop->writeset_in);
+        XFREE(winop->readset_out);
+        XFREE(winop->writeset_out);
+        XFREE(winop->exset_out);
+        XFREE(winop->events);
+        XFREE(winop);
+        return (NULL);
 }
 
 int
@@ -216,26 +221,27 @@
 
 	for (i=0;i<win32op->n_events;++i) {
 		if(win32op->events[i] == ev) {
-            event_debug(("%s: Event for %d already inserted.", __func__, (int)ev->ev_fd));
+			event_debug(("%s: Event for %d already inserted.",
+				     __func__, (int)ev->ev_fd));
 			return (0);
 		}
 	}
-    event_debug(("%s: adding event for %d", __func__, (int)ev->ev_fd));
+	event_debug(("%s: adding event for %d", __func__, (int)ev->ev_fd));
 	if (ev->ev_events & EV_READ) {
 		if (do_fd_set(win32op, ev->ev_fd, 1)<0)
-            return (-1);
+			return (-1);
 	}
 	if (ev->ev_events & EV_WRITE) {
 		if (do_fd_set(win32op, ev->ev_fd, 0)<0)
-            return (-1);
+			return (-1);
 	}
 
 	if (win32op->n_events_alloc == win32op->n_events) {
-        size_t sz;
+		size_t sz;
 		win32op->n_events_alloc *= 2;
-        sz = sizeof(struct event*)*win32op->n_events_alloc;
+		sz = sizeof(struct event*)*win32op->n_events_alloc;
 		if (!(win32op->events = realloc(win32op->events, sz)))
-            return (-1);          
+			return (-1);
 	}
 	win32op->events[win32op->n_events++] = ev;
 
@@ -250,8 +256,6 @@
 	if (ev->ev_events & EV_SIGNAL)
 		return ((int)signal(EVENT_SIGNAL(ev), SIG_IGN));
 
-	/* printf("Remove %d for %d (%p)\n...", ev->ev_fd, ev->ev_events, ev); */
-
 	found = -1;
 	for (i=0;i<win32op->n_events;++i) {
 		if(win32op->events[i] == ev) {
@@ -259,11 +263,12 @@
 			break;
 		}
 	}
-    if (found < 0) {
-        event_debug(("%s: Unable to remove non-inserted event for %d", __func__, ev->ev_fd));
+	if (found < 0) {
+		event_debug(("%s: Unable to remove non-inserted event for %d",
+			     __func__, ev->ev_fd));
 		return (-1);
-    }
-    event_debug(("%s: Removing event for %d", __func__, ev->ev_fd)); 
+	}
+	event_debug(("%s: Removing event for %d", __func__, ev->ev_fd));
 	if (ev->ev_events & EV_READ)
 		do_fd_clear(win32op, ev->ev_fd, 1);
 	if (ev->ev_events & EV_WRITE)
@@ -276,25 +281,27 @@
 	return 0;
 }
 
-static void fd_set_copy(struct win_fd_set *out, const struct win_fd_set *in)
+static void
+fd_set_copy(struct win_fd_set *out, const struct win_fd_set *in)
 {
 	out->fd_count = in->fd_count;
 	memcpy(out->fd_array, in->fd_array, in->fd_count * (sizeof(SOCKET)));
 }
 
 /*
-static void dump_fd_set(struct win_fd_set *s)
-{
-	unsigned int i;
-	printf("[ ");
-	for(i=0;i<s->fd_count;++i)
-		printf("%d ",(int)s->fd_array[i]);
-	printf("]\n");
-}
+  static void dump_fd_set(struct win_fd_set *s)
+  {
+  unsigned int i;
+  printf("[ ");
+  for(i=0;i<s->fd_count;++i)
+  printf("%d ",(int)s->fd_array[i]);
+  printf("]\n");
+  }
 */
 
 int
-win32_dispatch(struct event_base *base, struct win32op *win32op, struct timeval *tv)
+win32_dispatch(struct event_base *base, struct win32op *win32op,
+	       struct timeval *tv)
 {
 	int res = 0;
 	int i;
@@ -304,22 +311,23 @@
 	fd_set_copy(win32op->exset_out, win32op->readset_in);
 	fd_set_copy(win32op->writeset_out, win32op->writeset_in);
 
-	fd_count = (win32op->readset_out->fd_count > win32op->writeset_out->fd_count) ?
-		win32op->readset_out->fd_count : win32op->writeset_out->fd_count;
+	fd_count =
+           (win32op->readset_out->fd_count > win32op->writeset_out->fd_count) ?
+	    win32op->readset_out->fd_count : win32op->writeset_out->fd_count;
 
-    if (!fd_count) {
-        /* Windows doesn't like you to call select() with no sockets. */
-        Sleep(timeval_to_ms(tv));
-        signal_process();
-        return (0);
-    }
+	if (!fd_count) {
+		/* Windows doesn't like you to call select() with no sockets */
+		Sleep(timeval_to_ms(tv));
+		signal_process();
+		return (0);
+	}
 
 	res = select(fd_count,
 		     (struct fd_set*)win32op->readset_out,
 		     (struct fd_set*)win32op->writeset_out,
 		     (struct fd_set*)win32op->exset_out, tv);
 
-    event_debug(("%s: select returned %d", __func__, res));
+	event_debug(("%s: select returned %d", __func__, res));
 
 	if(res <= 0) {
 		signal_process();
@@ -356,7 +364,8 @@
 }
 
 
-static int signal_handler(int sig)
+static int
+signal_handler(int sig)
 {
 	evsigcaught[sig]++;
 	signal_caught = 1;