Back to index

courier  0.68.2
Classes | Defines | Functions | Variables
imaptoken.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  imaptoken
struct  imapflags
struct  imapkeywords

Defines

#define IT_ATOM   0
#define IT_NUMBER   1
#define IT_QUOTED_STRING   2
#define IT_LITERAL_STRING_START   3
#define IT_LPAREN   4
#define IT_RPAREN   5
#define IT_NIL   6
#define IT_ERROR   7
#define IT_EOL   8
#define IT_LBRACKET   9
#define IT_RBRACKET   10
#define READ()
#define IT_MAX_ATOM_SIZE   16384

Functions

struct imaptokennexttoken (void)
struct imaptokencurrenttoken (void)
struct imaptokennexttoken_nouc (void)
struct imaptokennexttoken_noparseliteral (void)
struct imaptokennexttoken_okbracket (void)
struct imaptokennexttoken_nouc_okbracket (void)
int ismsgset (struct imaptoken *)
int ismsgset_str (const char *)
void read_timeout (time_t)
void read_eol ()
void unread (int)
size_t doread (char *buf, size_t bufsiz)
void readfill ()
void read_string (char **, unsigned long *, unsigned long)
char * my_strdup (const char *s)
void smap_readline (char *buffer, size_t bufsize)

Variables

char * imap_readptr
size_t imap_readptrleft

Class Documentation

struct imaptoken

Definition at line 14 of file imaptoken.h.

Class Members
char * tokenbuf
size_t tokenbuf_size
unsigned long tokennum
short tokentype
struct imapflags

Definition at line 62 of file imaptoken.h.

Class Members
char answered
char deleted
char drafts
char flagged
char recent
char seen
struct imapkeywords

Definition at line 71 of file imaptoken.h.

Class Members
struct imapkeyword * first_keyword
struct imapkeyword * last_keyword

Define Documentation

#define IT_ATOM   0

Definition at line 21 of file imaptoken.h.

#define IT_EOL   8

Definition at line 29 of file imaptoken.h.

#define IT_ERROR   7

Definition at line 28 of file imaptoken.h.

#define IT_LBRACKET   9

Definition at line 30 of file imaptoken.h.

#define IT_LITERAL_STRING_START   3

Definition at line 24 of file imaptoken.h.

#define IT_LPAREN   4

Definition at line 25 of file imaptoken.h.

#define IT_MAX_ATOM_SIZE   16384

Definition at line 79 of file imaptoken.h.

#define IT_NIL   6

Definition at line 27 of file imaptoken.h.

#define IT_NUMBER   1

Definition at line 22 of file imaptoken.h.

#define IT_QUOTED_STRING   2

Definition at line 23 of file imaptoken.h.

#define IT_RBRACKET   10

Definition at line 31 of file imaptoken.h.

#define IT_RPAREN   5

Definition at line 26 of file imaptoken.h.

#define READ ( )
Value:
( imap_readptrleft ? \
       (--imap_readptrleft, (int)(unsigned char)*imap_readptr++): \
       (readfill(), --imap_readptrleft, (int)(unsigned char)*imap_readptr++))

Definition at line 54 of file imaptoken.h.


Function Documentation

struct imaptoken* currenttoken ( void  ) [read]

Definition at line 468 of file imaptoken.c.

{
       return (&curtoken);
}

Here is the caller graph for this function:

size_t doread ( char *  buf,
size_t  bufsiz 
)

Definition at line 114 of file imaptoken.c.

{
fd_set fds;
struct timeval       tv;
time_t t;
int n = 0;

       time(&t);
       if (t >= readtimeout)       disconnected_timeout();

       FD_ZERO(&fds);
       FD_SET(0, &fds);
       tv.tv_sec=readtimeout - t;
       tv.tv_usec=0;

       if (select(1, &fds, 0, 0, &tv) <= 0)
       {
              disconnected_timeout();
              return (0);
       }
       if (!FD_ISSET(0, &fds) || (n=read(0, buf, bufsiz)) <= 0)
       {
              if ( n > 0 )
                     bytes_received_count += n; /* count received bytes */
              disconnected();
              return (0);
       }
       if ( n > 0 )
              bytes_received_count += n; /* count received bytes */
       return (n);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ismsgset ( struct imaptoken )

Definition at line 518 of file imaptoken.c.

{

       if (tok->tokentype == IT_NUMBER)   return (1);
       if (tok->tokentype != IT_ATOM)            return (0);

       return ismsgset_str(tok->tokenbuf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ismsgset_str ( const char *  )

Definition at line 528 of file imaptoken.c.

{
       while (isdigit((int)(unsigned char)*p) || *p == '*')
       {
              if (*p == '0')       return (0);
              if (*p == '*')
                     ++p;
              else
                     do
                     {
                            ++p;
                     } while (isdigit((int)(unsigned char)*p));

              if (*p == ':')
              {
                     ++p;
                     if (!isdigit((int)(unsigned char)*p) &&
                            *p != '*')
                            return (0);
                     if (*p == '0')       return (0);
                     if (*p == '*')
                            ++p;
                     else
                            do
                            {
                                   ++p;
                            } while (isdigit((int)(unsigned char)*p));
              }
              if (*p != ',')       break;
              ++p;
       }
       if (*p)       return (0);
       return (1);
}

Here is the caller graph for this function:

char* my_strdup ( const char *  s)

Definition at line 510 of file imaptoken.c.

{
char   *q=strdup(s);

       if (!q)       write_error_exit("malloc");
       return (q);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct imaptoken* nexttoken ( void  ) [read]

Definition at line 430 of file imaptoken.c.

{
       return (readtoken(1));
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct imaptoken* nexttoken_noparseliteral ( void  ) [read]

Definition at line 473 of file imaptoken.c.

{
       return (do_readtoken(0));
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct imaptoken* nexttoken_nouc ( void  ) [read]

Definition at line 435 of file imaptoken.c.

{
       return (readtoken(0));
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct imaptoken* nexttoken_nouc_okbracket ( void  ) [read]

Definition at line 455 of file imaptoken.c.

{
       struct imaptoken *t;

       LBRACKET_CHAR=RBRACKET_CHAR='\n';

       t=nexttoken_nouc();

       LBRACKET_CHAR='[';
       RBRACKET_CHAR=']';
       return (t);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct imaptoken* nexttoken_okbracket ( void  ) [read]

Definition at line 442 of file imaptoken.c.

{
       struct imaptoken *t;

       LBRACKET_CHAR=RBRACKET_CHAR='\n';

       t=nexttoken();

       LBRACKET_CHAR='[';
       RBRACKET_CHAR=']';
       return (t);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void read_eol ( )

Definition at line 159 of file imaptoken.c.

{
int    c;

       while ( (c=READ()) != '\n')
              ;
       curtoken.tokentype=IT_EOL;
}

Here is the caller graph for this function:

void read_string ( char **  ,
unsigned long *  ,
unsigned  long 
)

Definition at line 480 of file imaptoken.c.

{
       if (imap_readptrleft == 0)
       {
              /* Keep reading until we fill the buffer or until we've
              ** read the entire string.
              */

              read_timeout(SOCKET_TIMEOUT);
              imap_readptr=readbuf;
              while (imap_readptrleft < sizeof(readbuf) && imap_readptrleft < cnt)
                     imap_readptrleft += doread(readbuf+imap_readptrleft,
                                          sizeof(readbuf)-imap_readptrleft);
       }

       if (cnt < imap_readptrleft) /* Can satisfy fully from buffer */
       {
              *ptr=imap_readptr;
              *left=cnt;
              imap_readptr += cnt;
              imap_readptrleft -= cnt;
              return;
       }

       *ptr=imap_readptr;
       *left=imap_readptrleft;
       imap_readptrleft=0;
       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void read_timeout ( time_t  )

Definition at line 168 of file imaptoken.c.

{
time_t tt;

       time(&tt);
       readtimeout=tt+t;
}

Here is the caller graph for this function:

void readfill ( )

Definition at line 146 of file imaptoken.c.

Here is the call graph for this function:

void smap_readline ( char *  buffer,
size_t  bufsize 
)

Here is the caller graph for this function:

void unread ( int  )

Definition at line 154 of file imaptoken.c.

{
       UNREAD(c);
}

Here is the caller graph for this function:


Variable Documentation

char* imap_readptr

Definition at line 31 of file imaptoken.c.

Definition at line 32 of file imaptoken.c.