1226031Sstas#!/usr/local/bin/python 2226031Sstas# -*- coding: iso-8859-1 -*- 3226031Sstas 4226031Sstas# $Id$ 5226031Sstas 6226031Sstas# Copyright (c) 2008 Kungliga Tekniska H��gskolan 7226031Sstas# (Royal Institute of Technology, Stockholm, Sweden). 8226031Sstas# All rights reserved. 9226031Sstas# 10226031Sstas# Redistribution and use in source and binary forms, with or without 11226031Sstas# modification, are permitted provided that the following conditions 12226031Sstas# are met: 13226031Sstas# 14226031Sstas# 1. Redistributions of source code must retain the above copyright 15226031Sstas# notice, this list of conditions and the following disclaimer. 16226031Sstas# 17226031Sstas# 2. Redistributions in binary form must reproduce the above copyright 18226031Sstas# notice, this list of conditions and the following disclaimer in the 19226031Sstas# documentation and/or other materials provided with the distribution. 20226031Sstas# 21226031Sstas# 3. Neither the name of the Institute nor the names of its contributors 22226031Sstas# may be used to endorse or promote products derived from this software 23226031Sstas# without specific prior written permission. 24226031Sstas# 25226031Sstas# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 26226031Sstas# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27226031Sstas# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28226031Sstas# ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 29226031Sstas# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30226031Sstas# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31226031Sstas# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32226031Sstas# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33226031Sstas# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34226031Sstas# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35226031Sstas# SUCH DAMAGE. 36226031Sstas 37226031Sstasimport re 38226031Sstasimport string 39226031Sstas 40226031Sstasdef _merge_table(res, source): 41226031Sstas for table in source.keys(): 42226031Sstas res[table] = res.get(table, []) + source.get(table, []) 43226031Sstas 44226031Sstasname_error = ['C.1.2', 'C.2.2', 'C.3', 'C.4', 'C.5', 'C.6', 'C.7', 'C.8', 'C.9'] 45226031Sstasldap_error = ['A.1', 'C.3', 'C.4', 'C.5', 'C.8', 'rfc4518-error' ] 46226031Sstassasl_error = ['C.1.2', 'C.2.1', 'C.2.2', 'C.3', 'C.4', 'C.5', 'C.6', 'C.7', 'C.8', 'C.9'] 47226031Sstas 48226031Sstasname_map = ['B.1', 'B.2'] 49226031Sstasldap_map = ['rfc4518-map'] 50226031Sstasldap_case_map = ['rfc4518-map', 'B.2'] 51226031Sstassasl_map = ['C.1.2', 'B.1'] 52226031Sstas 53226031Sstasdef symbols(tabledict, tables): 54226031Sstas """return CPP symbols to use for this symbols""" 55226031Sstas list = [] 56226031Sstas for x in tables: 57226031Sstas list = list + tabledict.get(x, []) 58226031Sstas if len(list) == 0: 59226031Sstas return "" 60226031Sstas return "|".join(map(lambda x: "WIND_PROFILE_%s" % (string.upper(x)), list)) 61226031Sstas 62226031Sstasdef get_errorlist(): 63226031Sstas d = dict() 64226031Sstas _merge_table(d, dict(map(lambda x: [x, ['name']], name_error))) 65226031Sstas _merge_table(d, dict(map(lambda x: [x, ['ldap']], ldap_error))) 66226031Sstas _merge_table(d, dict(map(lambda x: [x, ['sasl']], sasl_error))) 67226031Sstas return d 68226031Sstas 69226031Sstasdef get_maplist(): 70226031Sstas d = dict() 71226031Sstas _merge_table(d, dict(map(lambda x: [x, ['name']], name_map))) 72226031Sstas _merge_table(d, dict(map(lambda x: [x, ['ldap']], ldap_map))) 73226031Sstas _merge_table(d, dict(map(lambda x: [x, ['ldap_case']], ldap_case_map))) 74226031Sstas _merge_table(d, dict(map(lambda x: [x, ['sasl']], sasl_map))) 75226031Sstas return d 76226031Sstas 77226031Sstasdef sort_merge_trans(trans): 78226031Sstas trans.sort() 79226031Sstas ret = [] 80226031Sstas last = 0 81226031Sstas for x in trans: 82226031Sstas if last: 83226031Sstas if last[0] == x[0]: 84226031Sstas last = (last[0], last[1], last[2], last[3] + x[3]) 85226031Sstas else: 86226031Sstas ret.append(last) 87226031Sstas last = x 88226031Sstas else: 89226031Sstas last = x 90226031Sstas if last: 91226031Sstas ret.append(last) 92226031Sstas return ret 93