#ifndef _folder_h_
#define _folder_h_

typedef struct AlFolder_Object_struct *AlFolder;

#include <stdio.h>
#include <string.h>
#include "assert.h"
#include "sysdep.h"
#include "bool.h"
#include "registry.h"
#include "darray.h"
#include "msg.h"
#include "FieldCore.h"
#include "FieldType.h"
#include "memory.h"
#include "profile.h"
#include "foldert.h"

#define KEY char *
#define STRING char *

/*********************************************************************/
/* defenitions for opening folders through Alfolder_create_from_file */
/*********************************************************************/
#define FOLDER_OPEN_RW      0  
  /* open to read or write */
#define FOLDER_OPEN_APPEND  1  
  /* open to just append */


/*************************************************************/
/*******  Definitions for Error Codes                 ********/
/*******  ------------------------------------------  ********/
/*******    these are returned by:                    ********/
/*******         AlFolder_get_error_code(AlFolder);   ********/
/*************************************************************/

#define NO_ERROR 0
#define BAD_STATE_FILE 1
#define TOO_MANY_STATE_FIELDS 2
#define TOO_FEW_STATE_FIELDS 3
#define BAD_UPROP_FILE 4
#define TOO_MANY_UPROP_FIELDS 5
#define TOO_FEW_UPROP_FIELDS 6
#define NO_FIELD_COUNT_IN_UPROP_FILE 7
#define CANT_WRITE_TO_FILE 8
#define CANT_ADD_FILE 9
#define CANT_REMOVE_FILE 10

/*************************************************************/
/*******  Definitions for Error Msgs (doc'ed here)    ********/
/*******  ------------------------------------------  ********/
/*******    these are indexed by:                     ********/
/*******         AlFolder_get_error_code(AlFolder);   ********/
/*******    and are returned by:                      ********/
/*******         AlFolder_get_error_msg(AlFolder);    ********/
/*******    the actually storage for the strings is   ********/
/*******    in the private header file "folderP.h"    ********/
/*************************************************************/
/*
0 "Folder :: No Error. All is fine in Folder Object."
1 "Folder :: State File for this Msg contains erroneous data."
2 "Folder :: State File for this Msg contains more fields than it should."
3 "Folder :: State File for this Msg contains less fields than it should."
4 "Folder: User Property Info for the Msg contains erroneous data."
5 "Folder: User Property Info for the Msg contains more fields than it should."
6 "Folder: User Property Info for the Msg contains less fields than it should."
7 "Folder: User Property Info for this Msg is missing required 'field-count:'."
8 "Folder:: Do not have write access to the file."
9 "Folder:: Failed attempt to add a msg to a folder."
10 "Folder:: Failed attempt to remove a msg from a folder."
*/


#ifdef __STDC__

/*********************************************************************/
/****** Functions to Create, Print, and Destroy a Folder Object ******/
/*********************************************************************/

extern AlFolder AlFolder_create_from_file(STRING, AlFolderType, 
					  Bool, Bool, Bool, int);
extern AlFolder AlFolder_create_from_stdin(AlFolderType, Bool, Bool, Bool);
extern NORET AlFolder_destroy(AlFolder);                  /* not written yet */

extern NORET AlFolder_print_self(AlFolder, FILE *);

/********************************************/
/****** Functions to Store Information ******/
/********************************************/

/* Manipulate Error Code Information, after an error has occurred */
/* -------------------------------------------------------------- */
extern NORET AlFolder_clear_error_code(AlFolder);
extern NORET AlFolder_from_Msg_error_code(AlFolder, int);

/* Functions needed by the folder type objects */
/* ------------------------------------------- */
extern NORET AlFolder_reset_name(AlFolder, char *);

/* Action Verb related functions */
/* ----------------------------- */
extern Bool AlFolder_remove_cur_msg(AlFolder);            /* not written yet */
extern Bool AlFolder_copy_cur_msg(AlFolder, AlFolder);    /* not written yet */
extern Bool AlFolder_move_cur_msg(AlFolder, AlFolder);    /* not written yet */

/********************************************/
/***** Functions to Retrieve Information ****/
/********************************************/

/* Get defaults for suppression flags */
/* ---------------------------------- */
Bool AlFolder_default_state_suppress();
Bool AlFolder_default_uprop_suppress();

/* Get Msg Dependent Information */
/* ----------------------------- */
extern Msg AlFolder_get_next_msg(AlFolder);
extern Msg AlFolder_get_current_msg(AlFolder);

/* Get State Information */
/* --------------------- */
extern char *AlFolder_get_name(AlFolder);
extern AlFolderType AlFolder_get_folder_type(AlFolder);   /* not written yet */
extern char *AlFolder_get_folder_type_name(AlFolder);     /* not written yet */
extern Bool AlFolder_get_recursion_switch(AlFolder);      /* not written yet */
extern Bool AlFolder_get_external_state_suppression(AlFolder); /* not written */
extern Bool AlFolder_get_external_uprop_suppression(AlFolder); /* not written */

/* Get Error Code Information, after an error has occurred */
/* ------------------------------------------------------- */
extern int AlFolder_get_error_code(AlFolder);
extern char *AlFolder_get_error_msg(AlFolder);

#else


/*********************************************************************/
/****** Functions to Create, Print, and Destroy a Folder Object ******/
/*********************************************************************/

extern AlFolder AlFolder_create_from_file();
extern AlFolder AlFolder_create_from_stdin();
extern NORET AlFolder_destroy();                          /* not written yet */

extern NORET AlFolder_print_self();

/********************************************/
/****** Functions to Store Information ******/
/********************************************/

/* Manipulate Error Code Information, after an error has occurred */
/* -------------------------------------------------------------- */
extern NORET AlFolder_clear_error_code();
extern NORET AlFolder_from_Msg_error_code();

/* Functions needed by the folder type objects */
/* ------------------------------------------- */
extern NORET AlFolder_reset_name();

/* Action Verb related functions */
/* ----------------------------- */
extern Bool AlFolder_remove_cur_msg();                    /* not written yet */
extern Bool AlFolder_copy_cur_msg();                      /* not written yet */
extern Bool AlFolder_move_cur_msg();                      /* not written yet */

/********************************************/
/***** Functions to Retrieve Information ****/
/********************************************/

/* Get defaults for suppression flags */
/* ---------------------------------- */
Bool AlFolder_default_state_suppress();
Bool AlFolder_default_uprop_suppress();

/* Get Msg Dependent Information */
/* ----------------------------- */
extern Msg AlFolder_get_next_msg();
extern Msg AlFolder_get_current_msg();

/* Get State Information */
/* --------------------- */
extern char *AlFolder_get_name();
extern AlFolderType AlFolder_get_folder_type();           /* not written yet */
extern char *AlFolder_get_folder_type_name();             /* not written yet */
extern Bool AlFolder_get_recursion_switch();              /* not written yet */
extern Bool AlFolder_get_external_state_suppression();    /* not written yet */
extern Bool AlFolder_get_external_uprop_suppression();    /* not written yet */

/* Get Error Code Information, after an error has occurred */
/* ------------------------------------------------------- */
extern int AlFolder_get_error_code();
extern char *AlFolder_get_error_msg();

#endif          /* end of  #ifdef __STDC__  */

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