Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / addressbook / libebook / gen-western-table.py
1 #! /usr/bin/env python
2
3 # Copyright (C) 2006 OpenedHand Ltd
4
5 # This program is free software; you can redistribute it and/or modify it under
6 # the terms of version 2 of the GNU Lesser General Public License as published
7 # by the Free Software Foundation.
8
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
12 # details.
13
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this program; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 # Author: Ross Burton <ross@openedhand.com>
19
20 import sys
21
22 var = None
23 strings = []
24
25 def output():
26     print "static const char %s_table[] = {" % var
27     for s in strings:
28         print "  \"%s\\0\"" % s
29     print "};"
30
31     print "static const guint %s_index[] = {" % var
32     index = 0
33     for s in strings:
34         print "  %d," % index
35         index += len(s) + 1
36     print "};\n"
37     
38 (S_VAR, S_STRING) = range(0, 2)
39 state = S_VAR
40
41 print "/* This file is generated by gen-western-table.py. DO NOT EDIT */"
42
43 for l in sys.stdin.readlines():
44     l = l.strip()
45     if l == "":
46         state = S_VAR
47         output()
48         var = None
49         strings = []
50     elif state == S_VAR:
51         var = l
52         state = S_STRING
53     elif state == S_STRING:
54         strings.append(l)
55
56 output()