[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 647406f 02/16: Table utility bare minimum stru
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 647406f 02/16: Table utility bare minimum structure in place |
Date: |
Wed, 24 Aug 2016 22:27:43 +0000 (UTC) |
branch: master
commit 647406fff3c82a1e5f941e205a28f9cc36dbb2f2
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
Table utility bare minimum structure in place
Following the TEMPLATE bare minimum structure, the new `Table' utility's
structure is now in place along with a simple `--information' option which
will later print the table information.
---
Makefile.am | 3 +
configure.ac | 12 +-
src/table/Makefile.am | 40 ++++++
src/table/args.h | 222 +++++++++++++++++++++++++++++++
src/table/asttable.conf | 23 ++++
src/table/cite.h | 38 ++++++
src/table/main.c | 56 ++++++++
src/table/main.h | 63 +++++++++
src/table/table.c | 42 ++++++
src/table/table.h | 29 ++++
src/table/ui.c | 335 +++++++++++++++++++++++++++++++++++++++++++++++
src/table/ui.h | 32 +++++
12 files changed, 894 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index 1559349..fae1bf4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -88,6 +88,9 @@ endif
if COND_SUBTRACTSKY
MAYBE_SUBTRACTSKY = src/subtractsky
endif
+if COND_TABLE
+ MAYBE_TABLE = src/table
+endif
#if COND_TEMPLATE
# MAYBE_TEMPLATE = src/TEMPLATE
#endif
diff --git a/configure.ac b/configure.ac
index 33b40cd..c3d54f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -299,10 +299,16 @@ AC_ARG_ENABLE([noisechisel],
[enable_noisechisel=notset])
AC_ARG_ENABLE([subtractsky],
[AS_HELP_STRING([--enable-subtractsky],
- [Install SubtractSky and other enabled packages only.])],
+ [Install SubtractSky and other enabled packages only.])],
[AS_IF([test "x$enable_subtractsky" != xno],
[enable_subtractsky=yes; ayes=true])],
[enable_subtractsky=notset])
+AC_ARG_ENABLE([table],
+ [AS_HELP_STRING([--enable-table],
+ [Install Table and other enabled packages only.])],
+ [AS_IF([test "x$enable_table" != xno],
+ [enable_table=yes; ayes=true])],
+ [enable_table=notset])
#AC_ARG_ENABLE([TEMPLATE],
# [AS_HELP_STRING([--enable-TEMPLATE],
# [Install TEMPLATE and other enabled packages only.])],
@@ -337,6 +343,7 @@ AS_IF([test $ayes = true ],
AS_IF([test $enable_mkprof = notset], [enable_mkprof=no])
AS_IF([test $enable_noisechisel = notset], [enable_noisechisel=no])
AS_IF([test $enable_subtractsky = notset], [enable_subtractsky=no])
+ AS_IF([test $enable_table = notset], [enable_table=no])
# AS_IF([test $enable_TEMPLATE = notset], [enable_TEMPLATE=no])
],
@@ -353,6 +360,7 @@ AS_IF([test $ayes = true ],
AS_IF([test $enable_mkprof = notset], [enable_mkprof=yes])
AS_IF([test $enable_noisechisel = notset], [enable_noisechisel=yes])
AS_IF([test $enable_subtractsky = notset], [enable_subtractsky=yes])
+ AS_IF([test $enable_table = notset], [enable_table=yes])
# AS_IF([test $enable_TEMPLATE = notset], [enable_TEMPLATE=yes])
]
)
@@ -375,6 +383,7 @@ AM_CONDITIONAL([COND_MKNOISE], [test $enable_mknoise = yes])
AM_CONDITIONAL([COND_MKPROF], [test $enable_mkprof = yes])
AM_CONDITIONAL([COND_NOISECHISEL], [test $enable_noisechisel = yes])
AM_CONDITIONAL([COND_SUBTRACTSKY], [test $enable_subtractsky = yes])
+AM_CONDITIONAL([COND_TABLE], [test $enable_table = yes])
#AM_CONDITIONAL([COND_TEMPLATE], [test $enable_TEMPLATE = yes])
@@ -388,6 +397,7 @@ AC_CONFIG_FILES([Makefile
doc/Makefile
lib/Makefile
tests/Makefile
+ src/table/Makefile
src/mkprof/Makefile
src/header/Makefile
src/mknoise/Makefile
diff --git a/src/table/Makefile.am b/src/table/Makefile.am
new file mode 100644
index 0000000..d5c6289
--- /dev/null
+++ b/src/table/Makefile.am
@@ -0,0 +1,40 @@
+## Process this file with automake to produce Makefile.inx
+##
+## Original author:
+## Mohammad Akhlaghi <address@hidden>
+## Contributing author(s):
+## Copyright (C) 2016, Free Software Foundation, Inc.
+##
+## Gnuastro is free software: you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## Gnuastro is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+
+
+
+
+
+## Utility and its sources
+bin_PROGRAMS = asttable
+
+asttable_SOURCES = main.c main.h cite.h ui.c ui.h args.h \
+table.c table.h
+
+asttable_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la \
+-lgalconfigfiles -lgalfits -lgalcheckset -lgaltiming -lgallinkedlist
+
+
+
+
+
+# To destribute the defaults file.
+# NOTE: the man page is created in doc/Makefile.am
+dist_sysconf_DATA = asttable.conf
diff --git a/src/table/args.h b/src/table/args.h
new file mode 100644
index 0000000..74fa061
--- /dev/null
+++ b/src/table/args.h
@@ -0,0 +1,222 @@
+/*********************************************************************
+Table - View and manipulate a FITS table structures.
+Table is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+ Mohammad Akhlaghi <address@hidden>
+Contributing author(s):
+Copyright (C) 2016, Free Software Foundation, Inc.
+
+Gnuastro is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#ifndef ARGS_H
+#define ARGS_H
+
+#include <argp.h>
+
+#include <gnuastro/commonargs.h>
+#include <gnuastro/linkedlist.h>
+#include <gnuastro/fixedstringmacros.h>
+
+
+
+
+
+
+
+
+
+
+/**************************************************************/
+/************** argp.h definitions ***************/
+/**************************************************************/
+
+
+
+
+/* Definition parameters for the argp: */
+const char *argp_program_version=SPACK_STRING"\n"GAL_STRINGS_COPYRIGHT
+ "\n\nWritten by Mohammad Akhlaghi";
+const char *argp_program_bug_address=PACKAGE_BUGREPORT;
+static char args_doc[] = "ASTRdata";
+
+
+
+
+
+const char doc[] =
+ /* Before the list of options: */
+ GAL_STRINGS_TOP_HELP_INFO
+ SPACK_NAME" print a FITS table or its information. \n"
+ GAL_STRINGS_MORE_HELP_INFO
+ /* After the list of options: */
+ "\v"
+ PACKAGE_NAME" home page: "PACKAGE_URL;
+
+
+
+
+
+/* Available letters for short options:
+
+ a b c d e f g j k l m n p r s t u v w x y z
+ A B C E F G H I J L M O Q R T U W X Y Z
+
+ Number keys used: Nothing!
+
+ Options with keys (second structure element) larger than 500 do not
+ have a short version.
+ */
+static struct argp_option options[] =
+ {
+ {
+ 0, 0, 0, 0,
+ "Input:",
+ 1
+ },
+
+
+
+
+ {
+ 0, 0, 0, 0,
+ "Output:",
+ 2
+ },
+
+
+
+ {
+ 0, 0, 0, 0,
+ "Operating modes:",
+ -1
+ },
+ {
+ "information",
+ 'i',
+ 0,
+ 0,
+ "Only print table and columns information.",
+ -1
+ },
+
+
+ {0}
+ };
+
+
+
+
+
+/* Parse a single option: */
+static error_t
+parse_opt(int key, char *arg, struct argp_state *state)
+{
+ /* Save the arguments structure: */
+ struct tableparams *p = state->input;
+
+ /* Set the pointer to the common parameters for all programs
+ here: */
+ state->child_inputs[0]=&p->cp;
+
+ /* In case the user incorrectly uses the equal sign (for example
+ with a short format or with space in the long format, then `arg`
+ start with (if the short version was called) or be (if the long
+ version was called with a space) the equal sign. So, here we
+ check if the first character of arg is the equal sign, then the
+ user is warned and the program is stopped: */
+ if(arg && arg[0]=='=')
+ argp_error(state, "incorrect use of the equal sign (`=`). For short "
+ "options, `=` should not be used and for long options, "
+ "there should be no space between the option, equal sign "
+ "and value");
+
+ switch(key)
+ {
+
+
+ /* Input: */
+
+
+ /* Output: */
+
+
+ /* Operating modes: */
+ case 'i':
+ p->information=1;
+ p->informationset=1;
+ break;
+
+
+ /* Read the non-option arguments: */
+ case ARGP_KEY_ARG:
+
+ /* See what type of input value it is and put it in. */
+ if( gal_fits_name_is_fits(arg) )
+ {
+ if(p->up.inputname)
+ argp_error(state, "only one input image should be given");
+ else
+ p->up.inputname=arg;
+ }
+ else
+ argp_error(state, "%s is not a valid file type", arg);
+ break;
+
+
+
+
+
+ /* The command line options and arguments are finished. */
+ case ARGP_KEY_END:
+ if(p->cp.setdirconf==0 && p->cp.setusrconf==0
+ && p->cp.printparams==0)
+ {
+ if(state->arg_num==0)
+ argp_error(state, "no argument given");
+ if(p->up.inputname==NULL)
+ argp_error(state, "no input FITS image(s) provided");
+ }
+ break;
+
+
+
+
+
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+
+
+
+
+/* Specify the children parsers: */
+struct argp_child children[]=
+ {
+ {&commonargp, 0, NULL, 0},
+ {0, 0, 0, 0}
+ };
+
+
+
+
+
+/* Basic structure defining the whole argument reading process. */
+static struct argp thisargp = {options, parse_opt, args_doc,
+ doc, children, NULL, NULL};
+
+#endif
diff --git a/src/table/asttable.conf b/src/table/asttable.conf
new file mode 100644
index 0000000..f5d6183
--- /dev/null
+++ b/src/table/asttable.conf
@@ -0,0 +1,23 @@
+# Default parameters (System) for Table.
+# Table is part of GNU Astronomy Utitlies.
+#
+# Use the long option name of each paramter followed by
+# a value. The name and value should be separated by
+# atleast one of the following charaacters:
+# space, `,`, `=` or `:`
+#
+# Run with `--help` option or read the manual for a full
+# explanation of what each option means.
+#
+# NOTE I: All counting is from zero, not one.
+# NOTE II: Lines starting with `#` are ignored.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved. This file is offered as-is,
+# without any warranty.
+
+# Input:
+ hdu 0
+
+# Output:
\ No newline at end of file
diff --git a/src/table/cite.h b/src/table/cite.h
new file mode 100644
index 0000000..de9ab4f
--- /dev/null
+++ b/src/table/cite.h
@@ -0,0 +1,38 @@
+/*********************************************************************
+Table - View and manipulate a FITS table structures.
+Table is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+ Mohammad Akhlaghi <address@hidden>
+Contributing author(s):
+Copyright (C) 2016, Free Software Foundation, Inc.
+
+Gnuastro is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#ifndef CITE_H
+#define CITE_H
+
+#define TABLEBIBTEX ""
+
+#define PRINTCITEABORT { \
+ printf("\nWe hope %s has been useful for your research.\n" \
+ "Citations are vital for the continued work on %s.\n" \
+ "Thank you for citing it in your research paper.\n" \
+ "\nPlease cite as \"%s\":\n\n%s\n\n%s", \
+ SPACK_NAME, SPACK_NAME, SPACK_STRING, \
+ GAL_STRINGS_MAIN_BIBTEX, TABLEBIBTEX); \
+ exit(EXIT_SUCCESS); \
+ }
+
+#endif
diff --git a/src/table/main.c b/src/table/main.c
new file mode 100644
index 0000000..b2eb42a
--- /dev/null
+++ b/src/table/main.c
@@ -0,0 +1,56 @@
+/*********************************************************************
+Table - View and manipulate a FITS table structures.
+Table is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+ Mohammad Akhlaghi <address@hidden>
+Contributing author(s):
+Copyright (C) 2016, Free Software Foundation, Inc.
+
+Gnuastro is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <progname.h>
+
+#include <gnuastro/timing.h> /* Includes time.h and sys/time.h */
+
+#include "main.h"
+
+#include "ui.h" /* needs main.h. */
+#include "table.h" /* needs main.h. */
+
+int
+main (int argc, char *argv[])
+{
+ struct tableparams p={{0}, {0}, 0};
+
+ /* Set the program name (needed by non-gnu operating systems): */
+ time(&p.rawtime);
+ set_program_name(argv[0]);
+
+ /* Read the input parameters. */
+ setparams(argc, argv, &p);
+
+ /* Run MakeProfiles */
+ table(&p);
+
+ /* Free all non-freed allocations. */
+ freeandreport(&p);
+
+ /* Return successfully.*/
+ return EXIT_SUCCESS;
+}
diff --git a/src/table/main.h b/src/table/main.h
new file mode 100644
index 0000000..0f3c1fb
--- /dev/null
+++ b/src/table/main.h
@@ -0,0 +1,63 @@
+/*********************************************************************
+Table - View and manipulate a FITS table structures.
+Table is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+ Mohammad Akhlaghi <address@hidden>
+Contributing author(s):
+Copyright (C) 2016, Free Software Foundation, Inc.
+
+Gnuastro is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#ifndef MAIN_H
+#define MAIN_H
+
+#include <gnuastro/fits.h>
+#include <gnuastro/commonparams.h>
+
+/* Progarm name macros: */
+#define SPACK "asttable" /* Subpackage executable name. */
+#define SPACK_NAME "Table" /* Subpackage full name. */
+#define SPACK_STRING SPACK_NAME" ("PACKAGE_NAME") "PACKAGE_VERSION
+
+
+
+
+
+
+struct uiparams
+{
+ char *inputname; /* Name of input file. */
+ int informationset;
+};
+
+
+
+
+
+struct tableparams
+{
+ /* Other structures: */
+ struct uiparams up; /* User interface parameters. */
+ struct gal_commonparams cp; /* Common parameters. */
+
+ /* Input: */
+ int information; /* ==1: only print information. */
+
+ /* Internal: */
+ int onlyview;
+ time_t rawtime; /* Starting time of the program. */
+};
+
+#endif
diff --git a/src/table/table.c b/src/table/table.c
new file mode 100644
index 0000000..ab560f2
--- /dev/null
+++ b/src/table/table.c
@@ -0,0 +1,42 @@
+/*********************************************************************
+Table - View and manipulate a FITS table structures.
+Table is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+ Mohammad Akhlaghi <address@hidden>
+Contributing author(s):
+Copyright (C) 2016, Free Software Foundation, Inc.
+
+Gnuastro is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#include <config.h>
+
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <gnuastro/fits.h>
+#include <gnuastro/linkedlist.h>
+
+#include "main.h"
+
+
+
+void
+table(struct tableparams *p)
+{
+
+}
diff --git a/src/table/table.h b/src/table/table.h
new file mode 100644
index 0000000..e28f32e
--- /dev/null
+++ b/src/table/table.h
@@ -0,0 +1,29 @@
+/*********************************************************************
+Table - View and manipulate a FITS table structures.
+Table is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+ Mohammad Akhlaghi <address@hidden>
+Contributing author(s):
+Copyright (C) 2016, Free Software Foundation, Inc.
+
+Gnuastro is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#ifndef TABLE_H
+#define TABLE_H
+
+void
+table(struct tableparams *p);
+
+#endif
diff --git a/src/table/ui.c b/src/table/ui.c
new file mode 100644
index 0000000..4903278
--- /dev/null
+++ b/src/table/ui.c
@@ -0,0 +1,335 @@
+/*********************************************************************
+Table - View and manipulate a FITS table structures.
+Table is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+ Mohammad Akhlaghi <address@hidden>
+Contributing author(s):
+Copyright (C) 2016, Free Software Foundation, Inc.
+
+Gnuastro is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#include <config.h>
+
+#include <math.h>
+#include <stdio.h>
+#include <errno.h>
+#include <error.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fitsio.h>
+
+#include <nproc.h> /* From Gnulib. */
+
+#include <gnuastro/fits.h>
+#include <gnuastro/timing.h> /* Includes time.h and sys/time.h */
+#include <gnuastro/checkset.h>
+#include <gnuastro/txtarray.h>
+#include <gnuastro/commonargs.h>
+#include <gnuastro/configfiles.h>
+
+#include "main.h"
+
+#include "ui.h" /* Needs main.h */
+#include "args.h" /* Needs main.h, includes argp.h. */
+
+
+/* Set the file names of the places where the default parameters are
+ put. */
+#define CONFIG_FILE SPACK CONF_POSTFIX
+#define SYSCONFIG_FILE SYSCONFIG_DIR "/" CONFIG_FILE
+#define USERCONFIG_FILEEND USERCONFIG_DIR CONFIG_FILE
+#define CURDIRCONFIG_FILE CURDIRCONFIG_DIR CONFIG_FILE
+
+
+
+
+
+
+
+
+
+
+/**************************************************************/
+/************** Options and parameters ***************/
+/**************************************************************/
+void
+readconfig(char *filename, struct tableparams *p)
+{
+ FILE *fp;
+ size_t lineno=0, len=200;
+ char *line, *name, *value;
+ /*struct uiparams *up=&p->up;*/
+ struct gal_commonparams *cp=&p->cp;
+ char key='a'; /* Not used, just a place holder. */
+
+ /* When the file doesn't exist or can't be opened, it is ignored. It
+ might be intentional, so there is no error. If a parameter is
+ missing, it will be reported after all defaults are read. */
+ fp=fopen(filename, "r");
+ if (fp==NULL) return;
+
+
+ /* Allocate some space for `line` with `len` elements so it can
+ easily be freed later on. The value of `len` is arbitarary at
+ this point, during the run, getline will change it along with the
+ pointer to line. */
+ errno=0;
+ line=malloc(len*sizeof *line);
+ if(line==NULL)
+ error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+ len * sizeof *line);
+
+ /* Read the tokens in the file: */
+ while(getline(&line, &len, fp) != -1)
+ {
+ /* Prepare the "name" and "value" strings, also set lineno. */
+ GAL_CONFIGFILES_START_READING_LINE;
+
+
+
+
+ /* Inputs: */
+ if(strcmp(name, "hdu")==0)
+ {
+ if(cp->hduset) continue;
+ errno=0;
+ cp->hdu=malloc(strlen(value)+1);
+ if(cp->hdu==NULL)
+ error(EXIT_FAILURE, errno, "space for HDU");
+ strcpy(cp->hdu, value);
+ cp->hduset=1;
+ }
+
+
+
+ /* Outputs */
+
+
+
+
+ /* Operating modes: */
+ else if (strcmp(name, "information")==0)
+ {
+ if(up->informationset) continue;
+ gal_checkset_int_zero_or_one(value, &p->information, name,
+ key, SPACK, filename, lineno);
+ up->informationset=1;
+ }
+
+
+ /* Read options common to all programs */
+ GAL_CONFIGFILES_READ_COMMONOPTIONS_FROM_CONF
+
+
+ else
+ error_at_line(EXIT_FAILURE, 0, filename, lineno,
+ "`%s` not recognized.\n", name);
+ }
+
+ free(line);
+ fclose(fp);
+}
+
+
+
+
+
+void
+printvalues(FILE *fp, struct tableparams *p)
+{
+ /*struct uiparams *up=&p->up;*/
+ struct gal_commonparams *cp=&p->cp;
+
+
+ /* Print all the options that are set. Separate each group with a
+ commented line explaining the options in that group. */
+ fprintf(fp, "\n# Input image:\n");
+ if(cp->hduset)
+ GAL_CHECKSET_PRINT_STRING_MAYBE_WITH_SPACE("hdu", cp->hdu);
+
+
+ /* For the operating mode, first put the macro to print the common
+ options, then the (possible options particular to this
+ program). */
+ fprintf(fp, "\n# Operating mode:\n");
+ GAL_CONFIGFILES_PRINT_COMMONOPTIONS;
+}
+
+
+
+
+
+
+/* Note that numthreads will be used automatically based on the
+ configure time. */
+void
+checkifset(struct tableparams *p)
+{
+ /*struct uiparams *up=&p->up;*/
+ struct gal_commonparams *cp=&p->cp;
+
+ int intro=0;
+ if(cp->hduset==0)
+ GAL_CONFIGFILES_REPORT_NOTSET("hdu");
+
+
+ GAL_CONFIGFILES_END_OF_NOTSET_REPORT;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**************************************************************/
+/*************** Sanity Check *******************/
+/**************************************************************/
+void
+sanitycheck(struct tableparams *p)
+{
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**************************************************************/
+/*************** Preparations *******************/
+/**************************************************************/
+void
+preparearrays(struct tableparams *p)
+{
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**************************************************************/
+/************ Set the parameters *************/
+/**************************************************************/
+void
+setparams(int argc, char *argv[], struct tableparams *p)
+{
+ struct gal_commonparams *cp=&p->cp;
+
+ /* Set the non-zero initial values, the structure was initialized to
+ have a zero value for all elements. */
+ cp->spack = SPACK;
+ cp->verb = 1;
+ cp->numthreads = num_processors(NPROC_CURRENT);
+ cp->removedirinfo = 1;
+
+ /* Read the arguments. */
+ errno=0;
+ if(argp_parse(&thisargp, argc, argv, 0, 0, p))
+ error(EXIT_FAILURE, errno, "parsing arguments");
+
+ /* Add the user default values and save them if asked. */
+ GAL_CONFIGFILES_CHECK_SET_CONFIG;
+
+ /* Check if all the required parameters are set. */
+ checkifset(p);
+
+ /* Print the values for each parameter. */
+ if(cp->printparams)
+ GAL_CONFIGFILES_REPORT_PARAMETERS_SET;
+
+ /* Do a sanity check. */
+ sanitycheck(p);
+
+ /* Make the array of input images. */
+ preparearrays(p);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**************************************************************/
+/************ Free allocated, report *************/
+/**************************************************************/
+void
+freeandreport(struct tableparams *p)
+{
+ /* Free the allocated arrays: */
+ free(p->cp.hdu);
+ free(p->cp.output);
+
+ /* Close the FITS file:
+ if(fits_close_file(p->fptr, &status))
+ gal_fits_io_error(status, NULL);
+ */
+
+}
diff --git a/src/table/ui.h b/src/table/ui.h
new file mode 100644
index 0000000..c200304
--- /dev/null
+++ b/src/table/ui.h
@@ -0,0 +1,32 @@
+/*********************************************************************
+Table - View and manipulate a FITS table structures.
+Table is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+ Mohammad Akhlaghi <address@hidden>
+Contributing author(s):
+Copyright (C) 2016, Free Software Foundation, Inc.
+
+Gnuastro is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#ifndef UI_H
+#define UI_H
+
+void
+setparams(int argc, char *argv[], struct tableparams *p);
+
+void
+freeandreport(struct tableparams *p);
+
+#endif
- [gnuastro-commits] master updated (a1e40c8 -> b78b0c7), Mohammad Akhlaghi, 2016/08/24
- [gnuastro-commits] master 474db42 07/16: Table and TEMPLATE added to the genauthors, Mohammad Akhlaghi, 2016/08/24
- [gnuastro-commits] master 56bd4e5 03/16: checkset func for some option value allocations, Mohammad Akhlaghi, 2016/08/24
- [gnuastro-commits] master c113fc3 09/16: Allocation for FITS types by datatype, not bitpix, Mohammad Akhlaghi, 2016/08/24
- [gnuastro-commits] master 9c7d9a0 10/16: Blank replacement function now accepts datatype, Mohammad Akhlaghi, 2016/08/24
- [gnuastro-commits] master 2071999 08/16: Blank CFITSIO pointers set by datatype, not bitpix, Mohammad Akhlaghi, 2016/08/24
- [gnuastro-commits] master 01dfb1b 05/16: Some code management in Table, Mohammad Akhlaghi, 2016/08/24
- [gnuastro-commits] master d09e850 04/16: FITS table column information printed by Table, Mohammad Akhlaghi, 2016/08/24
- [gnuastro-commits] master 5606978 11/16: Configuration file in tests/during-dev.sh, Mohammad Akhlaghi, 2016/08/24
- [gnuastro-commits] master c719806 06/16: Table accepts specified column number, name and regex, Mohammad Akhlaghi, 2016/08/24
- [gnuastro-commits] master 647406f 02/16: Table utility bare minimum structure in place,
Mohammad Akhlaghi <=
- [gnuastro-commits] master ad16c2a 12/16: Cosmetic changes in fits and txtarray libraries, Mohammad Akhlaghi, 2016/08/24
- [gnuastro-commits] master b16c7a4 15/16: New Section added to the book for Table, Mohammad Akhlaghi, 2016/08/24
- [gnuastro-commits] master cd5b5cf 13/16: Table prints contents of a FITS table, Mohammad Akhlaghi, 2016/08/24
- [gnuastro-commits] master b553085 01/16: Template for creating a new utility added, Mohammad Akhlaghi, 2016/08/24
- [gnuastro-commits] master ce08c34 14/16: FITS (binary) tables <--> plain text in Table, Mohammad Akhlaghi, 2016/08/24
- [gnuastro-commits] master b78b0c7 16/16: New Table utility merged, Mohammad Akhlaghi, 2016/08/24