* @param client unused
* @param hdr inbound message from the FIFO
*/
-static void
+static int
stdin_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
{
struct SendBuffer *write_pout = cls;
if ( (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) ||
(sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) > sendsize) )
{
- fprintf (stderr, "Received malformed message\n");
+ FPRINTF (stderr, "%s", "Received malformed message\n");
exit (1);
}
payload_size = sendsize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage);
&in[1],
payload_size);
write_pout->size += payload_size;
+ return GNUNET_OK;
}
* @param client unused
* @param hdr the message we received to copy to the buffer
*/
-static void
+static int
file_in_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
{
struct SendBuffer *write_std = cls;
}
memcpy (write_std->buf + write_std->size, hdr, sendsize);
write_std->size += sendsize;
+ return GNUNET_OK;
}
}
/* make the fifos if needed */
- if (0 != stat (FIFO_FILE1, &st))
+ umask (0);
+ if ( (GNUNET_OK != GNUNET_DISK_directory_create_for_file (FIFO_FILE1)) ||
+ (GNUNET_OK != GNUNET_DISK_directory_create_for_file (FIFO_FILE2)) )
{
- if (0 == stat (FIFO_FILE2, &st))
- {
- FPRINTF (stderr, "%s", "FIFO_FILE2 exists, but FIFO_FILE1 not\n");
- exit (1);
- }
- umask (0);
- erg = mkfifo (FIFO_FILE1, 0666);
- if (0 != erg)
- {
- FPRINTF (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE1,
- strerror (errno));
- }
- erg = mkfifo (FIFO_FILE2, 0666);
- if (0 != erg)
+ FPRINTF (stderr, "Failed to create directory for file `%s'\n", FIFO_FILE1);
+ return 1;
+ }
+ if (0 == strcmp (argv[1], "1") )
+ {
+ if (0 != stat (FIFO_FILE1, &st))
{
- FPRINTF (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE2,
- strerror (errno));
+ erg = mkfifo (FIFO_FILE1, 0666);
+ if ( (0 != erg) && (EEXIST != errno) )
+ FPRINTF (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE1,
+ strerror (errno));
}
}
else
{
if (0 != stat (FIFO_FILE2, &st))
{
- FPRINTF (stderr, "%s", "FIFO_FILE1 exists, but FIFO_FILE2 not\n");
- exit (1);
+ erg = mkfifo (FIFO_FILE2, 0666);
+ if ( (0 != erg) && (EEXIST != errno) )
+ FPRINTF (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE2,
+ strerror (errno));
}
}
- if (0 != strcmp (argv[1], "1"))
+ if (0 == strcmp (argv[1], "1"))
{
first = 1;
fpin = fopen (FIFO_FILE1, "r");
FPRINTF (stderr, "fopen of read FIFO_FILE1 failed: %s\n", STRERROR (errno));
goto end;
}
- fpout = fopen (FIFO_FILE2, "w");
+ if (NULL == (fpout = fopen (FIFO_FILE2, "w")))
+ {
+ mkfifo (FIFO_FILE2, 0666);
+ fpout = fopen (FIFO_FILE2, "w");
+ }
if (NULL == fpout)
{
FPRINTF (stderr, "fopen of write FIFO_FILE2 failed: %s\n", STRERROR (errno));
else
{
first = 0;
- fpout = fopen (FIFO_FILE1, "w");
+ if (NULL == (fpout = fopen (FIFO_FILE1, "w")))
+ {
+ mkfifo (FIFO_FILE1, 0666);
+ fpout = fopen (FIFO_FILE1, "w");
+ }
if (NULL == fpout)
{
FPRINTF (stderr, "fopen of write FIFO_FILE1 failed: %s\n", STRERROR (errno));