[uim-commit] r361 - trunk/examples/uim-custom
yamaken@freedesktop.org
yamaken@freedesktop.org
Wed Jan 26 10:03:25 PST 2005
Author: yamaken
Date: 2005-01-26 10:03:21 -0800 (Wed, 26 Jan 2005)
New Revision: 361
Modified:
trunk/examples/uim-custom/uim-custom-dump.c
trunk/examples/uim-custom/uim-custom-update.c
trunk/examples/uim-custom/uim-custom-variable.c
Log:
* examples/uim-custom/uim-custom-update.c
- (main): Add error handlings around uim_init() and
uim_custom_enable()
* examples/uim-custom/uim-custom-dump.c
- (main): Ditto
* examples/uim-custom/uim-custom-variable.c
- (main): Ditto
Modified: trunk/examples/uim-custom/uim-custom-dump.c
===================================================================
--- trunk/examples/uim-custom/uim-custom-dump.c 2005-01-26 17:56:32 UTC (rev 360)
+++ trunk/examples/uim-custom/uim-custom-dump.c 2005-01-26 18:03:21 UTC (rev 361)
@@ -86,16 +86,24 @@
int
main(int argc, char *argv[])
{
- char **primary_groups, **grp;
+ if (uim_init() < 0) {
+ fprintf(stderr, "uim_init() failed.\n");
+ return -1;
+ }
- uim_init();
- uim_custom_enable();
+ if (uim_custom_enable()) {
+ char **primary_groups, **grp;
- primary_groups = uim_custom_primary_groups();
- for (grp = primary_groups; *grp; grp++) {
- dump_group(*grp);
+ primary_groups = uim_custom_primary_groups();
+ for (grp = primary_groups; *grp; grp++) {
+ dump_group(*grp);
+ }
+ uim_custom_symbol_list_free(primary_groups);
+ } else {
+ fprintf(stderr, "uim_custom_enable() failed.\n");
+ uim_quit();
+ return -1;
}
- uim_custom_symbol_list_free(primary_groups);
uim_quit();
Modified: trunk/examples/uim-custom/uim-custom-update.c
===================================================================
--- trunk/examples/uim-custom/uim-custom-update.c 2005-01-26 17:56:32 UTC (rev 360)
+++ trunk/examples/uim-custom/uim-custom-update.c 2005-01-26 18:03:21 UTC (rev 361)
@@ -37,17 +37,24 @@
int
main(int argc, char *argv[])
{
- uim_init();
- uim_custom_enable();
+ if (uim_init() < 0) {
+ fprintf(stderr, "uim_init() failed.\n");
+ return -1;
+ }
- /* save custom variables into ~/.uim.d/customs/custom-*.scm */
- uim_custom_save();
+ if (uim_custom_enable()) {
+ /* save custom variables into ~/.uim.d/customs/custom-*.scm */
+ uim_custom_save();
- /*
- broadcast updated custom variables to every uim client processes
- via uim-helper-server
- */
- uim_custom_broadcast();
+ /*
+ broadcast updated custom variables to every uim client processes
+ via uim-helper-server
+ */
+ } else {
+ fprintf(stderr, "uim_custom_enable() failed.\n");
+ uim_quit();
+ return -1;
+ }
uim_quit();
Modified: trunk/examples/uim-custom/uim-custom-variable.c
===================================================================
--- trunk/examples/uim-custom/uim-custom-variable.c 2005-01-26 17:56:32 UTC (rev 360)
+++ trunk/examples/uim-custom/uim-custom-variable.c 2005-01-26 18:03:21 UTC (rev 361)
@@ -138,40 +138,48 @@
int
main(int argc, char *argv[])
{
- uim_bool succeeded;
- struct uim_custom *custom;
+ if (uim_init() < 0) {
+ fprintf(stderr, "uim_init() failed.\n");
+ return -1;
+ }
- uim_init();
- uim_custom_enable();
+ if (uim_custom_enable()) {
+ uim_bool succeeded;
+ struct uim_custom *custom;
- custom = uim_custom_get("anthy-candidate-op-count");
- if (custom) {
- inspect_custom(custom);
+ custom = uim_custom_get("anthy-candidate-op-count");
+ if (custom) {
+ inspect_custom(custom);
- printf("\ntrying that modify the custom value to 100\n");
- custom->value->as_int = 100; /* out of range */
- succeeded = uim_custom_set(custom);
- printf("succeeded = %s\n", succeeded ? "true" : "false");
+ printf("\ntrying that modify the custom value to 100\n");
+ custom->value->as_int = 100; /* out of range */
+ succeeded = uim_custom_set(custom);
+ printf("succeeded = %s\n", succeeded ? "true" : "false");
- printf("\ncurrent status of struct uim_custom *custom\n");
- inspect_custom(custom); /* shows 100 as value */
- uim_custom_free(custom);
+ printf("\ncurrent status of struct uim_custom *custom\n");
+ inspect_custom(custom); /* shows 100 as value */
+ uim_custom_free(custom);
- printf("\ncurrent status of real custom value\n");
- custom = uim_custom_get("anthy-candidate-op-count");
- inspect_custom(custom); /* shows real value */
+ printf("\ncurrent status of real custom value\n");
+ custom = uim_custom_get("anthy-candidate-op-count");
+ inspect_custom(custom); /* shows real value */
- printf("\ntrying that modify the custom value to 5\n");
- custom->value->as_int = 5; /* valid */
- succeeded = uim_custom_set(custom);
- printf("succeeded = %s\n\n", succeeded ? "true" : "false");
- inspect_custom(custom);
+ printf("\ntrying that modify the custom value to 5\n");
+ custom->value->as_int = 5; /* valid */
+ succeeded = uim_custom_set(custom);
+ printf("succeeded = %s\n\n", succeeded ? "true" : "false");
+ inspect_custom(custom);
- uim_custom_free(custom);
+ uim_custom_free(custom);
+ }
+
+ uim_custom_save(); /* save updated custom value into ~/.uim.d/customs/ */
+ } else {
+ fprintf(stderr, "uim_custom_enable() failed.\n");
+ uim_quit();
+ return -1;
}
- uim_custom_save(); /* save updated custom value into ~/.uim.d/customs/ */
-
uim_quit();
return 0;
More information about the Uim-commit
mailing list