commit
1c0e4f222d
@ -1,3 +1,8 @@
|
|||||||
|
2020-05-16 Stefan Kropp <stefan.kropp@posteo.de>
|
||||||
|
Release 0.1.1
|
||||||
|
* Display help, if no parameter has been set
|
||||||
|
* fixed g_error_matches handling for config file
|
||||||
|
|
||||||
2020-05-16 DebXWoody <stefan@debxwoody.de>
|
2020-05-16 DebXWoody <stefan@debxwoody.de>
|
||||||
|
|
||||||
Release 0.1.0
|
Release 0.1.0
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
AC_INIT([xmppc], [0.1.0], [stefan@debxwoody.de])
|
AC_INIT([xmppc], [0.2.0-dev], [stefan.kropp@posteo.de])
|
||||||
AC_CONFIG_AUX_DIR([build-aux])
|
AC_CONFIG_AUX_DIR([build-aux])
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
AC_CONFIG_SRCDIR([src/main.c])
|
AC_CONFIG_SRCDIR([src/main.c])
|
||||||
|
63
src/main.c
63
src/main.c
@ -338,6 +338,11 @@ int main(int argc, char *argv[]) {
|
|||||||
printf("!!! WARNING: XMPPC is running in development mode !!!\n");
|
printf("!!! WARNING: XMPPC is running in development mode !!!\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(argc < 2) {
|
||||||
|
_show_help();
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
INIT_XMPPC(xmppc);
|
INIT_XMPPC(xmppc);
|
||||||
|
|
||||||
static int verbose_flag = 0;
|
static int verbose_flag = 0;
|
||||||
@ -420,33 +425,41 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loading config file if jid not provided by command line
|
// Loading config file
|
||||||
if (jid == NULL) {
|
GKeyFile *config_file = g_key_file_new();
|
||||||
GKeyFile *config_file = g_key_file_new();
|
GError *error = NULL;
|
||||||
GError *error = NULL;
|
GString* configfile = g_string_new( g_get_home_dir());
|
||||||
GString* configfile = g_string_new( g_get_home_dir());
|
g_string_append(configfile,"/.config/xmppc.conf");
|
||||||
g_string_append(configfile,"/.config/xmppc.conf");
|
gboolean configfilefound = g_key_file_load_from_file(
|
||||||
gboolean configfilefound = g_key_file_load_from_file(
|
config_file,
|
||||||
config_file,
|
configfile->str,
|
||||||
configfile->str,
|
G_KEY_FILE_NONE,
|
||||||
G_KEY_FILE_NONE,
|
&error);
|
||||||
&error);
|
|
||||||
|
|
||||||
if (!configfilefound) {
|
if (!configfilefound) {
|
||||||
if(!g_error_matches(error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND)) {
|
if(error && !g_error_matches(error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
|
||||||
logError(&xmppc, "Error loading key file: %s", error->message);
|
logError(&xmppc, "Error loading key file: %s\n", error->message);
|
||||||
return -1;
|
return EXIT_FAILURE;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(jid == NULL && pwd == NULL) {
|
|
||||||
logInfo(&xmppc,"Loading default account\n");
|
|
||||||
if( account == NULL ) {
|
|
||||||
account = "default";
|
|
||||||
}
|
|
||||||
jid = g_key_file_get_value (config_file, account, "jid" ,&error);
|
|
||||||
pwd = g_key_file_get_value (config_file, account, "pwd" ,&error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if(jid == NULL && account == NULL) {
|
||||||
|
printf("You need either --jid or --account parameter or a default account\n");
|
||||||
|
_show_help();
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
error = NULL;
|
||||||
|
|
||||||
|
if(jid == NULL && pwd == NULL) {
|
||||||
|
logInfo(&xmppc,"Loading default account\n");
|
||||||
|
if( account == NULL ) {
|
||||||
|
account = "default";
|
||||||
|
}
|
||||||
|
jid = g_key_file_get_value (config_file, account, "jid" ,&error);
|
||||||
|
if( error ) {
|
||||||
|
logError(&xmppc, "No jid found in configuration file. %s\n", error->message);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
pwd = g_key_file_get_value (config_file, account, "pwd" ,&error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !pwd ) {
|
if ( !pwd ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user