#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/conf.h>
#include <sys/file.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <errno.h>
#include <sys/param.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <resolv.h>

/* Error codes */
#define ERR_USAGE     1
#define ERR_HOST      2
#define ERR_SERVICE   3
#define ERR_SOCKET    4
#define ERR_CONNECT   5
#define ERR_WRITE     6
#define ERR_RECV      7
#define DEFAULT_HOST "MIT.EDU"
#define DEFAULT_DOMAIN ".MIT.EDU"
#define DEFAULT_DOMAINL ".mit.edu"
#define	MAXALIASES	35
#define	MAXADDRS	35
#if PACKETSZ > 1024
#define	MAXPACKET	PACKETSZ
#else
#define	MAXPACKET	1024
#endif

/* function prototypes */
void usage_exit();
int expn_do_socket(struct hostent *hp);
int expn_do_send(int s,char *request,int rec);
struct hostent * expn_do_lookup(char *host,char *recipient);
void expn_do_args(char **,char [],char []);
extern char * expn_getmxbyname(char *);
#ifdef Linux
extern int gethostname (char *name,int namelen);
#endif
#ifndef __NetBSD__
#ifndef sun
extern int dn_skipname(unsigned char *,unsigned char *);
#endif
#endif
#ifdef sun
#ifndef res_nameinquery
extern int res_search(char *,int,int,unsigned char *,int);
extern int dn_expand(char *,unsigned char *,unsigned char *,char *,int);
#endif
#endif


/* globals */

typedef union 
{
  HEADER hdr;
  u_char buf[MAXPACKET];
} querybuf;

typedef union 
{
  long al;
  char ac;
} align;
char *whoami;
extern int errno;
extern int h_errno;
#ifdef __NetBSD__
extern const char *const sys_errlist[];
#else
extern char *sys_errlist[];
#endif
static char *h_addr_ptrs[MAXADDRS + 1];
static struct hostent host;
static char *host_aliases[MAXALIASES];
static char hostbuf[BUFSIZ+1];
int vrfy=0,verb=0,bobo=0,print=0,last=0,nomx=0;
