X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=beep.c;h=452fc08376393f6cde807911fea3fc37e61c9f9c;hb=d31cb2bbaf2aa13d0cbb957a07cb2b66c6c16d1b;hp=e421e8fe60f4aef01db726467597b300de579594;hpb=37ef60ac9891a4bddc7d6a4bdba24837e10abd0f;p=pkg%2Fbeep.git diff --git a/beep.c b/beep.c index e421e8f..452fc08 100644 --- a/beep.c +++ b/beep.c @@ -48,7 +48,7 @@ #define CLOCK_TICK_RATE 1193180 #endif -#define VERSION_STRING "beep-1.2.2" +#define VERSION_STRING "beep-1.3" char *copyright = "Copyright (C) Johnathan Nightingale, 2002. " "Use and Distribution subject to GPL. " @@ -108,11 +108,11 @@ void do_beep(int freq) { } else { /* BEEP_TYPE_EVDEV */ struct input_event e; - + e.type = EV_SND; e.code = SND_TONE; e.value = freq; - + write(console_fd, &e, sizeof(struct input_event)); } } @@ -121,10 +121,10 @@ void do_beep(int freq) { /* If we get interrupted, it would be nice to not leave the speaker beeping in perpetuity. */ void handle_signal(int signum) { - + if(console_device) free(console_device); - + switch(signum) { case SIGINT: if(console_fd >= 0) { @@ -142,7 +142,7 @@ void handle_signal(int signum) { /* print usage and exit */ void usage_bail(const char *executable_name) { printf("Usage:\n%s [-f freq] [-l length] [-r reps] [-d delay] " - "[-D delay] [-s] [-c] [-e device]\n", + "[-D delay] [-s] [-c] [--verbose | --debug] [-e device]\n", executable_name); printf("%s [Options...] [-n] [--new] [Options...] ... \n", executable_name); printf("%s [-h] [--help]\n", executable_name); @@ -278,7 +278,7 @@ void play_beep(beep_parms_t parms) { else if((console_fd = open("/dev/tty0", O_WRONLY)) == -1) console_fd = open("/dev/vc/0", O_WRONLY); - + if(console_fd == -1) { fprintf(stderr, "Could not open %s for writing\n", console_device != NULL ? console_device : "/dev/tty0 or /dev/vc/0"); @@ -297,7 +297,7 @@ void play_beep(beep_parms_t parms) { do_beep(parms.freq); /* Look ma, I'm not ansi C compatible! */ usleep(1000*parms.length); /* wait... */ - do_beep(0); + do_beep(0); /* stop beep */ if(parms.end_delay || (i+1 < parms.reps)) usleep(1000*parms.delay); /* wait... */ } /* repeat. */ @@ -362,6 +362,6 @@ int main(int argc, char **argv) { if(console_device) free(console_device); - + return EXIT_SUCCESS; }