aboutsummaryrefslogtreecommitdiffstats
path: root/src/cg-base.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cg-base.c')
-rw-r--r--src/cg-base.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/src/cg-base.c b/src/cg-base.c
index 52624d9..18f782e 100644
--- a/src/cg-base.c
+++ b/src/cg-base.c
@@ -20,6 +20,7 @@
#include <libcoopgamma.h>
+#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -66,18 +67,59 @@ static int list_methods(void)
}
+static int list_crtcs(libcoopgamma_context_t* restrict cg)
+{
+ char** list;
+ size_t i;
+
+ list = libcoopgamma_get_crtcs_sync(cg);
+ if (list == NULL)
+ return -1;
+ for (i = 0; list[i]; i++)
+ printf("%s\n", list[i]);
+ free(list);
+ if (fflush(stdout) < 0)
+ return -1;
+
+ return 0;
+}
+
+
int main(int argc, char* argv[])
{
+ libcoopgamma_context_t cg;
+ int init_failed = 0;
+ int stage = 0;
+
argv0 = argv[0];
if (initialise_proc() < 0)
goto fail;
- list_methods();
+ if (list_methods() < 0)
+ goto fail;
+ if (libcoopgamma_context_initialise(&cg) < 0)
+ goto fail;
+ stage++;
+ if (libcoopgamma_connect(NULL, NULL, &cg) < 0)
+ {
+ init_failed = (errno == 0);
+ goto fail;
+ }
+ stage++;
+
+ if (list_crtcs(&cg) < 0)
+ goto fail;
+ libcoopgamma_context_destroy(&cg, 1);
return 0;
fail:
- perror(argv0);
+ if (init_failed)
+ fprintf(stderr, "%s: server failed to initialise\n", argv0);
+ else
+ perror(argv0);
+ if (stage >= 1)
+ libcoopgamma_context_destroy(&cg, stage >= 2);
return 1;
}