1 Author: Gerfried Fuchs <rhonda@debian.at> vim:ft=diff:
2 Description: Add support for --verbose/--debug option (BTS #297791, #335027)
4 Index: beep-1.2.2/beep.c
5 ===================================================================
6 --- beep-1.2.2.orig/beep.c
8 @@ -83,6 +83,7 @@ typedef struct beep_parms_t {
9 so that beep can be tucked appropriately into a text-
12 + int verbose; /* verbose output? */
13 struct beep_parms_t *next; /* in case -n/--new is used. */
16 @@ -110,7 +111,7 @@ void handle_signal(int signum) {
17 /* print usage and exit */
18 void usage_bail(const char *executable_name) {
19 printf("Usage:\n%s [-f freq] [-l length] [-r reps] [-d delay] "
20 - "[-D delay] [-s] [-c]\n",
21 + "[-D delay] [-s] [-c] [--verbose | --debug]\n",
23 printf("%s [Options...] [-n] [--new] [Options...] ... \n", executable_name);
24 printf("%s [-h] [--help]\n", executable_name);
25 @@ -131,6 +132,7 @@ void usage_bail(const char *executable_n
26 * "-D <delay in ms>" (similar to -d, but delay after last repetition as well)
27 * "-s" (beep after each line of input from stdin, echo line to stdout)
28 * "-c" (beep after each char of input from stdin, echo char to stdout)
29 + * "--verbose/--debug"
33 @@ -141,9 +143,11 @@ void usage_bail(const char *executable_n
34 void parse_command_line(int argc, char **argv, beep_parms_t *result) {
37 - struct option opt_list[4] = {{"help", 0, NULL, 'h'},
38 + struct option opt_list[6] = {{"help", 0, NULL, 'h'},
39 {"version", 0, NULL, 'V'},
40 {"new", 0, NULL, 'n'},
41 + {"verbose", 0, NULL, 'X'},
42 + {"debug", 0, NULL, 'X'},
44 while((c = getopt_long(argc, argv, "f:l:r:d:D:schvVn", opt_list, NULL))
46 @@ -204,9 +208,13 @@ void parse_command_line(int argc, char *
47 result->next->delay = DEFAULT_DELAY;
48 result->next->end_delay = DEFAULT_END_DELAY;
49 result->next->stdin_beep = DEFAULT_STDIN_BEEP;
50 + result->next->verbose = result->verbose;
51 result->next->next = NULL;
52 result = result->next; /* yes, I meant to do that. */
54 + case 'X' : /* --debug / --verbose */
55 + result->verbose = 1;
57 case 'h' : /* notice that this is also --help */
60 @@ -217,6 +225,11 @@ void parse_command_line(int argc, char *
61 void play_beep(beep_parms_t parms) {
62 int i; /* loop counter */
64 + if(parms.verbose == 1)
65 + fprintf(stderr, "[DEBUG] %d times %d ms beeps (%d delay between, "
66 + "%d delay after) @ %.2f Hz\n",
67 + parms.reps, parms.length, parms.delay, parms.end_delay, parms.freq);
69 /* try to snag the console */
70 if((console_fd = open("/dev/console", O_WRONLY)) == -1) {
71 fprintf(stderr, "Could not open /dev/console for writing.\n");
72 @@ -253,6 +266,7 @@ int main(int argc, char **argv) {
73 parms->delay = DEFAULT_DELAY;
74 parms->end_delay = DEFAULT_END_DELAY;
75 parms->stdin_beep = DEFAULT_STDIN_BEEP;
79 signal(SIGINT, handle_signal);