/* nifty.h -- useful macros, etc.
 *
 * Copyright 1988, Chris Newman
 * All Rights Reserved
 * Permission is granted ot copy, modify, and use this as long
 * as this notice remains intact.  This is a nifty program.
 *
 * Some of these #defines were swiped from various places
 *
 * DISCLAIMER: the author (and maintainer) of this program is not responsible
 * for any damage or other problems caused by it.
 *
 * $Author: ppessi $ $Revision: 1.7 $ $Date: 1993/10/07 23:59:39 $
 */

#ifndef _NIFTY_
#define _NIFTY_

#define PROGNAME "Napsaterm"
#define DEFAULTFONT "napsa/11"
#define RESOURCELIST "amitcp:db/napsaprefs\0" "s:napsaprefs\0" "s:niftyprefs\0"

/* types */
#define	Boolean int
typedef	char    BOOLEAN;
typedef	unsigned short ushort;
typedef	unsigned char  uchar;

enum iotype { serial, stdio, dnet, rlogin };

/* constants */
#undef CTRL
#define CTRL(a) ((a) & 0x1f)
#define	ESC	'\033'
#define	DEL	'\177'

/* bound and limit macros */
#define	SLIMIT(a, b)	    ((a) >= (b) ? ((a) = (b) - 1) : (a))
#define	SLIMITCK(a, b)	    if ((a) >= (b)) (a) = (b) - 1
#define	MAXBOUND(a, b)	    ((a) > (b) ? (a) = (b): (a))
#define	MAXBOUNDCK(a, b)    if ((a) > (b)) (a) = (b)
#define	MINBOUND(a, b)	    ((a) < (b) ? (a) = (b): (a))
#define	MINBOUNDCK(a, b)    if ((a) < (b)) (a) = (b)
#define	BOUNDS(a, l, h)	    ((a) < (l) ? (a) = (l) : ((a) > (h) ? (a) = (h) : (a)))
#define	BOUNDSCK(a, l, h)   if ((a) < (l)) (a) = (l); else if ((a) > (h)) (a) = (h)

/* useful macros */
#undef ABS
#undef MIN
#undef MAX
#define	ABS(a)	    ((a) < 0 ? -(a) : (a))
#define	MAX(a, b)   ((a) > (b) ? (a) : (b))
#define	MIN(a, b)   ((a) < (b) ? (a) : (b))
#define	XSWAP(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
#define SWAP(a, b)  {register int xxx = a; a = b; b = xxx;}
#define	XOR(a, b)   ( ((a) ? 1 : 0) ^ ((b) ? 1 : 0) )

/* case macros */
#define	ISDIGIT	     '0': case '1': case '2': case '3': case '4': case '5': \
      case '6': case '7': case '8': case '9'
#define	ISUPPER	     'A': case 'B': case 'C': case 'D': case 'E': case 'F': \
      case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': \
      case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': \
      case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z'
#define	ISLOWER	     'a': case 'b': case 'c': case 'd': case 'e': case 'f': \
      case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': \
      case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': \
      case 'u': case 'v': case 'w': case 'x': case 'y': case 'z'
#define	ISALPHA	    ISUPPER: case ISLOWER
#define	PRINTABLE    ' ': case '!': case '"': case '#': case '$': case '%': \
      case '&': case'\'': case '(': case ')': case '*': case '+': case ',': \
      case '-': case '.': case '/': case ':': case ';': case ISDIGIT: \
      case '<': case '=': case '>': case '?': case '@': case ISUPPER: \
      case '[': case'\\': case ']': case '^': case '_': case '`': \
      case ISLOWER: case '{': case '|': case '}': case '~'

#include "all_protos.h"
#endif 

