/* This file contains definitions for use by the Hesiod name service and
 * applications.
 *
 * For copying and distribution information, see the file <mit-copyright.h>.
 *
 * Original version by Steve Dyer, IBM/Project Athena.
 *
 *	$Id: hesiod.h,v 1.1 1995/11/02 05:27:09 ghudson Exp ghudson $
 */

#ifndef _HESIOD_H
#define _HESIOD_H

#include <pwd.h>
#include <grp.h>
#include <netdb.h>
#include <sys/cdefs.h>

/* Configuration information. */

#define HESIOD_CONF	"/etc/hesiod.conf"	/* Configuration file. */
#define DEF_RHS		".Athena.MIT.EDU"	/* Defaults if HESIOD_CONF */
#define DEF_LHS		".ns"			/*    file is not present. */

/* Error codes. */

#define	HES_ER_UNINIT	-1	/* uninitialized */
#define	HES_ER_OK	0	/* no error */
#define	HES_ER_NOTFOUND	1	/* Hesiod name not found by server */
#define HES_ER_CONFIG	2	/* local problem (no config file?) */
#define HES_ER_NET	3	/* network problem */
#define HES_ER_RANGE	4	/* return buffer not large enough */
#define HES_ER_NOMEM	5	/* insufficient memory is available */
#define HES_ER_INVAL	6	/* invalid response from hesiod server */

/* For use in getting post-office information. */

struct hes_postoffice {
	char	*po_type;
	char	*po_host;
	char	*po_name;
};

/* Reentrant.  (Of course, our resolver isn't thread-safe yet.) */
int hes_init __P((void));
int hes_to_bind_r __P((const char *HesiodName, const char *HesiodNameType,
		       char *buffer, int buflen));
int hes_resolve_r __P((const char *HesiodName, const char *HesiodNameType,
		       char **retvec, int retveclen));
int hes_getpwnam_r __P((const char *nam, struct passwd *entry, char *buf,
			int bufsize));
int hes_getpwuid_r __P((int uid, struct passwd *entry, char *buf,
			int bufsize));
int hes_getgrnam_r __P((const char *nam, struct group *entry, char *buf,
			int bufsize));
int hes_getgrgid_r __P((gid_t gid, struct group *entry, char *buf,
			int bufsize));
int hes_getmailhost_r __P((const char *user, struct hes_postoffice *ret,
			   char *linebuf, int bufsize));
int hes_getservbyname_r __P((const char *name, const char *proto,
			     struct servent *result, char *buffer,
			     int buflen));

/* Non-reentrant. */
char *hes_to_bind __P((const char *HesiodName, const char *HesiodNameType));
char **hes_resolve __P((const char *HesiodName, const char *HesiodNameType));
int hes_error __P((void));
struct passwd *hes_getpwnam __P((const char *nam));
struct passwd *hes_getpwuid __P((int uid));
struct group *hes_getgrnam __P((const char *nam));
struct group *hes_getgrgid __P((gid_t gid));
struct hes_postoffice *hes_getmailhost __P((const char *user));
struct servent *hes_getservbyname __P((const char *name, const char *proto));

#endif /* _HESIOD_H */

