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

  SLS 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

  SLS 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 SLS; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef SERVER_HH
# define SERVER_HH

# include "sll/connection.hh"
Seblu's avatar
Seblu committed
# include <set>
# include <pthread.h>
Seblu's avatar
Seblu committed

class Server {
public:
  typedef std::set<string> Stringset;
  typedef std::set<pthread_t> Threadset;

  enum e_client {
    CLI_DAEMON,
    CLI_CONSOLE
  };
Seblu's avatar
Seblu committed

public:
  Server();
  ~Server();
Seblu's avatar
Seblu committed

  void start(int port, size_t max_conn, bool verbose = false);
Seblu's avatar
Seblu committed
  void stop();

  bool started();

  e_client login();

  static void *start_client(void *);
Seblu's avatar
Seblu committed

private:
  Stringset logged_hosts_;
  Stringset logged_users_;
Seblu's avatar
Seblu committed

  Threadset threads_;
  pthread_mutex_t threads_mutex_;

  Connection conn_;
  size_t max_conn_;
  bool verbose_;
Seblu's avatar
Seblu committed
};

void *start_client(void *fd);


Seblu's avatar
Seblu committed
#endif