(argfreq <= 0))
usage_bail(argv[0]);
else
+ if (result->freq != 0)
+ fprintf(stderr, "WARNING: multiple -f values given, only last "
+ "one is used.\n");
result->freq = argfreq;
break;
case 'l' : /* length */
exit(0);
break;
case 'n' : /* also --new - create another beep */
+ if (result->freq == 0)
+ result->freq = DEFAULT_FREQ;
result->next = (beep_parms_t *)malloc(sizeof(beep_parms_t));
- result->next->freq = DEFAULT_FREQ;
+ result->next->freq = 0;
result->next->length = DEFAULT_LENGTH;
result->next->reps = DEFAULT_REPS;
result->next->delay = DEFAULT_DELAY;
usage_bail(argv[0]);
}
}
+ if (result->freq == 0)
+ result->freq = DEFAULT_FREQ;
}
void play_beep(beep_parms_t parms) {
parms.reps, parms.length, parms.delay, parms.end_delay, parms.freq);
/* try to snag the console */
- if((console_fd = open("/dev/console", O_WRONLY)) == -1) {
- fprintf(stderr, "Could not open /dev/console for writing.\n");
- printf("\a"); /* Output the only beep we can, in an effort to fall back on usefulness */
- perror("open");
- exit(1);
+ if((console_fd = open("/dev/tty0", O_WRONLY)) == -1) {
+ if((console_fd = open("/dev/vc/0", O_WRONLY)) == -1) {
+ fprintf(stderr, "Could not open /dev/tty0 or /dev/vc/0 for writing.\n");
+ printf("\a"); /* Output the only beep we can, in an effort to fall back on usefulness */
+ perror("open");
+ exit(1);
+ }
}
/* Beep */
char sin[4096], *ptr;
beep_parms_t *parms = (beep_parms_t *)malloc(sizeof(beep_parms_t));
- parms->freq = DEFAULT_FREQ;
+ parms->freq = 0;
parms->length = DEFAULT_LENGTH;
parms->reps = DEFAULT_REPS;
parms->delay = DEFAULT_DELAY;