Skip to content
slc.cc 1.14 KiB
Newer Older
Seblu's avatar
Seblu committed

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

#include "slc.hh"
#include "options.hh"
Seblu's avatar
Seblu committed
#include "screen.hh"
#include "history.hh"
#include "error.hh"
#include "connection.hh"
Seblu's avatar
Seblu committed

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

Seblu's avatar
Seblu committed
void main2();

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[])
{
Seblu's avatar
Seblu committed
  pthread_t t;

  try {
    // get argvline options
    O.load(argc, argv);

    // get environment options
    O.loadenv();

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

    // Create graphic env
    S.init();

    // Showing login screen. Retrieve user/pass.
    S.login();

    // Showing dialog screen
    S.dialog();

Seblu's avatar
Seblu committed
    // start connexion
    C.start();

Seblu's avatar
Seblu committed
    // Start reader thread
    pthread_create(&t, 0, (void *(*)(void *)) main2, 0);

    // Treat keyboards events
    S.eventsloop();

    // 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
*/
void main2() {
  S.socket_reader();
}