#ifndef _H_CLISTUSERS
#define _H_CLISTUSERS

class CListUsers;

#include "mbot.h"

class CListUsers : public CList {
public:
  CListUsers (CNetServer *, const char *);
  ~CListUsers (void);

  struct user_type {
    CString mask;			// mask (nick!user@host)
    CString cur_mask;			// current mask, complete
    CString pass;			// encrypted password
    short int level;			// user level
    bool id;				// if it's identified
    CString msg;			// join msg
    user_type (c_char m, c_char p, short int l, c_char ms) :
      mask (m, MASK_SIZE), cur_mask (MASK_SIZE), pass (p, ENC_PASS_SIZE),
      level (l), id (0), msg (ms, MSG_SIZE) {}
  };

  bool add_user (const char *, const char *, int, const char *);
  bool del_user (const char *);
  bool match_check_pass (const char *, const char *);
  void match_set_pass (const char *, const char *);
  void abs_set_pass (const char *, const char *);
  void match_set_msg (const char *, const char *);
  void abs_set_msg (const char *, const char *);
  void abs_set_mask (const char *, const char *);
  void match_set_level (const char *, int);
  void abs_set_level (const char *, int);
  int abs_user_index(const char *);
  void match_set_id (const char *, bool);
  struct user_type *match_mask2user (c_char);
  struct user_type *abs_mask2user (c_char);
  int match_mask_level (const char *);
  int match_mask_reallevel (const char *);

private:

  bool load_users (void);
  bool save_users (void);
  void addlist_user (c_char, c_char, int, c_char);
  bool dellist_user (c_char);

  CString filename;
  CNetServer* s;			// server to which belongs

};

#endif
