#ifndef LIBGNXID_H
#define LIBGNXID_H

#include <string>
#include <vector>
#include <iostream>

#include <log4cpp/Priority.hh>
#include <klog.h>

struct HardwareIdentity
{
	std::string real_name;
	std::vector<std::string> aliases;
	int hardware_number;
};

struct gnx_param
{
   std::string param;
   std::string value;
};

class GnxIdentifier
{
public:
	GnxIdentifier(cKlog* gnxidLog);

	bool determineIdentity();
	bool isIdentityFound() { return identity_found; };
	std::string getHardwareName();
	int getHardwareNumber();
	std::ostream & listParams(std::ostream & os);
	void loadParams();
	void addParameter(std::string,std::string);
	int execute(int cp_argc, char *cp_argv[],bool script);

private:
	void findKnownIdentities();
	bool parseIdentityLine(HardwareIdentity& possible_identity, std::string shorthand_line);
	void tryLog(std::string message, log4cpp::Priority::PriorityLevel logLevel);
	void tryLog(std::string message);
	void logFullId(log4cpp::Priority::PriorityLevel logLevel);	
	void parse_params();
	void search_wan();
	void add_wan_mac();

	bool identity_found;
	HardwareIdentity the_identity;
	std::vector<HardwareIdentity> known_identities;
	cKlog* gnxid_log;
	std::vector<gnx_param> mParams;
};

class GnxDTParser
{
private :
   static GnxIdentifier * mGNxId;
   static int ftw_cb (const char *fpath, const struct stat *sb, int typeflag,struct FTW *pftw);
public :
   static int parse(GnxIdentifier *gnxid,char *fpath);
};

#endif /* LIBGNXID_H */
