Skip to content
sld.cc 1.13 KiB
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
//

#include <signal.h>

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

Seblu's avatar
Seblu committed
int main(int argc, char *argv[])
{
  SLDaemon &daemon = SLDaemon::Instance();
  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

    // register sigchild handler
    if (signal(SIGCHLD, sigchild) == SIG_ERR) {
      perror("sld: error");
      return ERR_UNKNOWN;
    }

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
}