[Pcsclite-git-commit] [pcsc-tools] 15/32: pcsc_scan: add spin_* functions

Ludovic Rousseau rousseau at moszumanska.debian.org
Thu May 4 15:44:48 UTC 2017


This is an automated email from the git hooks/post-receive script.

rousseau pushed a commit to branch master
in repository pcsc-tools.

commit 2921f884bc66580226c22af2f181585bc1befcac
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Sat Apr 8 14:56:18 2017 +0200

    pcsc_scan: add spin_* functions
    
    spin_start(): init the animation
    spin_update(): draw next animation state
    spin_suspend(): hide the animation
---
 pcsc_scan.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/pcsc_scan.c b/pcsc_scan.c
index aa3b718..1c2cb89 100644
--- a/pcsc_scan.c
+++ b/pcsc_scan.c
@@ -69,6 +69,29 @@ static void usage(void)
 	printf("  -h : this help\n");
 } /* usage */
 
+unsigned int spin_state = 0;
+static void spin_start(void)
+{
+	spin_state = 0;
+}
+
+static void spin_update(void)
+{
+	char patterns[] = {'-', '\\', '|', '/'};
+	char c = patterns[spin_state];
+	spin_state++;
+	if (spin_state >= sizeof patterns)
+		spin_state = 0;
+	printf("\33[3D %c ", c);
+	fflush(stdout);
+}
+
+static void spin_suspend(void)
+{
+	printf("\33[2D \33[2D");
+	fflush(stdout);
+}
+
 int main(int argc, char *argv[])
 {
 	int current_reader;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pcsclite/pcsc-tools.git



More information about the Pcsclite-cvs-commit mailing list