Commit 39429508 39429508b7e28756e6f3d9f3030eaa87c7333bd3 by Alain Magloire

mbx_mbox.c mbx_unix.c

.
1 parent ff8d17bd
......@@ -24,6 +24,7 @@
#include <mbx_mbox.h>
#include <mbx_unix.h>
#include <mbx_mdir.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
......@@ -52,12 +53,18 @@ int
mailbox_mbox_init (mailbox_t *mbox, const char *name)
{
struct stat st;
char *scheme = strstr (name, "://");
if (scheme)
{
scheme += 3;
name = scheme;
}
/*
If they want to creat ?? should they know the type ???
What is the best course of action ??
*/
if (stat (name, &st) == -1)
if (stat (name, &st) < 0)
{
return errno; /* errno set by stat () */
}
......@@ -117,8 +124,7 @@ mailbox_mbox_init (mailbox_t *mbox, const char *name)
}
/* Why can't a mailbox be FIFO ? or a DOOR/Portal ? */
errno = EINVAL;
return -1;
return EINVAL;
}
void
......
......@@ -226,12 +226,18 @@ mailbox_unix_init (mailbox_t *pmbox, const char *name)
mailbox_unix_data_t mud;
char *sep;
/* sanity check */
if (name == NULL || *name == '\0')
{
return EINVAL;
}
/* pass the url */
sep = strstr (name, "unix://");
if (sep)
name += 7;
/* allocate memory for mbox */
mbox = calloc (1, sizeof (*mbox));
if (mbox == NULL)
......