![]() |
![]() |
![]() |
PHOEBE Reference Manual | ![]() |
---|---|---|---|---|
PHOEBE_config_entry; extern PHOEBE_config_entry **PHOEBE_config_table; extern int PHOEBE_config_table_size; PHOEBE_config_entry* phoebe_config_entry_new (); int phoebe_config_entry_add (PHOEBE_type type, char *keyword, ...); int phoebe_config_entry_get (char *keyword, ...); int phoebe_config_entry_set (char *keyword, ...); int phoebe_config_entry_free (PHOEBE_config_entry *entry); int phoebe_config_populate (); int phoebe_config_free (); int phoebe_configure (); int phoebe_config_peek (char *filename); int phoebe_config_load (char *filename); int phoebe_config_save (char *filename); int phoebe_config_import (char *filename);
typedef struct { PHOEBE_type type; char *keyword; PHOEBE_value *value; PHOEBE_value *defval; } PHOEBE_config_entry;
PHOEBE_config_entry* phoebe_config_entry_new ();
Initializes memory for PHOEBE_config_entry and NULLifies all structure
pointers. The memory should be freed by phoebe_config_entry_free()
once
the entry is no longer necessary.
Returns : |
a newly allocated PHOEBE_config_entry. |
int phoebe_config_entry_add (PHOEBE_type type, char *keyword, ...);
Adds a new configuration entry to the PHOEBE_config_table and bumps
the number of configuration entries PHOEBE_config_table_size (a
global variable) by 1. phoebe_config_entry_add()
is the only function
that should be used to add entries to the configuration table.
Examples:
status = phoebe_config_entry_add (PHOEBE_STRING, "PHOEBE_BASE_DIR", "/usr/local/share/phoebe"); status = phoebe_config_entry_add (PHOEBE_BOOL, "PHOEBE_LD_SWITCH", 1);
|
a PHOEBE_type of the configuration entry; TYPE_INT , TYPE_BOOL ,
TYPE_DOUBLE and TYPE_STRING are supported.
|
|
a string identifying the configuration entry. |
|
the default value of the configuration entry; the type of the
argument should match type .
|
Returns : |
PHOEBE_error_code. |
int phoebe_config_entry_get (char *keyword, ...);
Assigns the configuration option keyword
to the passed value.
Example:
char *tmpdir; int ldstate; status = phoebe_config_entry_get ("PHOEBE_TEMP_DIR", &tmpdir); status = phoebe_config_entry_get ("PHOEBE_LD_SWITCH", &ldstate);
Do not free the contents of so-assigned strings - these merely point to the actual values in the configuration table.
|
a string identifying the configuration entry. |
|
a reference to the value of the type that matches keyword type.
|
Returns : |
PHOEBE_error_code. |
int phoebe_config_entry_set (char *keyword, ...);
Sets the configuration option keyword
to the passed value.
Example:
status = phoebe_config_entry_set ("PHOEBE_TEMP_DIR", "/tmp"); status = phoebe_config_entry_set ("PHOEBE_LD_SWITCH", 0);
|
a string identifying the configuration entry. |
|
a value of the type that matches keyword type.
|
Returns : |
PHOEBE_error_code. |
int phoebe_config_entry_free (PHOEBE_config_entry *entry);
Frees the memory occupied by the configuration entry entry
.
|
a pointer to the configuration entry that should be freed. |
Returns : |
PHOEBE_error_code. |
int phoebe_config_populate ();
Initializes all configuration keywords and their default values and
adds them to the global PHOEBE_config_table. All drivers need to
implement their own *_config_populate()
function analogous to this
function.
Returns : |
PHOEBE_error_code. |
int phoebe_config_free ();
Frees all configuration entries in the global PHOEBE_config_table.
Returns : |
PHOEBE_error_code. |
int phoebe_configure ();
Looks for the configuration file, loads it (if found) and reads in the configuration entries. The configuration filename is hardcoded to phoebe.config (this should be changed in future), but the configuration directory PHOEBE_HOME_DIR can be set by the drivers.
The order of the checked config directories is:
1) PHOEBE_HOME_DIR if not NULL, 2) Current ~/.phoebe-VERSION (i.e. ~/.phoebe-0.32), 3) Previous (but compatible) ~/.phoebe-VERSIONs (i.e. ~/.phoebe-0.31, ~/.phoebe-0.30), in the decreasing order (most recent come first), 4) Legacy ~/.phoebe
If a legacy (pre-0.30) config file is found, its configuration entries will be imported. In all cases the configuration directory will be set to the current ~/.phoebe-VERSION so that saving a configuration file stores the settings to the current directory.
Once the configuration file is open, the function configures all PHOEBE features (passband transmission functions, limb darkening coefficients etc).
If the configuration file is not found, defaults are assumed.
Returns : |
int phoebe_config_peek (char *filename);
Use this function to peek into the configuration file. The function returns SUCCESS if the configuration file exists and conforms to the current version specs, ERROR_PHOEBE_CONFIG_LEGACY_FILE if the file exists but conforms to the earlier (legacy) versions of PHOEBE, and it returns ERROR_PHOEBE_CONFIG_NOT_FOUND or ERROR_PHOEBE_CONFIG_OPEN_FAILED if the file is not found or cannot be opened.
|
configuration filename |
Returns : |
PHOEBE_error_code. |
int phoebe_config_load (char *filename);
Opens a configuration file filename
and reads out all configuration
fields. The file has to conform to the current PHOEBE version (0.30)
specifications, namely KEYWORD = VALUE entries.
|
configuration filename. |
Returns : |
PHOEBE_error_code. |
int phoebe_config_save (char *filename);
Saves all entries in the global configuration table PHOEBE_config_table
to a configuration file filename
.
|
configuration filename. |
Returns : |
PHOEBE_error_code. |
int phoebe_config_import (char *filename);
Opens a pre-0.30 configuration file and reads out the entries. The configuration file had a hard-coded set of keywords that we check for one by one.
|
|
Returns : |
PHOEBE_error_code. |