RPM library for Win32 allows you to query content of the RPM packages (Caldera,Mandrake,RedHat,SuSE) on Win 98/NT/2k platforms.
Supported functionality includes:
  • query package for meta informations (name, version, description, group, etc.)
  • extract archive files to the specified directory (gzip and bzip2 compression methods are supported)

    In addition the Windows shell extension library is included. It extends standard Properties dialog with two new sheets (see examples below)
    and adds new command (Extract Files...) to the file context menu.

    Download:

    RPM library is distributed as source and binary packages - current version is 1.0. For download follow this link

    How to add support for RPM packages to your application:

    It's easy. RPM API is implemented as a COM object - so just refer to idl file for the interfaces details and
    have a look at the following sample code. I think it's selfexplained enough (if doesn't drop me an email).
    #include <rpm.h>
    #include <iostream.h>
    #include <comdef.h>
    #include <comutil.h>
    
    class Callback : public IExtractCallback
    {
    public:
    	Callback() {}
    
    // This must be correctly implemented, if your handler must be a COM Object (in this example it does not)
    // IUnknown
    	long __stdcall QueryInterface(const struct _GUID &,void ** ) { return 0; }
    	unsigned long __stdcall AddRef(void) { return 0; }
    	unsigned long __stdcall Release(void) { return 0; }
    
    // IDispatch
    	long __stdcall GetTypeInfoCount(unsigned int *) { return 0; }
    	long __stdcall GetTypeInfo(unsigned int,unsigned long,struct ITypeInfo ** ) { return 0; }
    	long __stdcall GetIDsOfNames(const struct _GUID &,unsigned short ** ,unsigned int,unsigned long,long *) { return 0; }
    	long __stdcall Invoke(long,const struct _GUID &,unsigned long,unsigned short,struct tagDISPPARAMS *,struct tagVARIANT *,struct tagEXCEPINFO *,unsigned int *) { return 0; }
    
    // IExtractCallback
    	STDMETHOD(Init)(/* [in] */ long filescount);
    	STDMETHOD(SetInfo)(/* [in] */ long index, /* [in] */ FileInfo file);
    	STDMETHOD(Confirmation)(/* [in] */ long index);
    };
    
    HRESULT Callback::Init( long filescount )
    {
    	cout << "Files: " << filescount << endl;
    	return S_OK;
    }
    
    HRESULT Callback::SetInfo( long index, FileInfo file )
    {
    	cout << _bstr_t( file.name );
    	return S_OK;
    }
    
    HRESULT Callback::Confirmation( long index )
    {
    	cout << " OK" << endl;
    	return S_OK;
    }
    
    int main(int argc, char* argv[])
    {
    	IRpm *pIRpm = NULL;
    
    	::CoInitialize( NULL );
    	::CoCreateInstance( CLSID_Rpm, NULL, CLSCTX_INPROC_SERVER, IID_IRpm, (LPVOID*)&pIRpm );
    
    	Callback cb;
    	PackageInfo pi;
    	FileInfo *fi = NULL;
    	long count = 0;
    
    	// both methods support these protocols
    	// file://c:/local_path/package.rpm
    	// file://unc_path/package.rpm
    	// ftp://server/path/package.rpm
    	// http://server/path/package.rpm
    	pIRpm->GetInfo( L"file://c:/path/package.i386.rpm", &pi, &fi, &count );
    	pIRpm->Extract( L"ftp://server/RPMS/package.i386.rpm", L"c:\\path_where_to_extract", &cb );
    
    	// free memory
    	::SysFreeString( pi.name );
    	::SysFreeString( pi.version );
    	::SysFreeString( pi.release );
    	::SysFreeString( pi.summary );
    	::SysFreeString( pi.group );
    	::SysFreeString( pi.description );
    	::SysFreeString( pi.distribution );
    	::SysFreeString( pi.vendor );
    	::SysFreeString( pi.license );
    	::SysFreeString( pi.copyright );
    	::SysFreeString( pi.packager );
    	::SysFreeString( pi.compressor );
    	::SysFreeString( pi.buildhost );
    	::SysFreeString( pi.url );
    
    	for( long i = 0; i < count; ++i )
    		::SysFreeString( fi[ i ].name );
    
    	::CoTaskMemFree( fi );
    
    	pIRpm->Release();
    	::CoUninitialize();
    
    	return 0;
    }
    

    Hosted by SourceForge Logo