testcfgfile.c 1.34 KB
Newer Older
Michel Kaempf's avatar
Michel Kaempf committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
// Test des fonctions de gestion des fichiers de config
// A compiler par 'make -f Makefile.cfgfile'

#include <pthread.h>
#include <stdio.h>
#include "../core/config.h"
#include "../core/common.h"
#include "../core/string.h"
#include "../core/log.h"
#include "../core/cfgfile.h"
#include "../core/debug.h"

// Global logging endpoint
C_Log* pLog = NULL;

int main()
{
  int iRc = 0;

  // Application initialisation
  handle hLog;
  pLog = new C_Log();
  printf("New log object created\n");

  pLog->Init("Testcfgfile.log");
  printf("Log object initiated\n");

  int iFlags = 0 | LOG_DBGMSG | LOG_SCR | LOG_FILE;
  hLog = pLog->Register("TestLog", iFlags);
  printf("Registered Testlog\n");


  // Tests of the cfg file
  printf("!!!!!!!!!!!!!!!!!! BEGIN !!!!!!!!!!!!!!!!\n");
  C_CfgFile CfgFile(hLog);
  CfgFile.Open("Test.conf");

  CfgFile.FindSection("Globals");
  C_String strVarName, strVarVal;
  CfgFile.Read(&strVarName, &strVarVal);
  strVarName.Display();
  strVarVal.Display();

  CfgFile.FindSection("Interfaces");
  CfgFile.FindEntry("VLANdefault", &strVarVal);
  strVarVal.Display();

  CfgFile.Close();
  printf("!!!!!!!!!!!!!!!!!!! END !!!!!!!!!!!!!!!!!\n");

  // Application termination
  pLog->Unregister(hLog);
  printf("TestLog unregistered\n");

  pLog->End();
  printf("Log ended\n");

  delete pLog;
  printf("Log deleted\n");

  return 0;
}