/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.TYPE		Header
.NAME		spclass.h
.LANGUAGE	C
.AUTHOR		Francois Ochsenbein [ESO-IPG]
.CATEGORY	Astronomic definitions
.COMMENTS	This module include astronomical declarations.
.ENVIRONMENT
.VERSION 1.0	02-Feb-1989: Creation
.VERSION 1.1	15-Feb-1995: ANSI-compatible

------------------------------------------------------------*/

#ifndef SPCLASS_DEF

#define SPCLASS_DEF	0

#ifndef _ARGS
#ifdef __STDC__
#define _ARGS(A)	A       /* ANSI */
#else
#define _ARGS(A)	()      /* Traditional */
#define const
#endif
#endif

#ifndef int4
#define int4 int
#define int8 long long
#endif


/*=========================================================================
		Components of a spectral classification
 *=========================================================================*/

typedef unsigned int4 sp_class;

#define _SP_COMPOSITE_	0x00800000
#define _SP_NOSUBCLASS_	0x00400000
#define _SP_UTEMP_	0x00010000
#define _SP_ULUM_	0x00008000
#define _SP_INCOMPLETE_	0x00004000
#define _SP_HOUK_	0x00002000
#define _SP_AVERAGED_	0x00001000
#define _SP_SOURCE_	0x00000800
#define _SP_VARIABLE_	0x00000080
#define _SP_EMISSION_	0x00000040
#define _SP_SHELL_	0x00000020
#define _SP_PECULIAR_	0x00000010
#define _SP_PROFILES_	0x0000000C
#define _SP_S_		0x00000004
#define _SP_N_		0x00000008
#define _SP_NN_		0x0000000C
#define _SP_ELEMENTS_	0x00000003
#define _SP_CN_		0x00000001
#define _SP_W_		0x00000002
#define _SP_M_		0x00000003

#define __SP_TEMP_	24
#define __SP_LUM_	17
#define __SP_QUAL_	 8

#define _SP_TEMP_	((sp_class)0xff << __SP_TEMP_)
#define _SP_LUM_	((sp_class)0x1f << __SP_LUM_)
#define _SP_QUAL_	((sp_class)7    << __SP_QUAL_)

	/* Getting the components of a spectral type */

#define SpTemp(sp)	((sp >> __SP_TEMP_) & 0xff)
#define SpLum(sp)	((sp >> __SP_LUM_ ) & 0x1f)
#define SpQual(sp)	((sp >> __SP_QUAL_) & 0x07)
#define SpPec(sp)	((sp              ) & 0xff)

	/* Checking some spectral pecularities */

#define isSp(sp, pec)	((sp) & pec)

#define isSp_v(sp)		isSp(sp, _SP_VARIABLE_)
#define isSp_e(sp)		isSp(sp, _SP_EMISSION_)
#define isSp_sh(sp)		isSp(sp, _SP_SHELL_)
#define isSp_p(sp)		isSp(sp, _SP_PECULIAR_)
#define isSp_s(sp)		(((sp)&_SP_PROFILES_) == _SP_S_)
#define isSp_n(sp)		(((sp)&_SP_PROFILES_) == _SP_N_)
#define isSp_nn(sp)		(((sp)&_SP_PROFILES_) == _SP_NN_)
#define isSp_CN(sp)		(((sp)&_SP_ELEMENTS_) == _SP_CN_)
#define isSp_w(sp)		(((sp)&_SP_ELEMENTS_) == _SP_W_)
#define isSp_m(sp)		(((sp)&_SP_ELEMENTS_) == _SP_M_)

#define Sp_bad(sp)		isSp(sp, _SP_INCOMPLETE_)
#define Sp_OK(sp)		!(Sp_bad)


/*=========================================================================
		Function Declarations
 *=========================================================================*/
int  tr_aks _ARGS((char *str, int len,  sp_class *sp ));
int  ed_ks  _ARGS((char *str, int size, sp_class  sp ));
char *kstoa _ARGS((sp_class sp ));

#endif
