Commit dc8e91fa dc8e91faa0d27e59e4c913f08ebaeb2cec70864d by Wojciech Polak

(_url_imap_init, _url_imaps_init): Call mu_url_init.

1 parent e25a55cd
...@@ -41,35 +41,55 @@ url_imap_destroy (mu_url_t url MU_ARG_UNUSED) ...@@ -41,35 +41,55 @@ url_imap_destroy (mu_url_t url MU_ARG_UNUSED)
41 } 41 }
42 42
43 /* 43 /*
44 IMAP URL: 44 IMAP URLs:
45 imap://[<user>[;AUTH=<auth>]@]<host>[/<mailbox>] 45 imap://[<user>[;AUTH=<auth>]@]<host>[/<mailbox>]
46 else
47 imap://[<user>[:<pass>]@]<host>[/<mailbox>] 46 imap://[<user>[:<pass>]@]<host>[/<mailbox>]
48 */ 47 */
49 48
50 int 49 int
51 _url_imap_init (mu_url_t url) 50 _url_imap_init (mu_url_t url)
52 { 51 {
53 int status = 0; 52 int status = mu_url_init (url, MU_IMAP_PORT, "imap");
53 if (status)
54 return status;
54 55
55 url->_destroy = url_imap_destroy; 56 url->_destroy = url_imap_destroy;
56 57
57 status = mu_url_parse (url); 58 if(!url->host || url->query)
59 return EINVAL;
60
61 /* fill in default auth, if necessary */
62 if (!url->auth)
63 {
64 url->auth = malloc (1 + 1);
65 if (!url->auth)
66 return ENOMEM;
67
68 url->auth[0] = '*';
69 url->auth[1] = '\0';
70 }
58 71
72 return 0;
73 }
74
75 /*
76 IMAPS URLs:
77 imaps://[<user>[;AUTH=<auth>]@]<host>[/<mailbox>]
78 imaps://[<user>[:<pass>]@]<host>[/<mailbox>]
79 */
80
81 int
82 _url_imaps_init (mu_url_t url)
83 {
84 int status = mu_url_init (url, MU_IMAPS_PORT, "imaps");
59 if (status) 85 if (status)
60 return status; 86 return status;
61 87
62 if(!url->host || url->query) 88 url->_destroy = url_imap_destroy;
63 return EINVAL;
64 89
65 /* is it pop? */ 90 if(!url->host || url->query)
66 if (strcmp ("imap", url->scheme) != 0)
67 return EINVAL; 91 return EINVAL;
68 92
69 /* fill in default port, if necesary */
70 if (url->port == 0)
71 url->port = MU_IMAP_PORT;
72
73 /* fill in default auth, if necessary */ 93 /* fill in default auth, if necessary */
74 if (!url->auth) 94 if (!url->auth)
75 { 95 {
...@@ -81,7 +101,7 @@ _url_imap_init (mu_url_t url) ...@@ -81,7 +101,7 @@ _url_imap_init (mu_url_t url)
81 url->auth[1] = '\0'; 101 url->auth[1] = '\0';
82 } 102 }
83 103
84 return status; 104 return 0;
85 } 105 }
86 106
87 #endif 107 #endif /* ENABLE_IMAP */
......