__init__.py 600 Bytes
Newer Older
root's avatar
root committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
import struct
import _DMDomain
import copy


DOMAIN_TYPE_MATCH="\x00"
DOMAIN_TYPE_CONTROL="\x01"

def ValidateDomainString(DomainStr, DomainType, DomainLen):
   _DMDomain.ValidateDomainString(DomainStr, DomainType, struct.pack('<B', DomainLen))
   stend=DomainStr.find("\x00")
   if stend==-1:
      stend=len(DomainStr)
   if stend > 32:
      stend=32
   DomainStr=copy.deepcopy(DomainStr[0:stend])
   return DomainStr

def DMDomainMatch(ControlStr, MatchStr, ControlLen):
   return bool(struct.unpack('<B',
         _DMDomain.DMDomainMatch(ControlStr, MatchStr, struct.pack('<B',ControlLen)))[0])