/*-=-=-=-=-=-=-=-=-=-=-=- RCCL/RCI Notice of Copyright -=-=-=-=-=-=-=-=-=-=-*
 *									    *
 *	Copyright (C) 1987, 1991 by John E. Lloyd and Vincent Hayward.	    *
 *									    *
 *	Information on copyright permissions, as well as a complete	    *
 *	disclaimer of warranty, is given in the file COPYRIGHT.		    *
 *									    *
 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

/*---------McGill-Computer-Vision-and-Robotics-Laboratory--C-Module---------
 *		
 * NAME:	macros.h
 *
 * USAGE:	#include <robot/macros.h>
 *
 * DESCRIPTION: Defintions of various macros which are helpful in writing
 *		RCI and RCL programs
 * 
 * NOTES:
 *
 * AUTHOR/DATE: Vincent Hayward, Purdue University, 1983
 *		John Lloyd, CaVRL, 1984
 *
 * UPDATES:
 *
 *-------------McGill-Computer-Vision-and-Robotics-Laboratory--------------*/

#ifndef MACROH
#define MACROH

#ifndef VERSION
#endif
#ifndef FILE
#include <stdio.h>
#endif

#define FABS(a)         (((a) < 0.) ? -(a) : (a))

#define ABS(a)          (((a) < 0) ? -(a) : (a))

#define ROUND(a)        ((a - (double)(int)a >= .5) ? (int)a + 1 : (int)a)

#define SET_CMD(cmd)		{chg. cmd .com = YES;}

#define SET_CMDVAL(cmd,val)	{chg. cmd .value = (val);\
				 chg. cmd .com = YES;\
				}

#define WAIT_CHG(cmd)	 	{while (chg. cmd .com != NO)\
			   	  { nap (0.10);\
			   	  }\
			 	}

#define WAITFOR(cond)	 	{while(!(cond))\
			   	  { nap (0.10);\
			   	  }\
			 	}

#define TERMIO(z)       do {errno = 0; z; pause();} while (errno == EINTR);

#define GETCHAR(c)      while ((c = getchar()) == ' '           \
			     || c == '\t' || c == '\n') ;

#define QUERY(c)        printf(" (y/n) ");                      \
			do {                                    \
				GETCHAR(c);                     \
			} while (c != 'y' && c != 'n');         \
			{int v;                                 \
			if ((v = getchar()) != '\n')            \
			 (void) ungetc(v, stdin);}

#endif
