From 18840f3a3b6839b7de6d902137dbd69cf5d77e1c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 3 Jun 2014 05:59:45 +0200 Subject: put monitor selection in its own function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/test/test.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/test/test.c b/src/test/test.c index 886b361..6c00d3d 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -177,23 +177,16 @@ static void error_test(void) } -int main(void) +static int select_monitor(libgamma_site_state_t* restrict site_state, + libgamma_partition_state_t* restrict part_state, + libgamma_crtc_state_t* restrict crtc_state) { - libgamma_site_state_t* site_state = malloc(sizeof(libgamma_site_state_t)); - libgamma_partition_state_t* part_state = malloc(sizeof(libgamma_partition_state_t)); - libgamma_crtc_state_t* crtc_state = malloc(sizeof(libgamma_crtc_state_t)); int method; char* site; char* tmp; char buf[256]; int r; - list_methods_lists(); - method_availability(); - list_default_sites(); - method_capabilities(); - error_test(); - printf("Select adjustment method:\n"); for (method = 0; method < LIBGAMMA_METHOD_COUNT; method++) printf(" %i: %s\n", method, method_name(method)); @@ -256,6 +249,25 @@ int main(void) return libgamma_perror("error", r), 1; } + return 0; +} + + +int main(void) +{ + libgamma_site_state_t* restrict site_state = malloc(sizeof(libgamma_site_state_t)); + libgamma_partition_state_t* restrict part_state = malloc(sizeof(libgamma_partition_state_t)); + libgamma_crtc_state_t* restrict crtc_state = malloc(sizeof(libgamma_crtc_state_t)); + + list_methods_lists(); + method_availability(); + list_default_sites(); + method_capabilities(); + error_test(); + + if (select_monitor(site_state, part_state, crtc_state)) + return 1; + libgamma_crtc_free(crtc_state); libgamma_partition_free(part_state); libgamma_site_free(site_state); -- cgit v1.2.3-70-g09d2