/*
 * node.h:  Common header file for server & client.
 */

#ifndef _NODE_H
#define _NODE_H

/* Values used in a node's flags field */
/* These flags are INTERNAL and are not saved to disk */
#define	N_ONSTACK	0x1    /* Tag Used for infinite loop protection */
#define	N_CALLEDON	0x2    /* Already been passed to a traverse func */
#define	N_RESOLVED	0x4    /* Have link node-ids been resolved to ptrs? */
#define N_SYSGEN_FN     0x20   /* File name should be maintained by server */
#define N_HIT           0x1000 /* Internal flag for WAIS search */

/* These are "real" flags that are saved to disk */
#define N_FAKE		0x8    /* Created by web_node to keep things happy */
#define N_TEXT          0x10   /* This is a document node */
#define N_IMAGE         0x40   /* The node is an image (GIF) at this time */
#define N_DONT_STAT     0x80   /* Stat the file to update modify date? */
#define N_SERVER_NODE   0x100  /* a link to another server */
#define N_MENU          0x200  /* this represents a menu item - reserved */
#define N_BINARY        0x400  /* this represents a binary item - reserved */
#define N_DONT_INDEX    0x800  /* Don't index this node for full text search */
#define N_TELNETSESSION 0x2000 /* client starts telnet Added Jan 1993 --lam */
#define N_PRIVATE_IP    0x4000 /* based on ip address for campus site only */
#define N_PRIVATE_KRB   0x8000 /* based on ip address, but from a list 
				  provided per source */

/* Don't save the following flags when we save the web */
#define N_NOSAVE        (N_ONSTACK | N_CALLEDON | N_RESOLVED | N_SYSGEN_FN |\
                        N_HIT)


#define	setflag(n, flag)	((n)->nd_flags |= (flag))
#define	clrflag(n, flag)	((n)->nd_flags &= ~(flag))
#define	flagset(n, flag)	((n)->nd_flags & (flag)) /* is the flag set */


#define	text_node(n)		flagset(n,N_TEXT)
#define is_menu_node(n)         ((flagset(n,N_MENU)) || (EXTRACT_NODE_TYPE(n_flags(n)) == NT_MENU) || (strcmp(n_file(n),"")==0))

/* Output codes necessitated by client bugs which crashed when a node's flags 
   field contained values it didn't like.  Thus the default output format 
   zeros out the flags field, while the new and better format sends the flags 
   across.  The format is changed with the 'O' transaction, which supposedly 
   only new clients will do, to request the new format & get the flags.   
   Added 8/12/92 ark */
#define NO_FLAGS_FORMAT          1        /* Zeros out flags field */
#define SEND_FLAGS_FORMAT        2        /* Sends flags unchanged */
#define TELNET_FORMAT            3        /* "Pretty printing" to make 
					     telnet readable */
#define NUM_FORMATS              3
#define DEFAULT_OUTPUT_FORMAT    NO_FLAGS_FORMAT


/*
 * Flags for web_traverse
 */
#define	TRAV_UP		0x1
#define TRAV_DOWN	0x2
#define	TRAV_OUT	(TRAV_UP|TRAV_DOWN)
#define	TRAV_NOREPEAT	0x4

#define	NLINE_MAXLEN	4096
#define	NL_SAVE		1
#define	NL_RESTORE	2
#define NL_RESTORE_OR   3
#define NL_RESTORE_AND  4  

/* Increased NLIST_MAX_LEN from 4096 to 8192 8/3/92 ark */
#define	NLIST_MAX_LEN   8192	/* Max # of nodes in current list */


/*
 * Macros to put the node type into the high byte of a long and to extract it
 */
#define HI_NODE_TYPE(nt)	(unsigned long)(nt << 24)	/* shift 3 bytes */
#define EXTRACT_NODE_TYPE(nt)	(unsigned char)(nt >> 24)

/*
 * Node type numbers and ranges
 */
#define NT_NOT_USED		0				/* node type isn't set in the high byte */
#define NT_MENU			1
#define NT_CSO_LIST		2				/* returned if cso finds more than one person */

#define NR_DOCS_BEG		6				/* first number in documents range */
#define NR_DOCS_END		35				/* last number in documents range */
#define NT_UNKNOWN_DOC	6				/* unknown document */
#define NT_ASCII		7				/* generic 7 bit ascii */
#define NT_UNICODE_16	8				/* two byte unicode */
#define NT_UNICODE_CMP	9				/* compressed unicode */
#define NT_NROFF		10				/* nroff format */
#define NT_TROFF		11				/* troff format */
#define NT_EZ			12				/* EZ format */
#define NT_RTF			13				/* Microsoft's Rich Text Format */
#define NT_SETEXT		14				/* Setext format */
#define NT_SMGL			15				/* SMGL format */
#define NT_WRI			16				/* Microsoft Write format */
#define NT_MSWORD		17				/* Microsoft Word document */
#define NT_MIME			18				/* Mime (hypertext mail) format */
#define NT_PDF			19				/* Format used by Acrobat */
#define NT_HTML			20				/* Hypertext format used by WWW */
#define NT_DVI			21				/* dvi is produced by latex */

#define NR_GRF_BEG		36				/* first number in graphics range */
#define NR_GRF_END		55				/* last number in graphics range */
#define NT_UNKNOWN_GRF	36				/* unknown graphics format */
#define NT_GIF			37
#define NT_JPEG			38
#define NT_JFIF			39				/* method of encoding jpeg */
#define NT_TIFF			40
#define NT_PS			41				/* postscript */
#define NT_EPS			42				/* encapsulated postscript */
#define NT_RGB			43

#define NR_VIDEO_BEG	56				/* first number in video range */
#define NR_VIDEO_END	75				/* last number in video range */
#define NT_UNKNOWN_VIDEO 56				/* unknown video format */
#define NT_MPEG			57
#define NT_QUICKTIME	58
#define NT_DL

#define NR_AUDIO_BEG	76				/* first number in audio range */
#define NR_AUDIO_END	95				/* last number in audio range */
#define NT_UNKNOWN_AUDIO 76				/* unknown audio format */
#define NT_ULAW			77
#define NT_WAVE			78
#define NT_VOC			79
#define NT_AIFF			80				/* Audio Interchange File Format */
#define NT_AIFF_C		81				/* Compressed AIFF */
#define NT_MOD			82				/* Amiga MOD format */

#define NR_MAC_BEG		96				/* first number in macintosh range */
#define NR_MAC_END		115				/* last number in macintosh range */
#define NT_MACBINARY	96				/* MacBinary */
#define NT_SIT			97				/* StuffIt */
#define NT_CPT			98				/* Compact Pro */

#define NR_DOS_BEG		116				/* first number in MS-DOS range */
#define NR_DOS_END		135				/* last number in MS-DOS range */
#define NT_DOS_BIN		116				/* generic binary */
#define NT_ZIP			117				/* created by pkzip */
#define NT_LZH			118
#define NT_ARC			119
#define NT_ZOO			120
#define NT_MS_HELP		121				/* Microsoft's help format */

#define NR_OTHER_BEG	136				/* first number in other range */
#define NR_OTHER_END	155				/* last number in other range */
#define NT_BINARY		136				/* generic binary */
#define NT_BINHEX		137
#define NT_UUENCODE		138
#define NT_BASE64		139
#define NT_FRAME		140				/* format used by FrameMaker */
#define NT_MS_EXCEL		141				/* Microsoft Excel format */

#define NR_SERVICES_BEG	156				/* first number in services range */
#define NR_SERVICES_END	175				/* last number in services range */
#define NT_TECHINFO		156				/* TechInfo server */
#define NT_SEARCH		157				/* serach, for gopher compatibility */
#define NT_CSO			158				/* name look up, for gopher */
#define NT_TELNET		159				/* telnet node */
#define NT_FTP			160				/* ftp node */
#define NT_URL                  161                             /* URL node */

#endif ndef _NODE_H









