summaryrefslogtreecommitdiff
path: root/src/transport/gnunet-transport-wlan-receiver.c
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-09-06 23:01:06 +0000
committerng0 <ng0@n0.is>2019-09-06 23:01:06 +0000
commitd0051cb6683c712cce3473d6b667208e4f61b75a (patch)
tree99f642c0e8f8c888a2bb3daa5280325dd8707d6d /src/transport/gnunet-transport-wlan-receiver.c
parent6e599264ad13e8fc105493d74d7c11d46f8739ed (diff)
plibc, commit 2
Diffstat (limited to 'src/transport/gnunet-transport-wlan-receiver.c')
-rw-r--r--src/transport/gnunet-transport-wlan-receiver.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/src/transport/gnunet-transport-wlan-receiver.c b/src/transport/gnunet-transport-wlan-receiver.c
index 04f30a683..9b31377e7 100644
--- a/src/transport/gnunet-transport-wlan-receiver.c
+++ b/src/transport/gnunet-transport-wlan-receiver.c
@@ -37,7 +37,7 @@ main (int argc, char *argv[])
time_t akt;
ssize_t ret;
pid_t pid;
- int commpipe[2]; /* This holds the fd for the input & output of the pipe */
+ int commpipe[2]; /* This holds the fd for the input & output of the pipe */
if (2 != argc)
{
@@ -46,34 +46,30 @@ main (int argc, char *argv[])
fprintf (stderr,
"Usage: %s interface-name\n"
"e.g. %s mon0\n",
- argv[0], argv[0]);
+ argv[0],
+ argv[0]);
return 1;
}
/* Setup communication pipeline first */
if (pipe (commpipe))
{
- fprintf (stderr,
- "Failed to create pipe: %s\n",
- STRERROR (errno));
+ fprintf (stderr, "Failed to create pipe: %s\n", strerror (errno));
exit (1);
}
/* Attempt to fork and check for errors */
if ((pid = fork ()) == -1)
{
- fprintf (stderr, "Failed to fork: %s\n",
- STRERROR (errno));
+ fprintf (stderr, "Failed to fork: %s\n", strerror (errno));
exit (1);
}
if (pid)
{
/* A positive (non-negative) PID indicates the parent process */
- if (0 != close (commpipe[1])) /* Close unused side of pipe (in side) */
- fprintf (stderr,
- "Failed to close fd: %s\n",
- strerror (errno));
+ if (0 != close (commpipe[1])) /* Close unused side of pipe (in side) */
+ fprintf (stderr, "Failed to close fd: %s\n", strerror (errno));
start = time (NULL);
count = 0;
while (1)
@@ -81,18 +77,18 @@ main (int argc, char *argv[])
ret = read (commpipe[0], msg_buf, sizeof (msg_buf));
if (0 > ret)
{
- fprintf (stderr, "read failed: %s\n", strerror (errno));
- break;
+ fprintf (stderr, "read failed: %s\n", strerror (errno));
+ break;
}
count += ret;
akt = time (NULL);
if (akt - start > 30)
{
- bytes_per_s = count / (akt - start);
- bytes_per_s /= 1024;
- printf ("recv %f kb/s\n", bytes_per_s);
- start = akt;
- count = 0;
+ bytes_per_s = count / (akt - start);
+ bytes_per_s /= 1024;
+ printf ("recv %f kb/s\n", bytes_per_s);
+ start = akt;
+ count = 0;
}
}
}
@@ -100,13 +96,15 @@ main (int argc, char *argv[])
{
/* A zero PID indicates that this is the child process */
(void) close (1);
- if (-1 == dup2 (commpipe[1], 1)) /* Replace stdin with the in side of the pipe */
+ if (-1 ==
+ dup2 (commpipe[1], 1)) /* Replace stdin with the in side of the pipe */
fprintf (stderr, "dup2 failed: %s\n", strerror (errno));
(void) close (commpipe[0]); /* Close unused side of pipe (in side) */
/* Replace the child fork with a new process */
- if (execlp
- ("gnunet-helper-transport-wlan", "gnunet-helper-transport-wlan",
- argv[1], NULL) == -1)
+ if (execlp ("gnunet-helper-transport-wlan",
+ "gnunet-helper-transport-wlan",
+ argv[1],
+ NULL) == -1)
{
fprintf (stderr, "Could not start gnunet-helper-transport-wlan!");
_exit (1);