~ubuntu-branches/ubuntu/hardy/uim/hardy

« back to all changes in this revision

Viewing changes to examples/uim-custom/uim-custom-dump.c

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2005-12-04 13:10:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051204131042-ktzc8b17zi7a3cw8
Tags: 1:0.4.9.1-1
* New upstream release
* libuim0-nox, libuim-nox-dev, and libuim0-dbg-nox is now obsolete.
  Because libuim0 does not depends on X11. They now become dummy package,
  therefore you can safely remove them.
* Add --enable-debug in configure again.
* debian/patches/08_fix_privilage_escalation_CVE_2005_3149: disabled.
* Fix Error on purge because update-uim-config is not found.
  (closes: Bug#339345)
* uim-qt: New package for Qt utilities for uim. qt-immodule does not
  contained yet because of Debian's Qt3 does not support immodule and
  because uim does not recognize libqt4-dev's headers properly. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Copyright (c) 2003-2005 uim Project http://uim.freedesktop.org/
 
3
 
 
4
  All rights reserved.
 
5
 
 
6
  Redistribution and use in source and binary forms, with or without
 
7
  modification, are permitted provided that the following conditions
 
8
  are met:
 
9
 
 
10
  1. Redistributions of source code must retain the above copyright
 
11
     notice, this list of conditions and the following disclaimer.
 
12
  2. Redistributions in binary form must reproduce the above copyright
 
13
     notice, this list of conditions and the following disclaimer in the
 
14
     documentation and/or other materials provided with the distribution.
 
15
  3. Neither the name of authors nor the names of its contributors
 
16
     may be used to endorse or promote products derived from this software
 
17
     without specific prior written permission.
 
18
 
 
19
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
 
20
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
21
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
22
  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
 
23
  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
24
  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
25
  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
26
  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
27
  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
28
  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
29
  SUCH DAMAGE.
 
30
 
 
31
*/
 
32
 
 
33
#include <stdlib.h>
 
34
#include <stdio.h>
 
35
#include <uim/uim.h>
 
36
#include <uim/uim-custom.h>
 
37
 
 
38
static uim_bool
 
39
dump_custom(const char *custom_sym)
 
40
{
 
41
  struct uim_custom *custom;
 
42
  char *def_literal;
 
43
 
 
44
  custom = uim_custom_get(custom_sym);
 
45
  if (custom) {
 
46
    /* human readable variable name and description */
 
47
    printf("\n;; %s\n;; %s\n", custom->label, custom->desc);
 
48
 
 
49
    def_literal = uim_custom_definition_as_literal(custom_sym);
 
50
    if (def_literal) {
 
51
      printf("%s\n", def_literal);
 
52
      free(def_literal);
 
53
    }
 
54
    uim_custom_free(custom);
 
55
  }
 
56
 
 
57
  return UIM_TRUE;
 
58
}
 
59
 
 
60
static uim_bool
 
61
dump_group(const char *group_sym)
 
62
{
 
63
  struct uim_custom_group *group;
 
64
  char **custom_syms, **custom_sym;
 
65
 
 
66
  group = uim_custom_group_get(group_sym);
 
67
  if (!group)
 
68
    return UIM_FALSE;
 
69
 
 
70
  /* print group header */
 
71
  printf(";;;\n;;; %s\n;;;\n", group->label);
 
72
 
 
73
  custom_syms = uim_custom_collect_by_group(group_sym);
 
74
  if (custom_syms) {
 
75
    for (custom_sym = custom_syms; *custom_sym; custom_sym++) {
 
76
      dump_custom(*custom_sym);
 
77
    }
 
78
    uim_custom_symbol_list_free(custom_syms);
 
79
  }
 
80
 
 
81
  printf("\n\n");
 
82
 
 
83
  return UIM_TRUE;
 
84
}
 
85
 
 
86
int
 
87
main(int argc, char *argv[])
 
88
{
 
89
  if (uim_init() < 0) {
 
90
    fprintf(stderr, "uim_init() failed.\n");
 
91
    return -1;
 
92
  }
 
93
 
 
94
  if (uim_custom_enable()) {
 
95
    char **primary_groups, **grp;
 
96
 
 
97
    primary_groups = uim_custom_primary_groups();
 
98
    for (grp = primary_groups; *grp; grp++) {
 
99
      dump_group(*grp);
 
100
    }
 
101
    uim_custom_symbol_list_free(primary_groups);
 
102
  } else {
 
103
    fprintf(stderr, "uim_custom_enable() failed.\n");
 
104
    uim_quit();
 
105
    return -1;
 
106
  }
 
107
 
 
108
  uim_quit();
 
109
 
 
110
  return 0;
 
111
}