/*
|
/*
|
* ldactoasc.h
|
* ldactoasc.h
|
*
|
*
|
* Include file for ldactoasc.c.
|
* Include file for ldactoasc.c.
|
*
|
*
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
*
|
*
|
* This file part of: SExtractor
|
* This file part of: SExtractor
|
*
|
*
|
* Copyright: (C) 2007-2010 IAP/CNRS/UPMC
|
* Copyright: (C) 2007-2010 Emmanuel Bertin -- IAP/CNRS/UPMC
|
*
|
|
* Author: Emmanuel Bertin (IAP)
|
|
*
|
*
|
* License: GNU General Public License
|
* License: GNU General Public License
|
*
|
*
|
* SExtractor is free software: you can redistribute it and/or modify
|
* SExtractor is free software: you can redistribute it and/or modify
|
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
* (at your option) any later version.
|
* (at your option) any later version.
|
* SExtractor is distributed in the hope that it will be useful,
|
* SExtractor is distributed in the hope that it will be useful,
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
|
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
|
*
|
*
|
* Last modified: 11/10/2010
|
* Last modified: 11/10/2010
|
*
|
*
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
|
|
/* Check if we are using a configure script here */
|
/* Check if we are using a configure script here */
|
#ifndef HAVE_CONFIG_H
|
#ifndef HAVE_CONFIG_H
|
#define VERSION "1.x"
|
#define VERSION "1.x"
|
#define DATE "2007-06-04"
|
#define DATE "2007-06-04"
|
#define THREADS_NMAX 16 /* max. number of threads */
|
#define THREADS_NMAX 16 /* max. number of threads */
|
#endif
|
#endif
|
|
|
/*------------------------ what, who, when and where ------------------------*/
|
/*------------------------ what, who, when and where ------------------------*/
|
|
|
#define BANNER "LDACtoASC"
|
#define BANNER "LDACtoASC"
|
#ifdef USE_THREADS
|
#ifdef USE_THREADS
|
#define MYVERSION VERSION "-MP"
|
#define MYVERSION VERSION "-MP"
|
#else
|
#else
|
#define MYVERSION VERSION
|
#define MYVERSION VERSION
|
#endif
|
#endif
|
#define COPYRIGHT "Emmanuel BERTIN <bertin@iap.fr>"
|
#define COPYRIGHT "Emmanuel BERTIN <bertin@iap.fr>"
|
#define WEBSITE "http://astromatic.net/software/sextractor/"
|
#define WEBSITE "http://astromatic.net/software/sextractor/"
|
#define INSTITUTE "IAP http://www.iap.fr"
|
#define INSTITUTE "IAP http://www.iap.fr"
|
|
|
/*----------------------------- Physical constants --------------------------*/
|
/*----------------------------- Physical constants --------------------------*/
|
|
|
#ifndef PI
|
#ifndef PI
|
#define PI 3.1415926535898
|
#define PI 3.1415926535898
|
#endif
|
#endif
|
|
|
/*----------------------------- Internal constants --------------------------*/
|
/*----------------------------- Internal constants --------------------------*/
|
|
|
#define BIG 1e+30 /* a huge number */
|
#define BIG 1e+30 /* a huge number */
|
#define TINY (1.0/BIG) /* a small number */
|
#define TINY (1.0/BIG) /* a small number */
|
#define OUTPUT stdout /* where all msgs are sent */
|
#define OUTPUT stdout /* where all msgs are sent */
|
#define MAXCHAR 512 /* max. number of characters */
|
#define MAXCHAR 512 /* max. number of characters */
|
#define MAXFILE 32768 /* max number of input files */
|
#define MAXFILE 32768 /* max number of input files */
|
|
|
/*------------ Set defines according to machine's specificities -------------*/
|
/*------------ Set defines according to machine's specificities -------------*/
|
|
|
#if 0
|
#if 0
|
#define NO_ENVVAR
|
#define NO_ENVVAR
|
#endif
|
#endif
|
|
|
/*--------------------- in case of missing constants ------------------------*/
|
/*--------------------- in case of missing constants ------------------------*/
|
|
|
#ifndef SEEK_SET
|
#ifndef SEEK_SET
|
#define SEEK_SET 0
|
#define SEEK_SET 0
|
#endif
|
#endif
|
#ifndef SEEK_CUR
|
#ifndef SEEK_CUR
|
#define SEEK_CUR 1
|
#define SEEK_CUR 1
|
#endif
|
#endif
|
|
|
#ifndef EXIT_SUCCESS
|
#ifndef EXIT_SUCCESS
|
#define EXIT_SUCCESS 0
|
#define EXIT_SUCCESS 0
|
#endif
|
#endif
|
#ifndef EXIT_FAILURE
|
#ifndef EXIT_FAILURE
|
#define EXIT_FAILURE -1
|
#define EXIT_FAILURE -1
|
#endif
|
#endif
|
|
|
/*---------------------------- return messages ------------------------------*/
|
/*---------------------------- return messages ------------------------------*/
|
|
|
#define RETURN_OK 0
|
#define RETURN_OK 0
|
#define RETURN_ERROR (-1)
|
#define RETURN_ERROR (-1)
|
#define RETURN_FATAL_ERROR (-2)
|
#define RETURN_FATAL_ERROR (-2)
|
|
|
/*------------------------------- Other Macros ------------------------------*/
|
/*------------------------------- Other Macros ------------------------------*/
|
|
|
#define DEXP(x) exp(2.30258509299*(x)) /* 10^x */
|
#define DEXP(x) exp(2.30258509299*(x)) /* 10^x */
|
|
|
#define QFREAD(ptr, size, afile, fname) \
|
#define QFREAD(ptr, size, afile, fname) \
|
if (fread(ptr, (size_t)(size), (size_t)1, afile)!=1) \
|
if (fread(ptr, (size_t)(size), (size_t)1, afile)!=1) \
|
error(EXIT_FAILURE, "*Error* while reading ", fname)
|
error(EXIT_FAILURE, "*Error* while reading ", fname)
|
|
|
#define QFWRITE(ptr, size, afile, fname) \
|
#define QFWRITE(ptr, size, afile, fname) \
|
if (fwrite(ptr, (size_t)(size), (size_t)1, afile)!=1) \
|
if (fwrite(ptr, (size_t)(size), (size_t)1, afile)!=1) \
|
error(EXIT_FAILURE, "*Error* while writing ", fname)
|
error(EXIT_FAILURE, "*Error* while writing ", fname)
|
|
|
#define QFSEEK(afile, offset, pos, fname) \
|
#define QFSEEK(afile, offset, pos, fname) \
|
if (fseek(afile, (offset), pos)) \
|
if (fseek(afile, (offset), pos)) \
|
error(EXIT_FAILURE,"*Error*: file positioning failed in ", \
|
error(EXIT_FAILURE,"*Error*: file positioning failed in ", \
|
fname)
|
fname)
|
|
|
#define QFTELL(pos, afile, fname) \
|
#define QFTELL(pos, afile, fname) \
|
if ((pos=ftell(afile))==-1) \
|
if ((pos=ftell(afile))==-1) \
|
error(EXIT_FAILURE,"*Error*: file position unknown in ", \
|
error(EXIT_FAILURE,"*Error*: file position unknown in ", \
|
fname)
|
fname)
|
|
|
#define QCALLOC(ptr, typ, nel) \
|
#define QCALLOC(ptr, typ, nel) \
|
{if (!(ptr = (typ *)calloc((size_t)(nel),sizeof(typ)))) \
|
{if (!(ptr = (typ *)calloc((size_t)(nel),sizeof(typ)))) \
|
error(EXIT_FAILURE, "Not enough memory for ", \
|
error(EXIT_FAILURE, "Not enough memory for ", \
|
#ptr " (" #nel " elements) !");;}
|
#ptr " (" #nel " elements) !");;}
|
|
|
#define QMALLOC(ptr, typ, nel) \
|
#define QMALLOC(ptr, typ, nel) \
|
{if (!(ptr = (typ *)malloc((size_t)(nel)*sizeof(typ)))) \
|
{if (!(ptr = (typ *)malloc((size_t)(nel)*sizeof(typ)))) \
|
error(EXIT_FAILURE, "Not enough memory for ", \
|
error(EXIT_FAILURE, "Not enough memory for ", \
|
#ptr " (" #nel " elements) !");;}
|
#ptr " (" #nel " elements) !");;}
|
|
|
#define QREALLOC(ptr, typ, nel) \
|
#define QREALLOC(ptr, typ, nel) \
|
{if (!(ptr = (typ *)realloc(ptr, (size_t)(nel)*sizeof(typ)))) \
|
{if (!(ptr = (typ *)realloc(ptr, (size_t)(nel)*sizeof(typ)))) \
|
error(EXIT_FAILURE, "Not enough memory for ", \
|
error(EXIT_FAILURE, "Not enough memory for ", \
|
#ptr " (" #nel " elements) !");;}
|
#ptr " (" #nel " elements) !");;}
|
|
|
#define QMEMCPY(ptrin, ptrout, typ, nel) \
|
#define QMEMCPY(ptrin, ptrout, typ, nel) \
|
{if (ptrin) \
|
{if (ptrin) \
|
{if (!(ptrout = (typ *)malloc((size_t)(nel)*sizeof(typ)))) \
|
{if (!(ptrout = (typ *)malloc((size_t)(nel)*sizeof(typ)))) \
|
error(EXIT_FAILURE, "Not enough memory for ", \
|
error(EXIT_FAILURE, "Not enough memory for ", \
|
#ptrout " (" #nel " elements) !"); \
|
#ptrout " (" #nel " elements) !"); \
|
memcpy(ptrout, ptrin, (size_t)(nel)*sizeof(typ));};;}
|
memcpy(ptrout, ptrin, (size_t)(nel)*sizeof(typ));};;}
|
|
|
#define QPOPEN(file, cmdline, flag) \
|
#define QPOPEN(file, cmdline, flag) \
|
{if (!(file=popen(cmdline, flag))) \
|
{if (!(file=popen(cmdline, flag))) \
|
error(EXIT_FAILURE, "*Error*: cannot execute ", cmdline);;}
|
error(EXIT_FAILURE, "*Error*: cannot execute ", cmdline);;}
|
|
|
#define RINT(x) (int)(floor(x+0.5))
|
#define RINT(x) (int)(floor(x+0.5))
|
|
|
#define NPRINTF if (prefs.verbose_type == NORM) fprintf
|
#define NPRINTF if (prefs.verbose_type == NORM) fprintf
|
|
|
#define NFPRINTF(w,x) {if (prefs.verbose_type == NORM) \
|
#define NFPRINTF(w,x) {if (prefs.verbose_type == NORM) \
|
fprintf(w, "\33[1M> %s\n\33[1A",x);}
|
fprintf(w, "\33[1M> %s\n\33[1A",x);}
|
|
|
#define FPRINTF if (prefs.verbose_type == FULL) fprintf
|
#define FPRINTF if (prefs.verbose_type == FULL) fprintf
|
|
|
#define QPRINTF if (prefs.verbose_type != QUIET) fprintf
|
#define QPRINTF if (prefs.verbose_type != QUIET) fprintf
|
|
|
#define QIPRINTF(w,x) {if (prefs.verbose_type == NORM) \
|
#define QIPRINTF(w,x) {if (prefs.verbose_type == NORM) \
|
fprintf(w, "\33[7m%s\33[0m\n", x); \
|
fprintf(w, "\33[7m%s\33[0m\n", x); \
|
else if (prefs.verbose_type == LOG) \
|
else if (prefs.verbose_type == LOG) \
|
fprintf(w, "%s\n", x);}
|
fprintf(w, "%s\n", x);}
|
|
|
#define QBPRINTF(w,x) {if (prefs.verbose_type == NORM) \
|
#define QBPRINTF(w,x) {if (prefs.verbose_type == NORM) \
|
fprintf(w, "\33[01;31m%s\33[0m\n", x); \
|
fprintf(w, "\33[01;31m%s\33[0m\n", x); \
|
else if (prefs.verbose_type == LOG) \
|
else if (prefs.verbose_type == LOG) \
|
fprintf(w, "%s\n", x);}
|
fprintf(w, "%s\n", x);}
|
|
|
|
|