pychm-0.8.4.1/0000755000076500000240000000000012367462143014105 5ustar dottedmagstaff00000000000000pychm-0.8.4.1/chm/0000755000076500000240000000000012367462143014654 5ustar dottedmagstaff00000000000000pychm-0.8.4.1/chm/__init__.py0000644000076500000240000000247112367355204016770 0ustar dottedmagstaff00000000000000# Copyright (C) 2003-2006 Rubens Ramos # # pychm 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. # # This program 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 this program; see the file COPYING. If not, # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA # ''' chm - A package to manipulate CHM files The chm package provides four modules: chm, chmlib, extra and _chmlib. _chmlib and chmlib are very low level libraries generated from SWIG interface files, and are simple wrappers around the API defined by the C library chmlib. The extra module adds full-text search support. the chm module provides some higher level classes to simplify access to the CHM files information. ''' __all__ = ["chm", "chmlib", "_chmlib", "extra"] __version__ = "0.8.4.1" __revision__ = "$Id$" pychm-0.8.4.1/chm/chm.py0000644000076500000240000005012512367355162016002 0ustar dottedmagstaff00000000000000# Copyright (C) 2003-2006 Rubens Ramos # # Based on code by: # Copyright (C) 2003 Razvan Cojocaru # # pychm 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. # # This program 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 this program; see the file COPYING. If not, # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA ''' chm - A high-level front end for the chmlib python module. The chm module provides high level access to the functionality included in chmlib. It encapsulates functions in the CHMFile class, and provides some additional features, such as the ability to obtain the contents tree of a CHM archive. ''' import chmlib import extra import array import string import os.path import sys charset_table = { 0: 'iso8859_1', # ANSI_CHARSET 238: 'iso8859_2', # EASTEUROPE_CHARSET 178: 'iso8859_6', # ARABIC_CHARSET 161: 'iso8859_7', # GREEK_CHARSET 177: 'iso8859_8', # HEBREW_CHARSET 162: 'iso8859_9', # TURKISH_CHARSET 222: 'iso8859_11', # THAI_CHARSET - hmm not in python 2.2... 186: 'iso8859_13', # BALTIC_CHARSET 204: 'cp1251', # RUSSIAN_CHARSET 255: 'cp437', # OEM_CHARSET 128: 'cp932', # SHIFTJIS_CHARSET 134: 'cp936', # GB2312_CHARSET 129: 'cp949', # HANGUL_CHARSET 136: 'cp950', # CHINESEBIG5_CHARSET 1: None, # DEFAULT_CHARSET 2: None, # SYMBOL_CHARSET 130: None, # JOHAB_CHARSET 163: None, # VIETNAMESE_CHARSET 77: None, # MAC_CHARSET } locale_table = { 0x0436: ('iso8859_1', "Afrikaans", "Western Europe & US"), 0x041c: ('iso8859_2', "Albanian", "Central Europe"), 0x0401: ('iso8859_6', "Arabic_Saudi_Arabia", "Arabic"), 0x0801: ('iso8859_6', "Arabic_Iraq", "Arabic"), 0x0c01: ('iso8859_6', "Arabic_Egypt", "Arabic"), 0x1001: ('iso8859_6', "Arabic_Libya", "Arabic"), 0x1401: ('iso8859_6', "Arabic_Algeria", "Arabic"), 0x1801: ('iso8859_6', "Arabic_Morocco", "Arabic"), 0x1c01: ('iso8859_6', "Arabic_Tunisia", "Arabic"), 0x2001: ('iso8859_6', "Arabic_Oman", "Arabic"), 0x2401: ('iso8859_6', "Arabic_Yemen", "Arabic"), 0x2801: ('iso8859_6', "Arabic_Syria", "Arabic"), 0x2c01: ('iso8859_6', "Arabic_Jordan", "Arabic"), 0x3001: ('iso8859_6', "Arabic_Lebanon", "Arabic"), 0x3401: ('iso8859_6', "Arabic_Kuwait", "Arabic"), 0x3801: ('iso8859_6', "Arabic_UAE", "Arabic"), 0x3c01: ('iso8859_6', "Arabic_Bahrain", "Arabic"), 0x4001: ('iso8859_6', "Arabic_Qatar", "Arabic"), 0x042b: (None, "Armenian", "Armenian"), 0x042c: ('iso8859_9', "Azeri_Latin", "Turkish"), 0x082c: ('cp1251', "Azeri_Cyrillic", "Cyrillic"), 0x042d: ('iso8859_1', "Basque", "Western Europe & US"), 0x0423: ('cp1251', "Belarusian", "Cyrillic"), 0x0402: ('cp1251', "Bulgarian", "Cyrillic"), 0x0403: ('iso8859_1', "Catalan", "Western Europe & US"), 0x0404: ('cp950', "Chinese_Taiwan", "Traditional Chinese"), 0x0804: ('cp936', "Chinese_PRC", "Simplified Chinese"), 0x0c04: ('cp950', "Chinese_Hong_Kong", "Traditional Chinese"), 0x1004: ('cp936', "Chinese_Singapore", "Simplified Chinese"), 0x1404: ('cp950', "Chinese_Macau", "Traditional Chinese"), 0x041a: ('iso8859_2', "Croatian", "Central Europe"), 0x0405: ('iso8859_2', "Czech", "Central Europe"), 0x0406: ('iso8859_1', "Danish", "Western Europe & US"), 0x0413: ('iso8859_1', "Dutch_Standard", "Western Europe & US"), 0x0813: ('iso8859_1', "Dutch_Belgian", "Western Europe & US"), 0x0409: ('iso8859_1', "English_United_States", "Western Europe & US"), 0x0809: ('iso8859_1', "English_United_Kingdom", "Western Europe & US"), 0x0c09: ('iso8859_1', "English_Australian", "Western Europe & US"), 0x1009: ('iso8859_1', "English_Canadian", "Western Europe & US"), 0x1409: ('iso8859_1', "English_New_Zealand", "Western Europe & US"), 0x1809: ('iso8859_1', "English_Irish", "Western Europe & US"), 0x1c09: ('iso8859_1', "English_South_Africa", "Western Europe & US"), 0x2009: ('iso8859_1', "English_Jamaica", "Western Europe & US"), 0x2409: ('iso8859_1', "English_Caribbean", "Western Europe & US"), 0x2809: ('iso8859_1', "English_Belize", "Western Europe & US"), 0x2c09: ('iso8859_1', "English_Trinidad", "Western Europe & US"), 0x3009: ('iso8859_1', "English_Zimbabwe", "Western Europe & US"), 0x3409: ('iso8859_1', "English_Philippines", "Western Europe & US"), 0x0425: ('iso8859_13', "Estonian", "Baltic",), 0x0438: ('iso8859_1', "Faeroese", "Western Europe & US"), 0x0429: ('iso8859_6', "Farsi", "Arabic"), 0x040b: ('iso8859_1', "Finnish", "Western Europe & US"), 0x040c: ('iso8859_1', "French_Standard", "Western Europe & US"), 0x080c: ('iso8859_1', "French_Belgian", "Western Europe & US"), 0x0c0c: ('iso8859_1', "French_Canadian", "Western Europe & US"), 0x100c: ('iso8859_1', "French_Swiss", "Western Europe & US"), 0x140c: ('iso8859_1', "French_Luxembourg", "Western Europe & US"), 0x180c: ('iso8859_1', "French_Monaco", "Western Europe & US"), 0x0437: (None, "Georgian", "Georgian"), 0x0407: ('iso8859_1', "German_Standard", "Western Europe & US"), 0x0807: ('iso8859_1', "German_Swiss", "Western Europe & US"), 0x0c07: ('iso8859_1', "German_Austrian", "Western Europe & US"), 0x1007: ('iso8859_1', "German_Luxembourg", "Western Europe & US"), 0x1407: ('iso8859_1', "German_Liechtenstein", "Western Europe & US"), 0x0408: ('iso8859_7', "Greek", "Greek"), 0x040d: ('iso8859_8', "Hebrew", "Hebrew"), 0x0439: (None, "Hindi", "Indic"), 0x040e: ('iso8859_2', "Hungarian", "Central Europe"), 0x040f: ('iso8859_1', "Icelandic", "Western Europe & US"), 0x0421: ('iso8859_1', "Indonesian", "Western Europe & US"), 0x0410: ('iso8859_1', "Italian_Standard", "Western Europe & US"), 0x0810: ('iso8859_1', "Italian_Swiss", "Western Europe & US"), 0x0411: ('cp932', "Japanese", "Japanese"), 0x043f: ('cp1251', "Kazakh", "Cyrillic"), 0x0457: (None, "Konkani", "Indic"), 0x0412: ('cp949', "Korean", "Korean"), 0x0426: ('iso8859_13', "Latvian", "Baltic",), 0x0427: ('iso8859_13', "Lithuanian", "Baltic",), 0x042f: ('cp1251', "Macedonian", "Cyrillic"), 0x043e: ('iso8859_1', "Malay_Malaysia", "Western Europe & US"), 0x083e: ('iso8859_1', "Malay_Brunei_Darussalam", "Western Europe & US"), 0x044e: (None, "Marathi", "Indic"), 0x0414: ('iso8859_1', "Norwegian_Bokmal", "Western Europe & US"), 0x0814: ('iso8859_1', "Norwegian_Nynorsk", "Western Europe & US"), 0x0415: ('iso8859_2', "Polish", "Central Europe"), 0x0416: ('iso8859_1', "Portuguese_Brazilian", "Western Europe & US"), 0x0816: ('iso8859_1', "Portuguese_Standard", "Western Europe & US"), 0x0418: ('iso8859_2', "Romanian", "Central Europe"), 0x0419: ('cp1251', "Russian", "Cyrillic"), 0x044f: (None, "Sanskrit", "Indic"), 0x081a: ('iso8859_2', "Serbian_Latin", "Central Europe"), 0x0c1a: ('cp1251', "Serbian_Cyrillic", "Cyrillic"), 0x041b: ('iso8859_2', "Slovak", "Central Europe"), 0x0424: ('iso8859_2', "Slovenian", "Central Europe"), 0x040a: ('iso8859_1', "Spanish_Trad_Sort", "Western Europe & US"), 0x080a: ('iso8859_1', "Spanish_Mexican", "Western Europe & US"), 0x0c0a: ('iso8859_1', "Spanish_Modern_Sort", "Western Europe & US"), 0x100a: ('iso8859_1', "Spanish_Guatemala", "Western Europe & US"), 0x140a: ('iso8859_1', "Spanish_Costa_Rica", "Western Europe & US"), 0x180a: ('iso8859_1', "Spanish_Panama", "Western Europe & US"), 0x1c0a: ('iso8859_1', "Spanish_Dominican_Repub", "Western Europe & US"), 0x200a: ('iso8859_1', "Spanish_Venezuela", "Western Europe & US"), 0x240a: ('iso8859_1', "Spanish_Colombia", "Western Europe & US"), 0x280a: ('iso8859_1', "Spanish_Peru", "Western Europe & US"), 0x2c0a: ('iso8859_1', "Spanish_Argentina", "Western Europe & US"), 0x300a: ('iso8859_1', "Spanish_Ecuador", "Western Europe & US"), 0x340a: ('iso8859_1', "Spanish_Chile", "Western Europe & US"), 0x380a: ('iso8859_1', "Spanish_Uruguay", "Western Europe & US"), 0x3c0a: ('iso8859_1', "Spanish_Paraguay", "Western Europe & US"), 0x400a: ('iso8859_1', "Spanish_Bolivia", "Western Europe & US"), 0x440a: ('iso8859_1', "Spanish_El_Salvador", "Western Europe & US"), 0x480a: ('iso8859_1', "Spanish_Honduras", "Western Europe & US"), 0x4c0a: ('iso8859_1', "Spanish_Nicaragua", "Western Europe & US"), 0x500a: ('iso8859_1', "Spanish_Puerto_Rico", "Western Europe & US"), 0x0441: ('iso8859_1', "Swahili", "Western Europe & US"), 0x041d: ('iso8859_1', "Swedish", "Western Europe & US"), 0x081d: ('iso8859_1', "Swedish_Finland", "Western Europe & US"), 0x0449: (None, "Tamil", "Indic"), 0x0444: ('cp1251', "Tatar", "Cyrillic"), 0x041e: ('iso8859_11', "Thai", "Thai"), 0x041f: ('iso8859_9', "Turkish", "Turkish"), 0x0422: ('cp1251', "Ukrainian", "Cyrillic"), 0x0420: ('iso8859_6', "Urdu", "Arabic"), 0x0443: ('iso8859_9', "Uzbek_Latin", "Turkish"), 0x0843: ('cp1251', "Uzbek_Cyrillic", "Cyrillic"), 0x042a: (None, "Vietnamese", "Vietnamese") } class CHMFile: "A class to manage access to CHM files." filename = "" file = None title = "" home = "/" index = None topics = None encoding = None lcid = None binaryindex = None def __init__(self): self.searchable = 0 def LoadCHM(self, archiveName): '''Loads a CHM archive. This function will also call GetArchiveInfo to obtain information such as the index file name and the topics file. It returns 1 on success, and 0 if it fails. ''' if self.filename is not None: self.CloseCHM() self.file = chmlib.chm_open(archiveName) if self.file is None: return 0 self.filename = archiveName self.GetArchiveInfo() return 1 def CloseCHM(self): '''Closes the CHM archive. This function will close the CHM file, if it is open. All variables are also reset. ''' if self.filename is not None: chmlib.chm_close(self.file) self.file = None self.filename = '' self.title = "" self.home = "/" self.index = None self.topics = None self.encoding = None def GetArchiveInfo(self): '''Obtains information on CHM archive. This function checks the /#SYSTEM file inside the CHM archive to obtain the index, home page, topics, encoding and title. It is called from LoadCHM. ''' self.searchable = extra.is_searchable(self.file) self.lcid = None result, ui = chmlib.chm_resolve_object(self.file, '/#SYSTEM') if (result != chmlib.CHM_RESOLVE_SUCCESS): sys.stderr.write('GetArchiveInfo: #SYSTEM does not exist\n') return 0 size, text = chmlib.chm_retrieve_object(self.file, ui, 4l, ui.length) if (size == 0): sys.stderr.write('GetArchiveInfo: file size = 0\n') return 0 buff = array.array('B', text) index = 0 while (index < size): cursor = buff[index] + (buff[index+1] * 256) if (cursor == 0): index += 2 cursor = buff[index] + (buff[index+1] * 256) index += 2 self.topics = '/' + text[index:index+cursor-1] elif (cursor == 1): index += 2 cursor = buff[index] + (buff[index+1] * 256) index += 2 self.index = '/' + text[index:index+cursor-1] elif (cursor == 2): index += 2 cursor = buff[index] + (buff[index+1] * 256) index += 2 self.home = '/' + text[index:index+cursor-1] elif (cursor == 3): index += 2 cursor = buff[index] + (buff[index+1] * 256) index += 2 self.title = text[index:index+cursor-1] elif (cursor == 4): index += 2 cursor = buff[index] + (buff[index+1] * 256) index += 2 self.lcid = buff[index] + (buff[index+1] * 256) elif (cursor == 6): index += 2 cursor = buff[index] + (buff[index+1] * 256) index += 2 tmp = text[index:index+cursor-1] if not self.topics: tmp1 = '/' + tmp + '.hhc' tmp2 = '/' + tmp + '.hhk' res1, ui1 = chmlib.chm_resolve_object(self.file, tmp1) res2, ui2 = chmlib.chm_resolve_object(self.file, tmp2) if not self.topics and res1 == chmlib.CHM_RESOLVE_SUCCESS: self.topics = '/' + tmp + '.hhc' if not self.index and res2 == chmlib.CHM_RESOLVE_SUCCESS: self.index = '/' + tmp + '.hhk' elif (cursor == 16): index += 2 cursor = buff[index] + (buff[index+1] * 256) index += 2 self.encoding = text[index:index+cursor-1] else: index += 2 cursor = buff[index] + (buff[index+1] * 256) index += 2 index += cursor self.GetWindowsInfo() if not self.lcid: self.lcid = extra.get_lcid(self.file) return 1 def GetTopicsTree(self): '''Reads and returns the topics tree. This auxiliary function reads and returns the topics tree file contents for the CHM archive. ''' if self.topics is None: return None if self.topics: res, ui = chmlib.chm_resolve_object(self.file, self.topics) if (res != chmlib.CHM_RESOLVE_SUCCESS): return None size, text = chmlib.chm_retrieve_object(self.file, ui, 0l, ui.length) if (size == 0): sys.stderr.write('GetTopicsTree: file size = 0\n') return None return text def GetIndex(self): '''Reads and returns the index tree. This auxiliary function reads and returns the index tree file contents for the CHM archive. ''' if self.index is None: return None if self.index: res, ui = chmlib.chm_resolve_object(self.file, self.index) if (res != chmlib.CHM_RESOLVE_SUCCESS): return None size, text = chmlib.chm_retrieve_object(self.file, ui, 0l, ui.length) if (size == 0): sys.stderr.write('GetIndex: file size = 0\n') return None return text def ResolveObject(self, document): '''Tries to locate a document in the archive. This function tries to locate the document inside the archive. It returns a tuple where the first element is zero if the function was successful, and the second is the UnitInfo for that document. The UnitInfo is used to retrieve the document contents ''' if self.file: path = os.path.abspath(document) return chmlib.chm_resolve_object(self.file, path) else: return (1, None) def RetrieveObject(self, ui, start=-1, length=-1): '''Retrieves the contents of a document. This function takes a UnitInfo and two optional arguments, the first being the start address and the second is the length. These define the amount of data to be read from the archive. ''' if self.file and ui: if length == -1: len = ui.length else: len = length if start == -1: st = 0l else: st = long(start) return chmlib.chm_retrieve_object(self.file, ui, st, len) else: return (0, '') def Search(self, text, wholewords=0, titleonly=0): '''Performs full-text search on the archive. The first parameter is the word to look for, the second indicates if the search should be for whole words only, and the third parameter indicates if the search should be restricted to page titles. This method will return a tuple, the first item indicating if the search results were partial, and the second item being a dictionary containing the results.''' if text and text != '' and self.file: return extra.search(self.file, text, wholewords, titleonly) else: return None def IsSearchable(self): '''Indicates if the full-text search is available for this archive - this flag is updated when GetArchiveInfo is called''' return self.searchable def GetEncoding(self): '''Returns a string that can be used with the codecs python package to encode or decode the files in the chm archive. If an error is found, or if it is not possible to find the encoding, None is returned.''' if self.encoding: vals = string.split(self.encoding, ',') if len(vals) > 2: try: return charset_table[int(vals[2])] except KeyError: pass return None def GetLCID(self): '''Returns the archive Locale ID''' if self.lcid in locale_table: return locale_table[self.lcid] else: return None def GetDWORD(self, buff, idx=0): '''Internal method. Reads a double word (4 bytes) from a buffer. ''' result = buff[idx] + (buff[idx+1] << 8) + (buff[idx+2] << 16) + \ (buff[idx+3] << 24) if result == 0xFFFFFFFF: result = 0 return result def GetString(self, text, idx): '''Internal method. Retrieves a string from the #STRINGS buffer. ''' next = string.find(text, '\x00', idx) chunk = text[idx:next] return chunk def GetWindowsInfo(self): '''Gets information from the #WINDOWS file. Checks the #WINDOWS file to see if it has any info that was not found in #SYSTEM (topics, index or default page. ''' result, ui = chmlib.chm_resolve_object(self.file, '/#WINDOWS') if (result != chmlib.CHM_RESOLVE_SUCCESS): return -1 size, text = chmlib.chm_retrieve_object(self.file, ui, 0l, 8) if (size < 8): return -2 buff = array.array('B', text) num_entries = self.GetDWORD(buff, 0) entry_size = self.GetDWORD(buff, 4) if num_entries < 1: return -3 size, text = chmlib.chm_retrieve_object(self.file, ui, 8l, entry_size) if (size < entry_size): return -4 buff = array.array('B', text) toc_index = self.GetDWORD(buff, 0x60) idx_index = self.GetDWORD(buff, 0x64) dft_index = self.GetDWORD(buff, 0x68) result, ui = chmlib.chm_resolve_object(self.file, '/#STRINGS') if (result != chmlib.CHM_RESOLVE_SUCCESS): return -5 size, text = chmlib.chm_retrieve_object(self.file, ui, 0l, ui.length) if (size == 0): return -6 if (not self.topics): self.topics = self.GetString(text, toc_index) if not self.topics.startswith("/"): self.topics = "/" + self.topics if (not self.index): self.index = self.GetString(text, idx_index) if not self.index.startswith("/"): self.index = "/" + self.index if (dft_index != 0): self.home = self.GetString(text, dft_index) if not self.home.startswith("/"): self.home = "/" + self.home pychm-0.8.4.1/chm/chmlib.py0000644000076500000240000000737012367173523016474 0ustar dottedmagstaff00000000000000# This file was created automatically by SWIG. # Don't modify this file, modify the SWIG interface instead. # This file is compatible with both classic and new-style classes. import _chmlib def _swig_setattr(self,class_type,name,value): if (name == "this"): if isinstance(value, class_type): self.__dict__[name] = value.this if hasattr(value,"thisown"): self.__dict__["thisown"] = value.thisown del value.thisown return method = class_type.__swig_setmethods__.get(name,None) if method: return method(self,value) self.__dict__[name] = value def _swig_getattr(self,class_type,name): method = class_type.__swig_getmethods__.get(name,None) if method: return method(self) raise AttributeError,name import types try: _object = types.ObjectType _newclass = 1 except AttributeError: class _object : pass _newclass = 0 CHM_UNCOMPRESSED = _chmlib.CHM_UNCOMPRESSED CHM_COMPRESSED = _chmlib.CHM_COMPRESSED CHM_MAX_PATHLEN = _chmlib.CHM_MAX_PATHLEN class chmUnitInfo(_object): __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, chmUnitInfo, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, chmUnitInfo, name) __swig_setmethods__["start"] = _chmlib.chmUnitInfo_start_set __swig_getmethods__["start"] = _chmlib.chmUnitInfo_start_get if _newclass:start = property(_chmlib.chmUnitInfo_start_get,_chmlib.chmUnitInfo_start_set) __swig_setmethods__["length"] = _chmlib.chmUnitInfo_length_set __swig_getmethods__["length"] = _chmlib.chmUnitInfo_length_get if _newclass:length = property(_chmlib.chmUnitInfo_length_get,_chmlib.chmUnitInfo_length_set) __swig_setmethods__["space"] = _chmlib.chmUnitInfo_space_set __swig_getmethods__["space"] = _chmlib.chmUnitInfo_space_get if _newclass:space = property(_chmlib.chmUnitInfo_space_get,_chmlib.chmUnitInfo_space_set) __swig_setmethods__["path"] = _chmlib.chmUnitInfo_path_set __swig_getmethods__["path"] = _chmlib.chmUnitInfo_path_get if _newclass:path = property(_chmlib.chmUnitInfo_path_get,_chmlib.chmUnitInfo_path_set) def __init__(self,*args): _swig_setattr(self, chmUnitInfo, 'this', apply(_chmlib.new_chmUnitInfo,args)) _swig_setattr(self, chmUnitInfo, 'thisown', 1) def __del__(self, destroy= _chmlib.delete_chmUnitInfo): try: if self.thisown: destroy(self) except: pass def __repr__(self): return "" % (self.this,) class chmUnitInfoPtr(chmUnitInfo): def __init__(self,this): _swig_setattr(self, chmUnitInfo, 'this', this) if not hasattr(self,"thisown"): _swig_setattr(self, chmUnitInfo, 'thisown', 0) _swig_setattr(self, chmUnitInfo,self.__class__,chmUnitInfo) _chmlib.chmUnitInfo_swigregister(chmUnitInfoPtr) chm_open = _chmlib.chm_open chm_close = _chmlib.chm_close CHM_PARAM_MAX_BLOCKS_CACHED = _chmlib.CHM_PARAM_MAX_BLOCKS_CACHED chm_set_param = _chmlib.chm_set_param CHM_RESOLVE_SUCCESS = _chmlib.CHM_RESOLVE_SUCCESS CHM_RESOLVE_FAILURE = _chmlib.CHM_RESOLVE_FAILURE chm_resolve_object = _chmlib.chm_resolve_object chm_retrieve_object = _chmlib.chm_retrieve_object CHM_ENUMERATE_NORMAL = _chmlib.CHM_ENUMERATE_NORMAL CHM_ENUMERATE_META = _chmlib.CHM_ENUMERATE_META CHM_ENUMERATE_SPECIAL = _chmlib.CHM_ENUMERATE_SPECIAL CHM_ENUMERATE_FILES = _chmlib.CHM_ENUMERATE_FILES CHM_ENUMERATE_DIRS = _chmlib.CHM_ENUMERATE_DIRS CHM_ENUMERATE_ALL = _chmlib.CHM_ENUMERATE_ALL CHM_ENUMERATOR_FAILURE = _chmlib.CHM_ENUMERATOR_FAILURE CHM_ENUMERATOR_CONTINUE = _chmlib.CHM_ENUMERATOR_CONTINUE CHM_ENUMERATOR_SUCCESS = _chmlib.CHM_ENUMERATOR_SUCCESS chm_enumerate = _chmlib.chm_enumerate chm_enumerate_dir = _chmlib.chm_enumerate_dir pychm-0.8.4.1/chm/extra.c0000644000076500000240000004201412367175574016155 0ustar dottedmagstaff00000000000000/* * extra.c - full-text search support for pychm * * Copyright (C) 2004 Rubens Ramos * * This program 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. * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. * * Author: Rubens Ramos * * Heavily based on work done by: * Pabs - chmdeco * Razvan Cojocaru - xCHM * */ #include "chm_lib.h" #ifdef __PYTHON__ #include "Python.h" #else #include #define PyObject void #endif #include #include #include #if defined(_WIN32) || defined(__WIN32__) # if defined(_MSC_VER) # if defined(STATIC_LINKED) # define MODEXPORT(a) a # define MODIMPORT(a) extern a # else # define MODEXPORT(a) __declspec(dllexport) a # define MODIMPORT(a) extern a # endif # else # if defined(__BORLANDC__) # define MODEXPORT(a) a _export # define MODIMPORT(a) a _export # else # define MODEXPORT(a) a # define MODIMPORT(a) a # endif # endif #else # define MODEXPORT(a) a # define MODIMPORT(a) a #endif #define false 0 #define true 1 #define FTS_HEADER_LEN 0x32 #define TOPICS_ENTRY_LEN 16 #define COMMON_BUF_LEN 1025 #define FREE(x) free (x); x = NULL static uint16_t get_uint16 (uint8_t* b) { return b[0] | b[1]<<8; } static uint32_t get_uint32 (uint8_t* b) { return b[0] | b[1]<<8 | b[2]<<16 | b[3]<<24; } static uint64_t get_uint64 (uint8_t* b) { return b[0] | b[1]<<8 | b[2]<<16 | b[3]<<24 | (uint64_t) b[4]<<32 | (uint64_t) b[5]<<40 | (uint64_t) b[6]<<48 | (uint64_t) b[7]<<56; } static uint64_t be_encint (unsigned char *buffer, size_t *length) { uint64_t result = 0; int shift=0; *length = 0; do { result |= ((*buffer) & 0x7f) << shift; shift += 7; *length = *length + 1; } while (*(buffer++) & 0x80); return result; } /* Finds the first unset bit in memory. Returns the number of set bits found. Returns -1 if the buffer runs out before we find an unset bit. */ static int ffus (unsigned char* byte, int* bit, size_t *length) { int bits = 0; *length = 0; while(*byte & (1 << *bit)){ if(*bit) --(*bit); else { ++byte; ++(*length); *bit = 7; } ++bits; } if(*bit) --(*bit); else { ++(*length); *bit = 7; } return bits; } static uint64_t sr_int(unsigned char* byte, int* bit, unsigned char s, unsigned char r, size_t *length) { uint64_t ret; unsigned char mask; int n, n_bits, num_bits, base, count; size_t fflen; *length = 0; if(!bit || *bit > 7 || s != 2) return ~(uint64_t)0; ret = 0; count = ffus(byte, bit, &fflen); *length += fflen; byte += *length; n_bits = n = r + (count ? count-1 : 0) ; while (n > 0) { num_bits = n > *bit ? *bit : n-1; base = n > *bit ? 0 : *bit - (n-1); switch (num_bits){ case 0: mask = 1; break; case 1: mask = 3; break; case 2: mask = 7; break; case 3: mask = 0xf; break; case 4: mask = 0x1f; break; case 5: mask = 0x3f; break; case 6: mask = 0x7f; break; case 7: mask = 0xff; break; default: mask = 0xff; break; } mask <<= base; ret = (ret << (num_bits+1)) | (uint64_t)((*byte & mask) >> base); if( n > *bit ){ ++byte; ++(*length); n -= *bit+1; *bit = 7; } else { *bit -= n; n = 0; } } if(count) ret |= (uint64_t)1 << n_bits; return ret; } static uint32_t get_leaf_node_offset(struct chmFile *chmfile, const char *text, uint32_t initial_offset, uint32_t buff_size, uint16_t tree_depth, struct chmUnitInfo *ui) { unsigned char word_len; unsigned char pos; uint16_t free_space; char *wrd_buf; char *word = NULL; uint32_t test_offset = 0; uint32_t i = sizeof(uint16_t); unsigned char *buffer = malloc (buff_size); if (NULL == buffer) return 0; while (--tree_depth) { if (initial_offset == test_offset) { FREE(buffer); return 0; } test_offset = initial_offset; if (chm_retrieve_object (chmfile, ui, buffer, initial_offset, buff_size) == 0) { FREE(buffer); return 0; } free_space = get_uint16 (buffer); while (i < buff_size - free_space) { word_len = *(buffer + i); pos = *(buffer + i + 1); wrd_buf = malloc (word_len); memcpy (wrd_buf, buffer + i + 2, word_len - 1); wrd_buf[word_len - 1] = 0; if (pos == 0) { FREE (word); word = (char *) strdup (wrd_buf); } else { word = realloc (word, word_len + pos + 1); strcpy (word + pos, wrd_buf); } FREE(wrd_buf); if (strcasecmp (text, word) <= 0) { initial_offset = get_uint32 (buffer + i + word_len + 1); break; } i += word_len + sizeof (unsigned char) + sizeof(uint32_t) + sizeof(uint16_t); } } if(initial_offset == test_offset) initial_offset = 0; FREE(word); FREE(buffer); return initial_offset; } static int pychm_process_wlc (struct chmFile *chmfile, uint64_t wlc_count, uint64_t wlc_size, uint32_t wlc_offset, unsigned char ds, unsigned char dr, unsigned char cs, unsigned char cr, unsigned char ls, unsigned char lr, struct chmUnitInfo *uimain, struct chmUnitInfo* uitbl, struct chmUnitInfo *uistrings, struct chmUnitInfo* topics, struct chmUnitInfo *urlstr, PyObject *dict) { uint32_t stroff, urloff; uint64_t i, j, count; size_t length; int wlc_bit = 7; size_t off = 0; uint64_t index = 0; unsigned char entry[TOPICS_ENTRY_LEN]; unsigned char combuf[COMMON_BUF_LEN]; unsigned char *buffer = malloc (wlc_size); char *url = NULL; char *topic = NULL; if (chm_retrieve_object(chmfile, uimain, buffer, wlc_offset, wlc_size) == 0) { FREE(buffer); return false; } for (i = 0; i < wlc_count; ++i) { if(wlc_bit != 7) { ++off; wlc_bit = 7; } index += sr_int(buffer + off, &wlc_bit, ds, dr, &length); off += length; if(chm_retrieve_object(chmfile, topics, entry, index * 16, TOPICS_ENTRY_LEN) == 0) { FREE(topic); FREE(url); FREE(buffer); return false; } combuf[COMMON_BUF_LEN - 1] = 0; stroff = get_uint32 (entry + 4); FREE (topic); if (chm_retrieve_object (chmfile, uistrings, combuf, stroff, COMMON_BUF_LEN - 1) == 0) { topic = strdup ("Untitled in index"); } else { combuf[COMMON_BUF_LEN - 1] = 0; topic = strdup (combuf); } urloff = get_uint32 (entry + 8); if(chm_retrieve_object (chmfile, uitbl, combuf, urloff, 12) == 0) { FREE(buffer); return false; } urloff = get_uint32 (combuf + 8); if (chm_retrieve_object (chmfile, urlstr, combuf, urloff + 8, COMMON_BUF_LEN - 1) == 0) { FREE(topic); FREE(url); FREE(buffer); return false; } combuf[COMMON_BUF_LEN - 1] = 0; FREE (url); url = strdup (combuf); if (url && topic) { #ifdef __PYTHON__ PyDict_SetItemString (dict, topic, PyString_FromString (url)); #else printf ("%s ==> %s\n", url, topic); #endif } count = sr_int (buffer + off, &wlc_bit, cs, cr, &length); off += length; for (j = 0; j < count; ++j) { sr_int (buffer + off, &wlc_bit, ls, lr, &length); off += length; } } FREE(topic); FREE(url); FREE(buffer); return true; } static int chm_search (struct chmFile *chmfile, const char *text, int whole_words, int titles_only, PyObject *dict) { unsigned char header[FTS_HEADER_LEN]; unsigned char doc_index_s; unsigned char doc_index_r; unsigned char code_count_s; unsigned char code_count_r; unsigned char loc_codes_s; unsigned char loc_codes_r; unsigned char word_len, pos; unsigned char *buffer; char *word = NULL; uint32_t node_offset; uint32_t node_len; uint16_t tree_depth; uint32_t i; uint16_t free_space; uint64_t wlc_count, wlc_size; uint32_t wlc_offset; char *wrd_buf; unsigned char title; size_t encsz; struct chmUnitInfo ui, uitopics, uiurltbl, uistrings, uiurlstr; int partial = false; if (NULL == text) return -1; if (chm_resolve_object (chmfile, "/$FIftiMain", &ui) != CHM_RESOLVE_SUCCESS || chm_resolve_object (chmfile, "/#TOPICS", &uitopics) != CHM_RESOLVE_SUCCESS || chm_resolve_object (chmfile, "/#STRINGS", &uistrings) != CHM_RESOLVE_SUCCESS || chm_resolve_object (chmfile, "/#URLTBL", &uiurltbl) != CHM_RESOLVE_SUCCESS || chm_resolve_object (chmfile, "/#URLSTR", &uiurlstr) != CHM_RESOLVE_SUCCESS) return false; if(chm_retrieve_object(chmfile, &ui, header, 0, FTS_HEADER_LEN) == 0) return false; doc_index_s = header[0x1E]; doc_index_r = header[0x1F]; code_count_s = header[0x20]; code_count_r = header[0x21]; loc_codes_s = header[0x22]; loc_codes_r = header[0x23]; if(doc_index_s != 2 || code_count_s != 2 || loc_codes_s != 2) { return false; } node_offset = get_uint32 (header + 0x14); node_len = get_uint32 (header + 0x2e); tree_depth = get_uint16 (header + 0x18); i = sizeof(uint16_t); buffer = malloc (node_len); node_offset = get_leaf_node_offset (chmfile, text, node_offset, node_len, tree_depth, &ui); if (!node_offset) { FREE(buffer); return false; } do { if (chm_retrieve_object (chmfile, &ui, buffer, node_offset, node_len) == 0) { FREE(word); FREE(buffer); return false; } free_space = get_uint16 (buffer + 6); i = sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t); encsz = 0; while (i < node_len - free_space) { word_len = *(buffer + i); pos = *(buffer + i + 1); wrd_buf = malloc (word_len); memcpy (wrd_buf, buffer + i + 2, word_len - 1); wrd_buf[word_len - 1] = 0; if (pos == 0) { FREE(word); word = (char *) strdup (wrd_buf); } else { word = realloc (word, word_len + pos + 1); strcpy (word + pos, wrd_buf); } FREE(wrd_buf); i += 2 + word_len; title = *(buffer + i - 1); wlc_count = be_encint (buffer + i, &encsz); i += encsz; wlc_offset = get_uint32 (buffer + i); i += sizeof(uint32_t) + sizeof(uint16_t); wlc_size = be_encint (buffer + i, &encsz); i += encsz; node_offset = get_uint32 (buffer); if (!title && titles_only) continue; if (whole_words && !strcasecmp(text, word)) { partial = pychm_process_wlc (chmfile, wlc_count, wlc_size, wlc_offset, doc_index_s, doc_index_r,code_count_s, code_count_r, loc_codes_s, loc_codes_r, &ui, &uiurltbl, &uistrings, &uitopics, &uiurlstr, dict); FREE(word); FREE(buffer); return partial; } if (!whole_words) { if (!strncasecmp (word, text, strlen(text))) { partial = true; pychm_process_wlc (chmfile, wlc_count, wlc_size, wlc_offset, doc_index_s, doc_index_r,code_count_s, code_count_r, loc_codes_s, loc_codes_r, &ui, &uiurltbl, &uistrings, &uitopics, &uiurlstr, dict); } else if (strncasecmp (text, word, strlen(text)) < -1) break; } } } while (!whole_words && !strncmp (word, text, strlen(text)) && node_offset); FREE(word); FREE(buffer); return partial; } typedef struct { const char *file; int offset; } Langrec; static Langrec lang_files[] = { {"/$FIftiMain", 0x7E}, {"$WWKeywordLinks/BTree", 0x34}, {"$WWAssociativeLinks/BTree", 0x34} }; #define LANG_FILES_SIZE (sizeof(lang_files)/sizeof(Langrec)) static int chm_get_lcid (struct chmFile *chmfile) { struct chmUnitInfo ui; uint32_t lang; int i; for (i=0; i \n"); printf ("> "); if (scanf ("%d %d %s", &whole_words, &titles_only, text)) partial = chm_search (file, text, whole_words, titles_only, NULL); else break; printf ("Partial = %d\n", partial); } chm_close (file); return 0; } return -1; } else { printf ("\n%s \n", argv[0]); return 0; } } #endif pychm-0.8.4.1/chm/swig_chm.c0000644000076500000240000010722412367175762016636 0ustar dottedmagstaff00000000000000/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 1.3.18 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make * changes to this file unless you know what you are doing--modify the SWIG * interface file instead. * ----------------------------------------------------------------------------- */ #define SWIGPYTHON #include "Python.h" /*********************************************************************** * common.swg * * This file contains generic SWIG runtime support for pointer * type checking as well as a few commonly used macros to control * external linkage. * * Author : David Beazley (beazley@cs.uchicago.edu) * * Copyright (c) 1999-2000, The University of Chicago * * This file may be freely redistributed without license or fee provided * this copyright message remains intact. ************************************************************************/ #include #if defined(_WIN32) || defined(__WIN32__) # if defined(_MSC_VER) # if defined(STATIC_LINKED) # define SWIGEXPORT(a) a # define SWIGIMPORT(a) extern a # else # define SWIGEXPORT(a) __declspec(dllexport) a # define SWIGIMPORT(a) extern a # endif # else # if defined(__BORLANDC__) # define SWIGEXPORT(a) a _export # define SWIGIMPORT(a) a _export # else # define SWIGEXPORT(a) a # define SWIGIMPORT(a) a # endif # endif #else # define SWIGEXPORT(a) a # define SWIGIMPORT(a) a #endif #ifdef SWIG_GLOBAL #define SWIGRUNTIME(a) SWIGEXPORT(a) #else #define SWIGRUNTIME(a) static a #endif #ifdef __cplusplus extern "C" { #endif typedef void *(*swig_converter_func)(void *); typedef struct swig_type_info *(*swig_dycast_func)(void **); typedef struct swig_type_info { const char *name; swig_converter_func converter; const char *str; void *clientdata; swig_dycast_func dcast; struct swig_type_info *next; struct swig_type_info *prev; } swig_type_info; #ifdef SWIG_NOINCLUDE SWIGIMPORT(swig_type_info *) SWIG_TypeRegister(swig_type_info *); SWIGIMPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *); SWIGIMPORT(void *) SWIG_TypeCast(swig_type_info *, void *); SWIGIMPORT(swig_type_info *) SWIG_TypeDynamicCast(swig_type_info *, void **); SWIGIMPORT(const char *) SWIG_TypeName(const swig_type_info *); SWIGIMPORT(swig_type_info *) SWIG_TypeQuery(const char *); SWIGIMPORT(void) SWIG_TypeClientData(swig_type_info *, void *); #else static swig_type_info *swig_type_list = 0; /* Register a type mapping with the type-checking */ SWIGRUNTIME(swig_type_info *) SWIG_TypeRegister(swig_type_info *ti) { swig_type_info *tc, *head, *ret, *next; /* Check to see if this type has already been registered */ tc = swig_type_list; while (tc) { if (strcmp(tc->name, ti->name) == 0) { /* Already exists in the table. Just add additional types to the list */ if (tc->clientdata) ti->clientdata = tc->clientdata; head = tc; next = tc->next; goto l1; } tc = tc->prev; } head = ti; next = 0; /* Place in list */ ti->prev = swig_type_list; swig_type_list = ti; /* Build linked lists */ l1: ret = head; tc = ti + 1; /* Patch up the rest of the links */ while (tc->name) { head->next = tc; tc->prev = head; head = tc; tc++; } if (next) next->prev = head; /**/ head->next = next; return ret; } /* Check the typename */ SWIGRUNTIME(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *ty) { swig_type_info *s; if (!ty) return 0; /* Void pointer */ s = ty->next; /* First element always just a name */ do { if (strcmp(s->name,c) == 0) { if (s == ty->next) return s; /* Move s to the top of the linked list */ s->prev->next = s->next; if (s->next) { s->next->prev = s->prev; } /* Insert s as second element in the list */ s->next = ty->next; if (ty->next) ty->next->prev = s; ty->next = s; s->prev = ty; /**/ return s; } s = s->next; } while (s && (s != ty->next)); return 0; } /* Cast a pointer up an inheritance hierarchy */ SWIGRUNTIME(void *) SWIG_TypeCast(swig_type_info *ty, void *ptr) { if ((!ty) || (!ty->converter)) return ptr; return (*ty->converter)(ptr); } /* Dynamic pointer casting. Down an inheritance hierarchy */ SWIGRUNTIME(swig_type_info *) SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { swig_type_info *lastty = ty; if (!ty || !ty->dcast) return ty; while (ty && (ty->dcast)) { ty = (*ty->dcast)(ptr); if (ty) lastty = ty; } return lastty; } /* Return the name associated with this type */ SWIGRUNTIME(const char *) SWIG_TypeName(const swig_type_info *ty) { return ty->name; } /* Search for a swig_type_info structure */ SWIGRUNTIME(swig_type_info *) SWIG_TypeQuery(const char *name) { swig_type_info *ty = swig_type_list; while (ty) { if (ty->str && (strcmp(name,ty->str) == 0)) return ty; if (ty->name && (strcmp(name,ty->name) == 0)) return ty; ty = ty->prev; } return 0; } /* Set the clientdata field for a type */ SWIGRUNTIME(void) SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_type_info *tc, *equiv; if (ti->clientdata == clientdata) return; ti->clientdata = clientdata; equiv = ti->next; while (equiv) { if (!equiv->converter) { tc = swig_type_list; while (tc) { if ((strcmp(tc->name, equiv->name) == 0)) SWIG_TypeClientData(tc,clientdata); tc = tc->prev; } } equiv = equiv->next; } } #endif #ifdef __cplusplus } #endif /*********************************************************************** * python.swg * * This file contains the runtime support for Python modules * and includes code for managing global variables and pointer * type checking. * * Author : David Beazley (beazley@cs.uchicago.edu) ************************************************************************/ #include "Python.h" #ifdef __cplusplus extern "C" { #endif #define SWIG_PY_INT 1 #define SWIG_PY_FLOAT 2 #define SWIG_PY_STRING 3 #define SWIG_PY_POINTER 4 #define SWIG_PY_BINARY 5 /* Flags for pointer conversion */ #define SWIG_POINTER_EXCEPTION 0x1 #define SWIG_POINTER_DISOWN 0x2 /* Exception handling in wrappers */ #define SWIG_fail goto fail /* Constant information structure */ typedef struct swig_const_info { int type; char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; #ifdef SWIG_NOINCLUDE SWIGEXPORT(PyObject *) SWIG_newvarlink(void); SWIGEXPORT(void) SWIG_addvarlink(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *)); SWIGEXPORT(int) SWIG_ConvertPtr(PyObject *, void **, swig_type_info *, int); SWIGEXPORT(int) SWIG_ConvertPacked(PyObject *, void *, int sz, swig_type_info *, int); SWIGEXPORT(char *) SWIG_PackData(char *c, void *, int); SWIGEXPORT(char *) SWIG_UnpackData(char *c, void *, int); SWIGEXPORT(PyObject *) SWIG_NewPointerObj(void *, swig_type_info *,int own); SWIGEXPORT(PyObject *) SWIG_NewPackedObj(void *, int sz, swig_type_info *); SWIGEXPORT(void) SWIG_InstallConstants(PyObject *d, swig_const_info constants[]); #else /* ----------------------------------------------------------------------------- * global variable support code. * ----------------------------------------------------------------------------- */ typedef struct swig_globalvar { char *name; /* Name of global variable */ PyObject *(*get_attr)(void); /* Return the current value */ int (*set_attr)(PyObject *); /* Set the value */ struct swig_globalvar *next; } swig_globalvar; typedef struct swig_varlinkobject { PyObject_HEAD swig_globalvar *vars; } swig_varlinkobject; static PyObject * swig_varlink_repr(swig_varlinkobject *v) { v = v; return PyString_FromString(""); } static int swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) { swig_globalvar *var; flags = flags; fprintf(fp,"Global variables { "); for (var = v->vars; var; var=var->next) { fprintf(fp,"%s", var->name); if (var->next) fprintf(fp,", "); } fprintf(fp," }\n"); return 0; } static PyObject * swig_varlink_getattr(swig_varlinkobject *v, char *n) { swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { return (*var->get_attr)(); } var = var->next; } PyErr_SetString(PyExc_NameError,"Unknown C global variable"); return NULL; } static int swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { return (*var->set_attr)(p); } var = var->next; } PyErr_SetString(PyExc_NameError,"Unknown C global variable"); return 1; } statichere PyTypeObject varlinktype = { PyObject_HEAD_INIT(0) 0, (char *)"swigvarlink", /* Type name */ sizeof(swig_varlinkobject), /* Basic size */ 0, /* Itemsize */ 0, /* Deallocator */ (printfunc) swig_varlink_print, /* Print */ (getattrfunc) swig_varlink_getattr, /* get attr */ (setattrfunc) swig_varlink_setattr, /* Set attr */ 0, /* tp_compare */ (reprfunc) swig_varlink_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_mapping*/ 0, /* tp_hash */ }; /* Create a variable linking object for use later */ SWIGRUNTIME(PyObject *) SWIG_newvarlink(void) { swig_varlinkobject *result = 0; result = PyMem_NEW(swig_varlinkobject,1); varlinktype.ob_type = &PyType_Type; /* Patch varlinktype into a PyType */ result->ob_type = &varlinktype; result->vars = 0; result->ob_refcnt = 0; Py_XINCREF((PyObject *) result); return ((PyObject*) result); } SWIGRUNTIME(void) SWIG_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { swig_varlinkobject *v; swig_globalvar *gv; v= (swig_varlinkobject *) p; gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); gv->name = (char *) malloc(strlen(name)+1); strcpy(gv->name,name); gv->get_attr = get_attr; gv->set_attr = set_attr; gv->next = v->vars; v->vars = gv; } /* Pack binary data into a string */ SWIGRUNTIME(char *) SWIG_PackData(char *c, void *ptr, int sz) { static char hex[17] = "0123456789abcdef"; int i; unsigned char *u = (unsigned char *) ptr; register unsigned char uu; for (i = 0; i < sz; i++,u++) { uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } /* Unpack binary data from a string */ SWIGRUNTIME(char *) SWIG_UnpackData(char *c, void *ptr, int sz) { register unsigned char uu = 0; register int d; unsigned char *u = (unsigned char *) ptr; int i; for (i = 0; i < sz; i++, u++) { d = *(c++); if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); *u = uu; } return c; } /* Convert a pointer value */ SWIGRUNTIME(int) SWIG_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) { swig_type_info *tc; char *c; static PyObject *SWIG_this = 0; int newref = 0; PyObject *pyobj = 0; if (!obj) return 0; if (obj == Py_None) { *ptr = 0; return 0; } #ifdef SWIG_COBJECT_TYPES if (!(PyCObject_Check(obj))) { if (!SWIG_this) SWIG_this = PyString_FromString("this"); pyobj = obj; obj = PyObject_GetAttr(obj,SWIG_this); newref = 1; if (!obj) goto type_error; if (!PyCObject_Check(obj)) { Py_DECREF(obj); goto type_error; } } *ptr = PyCObject_AsVoidPtr(obj); c = (char *) PyCObject_GetDesc(obj); if (newref) Py_DECREF(obj); goto cobject; #else if (!(PyString_Check(obj))) { if (!SWIG_this) SWIG_this = PyString_FromString("this"); pyobj = obj; obj = PyObject_GetAttr(obj,SWIG_this); newref = 1; if (!obj) goto type_error; if (!PyString_Check(obj)) { Py_DECREF(obj); goto type_error; } } c = PyString_AsString(obj); /* Pointer values must start with leading underscore */ if (*c != '_') { *ptr = (void *) 0; if (strcmp(c,"NULL") == 0) { if (newref) { Py_DECREF(obj); } return 0; } else { if (newref) { Py_DECREF(obj); } goto type_error; } } c++; c = SWIG_UnpackData(c,ptr,sizeof(void *)); if (newref) { Py_DECREF(obj); } #endif #ifdef SWIG_COBJECT_TYPES cobject: #endif if (ty) { tc = SWIG_TypeCheck(c,ty); if (!tc) goto type_error; *ptr = SWIG_TypeCast(tc,(void*) *ptr); } if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) { PyObject *zero = PyInt_FromLong(0); PyObject_SetAttrString(pyobj,(char*)"thisown",zero); Py_DECREF(zero); } return 0; type_error: if (flags & SWIG_POINTER_EXCEPTION) { if (ty) { char *temp = (char *) malloc(64+strlen(ty->name)); sprintf(temp,"Type error. Expected %s", ty->name); PyErr_SetString(PyExc_TypeError, temp); free((char *) temp); } else { PyErr_SetString(PyExc_TypeError,"Expected a pointer"); } } return -1; } /* Convert a packed value value */ SWIGRUNTIME(int) SWIG_ConvertPacked(PyObject *obj, void *ptr, int sz, swig_type_info *ty, int flags) { swig_type_info *tc; char *c; if ((!obj) || (!PyString_Check(obj))) goto type_error; c = PyString_AsString(obj); /* Pointer values must start with leading underscore */ if (*c != '_') goto type_error; c++; c = SWIG_UnpackData(c,ptr,sz); if (ty) { tc = SWIG_TypeCheck(c,ty); if (!tc) goto type_error; } return 0; type_error: if (flags) { if (ty) { char *temp = (char *) malloc(64+strlen(ty->name)); sprintf(temp,"Type error. Expected %s", ty->name); PyErr_SetString(PyExc_TypeError, temp); free((char *) temp); } else { PyErr_SetString(PyExc_TypeError,"Expected a pointer"); } } return -1; } /* Create a new pointer object */ SWIGRUNTIME(PyObject *) SWIG_NewPointerObj(void *ptr, swig_type_info *type, int own) { PyObject *robj; if (!ptr) { Py_INCREF(Py_None); return Py_None; } #ifdef SWIG_COBJECT_TYPES robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, (char *) type->name, NULL); #else { char result[1024]; char *r = result; *(r++) = '_'; r = SWIG_PackData(r,&ptr,sizeof(void *)); strcpy(r,type->name); robj = PyString_FromString(result); } #endif if (!robj || (robj == Py_None)) return robj; if (type->clientdata) { PyObject *inst; PyObject *args = Py_BuildValue((char*)"(O)", robj); Py_DECREF(robj); inst = PyObject_CallObject((PyObject *) type->clientdata, args); Py_DECREF(args); if (inst) { if (own) { PyObject *n = PyInt_FromLong(1); PyObject_SetAttrString(inst,(char*)"thisown",n); Py_DECREF(n); } robj = inst; } } return robj; } SWIGRUNTIME(PyObject *) SWIG_NewPackedObj(void *ptr, int sz, swig_type_info *type) { char result[1024]; char *r = result; if ((2*sz + 1 + strlen(type->name)) > 1000) return 0; *(r++) = '_'; r = SWIG_PackData(r,ptr,sz); strcpy(r,type->name); return PyString_FromString(result); } /* Install Constants */ SWIGRUNTIME(void) SWIG_InstallConstants(PyObject *d, swig_const_info constants[]) { int i; PyObject *obj; for (i = 0; constants[i].type; i++) { switch(constants[i].type) { case SWIG_PY_INT: obj = PyInt_FromLong(constants[i].lvalue); break; case SWIG_PY_FLOAT: obj = PyFloat_FromDouble(constants[i].dvalue); break; case SWIG_PY_STRING: obj = PyString_FromString((char *) constants[i].pvalue); break; case SWIG_PY_POINTER: obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); break; case SWIG_PY_BINARY: obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); break; default: obj = 0; break; } if (obj) { PyDict_SetItemString(d,constants[i].name,obj); Py_DECREF(obj); } } } #endif #ifdef __cplusplus } #endif /* -------- TYPES TABLE (BEGIN) -------- */ #define SWIGTYPE_p_chmUnitInfo swig_types[0] #define SWIGTYPE_p_unsigned_char swig_types[1] #define SWIGTYPE_p_char swig_types[2] #define SWIGTYPE_CHM_ENUMERATOR swig_types[3] #define SWIGTYPE_p_chmFile swig_types[4] static swig_type_info *swig_types[6]; /* -------- TYPES TABLE (END) -------- */ /*----------------------------------------------- @(target):= _chmlib.so ------------------------------------------------*/ #define SWIG_init init_chmlib #define SWIG_name "_chmlib" /* Copyright (C) 2003 Rubens Ramos pychm 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. This program 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 this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA $Id$ */ #include "chm_lib.h" #include static PyObject *my_callback = NULL; static PyObject * my_set_callback(PyObject *dummy, PyObject *arg) { PyObject *result = NULL; if (!PyCallable_Check(arg)) { PyErr_SetString(PyExc_TypeError, "parameter must be callable"); return NULL; } Py_XINCREF(arg); /* Add a reference to new callback */ Py_XDECREF(my_callback); /* Dispose of previous callback */ my_callback = arg; /* Remember new callback */ /* Boilerplate to return "None" */ Py_INCREF(Py_None); result = Py_None; return result; } int dummy_enumerator (struct chmFile *h, struct chmUnitInfo *ui, void *context) { PyObject *arglist; PyObject *result; PyObject *py_h; PyObject *py_ui; PyObject *py_c; py_h = SWIG_NewPointerObj((void *) h, SWIGTYPE_p_chmFile, 0); py_ui = SWIG_NewPointerObj((void *) ui, SWIGTYPE_p_chmUnitInfo, 0); py_c = PyCObject_AsVoidPtr(context); /* Time to call the callback */ arglist = Py_BuildValue("(OOO)", py_h, py_ui, py_c); if (arglist) { result = PyEval_CallObject(my_callback, arglist); Py_DECREF(arglist); Py_DECREF(result); Py_DECREF(py_h); Py_DECREF(py_ui); if (result == NULL) { return 0; /* Pass error back */ } else { return 1; } } else return 0; } static PyObject* t_output_helper(PyObject* target, PyObject* o) { PyObject* o2; PyObject* o3; if (!target) { target = o; } else if (target == Py_None) { Py_DECREF(Py_None); target = o; } else { if (!PyTuple_Check(target)) { o2 = target; target = PyTuple_New(1); PyTuple_SetItem(target, 0, o2); } o3 = PyTuple_New(1); PyTuple_SetItem(o3, 0, o); o2 = target; target = PySequence_Concat(o2, o3); Py_DECREF(o2); Py_DECREF(o3); } return target; } #ifdef __cplusplus extern "C" { #endif static PyObject *_wrap_chmUnitInfo_start_set(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmUnitInfo *arg1 = (struct chmUnitInfo *) 0 ; LONGUINT64 arg2 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if(!PyArg_ParseTuple(args,(char *)"OO:chmUnitInfo_start_set",&obj0,&obj1)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_chmUnitInfo,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; arg2 = (LONGUINT64) PyLong_AsUnsignedLongLong(obj1); if (PyErr_Occurred()) SWIG_fail; if (arg1) (arg1)->start = arg2; Py_INCREF(Py_None); resultobj = Py_None; return resultobj; fail: return NULL; } static PyObject *_wrap_chmUnitInfo_start_get(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmUnitInfo *arg1 = (struct chmUnitInfo *) 0 ; LONGUINT64 result; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"O:chmUnitInfo_start_get",&obj0)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_chmUnitInfo,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; result = (LONGUINT64) ((arg1)->start); resultobj = PyLong_FromUnsignedLongLong(result); return resultobj; fail: return NULL; } static PyObject *_wrap_chmUnitInfo_length_set(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmUnitInfo *arg1 = (struct chmUnitInfo *) 0 ; LONGUINT64 arg2 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if(!PyArg_ParseTuple(args,(char *)"OO:chmUnitInfo_length_set",&obj0,&obj1)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_chmUnitInfo,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; arg2 = (LONGUINT64) PyLong_AsUnsignedLongLong(obj1); if (PyErr_Occurred()) SWIG_fail; if (arg1) (arg1)->length = arg2; Py_INCREF(Py_None); resultobj = Py_None; return resultobj; fail: return NULL; } static PyObject *_wrap_chmUnitInfo_length_get(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmUnitInfo *arg1 = (struct chmUnitInfo *) 0 ; LONGUINT64 result; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"O:chmUnitInfo_length_get",&obj0)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_chmUnitInfo,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; result = (LONGUINT64) ((arg1)->length); resultobj = PyLong_FromUnsignedLongLong(result); return resultobj; fail: return NULL; } static PyObject *_wrap_chmUnitInfo_space_set(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmUnitInfo *arg1 = (struct chmUnitInfo *) 0 ; int arg2 ; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"Oi:chmUnitInfo_space_set",&obj0,&arg2)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_chmUnitInfo,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; if (arg1) (arg1)->space = arg2; Py_INCREF(Py_None); resultobj = Py_None; return resultobj; fail: return NULL; } static PyObject *_wrap_chmUnitInfo_space_get(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmUnitInfo *arg1 = (struct chmUnitInfo *) 0 ; int result; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"O:chmUnitInfo_space_get",&obj0)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_chmUnitInfo,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; result = (int) ((arg1)->space); resultobj = PyInt_FromLong((long)result); return resultobj; fail: return NULL; } static PyObject *_wrap_chmUnitInfo_path_set(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmUnitInfo *arg1 = (struct chmUnitInfo *) 0 ; char *arg2 ; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"Os:chmUnitInfo_path_set",&obj0,&arg2)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_chmUnitInfo,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; { if (arg2) strncpy(arg1->path,arg2,256+1); else arg1->path[0] = 0; } Py_INCREF(Py_None); resultobj = Py_None; return resultobj; fail: return NULL; } static PyObject *_wrap_chmUnitInfo_path_get(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmUnitInfo *arg1 = (struct chmUnitInfo *) 0 ; char *result; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"O:chmUnitInfo_path_get",&obj0)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_chmUnitInfo,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; result = (char *)(char *) ((arg1)->path); resultobj = PyString_FromString(result); return resultobj; fail: return NULL; } static PyObject *_wrap_new_chmUnitInfo(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmUnitInfo *result; if(!PyArg_ParseTuple(args,(char *)":new_chmUnitInfo")) goto fail; result = (struct chmUnitInfo *)(struct chmUnitInfo *) calloc(1, sizeof(struct chmUnitInfo)); resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_chmUnitInfo, 1); return resultobj; fail: return NULL; } static PyObject *_wrap_delete_chmUnitInfo(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmUnitInfo *arg1 = (struct chmUnitInfo *) 0 ; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"O:delete_chmUnitInfo",&obj0)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_chmUnitInfo,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; free((char *) arg1); Py_INCREF(Py_None); resultobj = Py_None; return resultobj; fail: return NULL; } static PyObject * chmUnitInfo_swigregister(PyObject *self, PyObject *args) { PyObject *obj; if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL; SWIG_TypeClientData(SWIGTYPE_p_chmUnitInfo, obj); Py_INCREF(obj); return Py_BuildValue((char *)""); } static PyObject *_wrap_chm_open(PyObject *self, PyObject *args) { PyObject *resultobj; char *arg1 ; struct chmFile *result; if(!PyArg_ParseTuple(args,(char *)"s:chm_open",&arg1)) goto fail; result = (struct chmFile *)chm_open((char const *)arg1); resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_chmFile, 0); return resultobj; fail: return NULL; } static PyObject *_wrap_chm_close(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmFile *arg1 = (struct chmFile *) 0 ; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"O:chm_close",&obj0)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_chmFile,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; chm_close(arg1); Py_INCREF(Py_None); resultobj = Py_None; return resultobj; fail: return NULL; } static PyObject *_wrap_chm_set_param(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmFile *arg1 = (struct chmFile *) 0 ; int arg2 ; int arg3 ; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"Oii:chm_set_param",&obj0,&arg2,&arg3)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_chmFile,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; chm_set_param(arg1,arg2,arg3); Py_INCREF(Py_None); resultobj = Py_None; return resultobj; fail: return NULL; } static PyObject *_wrap_chm_resolve_object(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmFile *arg1 = (struct chmFile *) 0 ; char *arg2 ; struct chmUnitInfo *arg3 = (struct chmUnitInfo *) 0 ; int result; struct chmUnitInfo *temp3 = (struct chmUnitInfo *) calloc(1, sizeof(struct chmUnitInfo)) ; PyObject * obj0 = 0 ; { arg3 = temp3; } if(!PyArg_ParseTuple(args,(char *)"Os:chm_resolve_object",&obj0,&arg2)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_chmFile,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; result = (int)chm_resolve_object(arg1,(char const *)arg2,arg3); resultobj = PyInt_FromLong((long)result); { PyObject *o, *o2, *o3; o = SWIG_NewPointerObj((void *) arg3, SWIGTYPE_p_chmUnitInfo, 1); if ((!resultobj) || (resultobj == Py_None)) { resultobj = o; }else { if (!PyTuple_Check(resultobj)) { PyObject *o2 = resultobj; resultobj = PyTuple_New(1); PyTuple_SetItem(resultobj,0,o2); } o3 = PyTuple_New(1); PyTuple_SetItem(o3,0,o); o2 = resultobj; resultobj = PySequence_Concat(o2,o3); Py_DECREF(o2); Py_DECREF(o3); } } return resultobj; fail: return NULL; } static PyObject *_wrap_chm_retrieve_object(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmFile *arg1 = (struct chmFile *) 0 ; struct chmUnitInfo *arg2 = (struct chmUnitInfo *) 0 ; unsigned char *arg3 = (unsigned char *) 0 ; LONGUINT64 arg4 ; LONGINT64 arg5 ; LONGINT64 result; unsigned char temp3 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; arg3 = &temp3; if(!PyArg_ParseTuple(args,(char *)"OOOO:chm_retrieve_object",&obj0,&obj1,&obj2,&obj3)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_chmFile,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; if ((SWIG_ConvertPtr(obj1,(void **) &arg2, SWIGTYPE_p_chmUnitInfo,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; arg4 = (LONGUINT64) PyLong_AsUnsignedLongLong(obj2); if (PyErr_Occurred()) SWIG_fail; arg5 = (LONGINT64) PyLong_AsLongLong(obj3); if (PyErr_Occurred()) SWIG_fail; { /* nasty hack */ arg3 = (unsigned char *) malloc(arg5); if (arg3 == NULL) SWIG_fail; } result = (LONGINT64)chm_retrieve_object(arg1,arg2,arg3,arg4,arg5); resultobj = PyLong_FromLongLong(result); { PyObject *o; o = PyString_FromStringAndSize(arg3, arg5); resultobj = t_output_helper(resultobj,o); free(arg3); } return resultobj; fail: return NULL; } static PyObject *_wrap_chm_enumerate(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmFile *arg1 = (struct chmFile *) 0 ; int arg2 ; CHM_ENUMERATOR arg3 = (CHM_ENUMERATOR) 0 ; void *arg4 = (void *) 0 ; int result; PyObject * obj0 = 0 ; PyObject * obj2 = 0 ; PyObject * obj3 = 0 ; if(!PyArg_ParseTuple(args,(char *)"OiOO:chm_enumerate",&obj0,&arg2,&obj2,&obj3)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_chmFile,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; { if (!my_set_callback(self, obj2)) goto fail; arg3 = dummy_enumerator; } { if (!(arg4 = PyCObject_FromVoidPtr(obj3, NULL))) goto fail; } result = (int)chm_enumerate(arg1,arg2,arg3,arg4); resultobj = PyInt_FromLong((long)result); return resultobj; fail: return NULL; } static PyObject *_wrap_chm_enumerate_dir(PyObject *self, PyObject *args) { PyObject *resultobj; struct chmFile *arg1 = (struct chmFile *) 0 ; char *arg2 ; int arg3 ; CHM_ENUMERATOR arg4 = (CHM_ENUMERATOR) 0 ; void *arg5 = (void *) 0 ; int result; PyObject * obj0 = 0 ; PyObject * obj3 = 0 ; PyObject * obj4 = 0 ; if(!PyArg_ParseTuple(args,(char *)"OsiOO:chm_enumerate_dir",&obj0,&arg2,&arg3,&obj3,&obj4)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_chmFile,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; { if (!my_set_callback(self, obj3)) goto fail; arg4 = dummy_enumerator; } { if (!(arg5 = PyCObject_FromVoidPtr(obj4, NULL))) goto fail; } result = (int)chm_enumerate_dir(arg1,(char const *)arg2,arg3,arg4,arg5); resultobj = PyInt_FromLong((long)result); return resultobj; fail: return NULL; } static PyMethodDef SwigMethods[] = { { (char *)"chmUnitInfo_start_set", _wrap_chmUnitInfo_start_set, METH_VARARGS }, { (char *)"chmUnitInfo_start_get", _wrap_chmUnitInfo_start_get, METH_VARARGS }, { (char *)"chmUnitInfo_length_set", _wrap_chmUnitInfo_length_set, METH_VARARGS }, { (char *)"chmUnitInfo_length_get", _wrap_chmUnitInfo_length_get, METH_VARARGS }, { (char *)"chmUnitInfo_space_set", _wrap_chmUnitInfo_space_set, METH_VARARGS }, { (char *)"chmUnitInfo_space_get", _wrap_chmUnitInfo_space_get, METH_VARARGS }, { (char *)"chmUnitInfo_path_set", _wrap_chmUnitInfo_path_set, METH_VARARGS }, { (char *)"chmUnitInfo_path_get", _wrap_chmUnitInfo_path_get, METH_VARARGS }, { (char *)"new_chmUnitInfo", _wrap_new_chmUnitInfo, METH_VARARGS }, { (char *)"delete_chmUnitInfo", _wrap_delete_chmUnitInfo, METH_VARARGS }, { (char *)"chmUnitInfo_swigregister", chmUnitInfo_swigregister, METH_VARARGS }, { (char *)"chm_open", _wrap_chm_open, METH_VARARGS }, { (char *)"chm_close", _wrap_chm_close, METH_VARARGS }, { (char *)"chm_set_param", _wrap_chm_set_param, METH_VARARGS }, { (char *)"chm_resolve_object", _wrap_chm_resolve_object, METH_VARARGS }, { (char *)"chm_retrieve_object", _wrap_chm_retrieve_object, METH_VARARGS }, { (char *)"chm_enumerate", _wrap_chm_enumerate, METH_VARARGS }, { (char *)"chm_enumerate_dir", _wrap_chm_enumerate_dir, METH_VARARGS }, { NULL, NULL } }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ static swig_type_info _swigt__p_chmUnitInfo[] = {{"_p_chmUnitInfo", 0, "struct chmUnitInfo *", 0},{"_p_chmUnitInfo"},{0}}; static swig_type_info _swigt__p_unsigned_char[] = {{"_p_unsigned_char", 0, "unsigned char *", 0},{"_p_unsigned_char"},{0}}; static swig_type_info _swigt__p_char[] = {{"_p_char", 0, "char *", 0},{"_p_char"},{0}}; static swig_type_info _swigt__CHM_ENUMERATOR[] = {{"_CHM_ENUMERATOR", 0, "CHM_ENUMERATOR", 0},{"_CHM_ENUMERATOR"},{0}}; static swig_type_info _swigt__p_chmFile[] = {{"_p_chmFile", 0, "struct chmFile *", 0},{"_p_chmFile"},{0}}; static swig_type_info *swig_types_initial[] = { _swigt__p_chmUnitInfo, _swigt__p_unsigned_char, _swigt__p_char, _swigt__CHM_ENUMERATOR, _swigt__p_chmFile, 0 }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ static swig_const_info swig_const_table[] = { { SWIG_PY_INT, (char *)"CHM_UNCOMPRESSED", (long) (0), 0, 0, 0}, { SWIG_PY_INT, (char *)"CHM_COMPRESSED", (long) (1), 0, 0, 0}, { SWIG_PY_INT, (char *)"CHM_MAX_PATHLEN", (long) 256, 0, 0, 0}, { SWIG_PY_INT, (char *)"CHM_PARAM_MAX_BLOCKS_CACHED", (long) 0, 0, 0, 0}, { SWIG_PY_INT, (char *)"CHM_RESOLVE_SUCCESS", (long) (0), 0, 0, 0}, { SWIG_PY_INT, (char *)"CHM_RESOLVE_FAILURE", (long) (1), 0, 0, 0}, { SWIG_PY_INT, (char *)"CHM_ENUMERATE_NORMAL", (long) (1), 0, 0, 0}, { SWIG_PY_INT, (char *)"CHM_ENUMERATE_META", (long) (2), 0, 0, 0}, { SWIG_PY_INT, (char *)"CHM_ENUMERATE_SPECIAL", (long) (4), 0, 0, 0}, { SWIG_PY_INT, (char *)"CHM_ENUMERATE_FILES", (long) (8), 0, 0, 0}, { SWIG_PY_INT, (char *)"CHM_ENUMERATE_DIRS", (long) (16), 0, 0, 0}, { SWIG_PY_INT, (char *)"CHM_ENUMERATE_ALL", (long) (31), 0, 0, 0}, { SWIG_PY_INT, (char *)"CHM_ENUMERATOR_FAILURE", (long) (0), 0, 0, 0}, { SWIG_PY_INT, (char *)"CHM_ENUMERATOR_CONTINUE", (long) (1), 0, 0, 0}, { SWIG_PY_INT, (char *)"CHM_ENUMERATOR_SUCCESS", (long) (2), 0, 0, 0}, {0}}; #ifdef __cplusplus } #endif #ifdef __cplusplus extern "C" #endif SWIGEXPORT(void) SWIG_init(void) { static PyObject *SWIG_globals = 0; static int typeinit = 0; PyObject *m, *d; int i; if (!SWIG_globals) SWIG_globals = SWIG_newvarlink(); m = Py_InitModule((char *) SWIG_name, SwigMethods); d = PyModule_GetDict(m); if (!typeinit) { for (i = 0; swig_types_initial[i]; i++) { swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]); } typeinit = 1; } SWIG_InstallConstants(d,swig_const_table); } pychm-0.8.4.1/chm/swig_chm.i0000644000076500000240000001404412367175765016644 0ustar dottedmagstaff00000000000000%module chmlib %include "typemaps.i" %include "cstring.i" %{ /* Copyright (C) 2003 Rubens Ramos Based on code by: Copyright (C) 2003 Razvan Cojocaru pychm 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. This program 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 this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA $Id$ */ #include "chm_lib.h" #include static PyObject *my_callback = NULL; static PyObject * my_set_callback(PyObject *dummy, PyObject *arg) { PyObject *result = NULL; if (!PyCallable_Check(arg)) { PyErr_SetString(PyExc_TypeError, "parameter must be callable"); return NULL; } Py_XINCREF(arg); /* Add a reference to new callback */ Py_XDECREF(my_callback); /* Dispose of previous callback */ my_callback = arg; /* Remember new callback */ /* Boilerplate to return "None" */ Py_INCREF(Py_None); result = Py_None; return result; } int dummy_enumerator (struct chmFile *h, struct chmUnitInfo *ui, void *context) { PyObject *arglist; PyObject *result; PyObject *py_h; PyObject *py_ui; PyObject *py_c; py_h = SWIG_NewPointerObj((void *) h, SWIGTYPE_p_chmFile, 0); py_ui = SWIG_NewPointerObj((void *) ui, SWIGTYPE_p_chmUnitInfo, 0); py_c = PyCObject_AsVoidPtr(context); /* Time to call the callback */ arglist = Py_BuildValue("(OOO)", py_h, py_ui, py_c); if (arglist) { result = PyEval_CallObject(my_callback, arglist); Py_DECREF(arglist); Py_DECREF(result); Py_DECREF(py_h); Py_DECREF(py_ui); if (result == NULL) { return 0; /* Pass error back */ } else { return 1; } } else return 0; } %} %typemap(in) CHM_ENUMERATOR { if (!my_set_callback(self, $input)) goto fail; $1 = dummy_enumerator; } %typemap(in) void *context { if (!($1 = PyCObject_FromVoidPtr($input, NULL))) goto fail; } %typemap(in, numinputs=0) struct chmUnitInfo *OutValue (struct chmUnitInfo *temp = (struct chmUnitInfo *) calloc(1, sizeof(struct chmUnitInfo))) { $1 = temp; } %typemap(argout) struct chmUnitInfo *OutValue { PyObject *o, *o2, *o3; o = SWIG_NewPointerObj((void *) $1, SWIGTYPE_p_chmUnitInfo, 1); if ((!$result) || ($result == Py_None)) { $result = o; } else { if (!PyTuple_Check($result)) { PyObject *o2 = $result; $result = PyTuple_New(1); PyTuple_SetItem($result,0,o2); } o3 = PyTuple_New(1); PyTuple_SetItem(o3,0,o); o2 = $result; $result = PySequence_Concat(o2,o3); Py_DECREF(o2); Py_DECREF(o3); } } %typemap(check) unsigned char *OUTPUT { /* nasty hack */ #ifdef __cplusplus $1 = ($1_ltype) new char[arg5]; #else $1 = ($1_ltype) malloc(arg5); #endif if ($1 == NULL) SWIG_fail; } %typemap(argout,fragment="t_output_helper") unsigned char *OUTPUT { PyObject *o; o = PyString_FromStringAndSize($1, arg5); $result = t_output_helper($result,o); #ifdef __cplusplus delete [] $1; #else free($1); #endif } #ifdef WIN32 typedef unsigned __int64 LONGUINT64; typedef __int64 LONGINT64; #else typedef unsigned long long LONGUINT64; typedef long long LONGINT64; #endif /* the two available spaces in a CHM file */ /* N.B.: The format supports arbitrarily many spaces, but only */ /* two appear to be used at present. */ #define CHM_UNCOMPRESSED (0) #define CHM_COMPRESSED (1) /* structure representing an ITS (CHM) file stream */ struct chmFile; /* structure representing an element from an ITS file stream */ #define CHM_MAX_PATHLEN 256 struct chmUnitInfo { LONGUINT64 start; LONGUINT64 length; int space; char path[CHM_MAX_PATHLEN+1]; }; /* open an ITS archive */ struct chmFile* chm_open(const char *filename); /* close an ITS archive */ void chm_close(struct chmFile *h); /* methods for ssetting tuning parameters for particular file */ #define CHM_PARAM_MAX_BLOCKS_CACHED 0 void chm_set_param(struct chmFile *h, int paramType, int paramVal); /* resolve a particular object from the archive */ #define CHM_RESOLVE_SUCCESS (0) #define CHM_RESOLVE_FAILURE (1) int chm_resolve_object(struct chmFile *h, const char *objPath, struct chmUnitInfo *OutValue); /* retrieve part of an object from the archive */ LONGINT64 chm_retrieve_object(struct chmFile *h, struct chmUnitInfo *ui, unsigned char *OUTPUT, LONGUINT64 addr, LONGINT64 len); /* enumerate the objects in the .chm archive */ typedef int (*CHM_ENUMERATOR)(struct chmFile *h, struct chmUnitInfo *ui, void *context); #define CHM_ENUMERATE_NORMAL (1) #define CHM_ENUMERATE_META (2) #define CHM_ENUMERATE_SPECIAL (4) #define CHM_ENUMERATE_FILES (8) #define CHM_ENUMERATE_DIRS (16) #define CHM_ENUMERATE_ALL (31) #define CHM_ENUMERATOR_FAILURE (0) #define CHM_ENUMERATOR_CONTINUE (1) #define CHM_ENUMERATOR_SUCCESS (2) int chm_enumerate(struct chmFile *h, int what, CHM_ENUMERATOR e, void *context); int chm_enumerate_dir(struct chmFile *h, const char *prefix, int what, CHM_ENUMERATOR e, void *context); pychm-0.8.4.1/COPYING0000644000076500000240000003542412367173523015151 0ustar dottedmagstaff00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS pychm-0.8.4.1/MANIFEST.in0000644000076500000240000000004712367353072015644 0ustar dottedmagstaff00000000000000include COPYING include chm/swig_chm.i pychm-0.8.4.1/PKG-INFO0000644000076500000240000000104212367462143015177 0ustar dottedmagstaff00000000000000Metadata-Version: 1.0 Name: pychm Version: 0.8.4.1 Summary: Python package to handle CHM files Home-page: https://github.com/dottedmag/pychm Author: Mikhail Gusarov Author-email: dottedmag@dottedmag.net License: GPL Description: The chm package provides three modules, chm, chmlib and extra, which provide access to the API implemented by the C library chmlib and some additional classes and functions. They are used to access MS-ITSS encoded files - Compressed Html Help files (.chm). Platform: UNKNOWN pychm-0.8.4.1/pychm.egg-info/0000755000076500000240000000000012367462143016717 5ustar dottedmagstaff00000000000000pychm-0.8.4.1/pychm.egg-info/dependency_links.txt0000644000076500000240000000000112367462143022765 0ustar dottedmagstaff00000000000000 pychm-0.8.4.1/pychm.egg-info/PKG-INFO0000644000076500000240000000104212367462143020011 0ustar dottedmagstaff00000000000000Metadata-Version: 1.0 Name: pychm Version: 0.8.4.1 Summary: Python package to handle CHM files Home-page: https://github.com/dottedmag/pychm Author: Mikhail Gusarov Author-email: dottedmag@dottedmag.net License: GPL Description: The chm package provides three modules, chm, chmlib and extra, which provide access to the API implemented by the C library chmlib and some additional classes and functions. They are used to access MS-ITSS encoded files - Compressed Html Help files (.chm). Platform: UNKNOWN pychm-0.8.4.1/pychm.egg-info/SOURCES.txt0000644000076500000240000000035212367462143020603 0ustar dottedmagstaff00000000000000COPYING MANIFEST.in README setup.py chm/__init__.py chm/chm.py chm/chmlib.py chm/extra.c chm/swig_chm.c chm/swig_chm.i pychm.egg-info/PKG-INFO pychm.egg-info/SOURCES.txt pychm.egg-info/dependency_links.txt pychm.egg-info/top_level.txtpychm-0.8.4.1/pychm.egg-info/top_level.txt0000644000076500000240000000000412367462143021443 0ustar dottedmagstaff00000000000000chm pychm-0.8.4.1/README0000644000076500000240000000120112367351152014754 0ustar dottedmagstaff00000000000000PyCHM ===== PyCHM is a Python library to manipulate CHM files (Microsoft HTML Help). The chm package contains four modules: * chm.chm: High-level support for CHM archives. * chm.extra: Extra utility functions - full-text search support, encoding detection. * chm._chmlib: Low level wrappers around the chmlib API (C part). * chm.chmlib: Low level wrappers around the chmlib API (Python part). License ------- Copyright (C) 2003-2006 Rubens Ramos Copyright (C) 2014 Mikhail Gusarov This library is licensed under the GPLv2+. Please refer to the COPYING file for more details. pychm-0.8.4.1/setup.cfg0000644000076500000240000000007312367462143015726 0ustar dottedmagstaff00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 pychm-0.8.4.1/setup.py0000644000076500000240000000222712367461655015631 0ustar dottedmagstaff00000000000000from setuptools import setup, Extension long_description = ''' The chm package provides three modules, chm, chmlib and extra, which provide access to the API implemented by the C library chmlib and some additional classes and functions. They are used to access MS-ITSS encoded files - Compressed Html Help files (.chm). ''' setup(name="pychm", version="0.8.4.1", description="Python package to handle CHM files", author="Rubens Ramos", author_email="rubensr@users.sourceforge.net", maintainer="Mikhail Gusarov", maintainer_email="dottedmag@dottedmag.net", url="https://github.com/dottedmag/pychm", license="GPL", long_description=long_description, py_modules=["chm.chm", "chm.chmlib"], ext_modules=[Extension("chm._chmlib", ["chm/swig_chm.c"], libraries=["chm"], extra_compile_args=["-DSWIG_COBJECT_TYPES"]), Extension("chm.extra", ["chm/extra.c"], extra_compile_args=["-D__PYTHON__"], libraries=["chm"])] )