Midgard2 Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties |
#include <midgard/midgard.h> typedef MidgardConfig; typedef MidgardConfigClass; MidgardConfigPrivate; enum MidgardDBType; MidgardConfig * midgard_config_new (void
); gboolean midgard_config_read_file (MidgardConfig *self
,const gchar *filename
,gboolean user
,GError **error
); gboolean midgard_config_read_file_at_path (MidgardConfig *self
,const gchar *filepath
,GError **error
); gboolean midgard_config_read_data (MidgardConfig *self
,const gchar *data
,GError **error
); gchar ** midgard_config_list_files (gboolean user
); gboolean midgard_config_save_file (MidgardConfig *self
,const gchar *name
,gboolean user
,GError **error
); gboolean midgard_config_create_blobdir (MidgardConfig *self
);
"authtype" gchar* : Read / Write "blobdir" gchar* : Read / Write "cachedir" gchar* : Read / Write "database" gchar* : Read / Write "dbdir" gchar* : Read / Write "dbpass" gchar* : Read / Write "dbtype" gchar* : Read / Write "dbuser" gchar* : Read / Write "host" gchar* : Read / Write "logfilename" gchar* : Read / Write "loglevel" gchar* : Read / Write "midgardpassword" gchar* : Read / Write "midgardusername" gchar* : Read / Write "pamfile" gchar* : Read / Write "port" guint : Read / Write "sharedir" gchar* : Read / Write "tablecreate" gboolean : Read / Write "tableupdate" gboolean : Read / Write "testunit" gboolean : Read / Write "vardir" gchar* : Read / Write
MidgardConfig class represents Midgard unified configuration file.
Underlying configuration file representation is limited to GKeyFile.
There are few ways to read configuration data: midgard_config_read_file()
, which
encapsulates real file location, midgard_config_read_file_at_path()
if file location
is not common or very specific for application or midgard_config_read_data()
, which
reads configuration from given buffer.
typedef enum { MIDGARD_DB_TYPE_MYSQL = 1, MIDGARD_DB_TYPE_POSTGRES, MIDGARD_DB_TYPE_FREETDS, MIDGARD_DB_TYPE_SQLITE, MIDGARD_DB_TYPE_ODBC, MIDGARD_DB_TYPE_ORACLE } MidgardDBType;
MidgardConfig * midgard_config_new (void
);
Initializes new instance of MidgardConfig object type. NULL is returned when object can not be initialized.
Returns : |
pointer to MidgardConfig object or NULL on failure. |
gboolean midgard_config_read_file (MidgardConfig *self
,const gchar *filename
,gboolean user
,GError **error
);
This method reads configuration file from the given name and sets MidgardConfig object's properties. Such initialized MidgardConfig instance may be reused among midgard-core and midgard-php extension for example, without any need to re-read configuration file and without any need to re-initalize MidgardConfig object instance.
Set TRUE
as user
boolean value to read files from user's home directory.
|
MidgardConfig object instance |
|
name of the file to read |
|
boolean switch for system or user's config files |
|
pointer to store error |
Returns : |
TRUE when file has been read , FALSE otherwise. |
Since 9.3
gboolean midgard_config_read_file_at_path (MidgardConfig *self
,const gchar *filepath
,GError **error
);
|
MidgardConfig instance |
|
a path to read file from |
|
a pointer to hold error |
Returns : |
TRUE if file has been read, FALSE otherwise |
gboolean midgard_config_read_data (MidgardConfig *self
,const gchar *data
,GError **error
);
|
MidgardConfig instance |
|
a NULL-terminated buffer containing the configuration |
|
a pointer to hold error |
Returns : |
TRUE if data has been read, FALSE otherwise |
gchar ** midgard_config_list_files (gboolean user
);
List all available configuration files.
If user
value is set to TRUE
, all available files from ~/.midgard/conf.d will be listed.
Only system files ( usually from /etc/midgard/conf.d ) will be listed if user
value is set to FALSE
.
Returned array should be freed when no longer needed.
|
boolean switch for system or user's config files |
Returns : |
newly allocated and NULL terminated array of file names. [transfer full]
|
gboolean midgard_config_save_file (MidgardConfig *self
,const gchar *name
,gboolean user
,GError **error
);
Saves configuration file for the given MidgardConfig.
This method saves configuration file with the given name.
If third user parameter is set to TRUE
, then configuration file will
be saved in ~/.midgard2/conf.d directory.
User's conf.d directory will be created if doesn't exist.
|
MidgardConfig instance |
|
configuration filename |
|
system or home directory switch |
|
pointer to store GError |
Returns : |
TRUE on success or FALSE ( with propper warning message ) if system wide
directory doesn't exist or file can not be saved. |
gboolean midgard_config_create_blobdir (MidgardConfig *self
);
Creates directories for blobs
|
MidgardConfig instance |
Returns : |
TRUE on success, FALSE otherwise. |
"authtype"
property"authtype" gchar* : Read / Write
Authentication type used with connection.
Default value: ""
"blobdir"
property"blobdir" gchar* : Read / Write
Location of the blobs directory.
Default value: ""
"database"
property"database" gchar* : Read / Write
Name of the database.
Default value: "midgard"
"dbdir"
property"dbdir" gchar* : Read / Write
Directory for SQLite database file ('~/.midgard2/data' by default).
Default value: ""
"dbpass"
property"dbpass" gchar* : Read / Write
Password used by user who is able to connect to database.
Default value: "midgard"
"dbtype"
property"dbtype" gchar* : Read / Write
Database type ( by default MySQL ).
Default value: "MySQL"
"dbuser"
property"dbuser" gchar* : Read / Write
Username for user who is able to connect to database.
Default value: "midgard"
"host"
property"host" gchar* : Read / Write
Database host ( 'localhost' by default ).
Default value: "localhost"
"logfilename"
property"logfilename" gchar* : Read / Write
Location of the log file.
Default value: ""
"midgardpassword"
property"midgardpassword" gchar* : Read / Write
Midgard user's password.
Default value: ""
"midgardusername"
property"midgardusername" gchar* : Read / Write
Midgard user's login.
Default value: ""
"pamfile"
property"pamfile" gchar* : Read / Write
Name of the file used with PAM authentication type.
Default value: ""
"sharedir"
property"sharedir" gchar* : Read / Write
Directory for shared, architecture independent files.
Default value: ""
"tablecreate"
property"tablecreate" gboolean : Read / Write
Database creation switch.
Default value: FALSE
"tableupdate"
property"tableupdate" gboolean : Read / Write
Database update switch.
Default value: FALSE
"testunit"
property"testunit" gboolean : Read / Write
Database and objects testing switch.
Default value: FALSE
"vardir"
property"vardir" gchar* : Read / Write
Application specific directories.
Default value: ""