/*
 *=======================================================================================
 * Name        :ModifLst.h
 *
 * Author      :vincent lhullier             Date :24/07/97
 *
 * Description :functions to manage modification list : header file
 *=======================================================================================
 * Modification -> Author :                  Date :
 * Description :
 *=======================================================================================
 */

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifndef __MODIFLST_H__
#define __MODIFLST_H__
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*
 =======================================================================================
	CONSTANTS 
 =======================================================================================
 */

/* 
 * character associated with a type of modification
 */
#define C_ModifChar_cAdd			'A'
#define C_ModifChar_cRebuild		'R'
#define C_ModifChar_cModif			'M'
#define C_ModifChar_cDelete			'D'
/*
 * type of modification
 */
#define C_ModifType_cError			-1
#define C_ModifType_cDestroy		0
#define C_ModifType_cAdd			1
#define C_ModifType_cRebuild		2
#define C_ModifType_cModif			3
#define C_ModifType_cDelete			4

/*
 =======================================================================================
	STRUCTURE 
 =======================================================================================
 */
/*
 * to store information about one modification 
 */
typedef struct tdstModif_
{
	long				lLine;
	BOOL				bConflict;
	struct tdstModif_	*p_stFather;
	char				cPrevType;
	char				cType;
	char				*szName; 
	struct tdstModif_	*p_stNext;
	struct tdstModif_	*p_stPrevious;
} tdstModif;

/*
 =======================================================================================
	External Globals
 =======================================================================================
 */
extern tdstModif	*g_p_stLastModif;
extern tdstModif	*g_p_stFirstModif;
extern long			g_lNumberOfModifs;
extern long			g_lNumberOfChildModifs;
extern long			g_lNumberOfFatherModifs;

extern char *g_a_szModifName[5];

/*
 =======================================================================================
	Functions
 =======================================================================================
 */

/*
 * function to decompose modification name
 */
BOOL		fn_bGetModifiedFile( tdstModif *_p_stModif, char *_szFileName, char *_szShortFileName );

/* get first child of a modif */
tdstModif	*fn_p_stGetChildModif( tdstModif *_p_stFather );
long		fn_lNumberOfChildModif( tdstModif *_p_stFather );

/* delete a notification on a section and set active all modif on sub section of this  */
//void		fn_vDeleteModifAndRestoreSubModif( tdstModif *_p_stModif );
void		fn_vRestoreSubModif( tdstModif *_p_stModif );

/* delete a modif from list */
long		fn_lDeleteModif( tdstModif *_p_stModif, BOOL _bDeleteChild );

/* delete all modif in list */
void		fn_vDeleteAllModifs( void );

/* search for a modification in the same file */
tdstModif	*fnp_stGetModifInFile( char *_szFileName, BOOL _bChild, BOOL _bAll );

/* delete all modif that are in a given file */
int			fn_iDeleteAllModifForAFile( char *_szFileName );

/* mak all modif that are in a file */
int			fn_iMarkAllModifForAFile( char *_szFileName );

/* get first valid modif */
tdstModif	*fn_p_stGetFirstNotMarkedModif( void );

/* delete modif file */
BOOL		fn_bDeleteModifFile( void );

/* rewrite modif file with all modif that are always in file */
void		fn_vWriteModifInFile( BOOL _bDelete );

/* function that read file where Modification list was saved. */
int			fn_iReadModificationFile( void );

/* update modification file */
void		fn_vUpdateModifFile( void );

/* clean modification list : delete all redondant modifications */
void		fn_vCleanModifList( void );

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#endif /*__MODIFLST_H__*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/