clang-format: Disable space-based alignment
This commit is contained in:
parent
255e17fe58
commit
dbdf5cc393
2 changed files with 49 additions and 34 deletions
|
@ -1,3 +1,12 @@
|
|||
BasedOnStyle: LLVM
|
||||
UseTab: Always
|
||||
AlignAfterOpenBracket: DontAlign
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveBitFields: None
|
||||
AlignConsecutiveMacros: None
|
||||
AlignEscapedNewlines: DontAlign
|
||||
AlignOperands: DontAlign
|
||||
AlignTrailingComments: False
|
||||
ContinuationIndentWidth: 8
|
||||
IndentWidth: 8
|
||||
UseTab: Always
|
||||
|
|
72
evtone.c
72
evtone.c
|
@ -28,31 +28,35 @@ error_t argp_parser(int key, char *arg, struct argp_state *state);
|
|||
const char *argp_program_version = "evtone 1.4";
|
||||
const char argp_args_doc[] = "TONE [TONE...]";
|
||||
const char argp_doc[] =
|
||||
"TONE is of the format HZ:MILLISECONDS\n"
|
||||
"Up to " TONE_MAX_STR " TONEs may be specified at once.\v"
|
||||
"Examples:\n"
|
||||
" \"evtone 440:1500\" plays a tone of 440Hz for 1500 milliseconds.\n"
|
||||
" \"evtone 440:1500 300:10\" plays a 440Hz tone for 1500 milliseconds\n"
|
||||
" followed by a 300Hz tone for 10 milliseconds\n"
|
||||
" \"evtone -d 440:1500 300:10\" will print what the program will do\n"
|
||||
" instead of actually doing it\n"
|
||||
" \"evtone -D /dev/input/event2 440:1000\" will play a 440Hz tone for\n"
|
||||
" 1000 milliseconds using the /dev/input/event2 device";
|
||||
"TONE is of the format HZ:MILLISECONDS\n"
|
||||
"Up to " TONE_MAX_STR " TONEs may be specified at once.\v"
|
||||
"Examples:\n"
|
||||
" \"evtone 440:1500\" plays a tone of 440Hz for 1500 milliseconds.\n"
|
||||
" \"evtone 440:1500 300:10\" plays a 440Hz tone for 1500 "
|
||||
"milliseconds\n"
|
||||
" followed by a 300Hz tone for 10 milliseconds\n"
|
||||
" \"evtone -d 440:1500 300:10\" will print what the program will do\n"
|
||||
" instead of actually doing it\n"
|
||||
" \"evtone -D /dev/input/event2 440:1000\" will play a 440Hz tone "
|
||||
"for\n"
|
||||
" 1000 milliseconds using the /dev/input/event2 device";
|
||||
|
||||
const struct argp_option argp_options[] = {
|
||||
{.name = "dry-run", .key = 'd', .doc = "Print what the program will do"},
|
||||
{.name = "device",
|
||||
.key = 'D',
|
||||
.arg = "FILE",
|
||||
.doc = "/dev/input device to use to play tones\n"
|
||||
"If not supplied the device will be guessed"},
|
||||
{0}};
|
||||
{.name = "dry-run",
|
||||
.key = 'd',
|
||||
.doc = "Print what the program will do"},
|
||||
{.name = "device",
|
||||
.key = 'D',
|
||||
.arg = "FILE",
|
||||
.doc = "/dev/input device to use to play tones\n"
|
||||
"If not supplied the device will be guessed"},
|
||||
{0}};
|
||||
|
||||
const struct argp args = {
|
||||
.options = argp_options,
|
||||
.parser = argp_parser,
|
||||
.args_doc = argp_args_doc,
|
||||
.doc = argp_doc,
|
||||
.options = argp_options,
|
||||
.parser = argp_parser,
|
||||
.args_doc = argp_args_doc,
|
||||
.doc = argp_doc,
|
||||
};
|
||||
|
||||
int parse_tone(char *arg, struct program_opts *opts) {
|
||||
|
@ -62,8 +66,8 @@ int parse_tone(char *arg, struct program_opts *opts) {
|
|||
}
|
||||
struct tone_cmd *tone = &opts->tones[opts->tone_count++];
|
||||
char canary;
|
||||
int rc =
|
||||
sscanf(arg, "%i:%i%c", &tone->tone_hz, &tone->duration_ms, &canary);
|
||||
int rc = sscanf(
|
||||
arg, "%i:%i%c", &tone->tone_hz, &tone->duration_ms, &canary);
|
||||
if (tone->tone_hz < 0 || tone->duration_ms < 0) {
|
||||
fprintf(stderr, "Error: TONE HZ or DURATION must be over 0\n");
|
||||
return 1;
|
||||
|
@ -110,24 +114,26 @@ struct program_opts *main_opts = 0;
|
|||
void cleanup_main_opts(void) { free(main_opts); }
|
||||
|
||||
int play_tones(int dry_run, const char *device, struct tone_cmd *tones,
|
||||
int tone_count);
|
||||
int tone_count);
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
main_opts = calloc(sizeof(struct program_opts), 1);
|
||||
if (main_opts == NULL) {
|
||||
fprintf(stderr, "Unable to allocate main program options. Out "
|
||||
"of memory?\n");
|
||||
fprintf(stderr,
|
||||
"Unable to allocate main program options. Out "
|
||||
"of memory?\n");
|
||||
return 1;
|
||||
}
|
||||
atexit(cleanup_main_opts); /* argp will exit instead of returning */
|
||||
error_t err = argp_parse(&args, argc, argv, 0, 0, main_opts);
|
||||
if (err) {
|
||||
fprintf(stderr, "Unable to parse program arguments. Please "
|
||||
"report this bug.\n");
|
||||
fprintf(stderr,
|
||||
"Unable to parse program arguments. Please "
|
||||
"report this bug.\n");
|
||||
return 1;
|
||||
}
|
||||
return play_tones(main_opts->dry_run, main_opts->device,
|
||||
main_opts->tones, main_opts->tone_count);
|
||||
main_opts->tones, main_opts->tone_count);
|
||||
}
|
||||
|
||||
/* TONE PROCESSING */
|
||||
|
@ -179,7 +185,7 @@ int setup_signals(void) {
|
|||
}
|
||||
|
||||
int play_tones(int dry_run, const char *device, struct tone_cmd *tones,
|
||||
int tone_count) {
|
||||
int tone_count) {
|
||||
_cleanup_fd_ int dev = open_device(dry_run, device);
|
||||
if (setup_signals() == -1) {
|
||||
return 1;
|
||||
|
@ -217,9 +223,9 @@ int play_tones(int dry_run, const char *device, struct tone_cmd *tones,
|
|||
#include <unistd.h>
|
||||
|
||||
const char *device_guesses[] = {
|
||||
"/dev/input/by-path/platform-pcspkr-event-spkr", /* pcspkr on x86 */
|
||||
"/dev/input/by-path/platform-beeper-event", /* pwm-beeper */
|
||||
0};
|
||||
"/dev/input/by-path/platform-pcspkr-event-spkr", /* pcspkr on x86 */
|
||||
"/dev/input/by-path/platform-beeper-event", /* pwm-beeper */
|
||||
0};
|
||||
|
||||
int try_open_device(int dry_run, const char *device) {
|
||||
if (dry_run) {
|
||||
|
|
Loading…
Add table
Reference in a new issue