Commit 39429508 39429508b7e28756e6f3d9f3030eaa87c7333bd3 by Alain Magloire

mbx_mbox.c mbx_unix.c

.
1 parent ff8d17bd
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
24 #include <mbx_mbox.h> 24 #include <mbx_mbox.h>
25 #include <mbx_unix.h> 25 #include <mbx_unix.h>
26 #include <mbx_mdir.h> 26 #include <mbx_mdir.h>
27 #include <string.h>
27 28
28 #include <errno.h> 29 #include <errno.h>
29 #include <sys/stat.h> 30 #include <sys/stat.h>
...@@ -52,12 +53,18 @@ int ...@@ -52,12 +53,18 @@ int
52 mailbox_mbox_init (mailbox_t *mbox, const char *name) 53 mailbox_mbox_init (mailbox_t *mbox, const char *name)
53 { 54 {
54 struct stat st; 55 struct stat st;
56 char *scheme = strstr (name, "://");
55 57
58 if (scheme)
59 {
60 scheme += 3;
61 name = scheme;
62 }
56 /* 63 /*
57 If they want to creat ?? should they know the type ??? 64 If they want to creat ?? should they know the type ???
58 What is the best course of action ?? 65 What is the best course of action ??
59 */ 66 */
60 if (stat (name, &st) == -1) 67 if (stat (name, &st) < 0)
61 { 68 {
62 return errno; /* errno set by stat () */ 69 return errno; /* errno set by stat () */
63 } 70 }
...@@ -117,8 +124,7 @@ mailbox_mbox_init (mailbox_t *mbox, const char *name) ...@@ -117,8 +124,7 @@ mailbox_mbox_init (mailbox_t *mbox, const char *name)
117 } 124 }
118 125
119 /* Why can't a mailbox be FIFO ? or a DOOR/Portal ? */ 126 /* Why can't a mailbox be FIFO ? or a DOOR/Portal ? */
120 errno = EINVAL; 127 return EINVAL;
121 return -1;
122 } 128 }
123 129
124 void 130 void
......
...@@ -226,12 +226,18 @@ mailbox_unix_init (mailbox_t *pmbox, const char *name) ...@@ -226,12 +226,18 @@ mailbox_unix_init (mailbox_t *pmbox, const char *name)
226 mailbox_unix_data_t mud; 226 mailbox_unix_data_t mud;
227 char *sep; 227 char *sep;
228 228
229
229 /* sanity check */ 230 /* sanity check */
230 if (name == NULL || *name == '\0') 231 if (name == NULL || *name == '\0')
231 { 232 {
232 return EINVAL; 233 return EINVAL;
233 } 234 }
234 235
236 /* pass the url */
237 sep = strstr (name, "unix://");
238 if (sep)
239 name += 7;
240
235 /* allocate memory for mbox */ 241 /* allocate memory for mbox */
236 mbox = calloc (1, sizeof (*mbox)); 242 mbox = calloc (1, sizeof (*mbox));
237 if (mbox == NULL) 243 if (mbox == NULL)
......