GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
clicker.c
Go to the documentation of this file.
1 
2 /*-
3  * G_clicker()
4  *
5  * Print a clock hand (one of '|', '/', '-', '\') to stderr.
6  * Used in place of G_percent for unknown number of iterations
7  *
8  */
9 #include <stdio.h>
10 #include <grass/gis.h>
11 
12 static struct state {
13  int prev;
14 } state;
15 
16 static struct state *st = &state;
17 
18 void G_clicker(void)
19 {
20  static const char clicks[] = "|/-\\";
21  int format = G_info_format();
22 
23  if (format == G_INFO_FORMAT_SILENT || G_verbose() < 1)
24  return;
25 
26  st->prev++;
27  st->prev %= 4;
28 
29  fprintf(stderr, "%1c\b", clicks[st->prev]);
30  fflush(stderr);
31 }
int G_verbose(void)
Get current verbosity level.
Definition: verbose.c:55
struct state * st
Definition: parser.c:104
#define G_INFO_FORMAT_SILENT
Definition: gis.h:361
void G_clicker(void)
Definition: clicker.c:18
int G_info_format(void)
Get current message format.
Definition: gis/error.c:532
struct state state
Definition: parser.c:103