linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 01/14] shared/shell: Add bt_shell_{noninteractive_}quit
Date: Mon, 26 Feb 2018 17:53:23 +0200	[thread overview]
Message-ID: <20180226155336.25875-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20180226155336.25875-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

The functions can be used to tell the shell to stop running.
---
 src/shared/shell.c | 16 ++++++++++++++++
 src/shared/shell.h |  3 +++
 2 files changed, 19 insertions(+)

diff --git a/src/shared/shell.c b/src/shared/shell.c
index 6cc797cdb..9ecb4c7be 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -866,6 +866,22 @@ void bt_shell_run(void)
 	data.init = false;
 }
 
+void bt_shell_quit(int status)
+{
+	if (status == EXIT_SUCCESS)
+		mainloop_exit_success();
+	else
+		mainloop_exit_failure();
+}
+
+void bt_shell_noninteractive_quit(int status)
+{
+	if (!data.mode || data.timeout)
+		return;
+
+	bt_shell_quit(status);
+}
+
 bool bt_shell_set_menu(const struct bt_shell_menu *menu)
 {
 	if (!menu)
diff --git a/src/shared/shell.h b/src/shared/shell.h
index 359629896..10747c955 100644
--- a/src/shared/shell.h
+++ b/src/shared/shell.h
@@ -68,6 +68,9 @@ void bt_shell_init(int argc, char **argv, const struct bt_shell_opt *opt);
 
 void bt_shell_run(void);
 
+void bt_shell_quit(int status);
+void bt_shell_noninteractive_quit(int status);
+
 bool bt_shell_set_menu(const struct bt_shell_menu *menu);
 
 bool bt_shell_add_submenu(const struct bt_shell_menu *menu);
-- 
2.14.3


  reply	other threads:[~2018-02-26 15:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-26 15:53 [PATCH BlueZ 00/14] shared/shell: Add proper support for non-interactive mode Luiz Augusto von Dentz
2018-02-26 15:53 ` Luiz Augusto von Dentz [this message]
2018-02-26 15:53 ` [PATCH BlueZ 02/14] shared/shell: Fix not reseting optind Luiz Augusto von Dentz
2018-02-26 15:53 ` [PATCH BlueZ 03/14] shared/shell: Fix timeout parameter Luiz Augusto von Dentz
2018-02-26 15:53 ` [PATCH BlueZ 04/14] shared/shell: Do not quit immediatelly on noninteractive mode Luiz Augusto von Dentz
2018-02-26 15:53 ` [PATCH BlueZ 05/14] shared/shell: Fix not handling sort options Luiz Augusto von Dentz
2018-02-26 15:53 ` [PATCH BlueZ 06/14] shared/shell: Disable bt_shell_prompt_input in noninteractive mode Luiz Augusto von Dentz
2018-02-26 15:53 ` [PATCH BlueZ 07/14] shared/shell: Disable readline while " Luiz Augusto von Dentz
2018-02-26 15:53 ` [PATCH BlueZ 08/14] sharead/mainloop-glib: Fix mainloop_exit* Luiz Augusto von Dentz
2018-02-26 15:53 ` [PATCH BlueZ 09/14] shared/mainloop-glib: Fix calling g_main_loop_quit with NULL Luiz Augusto von Dentz
2018-02-26 15:53 ` [PATCH BlueZ 10/14] shared/shell: Allow executing submenu commands Luiz Augusto von Dentz
2018-02-26 15:53 ` [PATCH BlueZ 11/14] client: Call bt_shell_noninteractive_quit when done with command Luiz Augusto von Dentz
2018-02-26 15:53 ` [PATCH BlueZ 12/14] shared/shell: Add bt_shell_usage Luiz Augusto von Dentz
2018-02-26 15:53 ` [PATCH BlueZ 13/14] shared/shell: Fix parsing of mandatory arguments Luiz Augusto von Dentz
2018-02-28 16:09 ` [PATCH BlueZ 00/14] shared/shell: Add proper support for non-interactive mode Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180226155336.25875-2-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).