Commit 722b5ff6 authored by Pekka Pessi's avatar Pekka Pessi

su-glib/su_source_test.c: fixed whitespace

darcs-hash:20081127230556-db55f-03ec055a37e32f7b80bafd6aa086eaf2019130dc.gz
parent e2ffd505
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
* @brief Test program for glib and su root event loop integration. * @brief Test program for glib and su root event loop integration.
* *
* @author Pekka Pessi <Pekka.Pessi@nokia.com> * @author Pekka Pessi <Pekka.Pessi@nokia.com>
* *
* @date Created: Thu Mar 18 19:40:51 1999 pessi * @date Created: Thu Mar 18 19:40:51 1999 pessi
*/ */
...@@ -74,7 +74,7 @@ short opt_verbatim = 0; ...@@ -74,7 +74,7 @@ short opt_verbatim = 0;
short opt_singlethread = 0; short opt_singlethread = 0;
GMainLoop *global_gmainloop = NULL; GMainLoop *global_gmainloop = NULL;
static su_socket_t udpsocket(void) static su_socket_t udpsocket(void)
{ {
su_socket_t s; su_socket_t s;
su_sockaddr_t su = { 0 }; su_sockaddr_t su = { 0 };
...@@ -98,7 +98,7 @@ static su_socket_t udpsocket(void) ...@@ -98,7 +98,7 @@ static su_socket_t udpsocket(void)
if (getsockname(s, &su.su_sa, &sulen) == SOCKET_ERROR) { if (getsockname(s, &su.su_sa, &sulen) == SOCKET_ERROR) {
su_perror("udpsocket: getsockname"); su_perror("udpsocket: getsockname");
exit(1); exit(1);
} }
if (opt_verbatim) if (opt_verbatim)
...@@ -118,7 +118,7 @@ static char *snow(su_time_t now) ...@@ -118,7 +118,7 @@ static char *snow(su_time_t now)
return buf; return buf;
} }
void void
do_ping(struct pinger *p, su_timer_t *t, void *p0) do_ping(struct pinger *p, su_timer_t *t, void *p0)
{ {
char buf[1024]; char buf[1024];
...@@ -129,7 +129,7 @@ do_ping(struct pinger *p, su_timer_t *t, void *p0) ...@@ -129,7 +129,7 @@ do_ping(struct pinger *p, su_timer_t *t, void *p0)
p->when = su_now(); p->when = su_now();
snprintf(buf, sizeof(buf), "Ping %d at %s", p->id++, snow(p->when)); snprintf(buf, sizeof(buf), "Ping %d at %s", p->id++, snow(p->when));
if (sendto(p->s, buf, strlen(buf), 0, if (sendto(p->s, buf, strlen(buf), 0,
&p->addr.su_sa, su_sockaddr_size(&p->addr)) == -1) { &p->addr.su_sa, su_sockaddr_size(&p->addr)) == -1) {
su_perror("do_ping: send"); su_perror("do_ping: send");
} }
...@@ -189,7 +189,7 @@ do_pong(struct pinger *p, su_timer_t *t, void *p0) ...@@ -189,7 +189,7 @@ do_pong(struct pinger *p, su_timer_t *t, void *p0)
p->id = 0; p->id = 0;
snprintf(buf, sizeof(buf), "Pong at %s", snow(su_now())); snprintf(buf, sizeof(buf), "Pong at %s", snow(su_now()));
if (sendto(p->s, buf, strlen(buf), 0, if (sendto(p->s, buf, strlen(buf), 0,
&p->addr.su_sa, su_sockaddr_size(&p->addr)) == -1) { &p->addr.su_sa, su_sockaddr_size(&p->addr)) == -1) {
su_perror("do_pong: send"); su_perror("do_pong: send");
} }
...@@ -412,7 +412,7 @@ usage(int exitcode) ...@@ -412,7 +412,7 @@ usage(int exitcode)
/* /*
* test su_wait functionality: * test su_wait functionality:
* *
* Create a ponger, waking up do_recv() when data arrives, * Create a ponger, waking up do_recv() when data arrives,
* then scheduling do_pong() by timer * then scheduling do_pong() by timer
* *
* Create a pinger, executed from timer, scheduling do_ping(), * Create a pinger, executed from timer, scheduling do_ping(),
...@@ -428,8 +428,8 @@ int main(int argc, char *argv[]) ...@@ -428,8 +428,8 @@ int main(int argc, char *argv[])
su_timer_t *t; su_timer_t *t;
unsigned long sleeppid = 0; unsigned long sleeppid = 0;
struct pinger struct pinger
pinger = { PINGER, "ping", 1 }, pinger = { PINGER, "ping", 1 },
ponger = { PONGER, "pong", 1 }; ponger = { PONGER, "pong", 1 };
char *argv0 = argv[0]; char *argv0 = argv[0];
...@@ -437,7 +437,7 @@ int main(int argc, char *argv[]) ...@@ -437,7 +437,7 @@ int main(int argc, char *argv[])
#if HAVE_OPEN_C #if HAVE_OPEN_C
dup2(1, 2); dup2(1, 2);
#endif #endif
while (argv[1]) { while (argv[1]) {
if (strcmp(argv[1], "-v") == 0) { if (strcmp(argv[1], "-v") == 0) {
opt_verbatim = 1; opt_verbatim = 1;
...@@ -465,9 +465,9 @@ int main(int argc, char *argv[]) ...@@ -465,9 +465,9 @@ int main(int argc, char *argv[])
#if HAVE_OPEN_C #if HAVE_OPEN_C
opt_verbatim = 1; opt_verbatim = 1;
opt_singlethread = 1; opt_singlethread = 1;
su_log_soft_set_level(su_log_default, 9); su_log_soft_set_level(su_log_default, 9);
#endif #endif
#if HAVE_SIGNAL #if HAVE_SIGNAL
signal(SIGTERM, term); signal(SIGTERM, term);
#endif #endif
...@@ -478,20 +478,20 @@ int main(int argc, char *argv[]) ...@@ -478,20 +478,20 @@ int main(int argc, char *argv[])
global_gmainloop = g_main_loop_new(NULL, FALSE); global_gmainloop = g_main_loop_new(NULL, FALSE);
g_assert(global_gmainloop); g_assert(global_gmainloop);
root = su_glib_root_create(NULL); root = su_glib_root_create(NULL);
if (!root) perror("su_root_glib_create"), exit(1); if (!root) perror("su_root_glib_create"), exit(1);
if (!g_source_attach(su_glib_root_gsource(root), g_main_loop_get_context(global_gmainloop))) if (!g_source_attach(su_glib_root_gsource(root), g_main_loop_get_context(global_gmainloop)))
perror("g_source_attach"), exit(1); perror("g_source_attach"), exit(1);
su_root_threading(root, 0 && !opt_singlethread); su_root_threading(root, 0 && !opt_singlethread);
if (su_clone_start(root, ping, &pinger, do_init, do_destroy) != 0) if (su_clone_start(root, ping, &pinger, do_init, do_destroy) != 0)
perror("su_clone_start"), exit(1); perror("su_clone_start"), exit(1);
if (su_clone_start(root, pong, &ponger, do_init, do_destroy) != 0) if (su_clone_start(root, pong, &ponger, do_init, do_destroy) != 0)
perror("su_clone_start"), exit(1); perror("su_clone_start"), exit(1);
/* Test timer, exiting after 200 milliseconds */ /* Test timer, exiting after 200 milliseconds */
t = su_timer_create(su_root_task(root), 200L); t = su_timer_create(su_root_task(root), 200L);
...@@ -499,7 +499,7 @@ int main(int argc, char *argv[]) ...@@ -499,7 +499,7 @@ int main(int argc, char *argv[])
su_perror("su_timer_create"), exit(1); su_perror("su_timer_create"), exit(1);
su_timer_set(t, (su_timer_f)do_exit, NULL); su_timer_set(t, (su_timer_f)do_exit, NULL);
su_msg_create(start_msg, su_clone_task(ping), su_clone_task(pong), su_msg_create(start_msg, su_clone_task(ping), su_clone_task(pong),
init_ping, 0); init_ping, 0);
su_msg_send(start_msg); su_msg_send(start_msg);
...@@ -511,7 +511,7 @@ int main(int argc, char *argv[]) ...@@ -511,7 +511,7 @@ int main(int argc, char *argv[])
su_timer_destroy(t); su_timer_destroy(t);
if (pinger.rtt_n) { if (pinger.rtt_n) {
printf("%s executed %u pings in %g, mean rtt=%g sec\n", name, printf("%s executed %u pings in %g, mean rtt=%g sec\n", name,
pinger.rtt_n, pinger.rtt_total, pinger.rtt_total / pinger.rtt_n); pinger.rtt_n, pinger.rtt_total, pinger.rtt_total / pinger.rtt_n);
} }
su_root_destroy(root); su_root_destroy(root);
...@@ -519,7 +519,7 @@ int main(int argc, char *argv[]) ...@@ -519,7 +519,7 @@ int main(int argc, char *argv[])
g_main_loop_unref(global_gmainloop), global_gmainloop = NULL; g_main_loop_unref(global_gmainloop), global_gmainloop = NULL;
if (opt_verbatim) if (opt_verbatim)
printf("%s exiting\n", argv0); printf("%s exiting\n", argv0);
#ifndef HAVE_WIN32 #ifndef HAVE_WIN32
#if HAVE_SIGNAL #if HAVE_SIGNAL
...@@ -531,6 +531,6 @@ int main(int argc, char *argv[]) ...@@ -531,6 +531,6 @@ int main(int argc, char *argv[])
#if HAVE_OPEN_C #if HAVE_OPEN_C
sleep(7); sleep(7);
#endif #endif
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment