diff -r 000000000000 -r ca70ae20a155 src/tools/py2sis/ensymble/symbianutil.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/tools/py2sis/ensymble/symbianutil.py Tue Feb 16 10:07:05 2010 +0530 @@ -0,0 +1,490 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +############################################################################## +# symbianutil.py - Utilities for working with Symbian OS-related data +# Copyright 2006, 2007, 2008, 2009 Jussi Ylänen +# +# This file is part of Ensymble developer utilities for Symbian OS(TM). +# +# Ensymble is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# Ensymble is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ensymble; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +############################################################################## + +import struct +import zlib + + +############################################################################## +# Miscellaneous functions +############################################################################## + +def uidstostring(uid1, uid2, uid3): + '''Return a string of UIDs and a checksum.''' + + crc = uidcrc(uid1, uid2, uid3) + return struct.pack("= 0x80000000L: + initialvalue -= 0x100000000L + initialvalue = int(initialvalue) + + value = long(zlib.crc32(data, initialvalue)) + + if value < 0: + value += 0x100000000L + + return value ^ finalxor + +def uidcrc(uid1, uid2, uid3): + '''Calculate a Symbian OS UID checksum.''' + + # Convert UIDs to a string and group even and odd characters + # into separate strings (in a Python v2.2 compatible way). + uidstr = struct.pack(" len(negstring): + return negstring + return posstring + +def capmasktorawdata(capmask): + '''Convert capability bit mask to raw four- or eight-character string.''' + + if capmask < (1L << 32): + return struct.pack("