/* ***********************IMPORTANT *********************************************
 *  Copyright (C) 2004-2007 Thierry Lagarde <tlagarde@users.sourceforge.net>
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License.
 *
 *
 *                      ********************
 *
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *
 *                      ********************
 *
 *
 * You are highly encouraged to send your changes to <tlagarde@users.sourceforge.net>
 * for possible incorporation into the main distribution.
 * By sending these changes to <tlagarde@users.sourceforge.net>,
 * it is assumed that you are offering <tlagarde@users.sourceforge.net>
 * the unlimited, non-exclusive right to reuse, modify, and relicense the code.
 *
 *
 *                      ********************
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **************************************************************************************/
#ifndef         __LOG
#define         __LOG

#include <glib.h>


enum enum_Categorie_Debug {
	CATEG_MAIN = 0,
	CATEG_THREAD_DETECT,
	CATEG_THREAD_SCAN,
	CATEG_THREAD_NOTIF_PORT,
	CATEG_THREAD_NOTIF_EQU,
	CATEG_BOUCLE_COMMUNIC,
	CATEG_RAFFRAICHIR_EQU,
	CATEG_NESSUS,
	CATEG_THREAD_SNMP_LISTE_ALL,
	CATEG_THREAD_SNMP_LISTE,
	CATEG_BOUCLE_SCAN,
	CATEG_INFO_AGENT,
	CATEG_PING_DETECT,
	CATEG_SCAN_PLAGE,
	CATEG_THREAD_ETAT_EQUIPEMENT,
	CATEG_THREAD_WAKEUP,
	CATEG_IP_DYNAMIC,
	CATEG_THREAD_SNMP_SCALAIRE,
	CATEG_COMM_SEND,
	CATEG_COMM_RECV,
	NB_CATEGORIE_DEBUG
};

struct Struct_Categorie {
	gint      Categorie;
	gchar    *Info;
	gchar	 *Fichier_Log;
	int       ID_Fichier_Log;
	gint	  used;	
	gboolean  deja_ouvert;
				
};

#ifdef __LOG_ENABLE
#include "Thread.h"
#include "Liste_Equipement.h"
#include "Notification_Equipement.h"
#include "Com/Communication.h"
#include "Thread_Detect.h"
#include "Notification_Port.h"
#include "Semaphore.h"
#include "Nessus.h"
#include "Snmp.h"
#include "Info.h"
#include "Scan_Signature.h"
#include "Liste_Sous_Reseau.h"
#include "Notification_Equipement.h"
#include "Scan_Equipement.h"
#include "Ip_Dynamic.h"


#define REPERTOIRE_LOG  "/var/log/autoscan-network/"
#define REPERTOIRE_LOG_EQUIPEMENT  "/var/log/autoscan-network/scan/"

struct struct_Cle_Privee {
	gint      Categorie;
	void     *Pointeur_Data;  
	int       ID_Fichier_Log;  
};


struct struct_Cle_Privee *Donnee_Cle_Main;
pthread_key_t Cle_privee_thread;
pthread_once_t once_cle_privee;



void Create_Log_Equipement (struct Struct_Liste_Equipement *Equipement);
void      Log_Equipement (struct Struct_Liste_Equipement *Equipement, gchar * Log);
void      create_cle_privee (void);
void 	  Initialisation_Log (void);
void 	  Initialisation_Repertoire_Log();
#endif

void      Envoie_Log_Equipement (gpointer * Donnee);
void Log (struct struct_Cle_Privee *Donnee_Cle,gchar *Log);
struct struct_Cle_Privee *Create_Log (gint Categorie,gchar *name,void *Data,gboolean Attache_Thread);
void Close_Log_Thread (struct struct_Cle_Privee *Donnee_Cle);
void Ckeck_Fermeture_Log ();
void Log_free (struct struct_Cle_Privee *Donnee_Cle,gchar *Texte);
void Close_Log_Main();
#endif
