Changeset 225 for trunk


Ignore:
Timestamp:
04/05/11 11:17:41 (13 years ago)
Author:
tim
Message:

added test case for python callback read/seek
began adding windows support in pyregfi
improved win32 build target

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/SConstruct

    r212 r225  
    11import sys
    22import os
    3 #import distutils.sysconfig
    43
    5 #cflags = '-std=gnu99 -pedantic -Wall'
    6 cflags = '-std=gnu99 -pedantic -Wall -fvisibility=hidden -ggdb'
    7 
     4cflags = '-std=gnu99 -pedantic -Wall -D_FILE_OFFSET_BITS=64 -fvisibility=hidden'
     5cflags += ' -ggdb'
    86
    97lib_src = ['lib/regfi.c',
  • trunk/lib/regfi.c

    r224 r225  
    612612  do
    613613  {
    614     rret = file_cb->read(file_cb, buf + rsize, *length - rsize);
     614    rret = file_cb->read(file_cb,
     615                         buf + rsize,
     616                         *length - rsize);
    615617    if(rret > 0)
    616618      rsize += rret;
  • trunk/python/pyregfi/__init__.py

    r224 r225  
    9595import sys
    9696import time
    97 import weakref
    9897from pyregfi.structures import *
    9998
     
    635634            pass
    636635       
     636        fh.seek(0)
    637637        self.raw_file = structures.REGFI_RAW_FILE()
    638638        self.raw_file.fh = fh
    639639        self.raw_file.seek = seek_cb_type(self.raw_file.cb_seek)
    640640        self.raw_file.read = read_cb_type(self.raw_file.cb_read)
    641         self.file = regfi.regfi_alloc_cb(self.raw_file, REGFI_ENCODING_UTF8)
    642 
     641        self.file = regfi.regfi_alloc_cb(pointer(self.raw_file), REGFI_ENCODING_UTF8)
     642        if not self.file:
     643            # XXX: switch to non-generic exception
     644            raise Exception("Could not open registry file.  Current log:\n"
     645                            + GetLogMessages())
    643646
    644647    def __getattr__(self, name):
  • trunk/python/pyregfi/structures.py

    r224 r225  
    8282
    8383
    84 # XXX: how can we know for sure the size of off_t and size_t?
    85 seek_cb_type = CFUNCTYPE(c_int64, POINTER(REGFI_RAW_FILE), c_uint64, c_int, use_errno=True)
    86 read_cb_type = CFUNCTYPE(c_int64, POINTER(REGFI_RAW_FILE), POINTER(c_char), c_uint64, use_errno=True)
     84# Load libregfi according to platform
     85regfi = None
     86if hasattr(ctypes, 'windll'):
     87    #regfi = ctypes.windll.libregfi
     88    regfi = ctypes.WinDLL('libregfi.dll', use_errno=True)
     89    CB_FACTORY = ctypes.WINFUNCTYPE
     90else:
     91    regfi = ctypes.CDLL(ctypes.util.find_library('regfi'), use_errno=True)
     92    CB_FACTORY = ctypes.CFUNCTYPE
     93
     94# XXX: how can we know for sure the size of off_t? 
     95#      -D_FILE_OFFSET_BITS=64 might help, need to research this
     96#      Also, may need to use something like ctypes_configure
     97#seek_cb_type = CB_FACTORY(c_int64, POINTER(REGFI_RAW_FILE), c_uint64, c_int, use_errno=True)
     98seek_cb_type = CB_FACTORY(c_int64, POINTER(REGFI_RAW_FILE), c_uint64, c_int)
     99#read_cb_type = CB_FACTORY(c_int64, POINTER(REGFI_RAW_FILE), POINTER(c_char), c_size_t, use_errno=True)
     100read_cb_type = CB_FACTORY(c_int64, POINTER(REGFI_RAW_FILE), POINTER(c_char), c_size_t)
    87101
    88102
     
    217231
    218232
    219 # Load libregfi and define function prototypes
    220 regfi = ctypes.CDLL(ctypes.util.find_library('regfi'), use_errno=True)
    221 
     233# Define function prototypes
    222234regfi.regfi_alloc.argtypes = [c_int, REGFI_ENCODING]
    223235regfi.regfi_alloc.restype = POINTER(REGFI_FILE)
Note: See TracChangeset for help on using the changeset viewer.