Skip to content
slc.cc 1.67 KiB
Newer Older
Seblu's avatar
Seblu committed
/*
  This file is part of SLC.
Seblu's avatar
Seblu committed
  Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net>
Seblu's avatar
Seblu committed

  SLC is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
Seblu's avatar
Seblu committed
  the Free Software Foundation; version 2 of the License.
Seblu's avatar
Seblu committed

  SLC 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 General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with SLC; if not, write to the Free Software
Seblu's avatar
Seblu committed
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
Seblu's avatar
Seblu committed
*/
Seblu's avatar
Seblu committed

#include "slc.hh"
#include "options.hh"
Seblu's avatar
Seblu committed
#include "screen.hh"
#include "history.hh"
Seblu's avatar
Seblu committed
#include "sll/connection.hh"
#include "engine.hh"

#include <getopt.h>
Seblu's avatar
Seblu committed

Seblu's avatar
Seblu committed
Engine E;
Seblu's avatar
Seblu committed
Screen S;
History H;
Connection C;
Seblu's avatar
Seblu committed

Seblu's avatar
Seblu committed
pthread_t g_thread_reader;
Seblu's avatar
Seblu committed

Seblu's avatar
Seblu committed
/*!
** Program entry point
**
** @param argc arg count
** @param argv arg vector
**
** @return program err code
*/
int main(int argc, char *argv[])
{
  try {
    // get argvline options
    O.load(argc, argv);

    // get environment options
    O.loadenv();

    // load cmd history
    H.load(O.history_file);

Seblu's avatar
Seblu committed
    // Starting engine
    E.on();
Seblu's avatar
Seblu committed
    // Stoping engine
    E.off();

    // Save history
    H.save(O.history_file);
  }
  catch (const Error &e) {
    endwin();
    e.print();
    _exit(e.code());
  }
Seblu's avatar
Seblu committed

  return 0;
}
Seblu's avatar
Seblu committed


/*!
** Entry point of the second thread which is used to
** print data sent by server
*/
Seblu's avatar
Seblu committed
void *thread_reader(void *) {
  while (C.connected())
    S << "<< " << C.recvln() << "\n";
  pthread_exit(0);
  return 0;
Seblu's avatar
Seblu committed
}