#pragma once
#include "ssl.hpp"
class IMAP {
private:
SSLConn* const ssl;
char buf[4096];
size_t bufoff, buflen;
ssize_t pop_line();
typedef bool (*line_cb_t)(const char*, size_t, void*);
static bool result_callback(const char* b, size_t l, void* ctx);
static bool response_callback(const char* b, size_t l, void* ctx);
static bool response_print_callback(const char* b, size_t l, void* ctx);
bool send_cmd(line_cb_t, void*, line_cb_t, void*, const char* fmt, ...);
public:
IMAP(SSLConn* s);
~IMAP();
bool init(bool, const char*, const char*);
bool handle(bool, const char*, const char*, const char*);
static bool is_quotable(const char*); // properly quotable 7bit string?
static bool is_quotable(const char*, size_t);
static char* do_quote(const char*, size_t);
static bool check_match(const char*&, unsigned& num, int=0); // verifies SEARCH syntax
};