Skip to content
sld.cc 972 B
Newer Older
Seblu's avatar
Seblu committed
//
// sld.cc for sld in /home/seblu
//
// Made by Seblu
// Login   <seblu@epita.fr>
//
// Started on  Fri Jun  1 02:09:43 2007 Seblu
// Last update Fri Jun  1 02:10:49 2007 Seblu
//

Seblu's avatar
Seblu committed
#include "sld.hh"

Seblu's avatar
Seblu committed
int main(int argc, char *argv[])
{
Seblu's avatar
Seblu committed
  SLDaemon daemon;
  SLDaemon::options *lineopt;
  SLDaemon::options *fileopt = NULL;
Seblu's avatar
Seblu committed

Seblu's avatar
Seblu committed
  try {
    //parse arg line options
    lineopt = daemon.getoptions(argc, argv);
    
    assert(lineopt);
    if (lineopt->conffile != "") {
      //parse conf file options
      fileopt = daemon.getoptions(lineopt->conffile);
    }
  }
  catch (const Error &e) {
    e.print();
    return e.code();
  }
  try {
    //apply config file option
    if (fileopt)
      daemon.applyoptions(fileopt);
Seblu's avatar
Seblu committed

Seblu's avatar
Seblu committed
    //apply parsed option
    daemon.applyoptions(lineopt);
Seblu's avatar
Seblu committed

Seblu's avatar
Seblu committed
    //execute receive command
    daemon.run();
  }
  catch (const Error &e) {
    std::cerr <<"sld: error: " << e.message() << std::endl;
    return e.code();
  }
Seblu's avatar
Seblu committed
  return ERR_UNKNOWN;
Seblu's avatar
Seblu committed
}