1 /*********************************************************************
2 Functions to check and set command line argument values and files.
3 This is part of GNU Astronomy Utilities (Gnuastro) package.
4 
5 Original author:
6      Mohammad Akhlaghi <mohammad@akhlaghi.org>
7 Contributing author(s):
8 Copyright (C) 2015-2021, Free Software Foundation, Inc.
9 
10 Gnuastro is free software: you can redistribute it and/or modify it
11 under the terms of the GNU General Public License as published by the
12 Free Software Foundation, either version 3 of the License, or (at your
13 option) any later version.
14 
15 Gnuastro is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
22 **********************************************************************/
23 #ifndef __GAL_CHECKSET_H__
24 #define __GAL_CHECKSET_H__
25 
26 /* Include other headers if necessary here. Note that other header files
27    must be included before the C++ preparations below */
28 #include <math.h>
29 #include <fitsio.h>
30 #include <gsl/gsl_rng.h>
31 #include <gnuastro-internal/options.h>
32 
33 /* C++ Preparations */
34 #undef __BEGIN_C_DECLS
35 #undef __END_C_DECLS
36 #ifdef __cplusplus
37 # define __BEGIN_C_DECLS extern "C" {
38 # define __END_C_DECLS }
39 #else
40 # define __BEGIN_C_DECLS                /* empty */
41 # define __END_C_DECLS                  /* empty */
42 #endif
43 /* End of C++ preparations */
44 
45 
46 
47 /* Actual header contants (the above were for the Pre-processor). */
48 __BEGIN_C_DECLS  /* From C++ preparations */
49 
50 
51 
52 
53 /**************************************************************/
54 /**********               Environment              ************/
55 /**************************************************************/
56 gsl_rng *
57 gal_checkset_gsl_rng(uint8_t envseed_bool, const char **name,
58                      unsigned long int *seed);
59 
60 size_t
61 gal_checkset_ram_available(int quietmmap);
62 
63 int
64 gal_checkset_need_mmap(size_t bytesize, size_t minmapsize, int quietmmap);
65 
66 
67 
68 
69 /**************************************************************/
70 /**********          Check fixed strings           ************/
71 /**************************************************************/
72 void
73 gal_checkset_known_types(char *optarg, int *type, char *filename,
74                          size_t lineno);
75 
76 
77 
78 /**************************************************************/
79 /**********          My String functions:          ************/
80 /**************************************************************/
81 int
82 gal_checkset_string_has_space(char *in);
83 
84 char *
85 gal_checkset_malloc_cat(char *inname, char *toappend);
86 
87 void
88 gal_checkset_allocate_copy(const char *arg, char **copy);
89 
90 void
91 gal_checkset_allocate_copy_set(char *arg, char **copy, int *set);
92 
93 char *
94 gal_checkset_dataset_name(char *filename, char *hdu);
95 
96 
97 
98 
99 /**************************************************************/
100 /********** Set file names and check if they exist ************/
101 /**************************************************************/
102 char *
103 gal_checkset_dir_part(char *filename);
104 
105 char *
106 gal_checkset_not_dir_part(char *filename);
107 
108 char *
109 gal_checkset_suffix_separate(char *name, char **suffix);
110 
111 char *
112 gal_checkset_make_unique_suffix(char *reference, char *suffix);
113 
114 void
115 gal_checkset_check_file(char *filename);
116 
117 int
118 gal_checkset_check_file_return(char *filename);
119 
120 int
121 gal_checkset_writable_notexist(char *filename);
122 
123 void    /* keep==0 && dontdelete==0: file will be deleted if exists.*/
124 gal_checkset_writable_remove(char *filename, int keep, int dontdelete);
125 
126 int
127 gal_checkset_dir_0_file_1(char *name, int dontdelete);
128 
129 char *
130 gal_checkset_automatic_output(struct gal_options_common_params *cp,
131                               char *inname, char *suffix);
132 
133 void
134 gal_checkset_check_dir_write_add_slash(char **dirname);
135 
136 int
137 gal_checkset_mkdir(char *dirname);
138 
139 
140 
141 __END_C_DECLS    /* From C++ preparations */
142 
143 #endif           /* __GAL_CHECKSET_H__ */
144