// Sample code file: NETDIR.H

// Warning: This code has been marked up for HTML
/*
 * netdir.h
 *
 * Copyright (C) 1989, Sun Microsystems, Inc.
 *
 * Portion Copyright (C) 1990, Novell, INc.
 *
 * This is the include file that defines various structures and
 * constants used by the netdir routines.
 *
 */

#ifndef _NETDIR_H
#define _NETDIR_H

#include <rpc/ndpsrpc.h>

#if defined(NWDOS) || defined(N_PLAT_DOS)
#endif /* NWDOS  N_PLAT_DOS */

#if defined(NWWIN) || defined(N_PLAT_MSW) || defined(N_PLAT_MSW4)
struct nd_addrlist {
    int             n_cnt;   /* number of netbufs */
    struct netbuf FAR *n_addrs;   /* the netbufs */
};

struct nd_hostservlist {
    int             h_cnt;         /* number of nd_hostservs */
    struct nd_hostserv FAR *h_hostservs;   /* the entries */
};

struct nd_hostserv {
    char FAR       *h_host;   /* the host name */
    char FAR       *h_serv;   /* the service name */
};

struct nd_mergearg {      /* parameter struct for option ND_MERGEADDR */
    char FAR       *s_uaddr;   /* input: server's univeral address */
    char FAR       *c_uaddr;   /* input: client's univeral address */
    char FAR       *m_uaddr;   /* output: merged univeral address */
};

struct nd_hostlist {
    int             h_cnt;   /* number of host entries */
    char FAR       *FAR *h_hosts;   /* array of host entries */
};

extern int N_API
netdir_gethostbyname(struct netconfig FAR *, char FAR *, \
           struct nd_addrlist FAR *FAR *);

extern int N_API
netdir_gethostbyaddr(struct netconfig FAR *, \
           struct nd_hostlist FAR *FAR *, struct netbuf FAR *);

extern char FAR * N_API
netdir_getlocalhost(struct netconfig FAR *);

extern int N_API
netdir_getbyname(struct netconfig FAR *, struct nd_hostserv FAR *, \
       struct nd_addrlist FAR * FAR *);

extern int N_API
netdir_getbyaddr(struct netconfig FAR *, struct nd_hostservlist FAR * FAR *, \
       struct netbuf FAR *);

extern int N_API 
netdir_options(struct netconfig FAR *, int, int, char FAR *);

extern void N_API
netdir_free(char FAR *, int);

extern struct netbuf FAR * N_API 
uaddr2taddr(struct netconfig FAR *, char FAR *);

extern char FAR * N_API
taddr2uaddr(struct netconfig FAR *, struct netbuf FAR *);

extern void N_API
netdir_perror(char FAR *);

extern char FAR * N_API
netdir_sperror(void);

/*
 * These are all objects that can be freed by netdir_free
 */
#define ND_HOSTSERV   0
#define ND_HOSTSERVLIST   1
#define ND_ADDR      2
#define ND_ADDRLIST   3
#define ND_HOSTLIST     4    

/*
 * These are the options for netdir_options
 */
#define ND_SET_BROADCAST   1
#define ND_SET_RESERVEDPORT   2
#define ND_CHECK_RESERVEDPORT   3
#define ND_MERGEADDR      4

/*
 * These are the various errors that can be encountered while attempting
 * to translate names to addresses. Note that none of them (except maybe
 * no memory) are truely fatal unless the ntoa deamon is on its last attempt
 * to translate the name.
 *
 * Negative errors terminate the search resolution process, positive errors
 * are treated as warnings.
 */
#define ND_BADARG   -2   /* Bad arguments passed     */
#define ND_NOMEM    -1   /* No virtual memory left    */
#define ND_OK      0   /* Translation successful    */
#define ND_NOHOST   1   /* Hostname was not resolvable    */
#define ND_NOSERV   2   /* Service was unknown       */
#define ND_NOSYM   3   /* Couldn't resolve symbol    */
#define ND_OPEN      4   /* File couldn't be opened    */
#define ND_ACCESS   5   /* File is not accessable    */
#define ND_UKNWN   6   /* Unknown object to be freed    */
#define ND_NOCTRL   7   /* Unknown option passed to netdir_options */
#define ND_FAILCTRL   8   /* Option failed in netdir_options */
#define ND_SYSTEM   9   /* Other System error           */

/*
 * The following special case host names are used to give the underlying
 * transport provider a clue as to the intent of the request.
 */

#define HOST_SELF   "\\1"   /* The generic bind address for this tp */
#define HOST_ANY   "\\2"   /* A "don't care" option for the host   */
#define HOST_BROADCAST   "\\3"   /* The broadcast address for this tp    */

#endif /* NWWIN */

#if defined(NWNLM) || defined(N_PLAT_NLM)
#endif /* NWNLM  N_PLAT_NLM */

#endif    /* !_NETDIR_H */