/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "strfuncs.h"
#include "str.h"
#include "array.h"
#include "net.h"
#include "istream.h"
#include "istream-sized.h"
#include "ostream.h"
#include "imap-url.h"
#include "imap-quote.h"
#include "imap-common.h"
#include "imap-commands.h"
#include "imap-urlauth.h"
#include "imap-urlauth-fetch.h"
struct cmd_urlfetch_context {
};
struct cmd_urlfetch_url {
const char *url;
};
{
return;
/* failed in the middle of a literal.
we need to disconnect. */
} else {
}
return;
}
}
{
return FALSE;
i_debug("URLFETCH: Canceling command; "
"aborting URLAUTH fetch requests prematurely");
}
}
return TRUE;
}
{
int ret;
/* are we in the middle of an urlfetch literal? */
return 1;
/* flush output to client if buffer is filled above optimum */
return ret;
}
/* transfer literal to client */
switch (res) {
return 1;
i_unreached();
return 0;
i_error("read(%s) failed: %s (URLFETCH)",
return -1;
/* client disconnected */
return -1;
}
i_unreached();
}
{
bool urls_pending;
return cmd_urlfetch_cancel(cmd);
/* finish a pending literal transfer */
if (ret < 0) {
return TRUE;
}
if (ret == 0) {
/* not finished; apparently output blocked again */
return FALSE;
}
else
if (urls_pending) {
/* waiting for imap urlauth service */
/* retrieve next url */
return FALSE;
}
/* finished */
return TRUE;
}
struct imap_urlauth_fetch_reply *reply)
{
int ret;
/* simple */
} else {
/* extended */
}
if (metadata)
} else {
if (reply->binary_has_nuls)
}
} else {
}
}
if (ret < 0) {
return -1;
}
if (ret == 0) {
/* not finished; apparently output blocked */
return 0;
}
else
}
return 1;
}
static int
{
int ret;
if (!in_io_handler)
/* fatal failure */
ret = -1;
/* URL fetch succeeded */
} else {
/* URL fetch failed */
}
ret = 1;
}
ret < 0) {
}
if (!in_io_handler)
return ret;
}
static int
struct cmd_urlfetch_url *ufurl_r)
{
const char *url_text;
else
/* read url */
return -1;
}
if (url_flags == 0)
return 0;
while (!IMAP_ARG_IS_EOL(params)) {
const char *fetch_param;
"Invalid URL fetch parameter.");
return -1;
}
else {
t_strdup_printf("Unknown URL fetch parameter: %s",
fetch_param));
return -1;
}
}
if ((url_flags & IMAP_URLAUTH_FETCH_FLAG_BODY) != 0 &&
(url_flags & IMAP_URLAUTH_FETCH_FLAG_BINARY) != 0) {
"URL cannot have both BODY and BINARY fetch parameters.");
return -1;
}
return 0;
}
{
return TRUE;
}
return FALSE;
if (IMAP_ARG_IS_EOL(args)) {
return TRUE;
}
/* parse url arguments and group them per userid */
return TRUE;
}
/* fatal error */
break;
}
}
/* finished */
return TRUE;
}
return FALSE;
}