/********************************************************************************************************************************/
/* Created:  9-NOV-2005 11:12:54 by OpenVMS SDL EV1-66     */
/* Source:   9-NOV-2005 11:12:49 ISK$SYSMAN:[LAISHEV.WORK.POP3]SPOP3DEF.SDL;74   */
/********************************************************************************************************************************/
/*** MODULE SPOP3DEF IDENT SPOP3DEF-1-X ***/
#ifndef __SPOP3DEF_LOADED
#define __SPOP3DEF_LOADED 1
 
#pragma __nostandard			 /* This file uses non-ANSI-Standard features */
#pragma __member_alignment __save
#pragma __nomember_alignment
#ifdef __INITIAL_POINTER_SIZE			 /* Defined whenever ptr size pragmas supported */
#pragma __required_pointer_size __save		 /* Save the previously-defined required ptr size */
#pragma __required_pointer_size __short		 /* And set ptr size default to 32-bit pointers */
#endif
 
#ifdef __cplusplus
    extern "C" {
#define __unknown_params ...
#define __optional_params ...
#else
#define __unknown_params
#define __optional_params ...
#endif
 
#ifndef __struct
#if !defined(__VAXC)
#define __struct struct
#else
#define __struct variant_struct
#endif
#endif
 
#ifndef __union
#if !defined(__VAXC)
#define __union union
#else
#define __union variant_union
#endif
#endif
 
/*++                                                                        */
/* Facility:                                                                */
/*   StarLet POP3 Server                                                    */
/*                                                                          */
/* Abstract:                                                                */
/*   An interface module defined  POP3 primitives, constants, this story is based on */
/*	RFC1939 (ftp://ftp.rfc-editor.org/in-notes/rfc1939.txt)             */
/*	                                                                    */
/*                                                                          */
/* Author:                                                                  */
/*   Ruslan R. Laishev                                                      */
/*                                                                          */
/* Creation Date: 23-MAR-2005                                               */
/*                                                                          */
/* Modification History:                                                    */
/*                                                                          */
/*	 1-SEP-2005	Added lkid field into the pop3ctx structure.        */
/*	 9-NOV-2005	Added sent flag to the message context structure.   */
/*                                                                          */
/*--                                                                        */
/*                                                                          */
/* Include RMS definitions                                                  */
/*                                                                          */
#define POP3__$K_PORT 110
#define SPOP3__$K_LINESZ 78
#define POP3__$K_EXPIRE 0
#define POP3__$K_LOGINTVL 180
#define SPOP3__$K_TIMEOUT 90
/*                                                                          */
/**++                                                                       */
/**                                                                         */
/**	POP3 Server-Clients command constants                               */
/**                                                                         */
/**--                                                                       */
/*                                                                          */
#define POP3CMD$K_QUIT 1                /* QUIT Command                     */
#define POP3CMD$K_STAT 2                /* STAT Command                     */
#define POP3CMD$K__LIST 3               /* LIST [msg] Command               */
#define POP3CMD$K_RETR 4                /* RETR msg Command                 */
#define POP3CMD$K_DELE 5                /* DELE msg Command                 */
#define POP3CMD$K_NOOP 6                /* NOOP Command                     */
#define POP3CMD$K_RSET 7                /* RSET Command                     */
#define POP3CMD$K_TOP 8                 /* TOP msg n Command                */
#define POP3CMD$K_UIDL 9                /* UIDL [msg] Command               */
#define POP3CMD$K_USER 10               /* USER name Command                */
#define POP3CMD$K_PASS 11               /* PASS pass Command                */
#define POP3CMD$K_SHUTDOWN 12           /* SHUTDOWN management command      */
#define POP3CMD$K_RESTART 13            /* RESTART management command       */
#define POP3CMD$K_STATUS 14             /* STATUS management command        */
#define POP3LVL$K_INITIAL 0
#define POP3LVL$K_LOGGED 1
/*                                                                          */
/**++                                                                       */
/**                                                                         */
/**	 Workers/threads context data structure                             */
/**                                                                         */
/**--                                                                       */
/*                                                                          */
#define POP3CTX$M_DEBUG 0x1
#define POP3CTX$M_TERMD 0x2
#define POP3CTX$M_USED 0x4
	
 
#ifdef __cplusplus		    /* Define structure prototypes */
struct _mhdr;
#endif		/* #ifdef __cplusplus */
 
#ifdef __NEW_STARLET
typedef struct _pop3ctx {               /* Session context structure        */
    void *pop3ctx$a_flink;
    void *pop3ctx$a_blink;
    unsigned int pop3ctx$l_dummy [4];
    unsigned __int64 pop3ctx$q_tid;     /* Thread ID, pthread_t             */
    unsigned __int64 pop3ctx$q_tid_;
    unsigned char pop3ctx$b_idx;        /* Thread index                     */
    unsigned int pop3ctx$l_chan;        /* Network I/O channel              */
    unsigned char pop3ctx$b_ulen;
    char pop3ctx$t_uname [12];
    unsigned char pop3ctx$b_alen;
    char pop3ctx$t_addr [15];
    unsigned int pop3ctx$l_level;       /* Session level, see POP3LVL*      */
    char pop3ctx$t_maildir [255];
    unsigned int pop3ctx$l_msgctx;      /* MAIL$_MESSAGE_FILE_CTX           */
    unsigned int pop3ctx$l_mfile;       /* MAIL.MAI file context            */
    struct _mhdr *pop3ctx$a_mlist;      /* Link to list of mail header      */
    unsigned int pop3ctx$l_mlistsz;     /* List count                       */
    struct _mhdr *pop3ctx$a_mlast;      /* Link to last accessed mail header */
    unsigned int pop3ctx$l_mdeltd;      /* Count of deleted messages        */
    unsigned int pop3ctx$l_mlines;      /* Total size of all mails in lines */
	FABDEF pop3ctx$r_mfab;       /* FAB structure                    */
	RABDEF pop3ctx$r_mrab;       /* RAB structure                    */
    __struct  {
        unsigned pop3ctx$v_debug : 1;   /* Session is under debug           */
        unsigned pop3ctx$v_termd : 1;   /* Session has been terminated      */
        unsigned pop3ctx$v_used : 1;    /* Context is in use                */
        unsigned pop3ctx$v_fill_0_ : 5;
        } pop3ctx$r_flags;
    unsigned int pop3ctx$l_expire;      /* A day to keep messages           */
    unsigned int pop3ctx$l_lkid;        /* A VMS Lock Id                    */
    } POP3CTX;
 
#if !defined(__VAXC)
#define pop3ctx$v_debug pop3ctx$r_flags.pop3ctx$v_debug
#define pop3ctx$v_termd pop3ctx$r_flags.pop3ctx$v_termd
#define pop3ctx$v_used pop3ctx$r_flags.pop3ctx$v_used
#endif		/* #if !defined(__VAXC) */
 
#else	    /* __OLD_STARLET */
struct pop3ctx {                        /* Session context structure        */
    void *pop3ctx$a_flink;
    void *pop3ctx$a_blink;
    unsigned int pop3ctx$l_dummy [4];
    unsigned int pop3ctx$q_tid [2];     /* Thread ID, pthread_t             */
    unsigned int pop3ctx$q_tid_ [2];
    unsigned char pop3ctx$b_idx;        /* Thread index                     */
    unsigned int pop3ctx$l_chan;        /* Network I/O channel              */
    unsigned char pop3ctx$b_ulen;
    char pop3ctx$t_uname [12];
    unsigned char pop3ctx$b_alen;
    char pop3ctx$t_addr [15];
    unsigned int pop3ctx$l_level;       /* Session level, see POP3LVL*      */
    char pop3ctx$t_maildir [255];
    unsigned int pop3ctx$l_msgctx;      /* MAIL$_MESSAGE_FILE_CTX           */
    unsigned int pop3ctx$l_mfile;       /* MAIL.MAI file context            */
    void *pop3ctx$a_mlist;              /* Link to list of mail header      */
    unsigned int pop3ctx$l_mlistsz;     /* List count                       */
    void *pop3ctx$a_mlast;              /* Link to last accessed mail header */
    unsigned int pop3ctx$l_mdeltd;      /* Count of deleted messages        */
    unsigned int pop3ctx$l_mlines;      /* Total size of all mails in lines */
    struct fabdef pop3ctx$r_mfab;       /* FAB structure                    */
    struct rabdef pop3ctx$r_mrab;       /* RAB structure                    */
    __struct  {
        unsigned pop3ctx$v_debug : 1;   /* Session is under debug           */
        unsigned pop3ctx$v_termd : 1;   /* Session has been terminated      */
        unsigned pop3ctx$v_used : 1;    /* Context is in use                */
        unsigned pop3ctx$v_fill_0_ : 5;
        } pop3ctx$r_flags;
    unsigned int pop3ctx$l_expire;      /* A day to keep messages           */
    unsigned int pop3ctx$l_lkid;        /* A VMS Lock Id                    */
    } ;
 
#if !defined(__VAXC)
#define pop3ctx$v_debug pop3ctx$r_flags.pop3ctx$v_debug
#define pop3ctx$v_termd pop3ctx$r_flags.pop3ctx$v_termd
#define pop3ctx$v_used pop3ctx$r_flags.pop3ctx$v_used
#endif		/* #if !defined(__VAXC) */
 
#endif	    /* #ifdef __NEW_STARLET */
/*                                                                          */
/**++                                                                       */
/**                                                                         */
/**      Mail list structure                                                */
/**                                                                         */
/**--                                                                       */
/*                                                                          */
#define MHDR$M_DECNET 0x1
#define MHDR$M_DELETED 0x2
#define MHDR$M_SENT 0x4
	
#ifdef __NEW_STARLET
typedef struct _mhdr {                  /* Mail header structure            */
    struct _mhdr *mhdr$a_next;          /* Link to next mail header structure */
    __union  {                          /* MAIL$_MESSAGE_BINARY_DATE        */
        unsigned int mhdr$l_date [2];
        unsigned __int64 mhdr$q_date;
        } mhdr$r_date;
    unsigned int mhdr$l_messid;         /* MAIL$_MESSAGE_ID                 */
    unsigned char mhdr$b_fromlen;
    char mhdr$t_from [255];             /* MAIL$_MESSAGE_FROM               */
    unsigned char mhdr$b_tolen;
    char mhdr$t_to [255];               /* MAIL$_MESSAGE_TO                 */
    unsigned char mhdr$b_subjlen;
    char mhdr$t_subj [255];             /* MAIL$_MESSAGE_SUBJECT            */
    unsigned int mhdr$l_lines;          /* MAIL$_MESSAGE_SIZE		    */
    unsigned char mhdr$b_extlen;
    char mhdr$t_extid [255];            /* MAIL$_MESSAGE_EXTID              */
    unsigned short int mhdr$w_flags;    /* MAIL$_MESSAGE_RETURN_FLAGS       */
    __struct  {
        unsigned mhdr$v_decnet : 1;     /* Message sent with DECNET         */
        unsigned mhdr$v_deleted : 1;    /* Message is marked for DELEtion   */
        unsigned mhdr$v_sent : 1;       /* Message has been sent            */
        unsigned mhdr$v_fill_1_ : 5;
        } mhdr$r_iflags;
    } MHDR;
 
#if !defined(__VAXC)
#define mhdr$l_date mhdr$r_date.mhdr$l_date
#define mhdr$q_date mhdr$r_date.mhdr$q_date
#define mhdr$v_decnet mhdr$r_iflags.mhdr$v_decnet
#define mhdr$v_deleted mhdr$r_iflags.mhdr$v_deleted
#define mhdr$v_sent mhdr$r_iflags.mhdr$v_sent
#endif		/* #if !defined(__VAXC) */
 
#else	    /* __OLD_STARLET */
struct mhdr {                           /* Mail header structure            */
    void *mhdr$a_next;                  /* Link to next mail header structure */
    __union  {                          /* MAIL$_MESSAGE_BINARY_DATE        */
        unsigned int mhdr$l_date [2];
        unsigned int mhdr$q_date [2];
        } mhdr$r_date;
    unsigned int mhdr$l_messid;         /* MAIL$_MESSAGE_ID                 */
    unsigned char mhdr$b_fromlen;
    char mhdr$t_from [255];             /* MAIL$_MESSAGE_FROM               */
    unsigned char mhdr$b_tolen;
    char mhdr$t_to [255];               /* MAIL$_MESSAGE_TO                 */
    unsigned char mhdr$b_subjlen;
    char mhdr$t_subj [255];             /* MAIL$_MESSAGE_SUBJECT            */
    unsigned int mhdr$l_lines;          /* MAIL$_MESSAGE_SIZE		    */
    unsigned char mhdr$b_extlen;
    char mhdr$t_extid [255];            /* MAIL$_MESSAGE_EXTID              */
    unsigned short int mhdr$w_flags;    /* MAIL$_MESSAGE_RETURN_FLAGS       */
    __struct  {
        unsigned mhdr$v_decnet : 1;     /* Message sent with DECNET         */
        unsigned mhdr$v_deleted : 1;    /* Message is marked for DELEtion   */
        unsigned mhdr$v_sent : 1;       /* Message has been sent            */
        unsigned mhdr$v_fill_1_ : 5;
        } mhdr$r_iflags;
    } ;
 
#if !defined(__VAXC)
#define mhdr$l_date mhdr$r_date.mhdr$l_date
#define mhdr$q_date mhdr$r_date.mhdr$q_date
#define mhdr$v_decnet mhdr$r_iflags.mhdr$v_decnet
#define mhdr$v_deleted mhdr$r_iflags.mhdr$v_deleted
#define mhdr$v_sent mhdr$r_iflags.mhdr$v_sent
#endif		/* #if !defined(__VAXC) */
 
#endif	    /* #ifdef __NEW_STARLET */
 
#pragma __member_alignment __restore
#ifdef __INITIAL_POINTER_SIZE			 /* Defined whenever ptr size pragmas supported */
#pragma __required_pointer_size __restore		 /* Restore the previously-defined required ptr size */
#endif
#ifdef __cplusplus
    }
#endif
#pragma __standard
 
#endif /* __SPOP3DEF_LOADED */
 
