From c89efc48e2204aa80035f0e24b2965e31a3f14b8 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Fri, 12 Aug 2016 22:40:33 +0200 Subject: indent --- .indent.pro | 47 ++++++++++++++++ config.c | 178 ++++++++++++++++++++++++++++++------------------------------ 2 files changed, 137 insertions(+), 88 deletions(-) create mode 100644 .indent.pro diff --git a/.indent.pro b/.indent.pro new file mode 100644 index 0000000..2de5cd1 --- /dev/null +++ b/.indent.pro @@ -0,0 +1,47 @@ +-TFILE +-Tfd_mask +-Tfd_set +-Tlinker_sym_tT +-Tu_char +-Tu_int +-Tu_long +-Tu_short +-TTAILQ_HEAD +-TTAILQ_ENTRY +-TLIST_HEAD +-TLIST_ENTRY +-TSTAILQ_HEAD +-TSTAILQ_ENTRY +-TSLIST_HEAD +-TSLIST_ENTRY +-bad +-bap +-nbbb +-nbc +-br +-nbs +-c41 +-cd41 +-cdb +-ce +-ci4 +-cli0 +-d0 +-di8 +-ndj +-ei +-nfc1 +-nfcb +-nut +-i8 +-ip8 +-l79 +-lc77 +-ldi0 +-nlp +-npcs +-psl +-sc +-nsob +-ta +-nv diff --git a/config.c b/config.c index 663f038..3aeee4f 100644 --- a/config.c +++ b/config.c @@ -59,36 +59,36 @@ enum { }; typedef struct { - int id; - char *name; -} keyword; + int id; + char *name; +} keyword; static keyword keywords[] = { - { KEYWORD_STRINGS, "Strings" }, - { KEYWORD_STRING, "String" }, - { KEYWORD_LINE, "Line" }, - { KEYWORD_MODE, "Mode" }, - { KEYWORD_MODE_ONE_OCTAVE, "midi_one_octave" }, - { KEYWORD_MODE_TWO_OCTAVES, "midi_two_octaves" }, - { KEYWORD_MODE_THREE_OCTAVES, "midi_three_octaves" }, - { KEYWORD_MODE_CONTROL, "midi_control" }, - { KEYWORD_MODE_CONTROL_INVERSE, "midi_control_inverse" }, - { KEYWORD_CHANNEL, "Channel" }, - { KEYWORD_NOTE, "Note" }, - { KEYWORD_AFTERTOUCH, "AfterTouch" }, - { KEYWORD_NONE, "none" }, - { KEYWORD_PITCH_BEND_UP, "pitch_bend_up" }, - { KEYWORD_PITCH_BEND_DOWN, "pitch_bend_down" }, - { KEYWORD_MIDI_CONTROL, "midi_control" }, - { KEYWORD_MIDI_CONTROL_INVERSE, "midi_control_inverse" }, - { KEYWORD_CONTROLLER, "Controller" }, - { KEYWORD_TIMETOSILENCE, "TimeToSilence" }, - { KEYWORD_TWOOCTAVESPLIT, "midi_two_octave_split" }, - { KEYWORD_THREEOCTAVESPLIT_1, "midi_three_octave_split_1" }, - { KEYWORD_THREEOCTAVESPLIT_2, "midi_three_octave_split_2" }, - { KEYWORD_MIDI_MAIN_CONTROL, "midi_main_control" }, - { KEYWORD_MIDI_MAIN_CHANNEL, "midi_main_channel" }, - { -1, 0 } + {KEYWORD_STRINGS, "Strings"}, + {KEYWORD_STRING, "String"}, + {KEYWORD_LINE, "Line"}, + {KEYWORD_MODE, "Mode"}, + {KEYWORD_MODE_ONE_OCTAVE, "midi_one_octave"}, + {KEYWORD_MODE_TWO_OCTAVES, "midi_two_octaves"}, + {KEYWORD_MODE_THREE_OCTAVES, "midi_three_octaves"}, + {KEYWORD_MODE_CONTROL, "midi_control"}, + {KEYWORD_MODE_CONTROL_INVERSE, "midi_control_inverse"}, + {KEYWORD_CHANNEL, "Channel"}, + {KEYWORD_NOTE, "Note"}, + {KEYWORD_AFTERTOUCH, "AfterTouch"}, + {KEYWORD_NONE, "none"}, + {KEYWORD_PITCH_BEND_UP, "pitch_bend_up"}, + {KEYWORD_PITCH_BEND_DOWN, "pitch_bend_down"}, + {KEYWORD_MIDI_CONTROL, "midi_control"}, + {KEYWORD_MIDI_CONTROL_INVERSE, "midi_control_inverse"}, + {KEYWORD_CONTROLLER, "Controller"}, + {KEYWORD_TIMETOSILENCE, "TimeToSilence"}, + {KEYWORD_TWOOCTAVESPLIT, "midi_two_octave_split"}, + {KEYWORD_THREEOCTAVESPLIT_1, "midi_three_octave_split_1"}, + {KEYWORD_THREEOCTAVESPLIT_2, "midi_three_octave_split_2"}, + {KEYWORD_MIDI_MAIN_CONTROL, "midi_main_control"}, + {KEYWORD_MIDI_MAIN_CHANNEL, "midi_main_channel"}, + {-1, 0} }; static int g_current_string; @@ -102,19 +102,20 @@ config_findkeyword(char **line) while (isspace(*_l)) ++_l; - for (i=0; keywords[i].name; ++i) { - size_t kl = strlen(keywords[i].name); - if (!strncasecmp(_l, keywords[i].name, kl)) { - if (!isspace(_l[kl]) && _l[kl]) - continue; - _l += strlen(keywords[i].name); + for (i = 0; keywords[i].name; ++i) { + size_t kl = strlen(keywords[i].name); - /* Skip rest of white spaces */ - while (isspace(*_l)) - ++_l; - *line = _l; - return keywords[i].id; - } + if (!strncasecmp(_l, keywords[i].name, kl)) { + if (!isspace(_l[kl]) && _l[kl]) + continue; + _l += strlen(keywords[i].name); + + /* Skip rest of white spaces */ + while (isspace(*_l)) + ++_l; + *line = _l; + return keywords[i].id; + } } return -1; } @@ -143,14 +144,14 @@ config_handle_line(char *line) int split_done = 0; char *_line = line; - //Skip leading spaces + /* Skip leading spaces */ while (isspace(*line)) ++line; if (*line == 0 || *line == '#' || *line == '\n') return 0; switch (config_findkeyword(&line)) { - case KEYWORD_STRINGS: + case KEYWORD_STRINGS: g_string_count = atol(line); if (!g_string_count || g_string_count > MAX_LINECOUNT) { fprintf(stderr, "Incorrect number of strings: %s\n", _line); @@ -158,7 +159,7 @@ config_handle_line(char *line) } printf("GLOBAL: Configuring expected lines %d\n", g_string_count); break; - case KEYWORD_STRING: + case KEYWORD_STRING: g_current_string = atol(line) - 1; printf("Switching to string: %d\n", g_current_string + 1); if (g_current_string < 0 || g_current_string > g_string_count) { @@ -166,57 +167,58 @@ config_handle_line(char *line) return -1; } break; - case KEYWORD_LINE: - { - LLine *l = &sc->line; - if (sscanf(line, "%d %d %d %d", &l->x0, &l->y0, &l->x1, &l->y1) != 4) { - fprintf(stderr, "Incorrect Line statement for string\n"); - return -1; - } - if (l->y0 > l->y1) { - l->y0 ^= l->y1; - l->y1 ^= l->y0; - l->y0 ^= l->y1; - l->x0 ^= l->x1; - l->x1 ^= l->x0; - l->x0 ^= l->x1; + case KEYWORD_LINE: + { + LLine *l = &sc->line; + if (sscanf(line, "%d %d %d %d", &l->x0, &l->y0, &l->x1, &l->y1) != 4) { + fprintf(stderr, "Incorrect Line statement for string\n"); + return -1; + } + if (l->y0 > l->y1) { + l->y0 ^= l->y1; + l->y1 ^= l->y0; + l->y0 ^= l->y1; + l->x0 ^= l->x1; + l->x1 ^= l->x0; + l->x0 ^= l->x1; + + } + if (l->y0 > g_min_y) + g_min_y = l->y0; + if (l->y1 < g_max_y) + g_max_y = l->y1; + break; } - if (l->y0 > g_min_y) - g_min_y = l->y0; - if (l->y1 < g_max_y) - g_max_y = l->y1; - break; - } - case KEYWORD_MODE: + case KEYWORD_MODE: switch (config_findkeyword(&line)) { - case KEYWORD_MODE_ONE_OCTAVE: + case KEYWORD_MODE_ONE_OCTAVE: sc->mode = midi_one_octave; printf("String %d is midi_one_octave\n", 1 + g_current_string); break; - case KEYWORD_MODE_TWO_OCTAVES: + case KEYWORD_MODE_TWO_OCTAVES: sc->mode = midi_two_octaves; printf("String %d is midi_two_octaves\n", 1 + g_current_string); break; - case KEYWORD_MODE_THREE_OCTAVES: + case KEYWORD_MODE_THREE_OCTAVES: sc->mode = midi_three_octaves; printf("String %d is midi_three_octaves\n", 1 + g_current_string); break; - case KEYWORD_MODE_CONTROL: + case KEYWORD_MODE_CONTROL: sc->mode = midi_control; printf("String %d is midi_control\n", 1 + g_current_string); break; - case KEYWORD_MODE_CONTROL_INVERSE: + case KEYWORD_MODE_CONTROL_INVERSE: sc->mode = midi_control_inv; printf("String %d is midi_control_inverse\n", 1 + g_current_string); break; - default: + default: fprintf(stderr, "Illegal Mode for string: %s\n", _line); return -1; } break; - case KEYWORD_CHANNEL: + case KEYWORD_CHANNEL: sc->channel = atol(line); if (sc->channel > 16) { fprintf(stderr, "Incorrect channel specified: %s.\n", _line); @@ -224,7 +226,7 @@ config_handle_line(char *line) } printf("String %d is on channel %d\n", g_current_string, sc->channel); break; - case KEYWORD_NOTE: + case KEYWORD_NOTE: sc->note = config_midi_note_from_string(line); if (sc->note == 0xff) { fprintf(stderr, "Unknown midi note specified: %s.\n", _line); @@ -232,42 +234,42 @@ config_handle_line(char *line) } printf("String %d is midi note %d\n", g_current_string, sc->note); break; - case KEYWORD_AFTERTOUCH: + case KEYWORD_AFTERTOUCH: switch (config_findkeyword(&line)) { - case KEYWORD_NONE: + case KEYWORD_NONE: sc->modifier = none; printf("String %d does not act aftertouch\n", 1 + g_current_string); break; - case KEYWORD_PITCH_BEND_UP: + case KEYWORD_PITCH_BEND_UP: sc->modifier = pitch_bend_up; printf("String %d acts aftertouch as pitch_bend_up\n", 1 + g_current_string); break; - case KEYWORD_PITCH_BEND_DOWN: + case KEYWORD_PITCH_BEND_DOWN: sc->modifier = pitch_bend_down; printf("String %d acts aftertouch as pitch_bend_down\n", 1 + g_current_string); break; - case KEYWORD_MIDI_CONTROL: + case KEYWORD_MIDI_CONTROL: sc->modifier = midi_controller; printf("String %d acts aftertouch as midi_controller\n", 1 + g_current_string); break; - case KEYWORD_MIDI_CONTROL_INVERSE: + case KEYWORD_MIDI_CONTROL_INVERSE: sc->modifier = midi_controller_inv; printf("String %d acts aftertouch as midi_controller_inverse\n", 1 + g_current_string); break; - default: + default: fprintf(stderr, "Illegal Modifier for string: %s\n", _line); return -1; } break; - case KEYWORD_CONTROLLER: + case KEYWORD_CONTROLLER: sc->controller = atol(line); printf("String %d is on midi_controller line %d\n", 1 + g_current_string, sc->controller); break; - case KEYWORD_TIMETOSILENCE: + case KEYWORD_TIMETOSILENCE: sc->timetosilence = atol(line); printf("String %d has a timetosilence of %d\n", 1 + g_current_string, sc->timetosilence); break; - case KEYWORD_TWOOCTAVESPLIT: + case KEYWORD_TWOOCTAVESPLIT: g_midi_two_octave_split = atol(line); printf("Splitting TWO octaves at %d%%\n", g_midi_two_octave_split); if (g_midi_two_octave_split < 0 || g_midi_two_octave_split > 100) { @@ -276,7 +278,7 @@ config_handle_line(char *line) } g_midi_two_octave_split = (256 * g_midi_two_octave_split) / 100; break; - case KEYWORD_THREEOCTAVESPLIT_1: + case KEYWORD_THREEOCTAVESPLIT_1: g_midi_three_octave_split_1 = atol(line); printf("Splitting THREE octaves top above %d%%\n", g_midi_three_octave_split_1); if (g_midi_three_octave_split_1 < 0 || g_midi_three_octave_split_1 > 100) { @@ -286,7 +288,7 @@ config_handle_line(char *line) g_midi_three_octave_split_1 = (256 * g_midi_three_octave_split_1) / 100; split_done = 1; break; - case KEYWORD_THREEOCTAVESPLIT_2: + case KEYWORD_THREEOCTAVESPLIT_2: g_midi_three_octave_split_2 = atol(line); printf("Splitting THREE octaves bottom below %d%%\n", g_midi_three_octave_split_2); if (g_midi_three_octave_split_2 < 0 || g_midi_three_octave_split_2 > 100) { @@ -296,7 +298,7 @@ config_handle_line(char *line) g_midi_three_octave_split_2 = (256 * g_midi_three_octave_split_2) / 100; split_done = 1; break; - case KEYWORD_MIDI_MAIN_CONTROL: + case KEYWORD_MIDI_MAIN_CONTROL: g_midi_main_control = atol(line); printf("All Strings modify controller %d\n", g_midi_main_control); if (g_midi_main_control > 127) { @@ -304,7 +306,7 @@ config_handle_line(char *line) return -1; } break; - case KEYWORD_MIDI_MAIN_CHANNEL: + case KEYWORD_MIDI_MAIN_CHANNEL: g_midi_main_channel = atol(line); printf("All Strings modify controller %d on channel %d\n", g_midi_main_control, g_midi_main_channel); if (g_midi_main_channel < 1 || g_midi_main_channel > 16) { @@ -312,13 +314,13 @@ config_handle_line(char *line) return -1; } break; - default: + default: fprintf(stderr, "Unhandled config line: %s\n", _line); return -1; } if (!split_done) - return 0; + return 0; /* split also true for two octaves */ if (g_midi_three_octave_split_2 < g_midi_three_octave_split_1) { -- cgit v1.2.3