mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 15:21:11 +00:00
updated
This commit is contained in:
parent
4d4d27e86b
commit
0ca75f1846
7 changed files with 1468 additions and 28 deletions
|
@ -1,11 +1,11 @@
|
|||
PROGS= showZobov
|
||||
PROGS= showZobov buildObservedVoids
|
||||
|
||||
CXX=g++
|
||||
CC=gcc
|
||||
|
||||
include config.mk
|
||||
|
||||
SOURCES= showZobov.cpp loadZobov.cpp zobovConf.c
|
||||
SOURCES= showZobov.cpp loadZobov.cpp zobovConf.c buildObservedVoids.cpp
|
||||
|
||||
LIBS= $(LDFLAGS)
|
||||
|
||||
|
@ -15,6 +15,8 @@ showZobov: showZobov.o loadZobov.o zobovConf.o
|
|||
|
||||
testZobov: testZobov.o loadZobov.o
|
||||
|
||||
buildObservedVoids: buildObservedVoids.o loadZobov.o buildObservedVoids_conf.o
|
||||
|
||||
depend: $(SOURCES)
|
||||
@echo "[DEPENDS] $^"
|
||||
@$(CC) $(CPPFLAGS) -M -MM $^ > .mydepends
|
||||
|
@ -36,7 +38,11 @@ clean:
|
|||
|
||||
zobovConf.c zobovConf.h: showZobov.ggo Makefile
|
||||
@echo "[OPT] $@"
|
||||
gengetopt -i $< -f zobovConf -a zobovConf_info -F zobovConf -C
|
||||
@gengetopt -i $< -f zobovConf -a zobovConf_info -F zobovConf -C
|
||||
|
||||
buildObservedVoids_conf.c buildObservedVoids_conf.h: buildObservedVoids.ggo Makefile
|
||||
@echo "[OPT] $@"
|
||||
@gengetopt -i $< -f buildObservedVoids_conf -a buildObservedVoids_info -F buildObservedVoids_conf -C
|
||||
|
||||
%.o: %.c
|
||||
@echo "[C] $< ..."
|
||||
|
|
1020
mytools/buildObservedVoids_conf.c
Normal file
1020
mytools/buildObservedVoids_conf.c
Normal file
File diff suppressed because it is too large
Load diff
239
mytools/buildObservedVoids_conf.h
Normal file
239
mytools/buildObservedVoids_conf.h
Normal file
|
@ -0,0 +1,239 @@
|
|||
/** @file buildObservedVoids_conf.h
|
||||
* @brief The header file for the command line option parser
|
||||
* generated by GNU Gengetopt version 2.22.2
|
||||
* http://www.gnu.org/software/gengetopt.
|
||||
* DO NOT modify this file, since it can be overwritten
|
||||
* @author GNU Gengetopt by Lorenzo Bettini */
|
||||
|
||||
#ifndef BUILDOBSERVEDVOIDS_CONF_H
|
||||
#define BUILDOBSERVEDVOIDS_CONF_H
|
||||
|
||||
/* If we use autoconf. */
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h> /* for FILE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifndef BUILDOBSERVEDVOIDS_CONF_PACKAGE
|
||||
/** @brief the program name (used for printing errors) */
|
||||
#define BUILDOBSERVEDVOIDS_CONF_PACKAGE "buildObservedVoids"
|
||||
#endif
|
||||
|
||||
#ifndef BUILDOBSERVEDVOIDS_CONF_PACKAGE_NAME
|
||||
/** @brief the complete program name (used for help and version) */
|
||||
#define BUILDOBSERVEDVOIDS_CONF_PACKAGE_NAME "buildObservedVoids"
|
||||
#endif
|
||||
|
||||
#ifndef BUILDOBSERVEDVOIDS_CONF_VERSION
|
||||
/** @brief the program version */
|
||||
#define BUILDOBSERVEDVOIDS_CONF_VERSION "0"
|
||||
#endif
|
||||
|
||||
/** @brief Where the command line options are stored */
|
||||
struct buildObservedVoids_info
|
||||
{
|
||||
const char *help_help; /**< @brief Print help and exit help description. */
|
||||
const char *version_help; /**< @brief Print version and exit help description. */
|
||||
char * desc_arg; /**< @brief The description file name for the voids (jozov generated). */
|
||||
char * desc_orig; /**< @brief The description file name for the voids (jozov generated) original value given at command line. */
|
||||
const char *desc_help; /**< @brief The description file name for the voids (jozov generated) help description. */
|
||||
char * adj_arg; /**< @brief Adjacent file name (jozov generated). */
|
||||
char * adj_orig; /**< @brief Adjacent file name (jozov generated) original value given at command line. */
|
||||
const char *adj_help; /**< @brief Adjacent file name (jozov generated) help description. */
|
||||
char * void_arg; /**< @brief Void/zone bind filename (jozov generated). */
|
||||
char * void_orig; /**< @brief Void/zone bind filename (jozov generated) original value given at command line. */
|
||||
const char *void_help; /**< @brief Void/zone bind filename (jozov generated) help description. */
|
||||
double minProba_arg; /**< @brief Minimal probability to accept (default='0.0'). */
|
||||
char * minProba_orig; /**< @brief Minimal probability to accept original value given at command line. */
|
||||
const char *minProba_help; /**< @brief Minimal probability to accept help description. */
|
||||
double densityThreshold_arg; /**< @brief Density threshold to consider a stable void (default='-0.8'). */
|
||||
char * densityThreshold_orig; /**< @brief Density threshold to consider a stable void original value given at command line. */
|
||||
const char *densityThreshold_help; /**< @brief Density threshold to consider a stable void help description. */
|
||||
char * ramsesDir_arg; /**< @brief Ramses base output directory. */
|
||||
char * ramsesDir_orig; /**< @brief Ramses base output directory original value given at command line. */
|
||||
const char *ramsesDir_help; /**< @brief Ramses base output directory help description. */
|
||||
int ramsesId_arg; /**< @brief Ramses output id. */
|
||||
char * ramsesId_orig; /**< @brief Ramses output id original value given at command line. */
|
||||
const char *ramsesId_help; /**< @brief Ramses output id help description. */
|
||||
char * configFile_arg; /**< @brief Configuration file. */
|
||||
char * configFile_orig; /**< @brief Configuration file original value given at command line. */
|
||||
const char *configFile_help; /**< @brief Configuration file help description. */
|
||||
char * output_arg; /**< @brief Output file (default='void_info.txt'). */
|
||||
char * output_orig; /**< @brief Output file original value given at command line. */
|
||||
const char *output_help; /**< @brief Output file help description. */
|
||||
char * gridOutput_arg; /**< @brief 3d grid output of voids (default='all_voids.nc'). */
|
||||
char * gridOutput_orig; /**< @brief 3d grid output of voids original value given at command line. */
|
||||
const char *gridOutput_help; /**< @brief 3d grid output of voids help description. */
|
||||
int quiet_flag; /**< @brief Quiet output (default=off). */
|
||||
const char *quiet_help; /**< @brief Quiet output help description. */
|
||||
|
||||
unsigned int help_given ; /**< @brief Whether help was given. */
|
||||
unsigned int version_given ; /**< @brief Whether version was given. */
|
||||
unsigned int desc_given ; /**< @brief Whether desc was given. */
|
||||
unsigned int adj_given ; /**< @brief Whether adj was given. */
|
||||
unsigned int void_given ; /**< @brief Whether void was given. */
|
||||
unsigned int minProba_given ; /**< @brief Whether minProba was given. */
|
||||
unsigned int densityThreshold_given ; /**< @brief Whether densityThreshold was given. */
|
||||
unsigned int ramsesDir_given ; /**< @brief Whether ramsesDir was given. */
|
||||
unsigned int ramsesId_given ; /**< @brief Whether ramsesId was given. */
|
||||
unsigned int configFile_given ; /**< @brief Whether configFile was given. */
|
||||
unsigned int output_given ; /**< @brief Whether output was given. */
|
||||
unsigned int gridOutput_given ; /**< @brief Whether gridOutput was given. */
|
||||
unsigned int quiet_given ; /**< @brief Whether quiet was given. */
|
||||
|
||||
} ;
|
||||
|
||||
/** @brief The additional parameters to pass to parser functions */
|
||||
struct buildObservedVoids_conf_params
|
||||
{
|
||||
int override; /**< @brief whether to override possibly already present options (default 0) */
|
||||
int initialize; /**< @brief whether to initialize the option structure buildObservedVoids_info (default 1) */
|
||||
int check_required; /**< @brief whether to check that all required options were provided (default 1) */
|
||||
int check_ambiguity; /**< @brief whether to check for options already specified in the option structure buildObservedVoids_info (default 0) */
|
||||
int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */
|
||||
} ;
|
||||
|
||||
/** @brief the purpose string of the program */
|
||||
extern const char *buildObservedVoids_info_purpose;
|
||||
/** @brief the usage string of the program */
|
||||
extern const char *buildObservedVoids_info_usage;
|
||||
/** @brief all the lines making the help output */
|
||||
extern const char *buildObservedVoids_info_help[];
|
||||
|
||||
/**
|
||||
* The command line parser
|
||||
* @param argc the number of command line options
|
||||
* @param argv the command line options
|
||||
* @param args_info the structure where option information will be stored
|
||||
* @return 0 if everything went fine, NON 0 if an error took place
|
||||
*/
|
||||
int buildObservedVoids_conf (int argc, char * const *argv,
|
||||
struct buildObservedVoids_info *args_info);
|
||||
|
||||
/**
|
||||
* The command line parser (version with additional parameters - deprecated)
|
||||
* @param argc the number of command line options
|
||||
* @param argv the command line options
|
||||
* @param args_info the structure where option information will be stored
|
||||
* @param override whether to override possibly already present options
|
||||
* @param initialize whether to initialize the option structure my_args_info
|
||||
* @param check_required whether to check that all required options were provided
|
||||
* @return 0 if everything went fine, NON 0 if an error took place
|
||||
* @deprecated use buildObservedVoids_conf_ext() instead
|
||||
*/
|
||||
int buildObservedVoids_conf2 (int argc, char * const *argv,
|
||||
struct buildObservedVoids_info *args_info,
|
||||
int override, int initialize, int check_required);
|
||||
|
||||
/**
|
||||
* The command line parser (version with additional parameters)
|
||||
* @param argc the number of command line options
|
||||
* @param argv the command line options
|
||||
* @param args_info the structure where option information will be stored
|
||||
* @param params additional parameters for the parser
|
||||
* @return 0 if everything went fine, NON 0 if an error took place
|
||||
*/
|
||||
int buildObservedVoids_conf_ext (int argc, char * const *argv,
|
||||
struct buildObservedVoids_info *args_info,
|
||||
struct buildObservedVoids_conf_params *params);
|
||||
|
||||
/**
|
||||
* Save the contents of the option struct into an already open FILE stream.
|
||||
* @param outfile the stream where to dump options
|
||||
* @param args_info the option struct to dump
|
||||
* @return 0 if everything went fine, NON 0 if an error took place
|
||||
*/
|
||||
int buildObservedVoids_conf_dump(FILE *outfile,
|
||||
struct buildObservedVoids_info *args_info);
|
||||
|
||||
/**
|
||||
* Save the contents of the option struct into a (text) file.
|
||||
* This file can be read by the config file parser (if generated by gengetopt)
|
||||
* @param filename the file where to save
|
||||
* @param args_info the option struct to save
|
||||
* @return 0 if everything went fine, NON 0 if an error took place
|
||||
*/
|
||||
int buildObservedVoids_conf_file_save(const char *filename,
|
||||
struct buildObservedVoids_info *args_info);
|
||||
|
||||
/**
|
||||
* Print the help
|
||||
*/
|
||||
void buildObservedVoids_conf_print_help(void);
|
||||
/**
|
||||
* Print the version
|
||||
*/
|
||||
void buildObservedVoids_conf_print_version(void);
|
||||
|
||||
/**
|
||||
* Initializes all the fields a buildObservedVoids_conf_params structure
|
||||
* to their default values
|
||||
* @param params the structure to initialize
|
||||
*/
|
||||
void buildObservedVoids_conf_params_init(struct buildObservedVoids_conf_params *params);
|
||||
|
||||
/**
|
||||
* Allocates dynamically a buildObservedVoids_conf_params structure and initializes
|
||||
* all its fields to their default values
|
||||
* @return the created and initialized buildObservedVoids_conf_params structure
|
||||
*/
|
||||
struct buildObservedVoids_conf_params *buildObservedVoids_conf_params_create(void);
|
||||
|
||||
/**
|
||||
* Initializes the passed buildObservedVoids_info structure's fields
|
||||
* (also set default values for options that have a default)
|
||||
* @param args_info the structure to initialize
|
||||
*/
|
||||
void buildObservedVoids_conf_init (struct buildObservedVoids_info *args_info);
|
||||
/**
|
||||
* Deallocates the string fields of the buildObservedVoids_info structure
|
||||
* (but does not deallocate the structure itself)
|
||||
* @param args_info the structure to deallocate
|
||||
*/
|
||||
void buildObservedVoids_conf_free (struct buildObservedVoids_info *args_info);
|
||||
|
||||
/**
|
||||
* The config file parser (deprecated version)
|
||||
* @param filename the name of the config file
|
||||
* @param args_info the structure where option information will be stored
|
||||
* @param override whether to override possibly already present options
|
||||
* @param initialize whether to initialize the option structure my_args_info
|
||||
* @param check_required whether to check that all required options were provided
|
||||
* @return 0 if everything went fine, NON 0 if an error took place
|
||||
* @deprecated use buildObservedVoids_conf_config_file() instead
|
||||
*/
|
||||
int buildObservedVoids_conf_configfile (const char *filename,
|
||||
struct buildObservedVoids_info *args_info,
|
||||
int override, int initialize, int check_required);
|
||||
|
||||
/**
|
||||
* The config file parser
|
||||
* @param filename the name of the config file
|
||||
* @param args_info the structure where option information will be stored
|
||||
* @param params additional parameters for the parser
|
||||
* @return 0 if everything went fine, NON 0 if an error took place
|
||||
*/
|
||||
int buildObservedVoids_conf_config_file (const char *filename,
|
||||
struct buildObservedVoids_info *args_info,
|
||||
struct buildObservedVoids_conf_params *params);
|
||||
|
||||
/**
|
||||
* Checks that all the required options were specified
|
||||
* @param args_info the structure to check
|
||||
* @param prog_name the name of the program that will be used to print
|
||||
* possible errors
|
||||
* @return
|
||||
*/
|
||||
int buildObservedVoids_conf_required (struct buildObservedVoids_info *args_info,
|
||||
const char *prog_name);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* BUILDOBSERVEDVOIDS_CONF_H */
|
|
@ -1,6 +1,6 @@
|
|||
CC= gcc
|
||||
CXX= g++
|
||||
CPPFLAGS= -I$(HOME)/Science/Software/CosmoToolbox/install/include
|
||||
LDFLAGS= -L$(HOME)/Science/Software/CosmoToolbox/install/lib -lCosmoTool
|
||||
CXXFLAGS= $(CPPFLAGS) -ggdb -O0 -ffast-math
|
||||
CFLAGS= $(CPPFLAGS) -ggdb -O0 -ffast-math
|
||||
CPPFLAGS=
|
||||
LDFLAGS= -lCosmoTool
|
||||
CXXFLAGS= $(CPPFLAGS) -ggdb -O3 -ffast-math
|
||||
CFLAGS= $(CPPFLAGS) -ggdb -O3 -ffast-math
|
||||
|
|
156
mytools/voidTree.hpp
Normal file
156
mytools/voidTree.hpp
Normal file
|
@ -0,0 +1,156 @@
|
|||
#ifndef _VOID_TREE_HPP
|
||||
#define _VOID_TREE_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <stdint.h>
|
||||
#include "loadZobov.hpp"
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
struct VoidNode
|
||||
{
|
||||
int vid;
|
||||
VoidNode *parent;
|
||||
std::list<VoidNode *> children;
|
||||
};
|
||||
|
||||
class VoidTree
|
||||
{
|
||||
protected:
|
||||
uint32_t totalNumNodes;
|
||||
VoidNode *nodes;
|
||||
VoidNode *rootNode;
|
||||
ZobovRep& zobov;
|
||||
public:
|
||||
typedef std::list<VoidNode *> VoidList;
|
||||
|
||||
int lookupParent(int voidId)
|
||||
{
|
||||
std::set<ZobovZone *> sref;
|
||||
sref.insert(zobov.allVoids[voidId].zId.begin(), zobov.allVoids[voidId].zId.end());
|
||||
|
||||
|
||||
std::vector<ZobovZone *> sout(sref.size());
|
||||
int lastSize = 0x7fffffff;
|
||||
int goodParent = voidId;
|
||||
|
||||
// Voids are sorted according to volume
|
||||
for (int i = voidId-1; i >= 0; i--)
|
||||
{
|
||||
std::set<ZobovZone *> s1;
|
||||
|
||||
int counter = 0;
|
||||
s1.insert(zobov.allVoids[i].zId.begin(), zobov.allVoids[i].zId.end());
|
||||
for (std::set<ZobovZone *>::iterator iter = s1.begin(), iter2 = sref.begin();
|
||||
iter != s1.end() && iter2 != sref.end();
|
||||
++iter)
|
||||
{
|
||||
if (*iter == *iter2)
|
||||
{
|
||||
counter++;
|
||||
++iter2;
|
||||
}
|
||||
else while (*iter > *iter2 && iter2 != sref.end())
|
||||
++iter2;
|
||||
}
|
||||
|
||||
if (counter == sref.size() && s1.size() < lastSize)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
VoidTree(ZobovRep& rep)
|
||||
: zobov(rep)
|
||||
{
|
||||
totalNumNodes = rep.allVoids.size();
|
||||
|
||||
nodes = new VoidNode[totalNumNodes];
|
||||
|
||||
for (int i = 0; i < rep.allVoids.size(); i++)
|
||||
{
|
||||
nodes[i].vid = i;
|
||||
nodes[i].parent = 0;
|
||||
nodes[i].children.clear();
|
||||
}
|
||||
|
||||
std::cout << "Linking voids together..." << std::endl;
|
||||
double volMin = 4*M_PI/3*pow(4.*512/500.,3);
|
||||
int inserted = 0;
|
||||
for (int i = rep.allVoids.size()-1; i>=0;i--)
|
||||
{
|
||||
if (rep.allVoids[i].volume < volMin) continue;
|
||||
|
||||
int p = lookupParent(i);
|
||||
|
||||
std::cout << i << std::endl;
|
||||
|
||||
if (p < 0)
|
||||
{
|
||||
if (i != 0)
|
||||
std::cerr << "Warning ! Voids without parent and it is not the root !" << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
nodes[p].children.push_back(&nodes[i]);
|
||||
nodes[i].parent = &nodes[p];
|
||||
inserted++;
|
||||
}
|
||||
|
||||
rootNode = 0;
|
||||
for (int i = inserted; i < totalNumNodes; i++)
|
||||
if (nodes[i].parent == 0)
|
||||
{
|
||||
if (rootNode != 0)
|
||||
{
|
||||
std::cerr << "Multiple root to the tree !!!" << std::endl;
|
||||
abort();
|
||||
}
|
||||
rootNode = &nodes[i];
|
||||
}
|
||||
}
|
||||
|
||||
~VoidTree()
|
||||
{
|
||||
delete[] nodes;
|
||||
}
|
||||
|
||||
int getParent(int vid) const
|
||||
{
|
||||
assert(nodes[vid].parent != 0);
|
||||
return nodes[vid].parent->vid;
|
||||
}
|
||||
|
||||
const VoidList& getChildren(int vid) const
|
||||
{
|
||||
return nodes[vid].children;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
void walkNode(VoidNode *node, T& traverse)
|
||||
{
|
||||
VoidList::iterator i;
|
||||
|
||||
if (!traverse(node))
|
||||
return;
|
||||
|
||||
while (i != node->children.end())
|
||||
{
|
||||
walkNode(*i, traverse);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void walk(T& traverse)
|
||||
{
|
||||
walkNode(rootNode, traverse);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
File autogenerated by gengetopt version 2.22
|
||||
File autogenerated by gengetopt version 2.22.2
|
||||
generated with the following command:
|
||||
gengetopt -i showZobov.ggo -f zobovConf -a zobovConf_info -F zobovConf -C
|
||||
|
||||
|
@ -17,6 +17,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef FIX_UNUSED
|
||||
#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
|
||||
#endif
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
#include "zobovConf.h"
|
||||
|
@ -119,6 +123,7 @@ void clear_given (struct zobovConf_info *args_info)
|
|||
static
|
||||
void clear_args (struct zobovConf_info *args_info)
|
||||
{
|
||||
FIX_UNUSED (args_info);
|
||||
args_info->desc_arg = NULL;
|
||||
args_info->desc_orig = NULL;
|
||||
args_info->adj_arg = NULL;
|
||||
|
@ -173,7 +178,9 @@ void init_args_info(struct zobovConf_info *args_info)
|
|||
void
|
||||
zobovConf_print_version (void)
|
||||
{
|
||||
printf ("%s %s\n", ZOBOVCONF_PACKAGE, ZOBOVCONF_VERSION);
|
||||
printf ("%s %s\n",
|
||||
(strlen(ZOBOVCONF_PACKAGE_NAME) ? ZOBOVCONF_PACKAGE_NAME : ZOBOVCONF_PACKAGE),
|
||||
ZOBOVCONF_VERSION);
|
||||
}
|
||||
|
||||
static void print_help_common(void) {
|
||||
|
@ -188,7 +195,7 @@ static void print_help_common(void) {
|
|||
printf("\n");
|
||||
|
||||
if (strlen(zobovConf_info_description) > 0)
|
||||
printf("%s\n", zobovConf_info_description);
|
||||
printf("%s\n\n", zobovConf_info_description);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -270,8 +277,9 @@ zobovConf_release (struct zobovConf_info *args_info)
|
|||
|
||||
|
||||
static void
|
||||
write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[])
|
||||
write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
|
||||
{
|
||||
FIX_UNUSED (values);
|
||||
if (arg) {
|
||||
fprintf(outfile, "%s=\"%s\"\n", opt, arg);
|
||||
} else {
|
||||
|
@ -361,7 +369,7 @@ zobovConf_free (struct zobovConf_info *args_info)
|
|||
char *
|
||||
gengetopt_strdup (const char *s)
|
||||
{
|
||||
char *result = NULL;
|
||||
char *result = 0;
|
||||
if (!s)
|
||||
return result;
|
||||
|
||||
|
@ -383,7 +391,7 @@ zobovConf_ext (int argc, char * const *argv, struct zobovConf_info *args_info,
|
|||
struct zobovConf_params *params)
|
||||
{
|
||||
int result;
|
||||
result = zobovConf_internal (argc, argv, args_info, params, NULL);
|
||||
result = zobovConf_internal (argc, argv, args_info, params, 0);
|
||||
|
||||
if (result == EXIT_FAILURE)
|
||||
{
|
||||
|
@ -406,7 +414,7 @@ zobovConf2 (int argc, char * const *argv, struct zobovConf_info *args_info, int
|
|||
params.check_ambiguity = 0;
|
||||
params.print_errors = 1;
|
||||
|
||||
result = zobovConf_internal (argc, argv, args_info, ¶ms, NULL);
|
||||
result = zobovConf_internal (argc, argv, args_info, ¶ms, 0);
|
||||
|
||||
if (result == EXIT_FAILURE)
|
||||
{
|
||||
|
@ -422,7 +430,7 @@ zobovConf_required (struct zobovConf_info *args_info, const char *prog_name)
|
|||
{
|
||||
int result = EXIT_SUCCESS;
|
||||
|
||||
if (zobovConf_required2(args_info, prog_name, NULL) > 0)
|
||||
if (zobovConf_required2(args_info, prog_name, 0) > 0)
|
||||
result = EXIT_FAILURE;
|
||||
|
||||
if (result == EXIT_FAILURE)
|
||||
|
@ -437,6 +445,7 @@ zobovConf_required (struct zobovConf_info *args_info, const char *prog_name)
|
|||
int
|
||||
zobovConf_required2 (struct zobovConf_info *args_info, const char *prog_name, const char *additional_error)
|
||||
{
|
||||
FIX_UNUSED (additional_error);
|
||||
int error = 0;
|
||||
|
||||
/* checks for required options */
|
||||
|
@ -500,13 +509,15 @@ static char *package_name = 0;
|
|||
static
|
||||
int update_arg(void *field, char **orig_field,
|
||||
unsigned int *field_given, unsigned int *prev_given,
|
||||
char *value, char *possible_values[], const char *default_value,
|
||||
char *value, const char *possible_values[],
|
||||
const char *default_value,
|
||||
zobovConf_arg_type arg_type,
|
||||
int check_ambiguity, int override,
|
||||
int no_free, int multiple_option,
|
||||
const char *long_opt, char short_opt,
|
||||
const char *additional_error)
|
||||
{
|
||||
FIX_UNUSED (field);
|
||||
char *stop_char = 0;
|
||||
const char *val = value;
|
||||
int found;
|
||||
|
@ -528,6 +539,7 @@ int update_arg(void *field, char **orig_field,
|
|||
return 1; /* failure */
|
||||
}
|
||||
|
||||
FIX_UNUSED (default_value);
|
||||
|
||||
if (field_given && *field_given && ! override)
|
||||
return 0;
|
||||
|
@ -595,7 +607,8 @@ int update_arg(void *field, char **orig_field,
|
|||
|
||||
|
||||
int
|
||||
zobovConf_internal (int argc, char * const *argv, struct zobovConf_info *args_info,
|
||||
zobovConf_internal (
|
||||
int argc, char * const *argv, struct zobovConf_info *args_info,
|
||||
struct zobovConf_params *params, const char *additional_error)
|
||||
{
|
||||
int c; /* Character of the parsed option. */
|
||||
|
@ -647,7 +660,7 @@ zobovConf_internal (int argc, char * const *argv, struct zobovConf_info *args_in
|
|||
{ "galax", 0, NULL, 0 },
|
||||
{ "output", 1, NULL, 'o' },
|
||||
{ "interactive", 0, NULL, 0 },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
c = getopt_long (argc, argv, "hVd:a:v:i:slm:b:r:f:qp:o:", long_options, &option_index);
|
||||
|
@ -883,7 +896,7 @@ failure:
|
|||
/* 3 is for "--" and "=" */
|
||||
|
||||
static int
|
||||
_zobovConf_configfile (char * const filename, int *my_argc)
|
||||
_zobovConf_configfile (const char *filename, int *my_argc)
|
||||
{
|
||||
FILE* file;
|
||||
char my_argv[CONFIG_FILE_LINE_BUFFER_SIZE+1];
|
||||
|
@ -895,14 +908,14 @@ _zobovConf_configfile (char * const filename, int *my_argc)
|
|||
size_t len, next_token;
|
||||
char delimiter;
|
||||
|
||||
if ((file = fopen(filename, "r")) == NULL)
|
||||
if ((file = fopen(filename, "r")) == 0)
|
||||
{
|
||||
fprintf (stderr, "%s: Error opening configuration file '%s'\n",
|
||||
ZOBOVCONF_PACKAGE, filename);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while ((fgets(linebuf, CONFIG_FILE_LINE_SIZE, file)) != NULL)
|
||||
while ((fgets(linebuf, CONFIG_FILE_LINE_SIZE, file)) != 0)
|
||||
{
|
||||
++line_num;
|
||||
my_argv[0] = '\0';
|
||||
|
@ -929,7 +942,7 @@ _zobovConf_configfile (char * const filename, int *my_argc)
|
|||
|
||||
if (fopt[next_token] == '\0') /* the line is over */
|
||||
{
|
||||
farg = NULL;
|
||||
farg = 0;
|
||||
equal = 0;
|
||||
goto noarg;
|
||||
}
|
||||
|
@ -1020,7 +1033,8 @@ _zobovConf_configfile (char * const filename, int *my_argc)
|
|||
}
|
||||
|
||||
int
|
||||
zobovConf_configfile (char * const filename,
|
||||
zobovConf_configfile (
|
||||
const char *filename,
|
||||
struct zobovConf_info *args_info,
|
||||
int override, int initialize, int check_required)
|
||||
{
|
||||
|
@ -1036,7 +1050,7 @@ zobovConf_configfile (char * const filename,
|
|||
}
|
||||
|
||||
int
|
||||
zobovConf_config_file (char * const filename,
|
||||
zobovConf_config_file (const char *filename,
|
||||
struct zobovConf_info *args_info,
|
||||
struct zobovConf_params *params)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/** @file zobovConf.h
|
||||
* @brief The header file for the command line option parser
|
||||
* generated by GNU Gengetopt version 2.22
|
||||
* generated by GNU Gengetopt version 2.22.2
|
||||
* http://www.gnu.org/software/gengetopt.
|
||||
* DO NOT modify this file, since it can be overwritten
|
||||
* @author GNU Gengetopt by Lorenzo Bettini */
|
||||
|
@ -20,10 +20,15 @@ extern "C" {
|
|||
#endif /* __cplusplus */
|
||||
|
||||
#ifndef ZOBOVCONF_PACKAGE
|
||||
/** @brief the program name */
|
||||
/** @brief the program name (used for printing errors) */
|
||||
#define ZOBOVCONF_PACKAGE "showZobov"
|
||||
#endif
|
||||
|
||||
#ifndef ZOBOVCONF_PACKAGE_NAME
|
||||
/** @brief the complete program name (used for help and version) */
|
||||
#define ZOBOVCONF_PACKAGE_NAME "showZobov"
|
||||
#endif
|
||||
|
||||
#ifndef ZOBOVCONF_VERSION
|
||||
/** @brief the program version */
|
||||
#define ZOBOVCONF_VERSION "0"
|
||||
|
@ -214,7 +219,7 @@ void zobovConf_free (struct zobovConf_info *args_info);
|
|||
* @return 0 if everything went fine, NON 0 if an error took place
|
||||
* @deprecated use zobovConf_config_file() instead
|
||||
*/
|
||||
int zobovConf_configfile (char * const filename,
|
||||
int zobovConf_configfile (const char *filename,
|
||||
struct zobovConf_info *args_info,
|
||||
int override, int initialize, int check_required);
|
||||
|
||||
|
@ -225,7 +230,7 @@ int zobovConf_configfile (char * const filename,
|
|||
* @param params additional parameters for the parser
|
||||
* @return 0 if everything went fine, NON 0 if an error took place
|
||||
*/
|
||||
int zobovConf_config_file (char * const filename,
|
||||
int zobovConf_config_file (const char *filename,
|
||||
struct zobovConf_info *args_info,
|
||||
struct zobovConf_params *params);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue