audiod: Improve receiver restart logic.
[paraslash.git] / client_common.c
index 9886cfe5f93ef187f0f61fc0642a68b41f0b0619..c1e23f7a53d228bde4b3c26149432a71029327ad 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1997-2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1997-2009 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -312,6 +312,7 @@ err_out:
  * \param argv Usual argument vector.
  * \param ct_ptr Points to dynamically allocated and initialized client task
  * struct upon successful return.
+ * \param loglevel If not \p NULL, the number of the loglevel is stored here.
  *
  * Check the command line options given by \a argc and argv, set default values
  * for user name and rsa key file, read further option from the config file.
@@ -319,10 +320,10 @@ err_out:
  *
  * \return Standard.
  */
-int client_open(int argc, char *argv[], struct client_task **ct_ptr)
+int client_open(int argc, char *argv[], struct client_task **ct_ptr,
+               int *loglevel)
 {
        char *home = para_homedir();
-       struct stat statbuf;
        int ret;
        struct client_task *ct = para_calloc(sizeof(struct client_task));
 
@@ -345,12 +346,12 @@ int client_open(int argc, char *argv[], struct client_task **ct_ptr)
        ct->config_file = ct->conf.config_file_given?
                para_strdup(ct->conf.config_file_arg) :
                make_message("%s/.paraslash/client.conf", home);
-       ret = stat(ct->config_file, &statbuf);
-       if (ret && ct->conf.config_file_given) {
+       ret = file_exists(ct->config_file);
+       if (!ret && ct->conf.config_file_given) {
                ret = -E_NO_CONFIG;
                goto out;
        }
-       if (!ret) {
+       if (ret) {
                struct client_cmdline_parser_params params = {
                        .override = 0,
                        .initialize = 0,
@@ -363,8 +364,9 @@ int client_open(int argc, char *argv[], struct client_task **ct_ptr)
                        &ct->conf, &params))
                        goto out;
        }
-       ret = 1;
-       PARA_INFO_LOG("loglevel: %d\n", ct->conf.loglevel_arg);
+       if (loglevel)
+               *loglevel = get_loglevel_by_name(ct->conf.loglevel_arg);
+       PARA_INFO_LOG("loglevel: %s\n", ct->conf.loglevel_arg);
        PARA_INFO_LOG("config_file: %s\n", ct->config_file);
        PARA_INFO_LOG("key_file: %s\n", ct->key_file);
        PARA_NOTICE_LOG("connecting %s:%d\n", ct->conf.hostname_arg,