summaryrefslogtreecommitdiff
path: root/libproto/mailer/remote.c
blob: ae96ceedffcd6cd380728d6cbf90515bdd3a016b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/* GNU Mailutils -- a suite of utilities for electronic mail
   Copyright (C) 2009, 2010 Free Software Foundation, Inc.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 3 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General
   Public License along with this library.  If not,
   see <http://www.gnu.org/licenses/>. */

/* This file provides backward-compatible "remote+" mailbox types,
   introduced in v. 2.0.

   They are only used by maidag.

   This file will be removed in v. 2.2
*/

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <stdlib.h>
#include <string.h>

#include <mailutils/errno.h>
#include <mailutils/error.h>
#include <mailutils/diag.h>

#include <mailutils/sys/url.h>
#include <mailutils/sys/mailer.h>
#include <mailutils/sys/registrar.h>

#ifdef ENABLE_SMTP

static int
_url_remote_init (mu_url_t url, const char *new_scheme)
{
  char *scheme;
  mu_record_t record;
  int rc;
  
  mu_diag_output (MU_DIAG_WARNING,
		  "%s: this URL scheme is deprecated, use %s instead",
		  url->name, new_scheme);

  rc = mu_registrar_lookup_scheme (new_scheme, &record);
  if (rc)
    return rc;

  scheme = strdup (new_scheme);
  if (!scheme)
    return ENOMEM;
  
  free (url->scheme);
  url->scheme = scheme;
  
  return record->_url ? record->_url (url) : 0;
}


static int
_url_remote_smtp_init (mu_url_t url)
{
  return _url_remote_init (url, "smtp");
}

static struct _mu_record _mu_remote_smtp_record = {
  MU_SMTP_PRIO,
  "remote+smtp",
  MU_RECORD_DEFAULT,
  MU_URL_CRED | MU_URL_INET | MU_URL_PATH | MU_URL_PARAM,
  MU_URL_HOST,
  _url_remote_smtp_init,	/* url init.  */
  _mu_mailer_mailbox_init,      /* Mailbox init.  */
  NULL,		                /* Mailer init.  */
  _mu_mailer_folder_init,	/* Folder init.  */
  NULL,				/* No need for a back pointer.  */
  NULL,				/* _is_scheme method.  */
  NULL,				/* _get_url method.  */
  NULL,				/* _get_mailbox method.  */
  NULL,				/* _get_mailer method.  */
  NULL				/* _get_folder method.  */
};

mu_record_t mu_remote_smtp_record = &_mu_remote_smtp_record;
#else
mu_record_t mu_remote_smtp_record = NULL;
#endif


#ifdef ENABLE_SENDMAIL
static int
_url_remote_sendmail_init (mu_url_t url)
{
  return _url_remote_init (url, "sendmail");
}

static struct _mu_record _mu_remote_sendmail_record =
{
  MU_SENDMAIL_PRIO,
  "remote+sendmail",
  MU_RECORD_DEFAULT,
  MU_URL_PATH,
  MU_URL_PATH,
  _url_remote_sendmail_init,    /* url init.  */
  _mu_mailer_mailbox_init,      /* Mailbox entry.  */
  _mu_mailer_sendmail_init, /* Mailer entry.  */
  _mu_mailer_folder_init, /* Folder entry.  */
  NULL, /* No need for a back pointer.  */
  NULL, /* _is_scheme method.  */
  NULL, /* _get_url method.  */
  NULL, /* _get_mailbox method.  */
  NULL, /* _get_mailer method.  */
  NULL  /* _get_folder method.  */
};


mu_record_t mu_remote_sendmail_record = &_mu_remote_sendmail_record;


static int
_url_remote_prog_init (mu_url_t url)
{
  return _url_remote_init (url, "prog");
}

static struct _mu_record _mu_remote_prog_record =
{
  MU_PROG_PRIO,
  "remote+prog",
  MU_RECORD_DEFAULT,
  MU_URL_CRED | MU_URL_PATH | MU_URL_QUERY,
  MU_URL_PATH,
  _url_remote_prog_init,    /* url init.  */
  _mu_mailer_mailbox_init,  /* Mailbox entry.  */
  _mu_mailer_prog_init, /* Mailer entry.  */
  _mu_mailer_folder_init, /* Folder entry.  */
  NULL, /* No need for a back pointer.  */
  NULL, /* _is_scheme method.  */
  NULL, /* _get_url method.  */
  NULL, /* _get_mailbox method.  */
  NULL, /* _get_mailer method.  */
  NULL  /* _get_folder method.  */
};

mu_record_t mu_remote_prog_record = &_mu_remote_prog_record;

#else
mu_record_t mu_remote_sendmail_record = NULL;
mu_record_t mu_remote_prog_record = NULL;
#endif

Return to:

Send suggestions and report system problems to the System administrator.