diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2020-08-04 19:45:27 +0100 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2020-08-08 09:34:36 +0100 |
commit | 4f5692b9c78f0a9fb92c2019d509b80e08a19636 (patch) | |
tree | b8fbe055c5dbcf19a075cb56d42381cc4504859c /demos/c | |
parent | e66ab52ed2d65ad6989e73b8c6c797faced8343a (diff) | |
download | ghostpdl-4f5692b9c78f0a9fb92c2019d509b80e08a19636.tar.gz |
Update api_test: test enumeration of parameters.
Diffstat (limited to 'demos/c')
-rw-r--r-- | demos/c/api_test.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/demos/c/api_test.c b/demos/c/api_test.c index 0577c128c..249339093 100644 --- a/demos/c/api_test.c +++ b/demos/c/api_test.c @@ -839,6 +839,45 @@ failearly: return code; } +char *types[] = { + "null", + "bool", + "int", + "float", + "name", + "string", + "long", + "i64", + "size_t", + "parsed" +}; + +static int +list_params(void *instance) +{ + void *iter = NULL; + char *key; + gs_set_param_type type; + char buffer[1024]; + int code; + + while ((code = gsapi_enumerate_params(instance, &iter, &key, &type)) == 0) { + printf("Key=%s, type=%s: ", key, type >= 0 && type <= 9 ? types[type] : "invalid"); + code = gsapi_get_param(instance, gs_spt_parsed, key, NULL); + if (code < 0) + break; + if (code > sizeof(buffer)) { + printf("<overly long value>\n"); + continue; + } + code = gsapi_get_param(instance, gs_spt_parsed, key, buffer); + if (code < 0) + break; + printf("%s\n", buffer); + } + return code; +} + static int param_test(const char *dev, char *outfile) { @@ -870,6 +909,13 @@ param_test(const char *dev, char *outfile) goto fail; } + /* List the params: */ + code = list_params(instance); + if (code < 0) { + printf("Error %d while listing params\n", code); + goto fail; + } + /* Run our test. */ code = gsapi_init_with_args(instance, argc, argv); if (code < 0) { @@ -921,11 +967,18 @@ param_test(const char *dev, char *outfile) printf("Bad buffer return"); goto fail; } - if (strcmp(buffer, "<</Sp#20ce/D#7Fl/Baz<0123>/Bar<313233>/Foo[/A/B/C/D/E]/VSamples[1 1 1 1]/HSamples[1 1 1 1]/Blend 0/QFactor 0.1>>")) { + if (strcmp(buffer, "<</Sp#20ce/D#7Fl/Baz<0123>/Bar(123)/Foo[/A/B/C/D/E]/VSamples[1 1 1 1]/HSamples[1 1 1 1]/Blend 0/QFactor 0.1>>")) { printf("Bad value return"); goto fail; } + /* List the params: */ + code = list_params(instance); + if (code < 0) { + printf("Error %d in while listing params\n", code); + goto fail; + } + /* Close the interpreter down (important, or we will leak!) */ code = gsapi_exit(instance); if (code < 0) { |