citadel
About: Citadel is an advanced messaging and collaboration system for groupware and BBS applications (preferred OS: Linux).
  Fossies Dox: citadel.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

imap_tools.c File Reference
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdarg.h>
#include <libcitadel.h>
#include "citadel.h"
#include "sysdep_decls.h"
#include "internet_addressing.h"
#include "serv_imap.h"
#include "imap_tools.h"
#include "ctdl_module.h"
Include dependency graph for imap_tools.c:

Go to the source code of this file.

Data Structures

struct  string
 

Macros

#define SHOW_ME_VAPPEND_PRINTF
 
#define string_append_s(s, p)   string_append_sn((s), (p), -1)
 
#define WILDMAT_TRUE   1
 
#define WILDMAT_FALSE   0
 
#define WILDMAT_ABORT   -1
 
#define WILDMAT_DELIM   '/'
 

Functions

static void string_init (struct string *s, char *buf, int bufsize)
 
static char * string_end (struct string *s)
 
static void string_append_sn (struct string *s, char *p, int len)
 
static void string_append_c (struct string *s, int c)
 
int utf8_getc (char **ptr)
 
static void utf7_closeb64 (struct string *out, int v, int i)
 
static char * toimap (char *destp, char *destend, char *src)
 
static int cfrommap (int c)
 
static char * fromimap (char *destp, char *destend, const char *src)
 
void MakeStringOf (StrBuf *Buf, int skip)
 
void TokenCutRight (citimap_command *Cmd, ConstStr *CutMe, int n)
 
void TokenCutLeft (citimap_command *Cmd, ConstStr *CutMe, int n)
 
int CmdAdjust (citimap_command *Cmd, int nArgs, int Realloc)
 
int imap_parameterize (citimap_command *Cmd)
 
long imap_mailboxname (char *buf, int bufsize, struct ctdlroom *qrbuf)
 
int imap_roomname (char *rbuf, int bufsize, const char *foldername)
 
int imap_is_message_set (const char *buf)
 
static int do_imap_match (const char *supplied_text, const char *supplied_p)
 
int imap_mailbox_matches_pattern (const char *pattern, char *mailboxname)
 
int imap_datecmp (const char *datestr, time_t msgtime)
 
void IAPrintf (const char *Format,...)
 
void iaputs (const char *Str, long Len)
 
void ireply (const char *Msg, long len)
 
void IReplyPrintf (const char *Format,...)
 
void IPutStr (const char *Msg, long Len)
 
void IUnbuffer (void)
 

Variables

static char * utf7_alphabet
 
static unsigned char utf7_rank [256]
 

Macro Definition Documentation

◆ SHOW_ME_VAPPEND_PRINTF

#define SHOW_ME_VAPPEND_PRINTF

Definition at line 22 of file imap_tools.c.

◆ string_append_s

#define string_append_s (   s,
 
)    string_append_sn((s), (p), -1)

Definition at line 76 of file imap_tools.c.

◆ WILDMAT_ABORT

#define WILDMAT_ABORT   -1

Definition at line 724 of file imap_tools.c.

◆ WILDMAT_DELIM

#define WILDMAT_DELIM   '/'

Definition at line 725 of file imap_tools.c.

◆ WILDMAT_FALSE

#define WILDMAT_FALSE   0

Definition at line 723 of file imap_tools.c.

◆ WILDMAT_TRUE

#define WILDMAT_TRUE   1

Definition at line 722 of file imap_tools.c.

Function Documentation

◆ cfrommap()

static int cfrommap ( int  c)
static

Definition at line 371 of file imap_tools.c.

Referenced by fromimap().

◆ CmdAdjust()

int CmdAdjust ( citimap_command Cmd,
int  nArgs,
int  Realloc 
)

◆ do_imap_match()

static int do_imap_match ( const char *  supplied_text,
const char *  supplied_p 
)
static

◆ fromimap()

static char * fromimap ( char *  destp,
char *  destend,
const char *  src 
)
static

Definition at line 297 of file imap_tools.c.

References cfrommap(), string_append_c(), string_append_sn(), string_end(), string_init(), and utf7_rank.

Referenced by imap_roomname().

◆ IAPrintf()

◆ iaputs()

void iaputs ( const char *  Str,
long  Len 
)

Definition at line 908 of file imap_tools.c.

References IMAP.

Referenced by imap_fetch_body(), imap_fetch_rfc822(), and imap_getacl().

◆ imap_datecmp()

int imap_datecmp ( const char *  datestr,
time_t  msgtime 
)

Definition at line 848 of file imap_tools.c.

Referenced by imap_do_search_msg().

◆ imap_is_message_set()

int imap_is_message_set ( const char *  buf)

Definition at line 690 of file imap_tools.c.

Referenced by imap_copy(), imap_do_search_msg(), imap_store(), imap_uidcopy(), and imap_uidstore().

◆ imap_mailbox_matches_pattern()

int imap_mailbox_matches_pattern ( const char *  pattern,
char *  mailboxname 
)

Definition at line 833 of file imap_tools.c.

References do_imap_match(), and WILDMAT_TRUE.

Referenced by imap_list_floors(), and imap_listroom().

◆ imap_mailboxname()

long imap_mailboxname ( char *  buf,
int  bufsize,
struct ctdlroom qrbuf 
)

◆ imap_parameterize()

◆ imap_roomname()

int imap_roomname ( char *  rbuf,
int  bufsize,
const char *  foldername 
)

◆ IPutStr()

◆ ireply()

void ireply ( const char *  Msg,
long  len 
)

Definition at line 914 of file imap_tools.c.

References __citimap::Cmd, IMAP, __citimap_command::Params, and __citimap::Reply.

◆ IReplyPrintf()

void IReplyPrintf ( const char *  Format,
  ... 
)

◆ IUnbuffer()

void IUnbuffer ( void  )

Definition at line 986 of file imap_tools.c.

References cputbuf(), IMAP, and __citimap::Reply.

Referenced by imap_append(), imap_command_loop(), and imap_greeting().

◆ MakeStringOf()

void MakeStringOf ( StrBuf *  Buf,
int  skip 
)

◆ string_append_c()

static void string_append_c ( struct string s,
int  c 
)
static

Definition at line 81 of file imap_tools.c.

References string::buffer, string::maxsize, string::size, and string_append_sn().

Referenced by fromimap(), toimap(), and utf7_closeb64().

◆ string_append_sn()

static void string_append_sn ( struct string s,
char *  p,
int  len 
)
static

Definition at line 63 of file imap_tools.c.

References string::buffer, string::maxsize, and string::size.

Referenced by fromimap(), string_append_c(), and toimap().

◆ string_end()

static char * string_end ( struct string s)
static

Definition at line 56 of file imap_tools.c.

References string::buffer, and string::size.

Referenced by fromimap(), and toimap().

◆ string_init()

static void string_init ( struct string s,
char *  buf,
int  bufsize 
)
static

Definition at line 49 of file imap_tools.c.

References string::buffer, string::maxsize, and string::size.

Referenced by fromimap(), and toimap().

◆ toimap()

static char * toimap ( char *  destp,
char *  destend,
char *  src 
)
static

◆ TokenCutLeft()

void TokenCutLeft ( citimap_command Cmd,
ConstStr *  CutMe,
int  n 
)

Definition at line 412 of file imap_tools.c.

Referenced by imap_do_search(), and imap_list().

◆ TokenCutRight()

void TokenCutRight ( citimap_command Cmd,
ConstStr *  CutMe,
int  n 
)

Definition at line 395 of file imap_tools.c.

References __citimap_command::CmdBuf.

Referenced by imap_do_search(), and imap_list().

◆ utf7_closeb64()

static void utf7_closeb64 ( struct string out,
int  v,
int  i 
)
static

Definition at line 200 of file imap_tools.c.

References string_append_c(), and utf7_alphabet.

Referenced by toimap().

◆ utf8_getc()

int utf8_getc ( char **  ptr)

Definition at line 126 of file imap_tools.c.

Referenced by toimap().

Variable Documentation

◆ utf7_alphabet

char* utf7_alphabet
static
Initial value:
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"

Definition at line 176 of file imap_tools.c.

Referenced by toimap(), and utf7_closeb64().

◆ utf7_rank

unsigned char utf7_rank[256]
static
Initial value:
= {
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3E,0x3F,0xFF,0xFF,0xFF,
0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,
0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,
0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,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