// -*-c++-*-
/* $Id: authdb.h,v 1.5 2002/01/06 19:30:36 dm Exp $ */

/*
 *
 * Copyright (C) 2001 David Mazieres (dm@uun.org)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2, or (at
 * your option) any later version.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 *
 */

#include "authdb_types.h"

struct authdb;

struct authcursor {
  sfsauth_dbrec ae;

  authcursor () {}
  virtual ~authcursor () {}
  virtual bool first () = 0;
  virtual bool next () = 0;
  virtual bool update () { return false; }

  virtual bool find_user_name (str name);
  virtual bool find_user_pubkey (const sfs_pubkey &key);
  virtual bool find_user_uid (u_int32_t uid);

  virtual bool find_group_name (str name);
  virtual bool find_group_gid (u_int32_t gid);
};


struct authdb {
  virtual ~authdb () {}
  virtual ptr<authcursor> open (bool writable) = 0;
};

str authdbrec2str (const sfsauth_dbrec *dbr);
bool str2authdbrec (sfsauth_dbrec *dbr, str s);
