#ifndef _msgP_h_
#define _msgP_h_

#include "msg.h"

#ifndef MSGDEBUG
#define MSGDEBUG 0
#endif

#if (MSGDEBUG == 0)
#define AlMsg_debug(str)
#define AlMsg_debug2(s1, s2) 
#else
#define AlMsg_debug(str) printf("%s\n", str)
#define AlMsg_debug2(s1, s2) printf("%s %s\n", s1, s2)
#endif            /* end of  #if (MSGDEBUG == 0)  */

/********************************************************************/
/* Define a stable usage of Registry_create() , etc. for my own use */
/********************************************************************/

#define AlMsg_ptr_Registry_create() \
  (Registry_create(Registry_ptrcmp, Registry_ptrhash))

#define AlMsg_str_Registry_create() \
  (Registry_create(Registry_strcmp, Registry_strhash))

#define AlMsg_caseless_str_Registry_create() \
  (Registry_create(Registry_strcasecmp, Registry_strcasehash))

#define AlMsg_Registry_add(reg, key, value) \
  Registry_add(reg, (VOIDP) key, (VOIDP) value)

#define AlMsg_Registry_get(reg, key)  Registry_get(reg, (VOIDP) key)

#define AlMsg_Registry_remove(reg, key)  Registry_remove(reg, (VOIDP) key)

#define AlMsg_Registry_replace_value(reg, key, newval) \
  Registry_replace_value(reg, (VOIDP) key, (VOIDP) newval)

/*************************************************************/
/*******  Definitions for Error Msgs                  ********/
/*******  ------------------------------------------  ********/
/*******    these are indexed by:                     ********/
/*******         AlMsg_get_error_code(Msg);           ********/
/*******    and are returned by:                      ********/
/*******         AlMsg_get_error_msg(Msg);            ********/
/*******    the codes are defined in "msg.h"          ********/
/*************************************************************/

const char *AlMsg_error_strings[] = {
 "Msg :: No Error. All is fine in Msg Object.",
 "Msg :: State File for this Msg contains erroneous data.",
 "Msg :: State File for this Msg contains more fields than it should.",
 "Msg :: State File for this Msg contains less fields than it should.",
 "Msg :: User Property File for this Msg contains erroneous data.",
 "Msg :: User Property File for this Msg contains more fields than it should.",
 "Msg :: User Property File for this Msg contains less fields than it should.",
 "Msg :: User Property File for this Msg is missing required 'field-count:'.",
 "Msg :: Can not delete. User property specified does not exist.",
 "Msg :: Can not append. User property specified does not exist.",
 "Msg :: Can not rename uprop. User property specified does not exist.",
 "Msg :: Can not copy uprop. User property specified does not exist.",
 "Msg :: Can not rename uprop. New user property specified already exists.",
 "Msg :: Can not get uprop. User property specified does not exist.",
 "Msg :: Can't get length of uprop. User property specified doesn't exist.",
 "Msg :: Can't set permanence of uprop. User property specified doesn't exist."
  };

typedef struct AlMsg_Object_struct {
  /* Name Spaces */
  Registry msg_field_registry;
  Registry registry_of_FC_registries;
  Registry user_property_registry;
  Registry fs_state_registry;          /* folder/mailer specific state info  */
  /* Folder info */
  AlFolder parent_folder;           /* Folder which created this Msg object  */
  char *msg_buffer;       /* buffer Msg ob was created from, owned by folder */
  /* User Propterties */
  int uprop_size;
  /* States */
  char *name_of_msg;
  int number_of_fields;
  int msg_line_length;
  int msg_char_length;
  int body_line_length;
  int body_char_length;
  Bool unprintables_in_body;
  Bool removed_flag; /* flags msg was removed from disk, shouldn't re-write */
  int error_code;
  int number_of_user_properties;      /* of the permanent kind */
  int state_field_count;
  unsigned int init_uprop_field_count;
  Bool suppress_states_out;
  Bool suppress_uprops_out;
  /* States that are purely for Data Collection */
  int num_rules_fired;
  int how_many_times_moved;
  char *moved_from;
  /* Body (text) of the Message */
  char *text_body;
 } AlMsgObject;

typedef struct AlMsg_Field_struct {
  int how_many;        /* number of strings in value array */
  char **values_array;      /* array of strings */
 } *MsgField, AlMsgFieldObject;

typedef struct AlMsg_UpropField_struct {
  char *key;           /* the name of the user property in string form  */
  char *value;         /* the value of the user property in string form */
  int length;          /* the number of characters in the value string  */
  Bool permanent;      /* flag if this uprop is to be saved in a file   */
 } MsgUpropField;

Registry AlMsg_Registry = NULL;

#endif         /* end of ifndef _msgP_h_ :: DO NOT WRITE BELOW THIS LINE. */
