Path: utzoo!attcan!uunet!mcsun!hp4nl!star.cs.vu.nl!huisjes@cs.vu.nl From: huisjes@cs.vu.nl (Michiel Huisjes) Newsgroups: comp.windows.x Subject: XtGetApplicationResources seems to fail under X11R4 Keywords: XtAppInitialize, XtGetApplicationResources Message-ID: <7757@star.cs.vu.nl> Date: 27 Sep 90 13:45:36 GMT Sender: news@cs.vu.nl Organization: Fac. Wiskunde & Informatica, VU, Amsterdam Lines: 90 It took me three hours to figure out that the sample program below is correct according to the docs available. The problem is, that XtAppInitialize accepts an XrmOptionDescRec options structure list, but XtGetApplicationResources fails to retrieve the right values afterwards. Calling the program with parameters "-nolabel -h galjas.cs.vu.nl -port 13 -update 400" will show that XtAppInitialize does indeed parse the options (i.e. argc == 1 after the call), but XtGetApplicationResources fails to give me anything else than the specified default values of { TRUE, NULL, NULL, "60" }; Am I really doing something wrong, or is this a bug? P.S. We're running SUN/OS 4.0.1 on a SPARC station using X11R4. -- Michiel Huisjes. (huisjes@cs.vu.nl) ..!uunet!cs.vu.nl!huisjes -- cut here -- #include #include #include typedef struct s_resources { Boolean show_label; String host_name; String port_number; String update_time; } XPingResources; /* * I tried "showLabel", "*showLabel", ".showLabel" and "Xping.showLabel" * but alas */ static XrmOptionDescRec options[] = { { "-nolabel", ".showLabel", XrmoptionNoArg, "False" }, { "-host", ".hostName", XrmoptionSepArg, NULL }, { "-h", "*hostName", XrmoptionSepArg, NULL }, { "-port", ".portName", XrmoptionSepArg, NULL }, { "-p", "*portName", XrmoptionSepArg, NULL }, { "-update", ".updateTime", XrmoptionSepArg, NULL }, { "-u", "*updateTime", XrmoptionSepArg, NULL }, }; static XtResource resource_specs[] = { { "showLabel", XtCBoolean, XtRBoolean, sizeof (Boolean), XtOffsetOf (XPingResources, show_label), XtRImmediate, (caddr_t) TRUE }, { "hostName", XtCString, XtRString, sizeof (String), XtOffsetOf (XPingResources, host_name), XtRString, NULL }, { "portName", XtCString, XtRString, sizeof (String), XtOffsetOf (XPingResources, port_number), XtRString, NULL }, { "updateTime", XtCString, XtRString, sizeof (String), XtOffsetOf (XPingResources, update_time), XtRString, "60" } }; static String fallback_resources[] = { "*highlightThickness: 0", "*font: devps.cb.10.75", NULL }; main (argc, argv) int argc; char *argv[]; { XtAppContext app_con; Widget Toplevel; XPingResources resources; Toplevel = XtAppInitialize (&app_con, "Xping", options, XtNumber (options), &argc, argv, fallback_resources, NULL, ZERO); XtGetApplicationResources (Toplevel, &resources, resource_specs, XtNumber (resource_specs), NULL, ZERO); printf ("argc = %d\n\n", argc); printf ("resources.show_label = %s\n", (resources.show_label == TRUE) ? "True" : "False"); printf ("resources.host_name = %s\n", (resources.host_name == NULL) ? "" : resources.host_name); printf ("resources.port_number = %s\n", (resources.port_number == NULL) ? "" : resources.port_number); printf ("resources.update_time = %s\n", resources.update_time); }