Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Win32::Daemon with 5.10.

by fenLisesi (Priest)
on Mar 24, 2008 at 17:50 UTC ( [id://675943]=perlquestion: print w/replies, xml ) Need Help??

fenLisesi has asked for the wisdom of the Perl Monks concerning the following question:

O, wise ones (humbled, as always, in your presence):

We are considering upgrading an application to 5.10, but we have not been able to get Win32::Daemon to work properly therewith.

After some tweaking, my colleague has been able to compile the code on CPAN, but it won't run. Dave Roth, the author of the module, doesn't seem to be responding to queries.

Win32::Daemon has been recommended here by some of the wisest monks. That leads me to believe that there are some users of the module in this here Monastery, some of whom may have tried to use it with 5.10. Has anyone else taken a shot at this? If not, I would like to pose it as a PerlMonks Challenge, please.

Suggestions for an alternative solution are welcome, too.

Replies are listed 'Best First'.
Re: Win32::Daemon with 5.10.
by BrowserUk (Patriarch) on Mar 25, 2008 at 10:17 UTC

    If you'd rather or need to build this yourself, the follow patches and makefile allow that using AS1000 and MSVC v6.0

    Patch (For application to the sourcecode from backpan)

    Note: The download link from Win32::Daemon is broken. It's for a completely different package (Win32::Scheduler)??

    diff -iwbur Win32-Daemon\daemon.cpp Win32-Daemon-510\daemon.cpp --- Win32-Daemon\daemon.cpp Sun Mar 19 14:14:52 2000 +++ Win32-Daemon-510\daemon.cpp Tue Mar 25 00:42:14 2008 @@ -102,7 +102,7 @@ croak( "Usage: " EXTENSION "::Constant( $Name, $Arg )\n" ); } - pszName = (char*) SvPV( ST( 0 ), na ); + pszName = (char*) SvPVX( ST( 0 ) ); eResult = Constant( pszName, &pBuffer ); switch( eResult ) @@ -287,7 +287,7 @@ croak( "Usage: " EXTENSION "::DeleteService( $ServiceName )\n +" ); } - if( NULL != ( pszServiceName = SvPV( ST( 0 ), na ) ) ) + if( NULL != ( pszServiceName = SvPVX( ST( 0 ) ) ) ) { SC_HANDLE hSc = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACC +ESS ); if( NULL != hSc ) @@ -332,7 +332,7 @@ if( 2 == items ) { - hService = SvIV( ST( 1 ) ); + hService = (SERVICE_STATUS_HANDLE) SvIV( ST( 1 ) ); } if( NULL != hService ) @@ -414,11 +414,11 @@ if( items ) { - pszWindowStation = SvPV( ST( 0 ), na ); + pszWindowStation = SvPVX( ST( 0 ) ); } if( 1 < items ) { - pszDesktop = SvPV( ST( 0 ), na ); + pszDesktop = SvPVX( ST( 0 ) ); } // Free your mind...and the current console. :) @@ -533,7 +533,7 @@ newXS( EXTENSION "::Timeout", XS_WIN32__Daemon_Timeout, + file ); newXS( EXTENSION "::GetServiceHandle", XS_WIN32__Daemon_GetServi +ceHandle, file ); - ST(0) = &sv_yes; + ST(0) = &PL_sv_yes; XSRETURN( retcode ); } diff -iwbur Win32-Daemon\test\TEST.PL Win32-Daemon-510\test\TEST.PL --- Win32-Daemon\test\TEST.PL Tue Jan 25 08:26:56 2000 +++ Win32-Daemon-510\test\TEST.PL Tue Mar 25 02:24:24 2008 @@ -1,4 +1,4 @@ -use Win32::Service::Daemon; +use Win32::Daemon; %Hash = ( name => 'PerlTest', @@ -8,7 +8,7 @@ pwd => '', ); -if( Win32::Service::Daemon::CreateService( \%Hash ) ) +if( Win32::Daemon::CreateService( \%Hash ) ) { print "Successfully added.\n"; } diff -iwbur Win32-Daemon\Win32Perl.h Win32-Daemon-510\Win32Perl.h --- Win32-Daemon\Win32Perl.h Sun Dec 12 17:21:48 1999 +++ Win32-Daemon-510\Win32Perl.h Tue Mar 25 00:45:20 2008 @@ -326,9 +326,10 @@ inline LPTSTR HashGetPV( PERL_OBJECT_PROTO HV *pHv, LPTSTR pszKey +Name ) { SV *pSv = HashGetSV( PERL_OBJECT_ARGS pHv, pszKeyName ); + if( NULL != pSv ) { - return( SvPV( pSv, na ) ); + return( SvPVX( pSv ) ); } else {

    makefile

    # makefile for Win23::Daemon (perl v510) # Derived manually by BrowserUk PERLLIB = c:\perl510\lib\CORE\perl510.lib SYSTEMLIBS = c:\cl\lib\User32.Lib c:\cl\lib\AdvAPI32.Lib INCLUDES = -I"c:\cl\include" -I"c:\perl510\lib\CORE" .cpp.obj : cl -c $(INCLUDES) $< Daemon.dll : Daemon.cpp CONSTANT.obj CWinStation.obj ServiceThread.obj + daemon.def cl -MT -LD -DWIN32 $(INCLUDES) $** $(PERLLIB) $(SYSTEMLIBS) /link + /NODEFAULTLIB:libc ServiceThread.obj : ServiceThread.cpp cl -c -EHsc $(INCLUDES) $?

    You'll need to copy Daemon.PM and Daemon.dll into appropriate places manually. Someone else will have to work out how to get EU::MM to produce a suitable makefile.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      BrowserUk,

      Thank you very much for this. We downloaded the backpan version from 2000-03-19, applied your patch, and it actually compiled with 5.10 and the tests ran successfully.

      It turns out, however, that this version is way too old to help us, because our application uses callbacks, a feature that was apparently added to Win32::Daemon on 2001-02-24.

Re: Win32::Daemon with 5.10.
by bingos (Vicar) on Mar 25, 2008 at 07:52 UTC

    There appears to be an updated version on Dave's FTP site with links for 5.10

      Thanks, bingos. That beta was apparently placed on the ftp site the day I posted my message. We couldn't get it to work very well, though. The callback subs never seem to get called.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://675943]
Approved by randyk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-18 22:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found