From djberg96 at gmail.com Wed Oct 1 16:53:46 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Wed, 01 Oct 2008 14:53:46 -0600 Subject: [Win32utils-devel] Problems with win32-dir and create_junction Message-ID: <48E3E35A.1080506@gmail.com> Hi, I don't know when this started happening, but I can't win32-dir tests to pass any more for the create_junction method. It looks like the junction is created, but it's not valid. Here's the results of the tests on Vista using the latest from CVS: Started ....................E.E................................. Finished in 0.477 seconds. 1) Error: test_create_junction_ascii(TC_Win32_Dir): Errno::EINVAL: Invalid argument - test_to_directory ./test/test_dir.rb:38:in `open' ./test/test_dir.rb:38:in `entries' ./test/test_dir.rb:38:in `test_create_junction_ascii' 2) Error: test_create_junction_unicode(TC_Win32_Dir): Errno::EINVAL: Invalid argument - ?????????? ./test/test_dir.rb:44:in `open' ./test/test_dir.rb:44:in `entries' ./test/test_dir.rb:44:in `test_create_junction_unicode' 56 tests, 111 assertions, 0 failures, 2 errors, 0 pendings, 0 omissions, 0 notifications rake aborted! Command failed with status (1): [C:/Ruby/bin/ruby -w -Ilib "C:/Ruby/lib/rub...] (See full trace by running task with --trace) Any ideas? Thanks, Dan From phasis at gmail.com Thu Oct 2 09:58:55 2008 From: phasis at gmail.com (Heesob Park) Date: Thu, 2 Oct 2008 22:58:55 +0900 Subject: [Win32utils-devel] Problems with win32-dir and create_junction In-Reply-To: <48E3E35A.1080506@gmail.com> References: <48E3E35A.1080506@gmail.com> Message-ID: Hi, 2008/10/2 Daniel Berger : > Hi, > > I don't know when this started happening, but I can't win32-dir tests to > pass any more for the create_junction method. > > It looks like the junction is created, but it's not valid. Here's the > results of the tests on Vista using the latest from CVS: > > Started > ....................E.E................................. > > Finished in 0.477 seconds. > > 1) Error: > test_create_junction_ascii(TC_Win32_Dir): > Errno::EINVAL: Invalid argument - test_to_directory > ./test/test_dir.rb:38:in `open' > ./test/test_dir.rb:38:in `entries' > ./test/test_dir.rb:38:in `test_create_junction_ascii' > > 2) Error: > test_create_junction_unicode(TC_Win32_Dir): > Errno::EINVAL: Invalid argument - ?????????? > ./test/test_dir.rb:44:in `open' > ./test/test_dir.rb:44:in `entries' > ./test/test_dir.rb:44:in `test_create_junction_unicode' > > 56 tests, 111 assertions, 0 failures, 2 errors, 0 pendings, 0 omissions, 0 > notifications > rake aborted! > Command failed with status (1): [C:/Ruby/bin/ruby -w -Ilib > "C:/Ruby/lib/rub...] > > (See full trace by running task with --trace) > > Any ideas? > It is due to the change of multi_to_wide method. Trailing \0's and wide_string.size mismatch problem. Modify line#111 of dir.rb wide_string = multi_to_wide(buf_target) To wide_string = multi_to_wide(buf_target)[0..-3] works for me in case of ascii junction. In case of the unicode, more work is needed. Regards, Park Heesob From Daniel.Berger at qwest.com Thu Oct 2 10:11:35 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 2 Oct 2008 09:11:35 -0500 Subject: [Win32utils-devel] Problems with win32-dir and create_junction In-Reply-To: References: <48E3E35A.1080506@gmail.com> Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514D59@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Heesob Park > Sent: Thursday, October 02, 2008 7:59 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Problems with win32-dir and > create_junction > > Hi, > > 2008/10/2 Daniel Berger : > > Hi, > > > > I don't know when this started happening, but I can't > win32-dir tests > > to pass any more for the create_junction method. > > > > It looks like the junction is created, but it's not valid. > Here's the > > results of the tests on Vista using the latest from CVS: > > > > Started > > ....................E.E................................. > > > > Finished in 0.477 seconds. > > > > 1) Error: > > test_create_junction_ascii(TC_Win32_Dir): > > Errno::EINVAL: Invalid argument - test_to_directory > > ./test/test_dir.rb:38:in `open' > > ./test/test_dir.rb:38:in `entries' > > ./test/test_dir.rb:38:in `test_create_junction_ascii' > > > > 2) Error: > > test_create_junction_unicode(TC_Win32_Dir): > > Errno::EINVAL: Invalid argument - ?????????? > > ./test/test_dir.rb:44:in `open' > > ./test/test_dir.rb:44:in `entries' > > ./test/test_dir.rb:44:in `test_create_junction_unicode' > > > > 56 tests, 111 assertions, 0 failures, 2 errors, 0 pendings, 0 > > omissions, 0 notifications rake aborted! > > Command failed with status (1): [C:/Ruby/bin/ruby -w -Ilib > > "C:/Ruby/lib/rub...] > > > > (See full trace by running task with --trace) > > > > Any ideas? > > > It is due to the change of multi_to_wide method. > Trailing \0's and wide_string.size mismatch problem. > > Modify line#111 of dir.rb > wide_string = multi_to_wide(buf_target) To > wide_string = multi_to_wide(buf_target)[0..-3] works for > me in case of ascii junction. Ah, ok. Thanks. Do you think we should automatically strip the trailing "\000\000" in the multi_to_wide method then? I think this would work because I modified wide_to_multi to automatically append "\000\000" to the incoming string if they weren't already there. > In case of the unicode, more work is needed. Any suggestions? Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Thu Oct 2 10:15:34 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 2 Oct 2008 09:15:34 -0500 Subject: [Win32utils-devel] Problems with win32-dir and create_junction In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB04514D59@ITOMAE2KM01.AD.QINTRA.COM> References: <48E3E35A.1080506@gmail.com> <7524A45A1A5B264FA4809E2156496CFB04514D59@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514D5A@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Berger, Daniel > Sent: Thursday, October 02, 2008 8:12 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Problems with win32-dir and > create_junction > Do you think we should automatically strip the trailing > "\000\000" in the multi_to_wide method then? I think this > would work because I modified wide_to_multi to automatically > append "\000\000" to the incoming string if they weren't > already there. On second thought, I think that might cause wide character functions to fail. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From phasis at gmail.com Thu Oct 2 10:25:24 2008 From: phasis at gmail.com (Heesob Park) Date: Thu, 2 Oct 2008 23:25:24 +0900 Subject: [Win32utils-devel] Problems with win32-dir and create_junction In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB04514D5A@ITOMAE2KM01.AD.QINTRA.COM> References: <48E3E35A.1080506@gmail.com> <7524A45A1A5B264FA4809E2156496CFB04514D59@ITOMAE2KM01.AD.QINTRA.COM> <7524A45A1A5B264FA4809E2156496CFB04514D5A@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: 2008/10/2 Berger, Daniel : >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Berger, Daniel >> Sent: Thursday, October 02, 2008 8:12 AM >> To: Development and ideas for win32utils projects >> Subject: Re: [Win32utils-devel] Problems with win32-dir and >> create_junction > > > >> Do you think we should automatically strip the trailing >> "\000\000" in the multi_to_wide method then? I think this >> would work because I modified wide_to_multi to automatically >> append "\000\000" to the incoming string if they weren't >> already there. > > On second thought, I think that might cause wide character functions to > fail. > I think it would be better to define new method for getting the wide_string length than to use String#size method. Regards, Park Heesob From Daniel.Berger at qwest.com Thu Oct 2 14:02:49 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 2 Oct 2008 13:02:49 -0500 Subject: [Win32utils-devel] Problems using a hand built OpenSSL on Windows Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514D5E@ITOMAE2KM01.AD.QINTRA.COM> Hi everyone, Windows XP Pro OpenSSL 0.9.8i Ruby 1.8.6-p114 Ok, I'm going a bit OT here, but I want to see if anyone knows the answer. I built Ruby with VC++ 8 (cl 14). I managed to build and install OpenSSL. I also managed to build the Ruby OpenSSL extension, after 1 minor tweak to x509.h to eliminate a macro conflict: --- x509.orig Thu Oct 02 11:30:10 2008 +++ x509.h Thu Oct 02 11:47:05 2008 @@ -116,6 +116,7 @@ /* Under Win32 these are defined in wincrypt.h */ #undef X509_NAME #undef X509_CERT_PAIR +#undef X509_EXTENSIONS #endif #define X509_FILETYPE_PEM 1 But, when I try to start Rails, for example, I get this: "The ordinal 284 could not be located in the dynamic link library SSLEAY32.DLL". Any idea on how to solve this? Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Thu Oct 2 14:20:54 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 2 Oct 2008 13:20:54 -0500 Subject: [Win32utils-devel] Problems using a hand built OpenSSL on Windows In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB04514D5E@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB04514D5E@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514D5F@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Berger, Daniel > Sent: Thursday, October 02, 2008 12:03 PM > To: Development and ideas for win32utils projects > Subject: [Win32utils-devel] Problems using a hand built > OpenSSL on Windows > > Hi everyone, > > Windows XP Pro > OpenSSL 0.9.8i > Ruby 1.8.6-p114 > > Ok, I'm going a bit OT here, but I want to see if anyone > knows the answer. > > I built Ruby with VC++ 8 (cl 14). I managed to build and > install OpenSSL. I also managed to build the Ruby OpenSSL > extension, after 1 minor tweak to x509.h to eliminate a macro > conflict: > > --- x509.orig Thu Oct 02 11:30:10 2008 > +++ x509.h Thu Oct 02 11:47:05 2008 > @@ -116,6 +116,7 @@ > /* Under Win32 these are defined in wincrypt.h */ #undef > X509_NAME #undef X509_CERT_PAIR > +#undef X509_EXTENSIONS > #endif > > #define X509_FILETYPE_PEM 1 > > But, when I try to start Rails, for example, I get this: > > "The ordinal 284 could not be located in the dynamic link > library SSLEAY32.DLL". > > Any idea on how to solve this? Disregard. This solved it: set PATH=c:\usr\local\openssl\bin;%PATH% I forgot how many apps ship with their own ssleay32.dll. It was using the wrong one. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From djberg96 at gmail.com Thu Oct 2 19:53:16 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Thu, 02 Oct 2008 17:53:16 -0600 Subject: [Win32utils-devel] Problems with win32-dir and create_junction In-Reply-To: References: <48E3E35A.1080506@gmail.com> <7524A45A1A5B264FA4809E2156496CFB04514D59@ITOMAE2KM01.AD.QINTRA.COM> <7524A45A1A5B264FA4809E2156496CFB04514D5A@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <48E55EEC.3050603@gmail.com> Heesob Park wrote: > 2008/10/2 Berger, Daniel : >>> -----Original Message----- >>> From: win32utils-devel-bounces at rubyforge.org >>> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >>> Berger, Daniel >>> Sent: Thursday, October 02, 2008 8:12 AM >>> To: Development and ideas for win32utils projects >>> Subject: Re: [Win32utils-devel] Problems with win32-dir and >>> create_junction >> >> >>> Do you think we should automatically strip the trailing >>> "\000\000" in the multi_to_wide method then? I think this >>> would work because I modified wide_to_multi to automatically >>> append "\000\000" to the incoming string if they weren't >>> already there. >> On second thought, I think that might cause wide character functions to >> fail. >> > I think it would be better to define new method for getting the > wide_string length > than to use String#size method. I have a very alpha "UString" class I've got in CVS (in the "shards" project, not win32utils) where I've been tinkering with a Windows-only subclass of String. It redefines methods like length, size, etc. I've pasted what I've done so far below. Or do you think that's overkill? Regards, Dan # ustring.rb - ALPHA class UString < String include Windows::Unicode include Windows::MSVCRT::String VERSION = '0.1.0' ACP = CP_ACP UTF7 = CP_UTF7 UTF8 = CP_UTF8 attr_accessor :encoding alias :at :[] def initialize(string, encoding = UTF8) ustring = multi_to_wide(string, encoding) @encoding = encoding super(ustring) end def inspect wide_to_multi(self, @encoding) end def to_s wide_to_multi(self, @encoding) end def to_str wide_to_multi(self, @encoding) end # Length in chars def length wcslen(self) end # Size in bytes def size strlen(wide_to_multi(self, @encoding)) end # Returns the character (not the numeric value) def [](n) wide_to_multi(self, @encoding).at(n, 1) end end From Daniel.Berger at qwest.com Wed Oct 15 17:48:59 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Wed, 15 Oct 2008 16:48:59 -0500 Subject: [Win32utils-devel] Problems with win32-dir and create_junction In-Reply-To: References: <48E3E35A.1080506@gmail.com><7524A45A1A5B264FA4809E2156496CFB04514D59@ITOMAE2KM01.AD.QINTRA.COM><7524A45A1A5B264FA4809E2156496CFB04514D5A@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514D85@ITOMAE2KM01.AD.QINTRA.COM> Hi, > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Heesob Park > Sent: Thursday, October 02, 2008 8:25 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Problems with win32-dir and > create_junction > > 2008/10/2 Berger, Daniel : > >> -----Original Message----- > >> From: win32utils-devel-bounces at rubyforge.org > >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf > Of Berger, > >> Daniel > >> Sent: Thursday, October 02, 2008 8:12 AM > >> To: Development and ideas for win32utils projects > >> Subject: Re: [Win32utils-devel] Problems with win32-dir and > >> create_junction > > > > > > > >> Do you think we should automatically strip the trailing > "\000\000" in > >> the multi_to_wide method then? I think this would work because I > >> modified wide_to_multi to automatically append "\000\000" to the > >> incoming string if they weren't already there. > > > > On second thought, I think that might cause wide character > functions > > to fail. > > > I think it would be better to define new method for getting > the wide_string length than to use String#size method. Here's a minimal WideString class: require 'windows/unicode' require 'windows/msvcrt/string' class WideString < String include Windows::Unicode include Windows::MSVCRT::String ACP = CP_ACP UTF7 = CP_UTF7 UTF8 = CP_UTF8 attr_accessor :encoding def initialize(string, encoding = UTF8) super(multi_to_wide(string, encoding)) @encoding = encoding end def length wcslen(self) * 2 end alias size length end Another approach is to monkey-patch String: require 'windows/msvcrt/string' class String include Windows::MSVCRT::String def wlength wcslen(self) * 2 end alias wsize wlength end What do you think? Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Thu Oct 16 12:00:11 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 16 Oct 2008 11:00:11 -0500 Subject: [Win32utils-devel] Readline with VC++ 8? Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514D89@ITOMAE2KM01.AD.QINTRA.COM> Hi, Anyone on the list manage to build readline on Windows with VC++ 8? If so, would you mind sharing the .so file? And then, if you don't mind, could you tell us how you did it? Thanks, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From luislavena at gmail.com Tue Oct 21 14:27:17 2008 From: luislavena at gmail.com (Luis Lavena) Date: Tue, 21 Oct 2008 15:27:17 -0300 Subject: [Win32utils-devel] Readline with VC++ 8? In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB04514D89@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB04514D89@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <71166b3b0810211127m3ee3d3fah7a44969811a0cda1@mail.gmail.com> On Thu, Oct 16, 2008 at 1:00 PM, Berger, Daniel wrote: > Hi, > > Anyone on the list manage to build readline on Windows with VC++ 8? If > so, would you mind sharing the .so file? > > And then, if you don't mind, could you tell us how you did it? > I did succeed on that field, long time ago. Was really hard make all the Makefile patches and source (mostly makefile patches). I think I have a svn copy based on gnuwin32 project source code. The problem with that is GNU Readline is a real mess, and the way the GNU win32 maintainers packaged everything is even worse. I'll try to find by copy and send those patches to you. > Thanks, > -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From Daniel.Berger at qwest.com Tue Oct 21 14:37:53 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Tue, 21 Oct 2008 13:37:53 -0500 Subject: [Win32utils-devel] Readline with VC++ 8? In-Reply-To: <71166b3b0810211127m3ee3d3fah7a44969811a0cda1@mail.gmail.com> References: <7524A45A1A5B264FA4809E2156496CFB04514D89@ITOMAE2KM01.AD.QINTRA.COM> <71166b3b0810211127m3ee3d3fah7a44969811a0cda1@mail.gmail.com> Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514DA2@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Luis Lavena > Sent: Tuesday, October 21, 2008 12:27 PM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Readline with VC++ 8? > > On Thu, Oct 16, 2008 at 1:00 PM, Berger, Daniel > wrote: > > Hi, > > > > Anyone on the list manage to build readline on Windows with > VC++ 8? If > > so, would you mind sharing the .so file? > > > > And then, if you don't mind, could you tell us how you did it? > > > > I did succeed on that field, long time ago. Was really hard > make all the Makefile patches and source (mostly makefile > patches). I think I have a svn copy based on gnuwin32 project > source code. > > The problem with that is GNU Readline is a real mess, and the > way the GNU win32 maintainers packaged everything is even worse. I don't know very much about what readline actually _does_ other than it's used for command shell apps. Maybe a pure Win32 version is in order? > I'll try to find by copy and send those patches to you. Excellent, thanks. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From luislavena at gmail.com Tue Oct 21 14:49:49 2008 From: luislavena at gmail.com (Luis Lavena) Date: Tue, 21 Oct 2008 15:49:49 -0300 Subject: [Win32utils-devel] Readline with VC++ 8? In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB04514DA2@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB04514D89@ITOMAE2KM01.AD.QINTRA.COM> <71166b3b0810211127m3ee3d3fah7a44969811a0cda1@mail.gmail.com> <7524A45A1A5B264FA4809E2156496CFB04514DA2@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <71166b3b0810211149r5fee073eje97e8444fb80036d@mail.gmail.com> On Tue, Oct 21, 2008 at 3:37 PM, Berger, Daniel wrote: > > >> -----Original Message----- >> From: win32utils-devel-bounces at rubyforge.org >> [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of >> Luis Lavena >> Sent: Tuesday, October 21, 2008 12:27 PM >> To: Development and ideas for win32utils projects >> Subject: Re: [Win32utils-devel] Readline with VC++ 8? >> >> On Thu, Oct 16, 2008 at 1:00 PM, Berger, Daniel >> wrote: >> > Hi, >> > >> > Anyone on the list manage to build readline on Windows with >> VC++ 8? If >> > so, would you mind sharing the .so file? >> > >> > And then, if you don't mind, could you tell us how you did it? >> > >> >> I did succeed on that field, long time ago. Was really hard >> make all the Makefile patches and source (mostly makefile >> patches). I think I have a svn copy based on gnuwin32 project >> source code. >> >> The problem with that is GNU Readline is a real mess, and the >> way the GNU win32 maintainers packaged everything is even worse. > > I don't know very much about what readline actually _does_ other than > it's used for command shell apps. oh, it does a lot of stuff, and sometimes it crashes. The problem is that gnuwin32 package maintainers added some patches that are not part officially of GNU Readline, since GNU ppl believe is not "pure" > Maybe a pure Win32 version is in order? > Yes, please, readline has big problems with win32console or long lines (100 chars) OT: what about deprecating Win32API and moving to ruby-ffi? >> I'll try to find by copy and send those patches to you. > > Excellent, thanks. > Checked on my backup catalog, is at home, will bring it tomorrow to the office. -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From Daniel.Berger at qwest.com Tue Oct 21 15:00:54 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Tue, 21 Oct 2008 14:00:54 -0500 Subject: [Win32utils-devel] Readline with VC++ 8? In-Reply-To: <71166b3b0810211149r5fee073eje97e8444fb80036d@mail.gmail.com> References: <7524A45A1A5B264FA4809E2156496CFB04514D89@ITOMAE2KM01.AD.QINTRA.COM><71166b3b0810211127m3ee3d3fah7a44969811a0cda1@mail.gmail.com><7524A45A1A5B264FA4809E2156496CFB04514DA2@ITOMAE2KM01.AD.QINTRA.COM> <71166b3b0810211149r5fee073eje97e8444fb80036d@mail.gmail.com> Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514DA5@ITOMAE2KM01.AD.QINTRA.COM> Hi, > > Maybe a pure Win32 version is in order? > > > > Yes, please, readline has big problems with win32console or > long lines (100 chars) I'm afraid I'm not qualified. Perhaps you are though? > OT: what about deprecating Win32API and moving to ruby-ffi? It's only available in Jruby and Rubinius as far as I know, and then only as Beta. Do we have the functions needed already declared in windows-pr? There's Windows::Console plus the MSVCRT functions. I'm willing to throw Windows 2000 under a bus on this, too, as I'm aware that Windows XP added several console functions that might be desired, or even necessary. > >> I'll try to find by copy and send those patches to you. > > > > Excellent, thanks. > > > > Checked on my backup catalog, is at home, will bring it > tomorrow to the office. Great, thanks. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Wed Oct 22 10:04:57 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Wed, 22 Oct 2008 09:04:57 -0500 Subject: [Win32utils-devel] Readline with VC++ 8? In-Reply-To: <71166b3b0810211149r5fee073eje97e8444fb80036d@mail.gmail.com> References: <7524A45A1A5B264FA4809E2156496CFB04514D89@ITOMAE2KM01.AD.QINTRA.COM><71166b3b0810211127m3ee3d3fah7a44969811a0cda1@mail.gmail.com><7524A45A1A5B264FA4809E2156496CFB04514DA2@ITOMAE2KM01.AD.QINTRA.COM> <71166b3b0810211149r5fee073eje97e8444fb80036d@mail.gmail.com> Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514DAF@ITOMAE2KM01.AD.QINTRA.COM> Hi, > Yes, please, readline has big problems with win32console or > long lines (100 chars) > > OT: what about deprecating Win32API and moving to ruby-ffi? > > >> I'll try to find by copy and send those patches to you. > > > > Excellent, thanks. > > > > Checked on my backup catalog, is at home, will bring it > tomorrow to the office. I came across "Inline" yesterday. http://rubyforge.org/projects/inline Maybe we can use this instead of readline? Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From luislavena at gmail.com Wed Oct 22 10:08:02 2008 From: luislavena at gmail.com (Luis Lavena) Date: Wed, 22 Oct 2008 11:08:02 -0300 Subject: [Win32utils-devel] Readline with VC++ 8? In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB04514DAF@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB04514D89@ITOMAE2KM01.AD.QINTRA.COM> <71166b3b0810211127m3ee3d3fah7a44969811a0cda1@mail.gmail.com> <7524A45A1A5B264FA4809E2156496CFB04514DA2@ITOMAE2KM01.AD.QINTRA.COM> <71166b3b0810211149r5fee073eje97e8444fb80036d@mail.gmail.com> <7524A45A1A5B264FA4809E2156496CFB04514DAF@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <71166b3b0810220708x46b4033bqda6e8ad74b91e879@mail.gmail.com> On Wed, Oct 22, 2008 at 11:04 AM, Berger, Daniel wrote: > Hi, > > > >> Yes, please, readline has big problems with win32console or >> long lines (100 chars) >> >> OT: what about deprecating Win32API and moving to ruby-ffi? >> >> >> I'll try to find by copy and send those patches to you. >> > >> > Excellent, thanks. >> > >> >> Checked on my backup catalog, is at home, will bring it >> tomorrow to the office. > > I came across "Inline" yesterday. > > http://rubyforge.org/projects/inline > > Maybe we can use this instead of readline? > I wish it was API-compliant with Readline, but it promises (uses Win32API for the low level keyboard events.) BTW, have the backup with me, now need to find the time to upload it for you :-D -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From Daniel.Berger at qwest.com Wed Oct 22 10:44:51 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Wed, 22 Oct 2008 09:44:51 -0500 Subject: [Win32utils-devel] Readline with VC++ 8? In-Reply-To: <71166b3b0810220708x46b4033bqda6e8ad74b91e879@mail.gmail.com> References: <7524A45A1A5B264FA4809E2156496CFB04514D89@ITOMAE2KM01.AD.QINTRA.COM><71166b3b0810211127m3ee3d3fah7a44969811a0cda1@mail.gmail.com><7524A45A1A5B264FA4809E2156496CFB04514DA2@ITOMAE2KM01.AD.QINTRA.COM><71166b3b0810211149r5fee073eje97e8444fb80036d@mail.gmail.com><7524A45A1A5B264FA4809E2156496CFB04514DAF@ITOMAE2KM01.AD.QINTRA.COM> <71166b3b0810220708x46b4033bqda6e8ad74b91e879@mail.gmail.com> Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514DB0@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Luis Lavena > Sent: Wednesday, October 22, 2008 8:08 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Readline with VC++ 8? > > On Wed, Oct 22, 2008 at 11:04 AM, Berger, Daniel > wrote: > > Hi, > > > > > > > >> Yes, please, readline has big problems with win32console or long > >> lines (100 chars) > >> > >> OT: what about deprecating Win32API and moving to ruby-ffi? > >> > >> >> I'll try to find by copy and send those patches to you. > >> > > >> > Excellent, thanks. > >> > > >> > >> Checked on my backup catalog, is at home, will bring it > tomorrow to > >> the office. > > > > I came across "Inline" yesterday. > > > > http://rubyforge.org/projects/inline > > > > Maybe we can use this instead of readline? > > > > I wish it was API-compliant with Readline, but it promises > (uses Win32API for the low level keyboard events.) Yeah, I put in a feature request for a "Readline compatibility mode". We'll see what comes of it. Frankly I think the current Readline API is screwball. It's a module instead of a class, everything's a module function, module instance variables being stored in weird ways, etc. And totally undocumented (in p114 anyway). If I can, I'll just replace the code I use with the Inline equivalent if possible. > BTW, have the backup with me, now need to find the time to > upload it for you :-D Thanks! Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Wed Oct 22 11:56:16 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Wed, 22 Oct 2008 10:56:16 -0500 Subject: [Win32utils-devel] Readline with VC++ 8? In-Reply-To: <71166b3b0810220708x46b4033bqda6e8ad74b91e879@mail.gmail.com> References: <7524A45A1A5B264FA4809E2156496CFB04514D89@ITOMAE2KM01.AD.QINTRA.COM><71166b3b0810211127m3ee3d3fah7a44969811a0cda1@mail.gmail.com><7524A45A1A5B264FA4809E2156496CFB04514DA2@ITOMAE2KM01.AD.QINTRA.COM><71166b3b0810211149r5fee073eje97e8444fb80036d@mail.gmail.com><7524A45A1A5B264FA4809E2156496CFB04514DAF@ITOMAE2KM01.AD.QINTRA.COM> <71166b3b0810220708x46b4033bqda6e8ad74b91e879@mail.gmail.com> Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514DB3@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Luis Lavena > Sent: Wednesday, October 22, 2008 8:08 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] Readline with VC++ 8? > > On Wed, Oct 22, 2008 at 11:04 AM, Berger, Daniel > wrote: > > Hi, > > > > > > > >> Yes, please, readline has big problems with win32console or long > >> lines (100 chars) > >> > >> OT: what about deprecating Win32API and moving to ruby-ffi? > >> > >> >> I'll try to find by copy and send those patches to you. > >> > > >> > Excellent, thanks. > >> > > >> > >> Checked on my backup catalog, is at home, will bring it > tomorrow to > >> the office. > > > > I came across "Inline" yesterday. > > > > http://rubyforge.org/projects/inline > > > > Maybe we can use this instead of readline? > > > > I wish it was API-compliant with Readline, but it promises > (uses Win32API for the low level keyboard events.) Oof. This whole time I thought irb required readline to work. Nope. It turns out I was hitting a LoadError bug in irb/init.rb: http://redmine.ruby-lang.org/issues/show/677 Two LoadError bugs in three days! What are the odds?! Anyway, once I fixed that, I was able to use the Rails console. Yay. Still, I think a pure Ruby Readline library would be very welcome in the Ruby world. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From luislavena at gmail.com Thu Oct 23 15:43:16 2008 From: luislavena at gmail.com (Luis Lavena) Date: Thu, 23 Oct 2008 16:43:16 -0300 Subject: [Win32utils-devel] Readline with VC++ 8? In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB04514DB3@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB04514D89@ITOMAE2KM01.AD.QINTRA.COM> <71166b3b0810211127m3ee3d3fah7a44969811a0cda1@mail.gmail.com> <7524A45A1A5B264FA4809E2156496CFB04514DA2@ITOMAE2KM01.AD.QINTRA.COM> <71166b3b0810211149r5fee073eje97e8444fb80036d@mail.gmail.com> <7524A45A1A5B264FA4809E2156496CFB04514DAF@ITOMAE2KM01.AD.QINTRA.COM> <71166b3b0810220708x46b4033bqda6e8ad74b91e879@mail.gmail.com> <7524A45A1A5B264FA4809E2156496CFB04514DB3@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <71166b3b0810231243q5f9fe239i83c86c01a92a6740@mail.gmail.com> On Wed, Oct 22, 2008 at 12:56 PM, Berger, Daniel wrote: > ... > > Oof. This whole time I thought irb required readline to work. Nope. It > turns out I was hitting a LoadError bug in irb/init.rb: > > http://redmine.ruby-lang.org/issues/show/677 > > Two LoadError bugs in three days! What are the odds?! > The odds are really high, is ruby source code, sometimes that stuff is really buried in :-P > Anyway, once I fixed that, I was able to use the Rails console. Yay. > Double yay! > Still, I think a pure Ruby Readline library would be very welcome in the > Ruby world. > Yes indeed, but the ruby tests for it do not provide too much information about it (those are plain silly if you ask me). Maybe RubySpec has something better about it? > Regards, > > Dan This is what I have for readline and VC8: http://gist.github.com/19167 But realized was version 4.3 since version 5 was a complete nightmare to build. I'll try to see where is that subversion repo and generate a package from it. -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams From djberg96 at gmail.com Sat Oct 25 20:47:40 2008 From: djberg96 at gmail.com (Daniel Berger) Date: Sat, 25 Oct 2008 18:47:40 -0600 Subject: [Win32utils-devel] ReadFileEx segfault Message-ID: <4903BE2C.70506@gmail.com> Hi, Windows Vista Ruby 1.8.6-p114 - One click I tried the following script below but it segfaults. One thing I realized is that we don't explicitly handle VOID callbacks (e.g. FileIOCompletionRoutine) in api.c. Could that be the issue? require 'windows/file' require 'windows/handle' require 'windows/error' require 'windows/synchronize' require 'windows/thread' include Windows::File include Windows::Handle include Windows::Error include Windows::Synchronize include Windows::Thread file = "test.txt" File.open(file, 'w'){ |fh| fh.puts "The quick brown fox jumped over" } overlapped = 0.chr * 20 overlapped[8,4] = [4].pack("L") handle = CreateFile( file, FILE_READ_DATA, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0 ) if handle == INVALID_HANDLE_VALUE raise get_last_error end buf = 0.chr * File.size(file) bytes = [0].pack('L') func = Win32::API::Callback.new('LLP', 'V'){ |err, bytes, olap| puts "Hello" } #bool = ReadFile(handle, buf, 5, bytes, overlapped) bool = ReadFileEx(handle, buf, 5, overlapped, func) unless bool error = GetLastError() if error == ERROR_IO_PENDING unless GetOverlappedResult(handle, overlapped, bytes, true) raise get_last_error end else CloseHandle(handle) raise error end end SleepEx(1,true) CloseHandle(handle) p buf.strip Regards, Dan From phasis at gmail.com Sun Oct 26 09:49:06 2008 From: phasis at gmail.com (Heesob Park) Date: Sun, 26 Oct 2008 22:49:06 +0900 Subject: [Win32utils-devel] ReadFileEx segfault In-Reply-To: <4903BE2C.70506@gmail.com> References: <4903BE2C.70506@gmail.com> Message-ID: Hi, 2008/10/26 Daniel Berger : > Hi, > > Windows Vista > Ruby 1.8.6-p114 - One click > > I tried the following script below but it segfaults. One thing I realized is > that we don't explicitly handle VOID callbacks (e.g. > FileIOCompletionRoutine) in api.c. Could that be the issue? > > require 'windows/file' > require 'windows/handle' > require 'windows/error' > require 'windows/synchronize' > require 'windows/thread' > > include Windows::File > include Windows::Handle > include Windows::Error > include Windows::Synchronize > include Windows::Thread > > file = "test.txt" > File.open(file, 'w'){ |fh| fh.puts "The quick brown fox jumped over" } > > overlapped = 0.chr * 20 > overlapped[8,4] = [4].pack("L") > > handle = CreateFile( > file, > FILE_READ_DATA, > FILE_SHARE_READ, > 0, > OPEN_EXISTING, > FILE_FLAG_OVERLAPPED, > 0 > ) > > if handle == INVALID_HANDLE_VALUE > raise get_last_error > end > > buf = 0.chr * File.size(file) > bytes = [0].pack('L') > > func = Win32::API::Callback.new('LLP', 'V'){ |err, bytes, olap| > puts "Hello" > } > > #bool = ReadFile(handle, buf, 5, bytes, overlapped) > bool = ReadFileEx(handle, buf, 5, overlapped, func) > > unless bool > error = GetLastError() > if error == ERROR_IO_PENDING > unless GetOverlappedResult(handle, overlapped, bytes, true) > raise get_last_error > end > else > CloseHandle(handle) > raise error > end > end > > SleepEx(1,true) > > CloseHandle(handle) > > p buf.strip > I looked into callback again and finally found the current implementation is a faulty product. Here is an ugly but reliable patch. If you use some assemby code, it might be more compact. --- api.c.org 2008-10-26 22:31:16.000000000 +0900 +++ api.c 2008-10-26 22:37:47.000000000 +0900 @@ -469,10 +469,13 @@ typedef struct { DWORD params[1]; } PARAM; +typedef struct { + DWORD params[16]; +} CALLPARAM; static VALUE ActiveCallback; -DWORD CallbackFunction(PARAM param) +DWORD CallbackFunction(CALLPARAM param) { VALUE v_proto, v_return, v_proc, v_retval; VALUE argv[16]; @@ -547,6 +550,61 @@ return 0; } +DWORD CALLBACK CallbackFunction0() { + CALLPARAM param = {0}; + param.params[0] = 0; + return CallbackFunction(param); +} +DWORD CALLBACK CallbackFunction1(DWORD p1) { + CALLPARAM param = {p1}; + return CallbackFunction(param); +} +DWORD CALLBACK CallbackFunction2(DWORD p1,DWORD p2) { + CALLPARAM param = {p1,p2}; + return CallbackFunction(param); +} +DWORD CALLBACK CallbackFunction3(DWORD p1,DWORD p2,DWORD p3) { + CALLPARAM param = {p1,p2,p3}; + return CallbackFunction(param); +} +DWORD CALLBACK CallbackFunction4(DWORD p1,DWORD p2,DWORD p3,DWORD p4) { + CALLPARAM param = {p1,p2,p3,p4}; + return CallbackFunction(param); +} +DWORD CALLBACK CallbackFunction5(DWORD p1,DWORD p2,DWORD p3,DWORD p4,DWORD p5) { + CALLPARAM param = {p1,p2,p3,p4,p5}; + return CallbackFunction(param); +} +DWORD CALLBACK CallbackFunction6(DWORD p1,DWORD p2,DWORD p3,DWORD p4,DWORD p5,DWORD p6) { + CALLPARAM param = {p1,p2,p3,p4,p5,p6}; + return CallbackFunction(param); +} +DWORD CALLBACK CallbackFunction7(DWORD p1,DWORD p2,DWORD p3,DWORD p4,DWORD p5,DWORD p6,DWORD p7) { + CALLPARAM param = {p1,p2,p3,p4,p5,p6,p7}; + return CallbackFunction(param); +} +DWORD CALLBACK CallbackFunction8(DWORD p1,DWORD p2,DWORD p3,DWORD p4,DWORD p5,DWORD p6,DWORD p7,DWORD p8) { + CALLPARAM param = {p1,p2,p3,p4,p5,p6,p7,p8}; + return CallbackFunction(param); +} +DWORD CALLBACK CallbackFunction9(DWORD p1,DWORD p2,DWORD p3,DWORD p4,DWORD p5,DWORD p6,DWORD p7,DWORD p8,DWORD p9) { + CALLPARAM param = {p1,p2,p3,p4,p5,p6,p7,p8,p9}; + return CallbackFunction(param); +} + +void *CallbackTable[] = { + CallbackFunction0, + CallbackFunction1, + CallbackFunction2, + CallbackFunction3, + CallbackFunction4, + CallbackFunction5, + CallbackFunction6, + CallbackFunction7, + CallbackFunction8, + CallbackFunction9 +}; + /* * call-seq: * Win32::API#call(arg1, arg2, ...) @@ -619,7 +677,8 @@ break; case _T_CALLBACK: ActiveCallback = v_arg; - param.params[i] = (LPARAM)CallbackFunction; + v_proto = rb_iv_get(ActiveCallback, "@prototype"); + param.params[i] = (LPARAM)CallbackTable[RSTRING(v_proto)->len]; break; case _T_STRING: param.params[i] = (unsigned long)RSTRING(v_arg)->ptr; Regards, Park Heesob From Daniel.Berger at qwest.com Tue Oct 28 16:32:55 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Tue, 28 Oct 2008 15:32:55 -0500 Subject: [Win32utils-devel] ReadFileEx segfault In-Reply-To: References: <4903BE2C.70506@gmail.com> Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514DEF@ITOMAE2KM01.AD.QINTRA.COM> Hi, > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Heesob Park > Sent: Sunday, October 26, 2008 7:49 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] ReadFileEx segfault > > Hi, > I looked into callback again and finally found the current > implementation is a faulty product. > > Here is an ugly but reliable patch. > If you use some assemby code, it might be more compact. Excellent! Works great. Applied to CVS. I'll put out a release as soon as I get my old laptop back from the repair shop (bad fan). Probably this weekend. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From Daniel.Berger at qwest.com Thu Oct 30 18:00:38 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Thu, 30 Oct 2008 17:00:38 -0500 Subject: [Win32utils-devel] win32-daemon 0.6.1 problem Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514E04@ITOMAE2KM01.AD.QINTRA.COM> Hi, Ruby 1.8.6-p114 built with VC++ 8 win32-service 0.6.1 (also built with VC++ 8) Windows XP Pro SP 2 I'm having trouble getting even this simple daemon to work. I can't even get it to log an error to the file. Any ideas? # demon.rb begin LOG_FILE = "C:\\demon_test.log" LOG_HANDLE = File.open(LOG_FILE, 'a') STDIN.close STDERR.reopen(LOG_HANDLE) STDOUT.reopen(LOG_HANDLE) require 'win32/daemon' include Win32 class Daemon def service_main while running? sleep 3 puts "service is running" end end def service_stop exit! end end Daemon.mainloop rescue Exception => err puts "ERROR: #{err}" puts puts "Our Daemon blowed up: " + err.backtrace.join("\n") raise ensure LOG_HANDLE.close if LOG_HANDLE && !LOG_HANDLE.closed? end # demo_ctl.rb require 'win32/service' require 'rbconfig' include Config include Win32 case ARGV.first.chomp when 'install' # Some path handling to deal with spaces and slashes path = File.join(CONFIG['bindir'], 'ruby.exe') + ' ' path += '"' + File.expand_path('demon.rb') + '"' path = path.tr("/", "\\") Service.create('DemoService', nil, :display_name => 'DemoService', :service_type => Service::WIN32_OWN_PROCESS, :description => 'Demo Service', :binary_path_name => path, :service_start_name => 'my_domain\my_userid', :password => 'my_password' ) puts "Service created" when 'stop' Service.stop('DemoService') puts "Service stopped" when 'start' Service.start('DemoService') puts "Service started" when 'uninstall' Service.delete('DemoService') puts "Service uninstalled" else STDERR.puts "Valid options are 'install', 'uninstall', 'stop' and 'start'" end In other news, it doesn't seem to like the default service_type. If I don't explicitly pass it an option the CreateService() call at line 332 will die. Maybe I should remove "interactive" as part of the default. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From phasis at gmail.com Fri Oct 31 06:52:01 2008 From: phasis at gmail.com (Heesob Park) Date: Fri, 31 Oct 2008 19:52:01 +0900 Subject: [Win32utils-devel] win32-daemon 0.6.1 problem In-Reply-To: <7524A45A1A5B264FA4809E2156496CFB04514E04@ITOMAE2KM01.AD.QINTRA.COM> References: <7524A45A1A5B264FA4809E2156496CFB04514E04@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: 2008/10/31 Berger, Daniel : > Hi, > > Ruby 1.8.6-p114 built with VC++ 8 > win32-service 0.6.1 (also built with VC++ 8) > Windows XP Pro SP 2 > > I'm having trouble getting even this simple daemon to work. I can't even > get it to log an error to the file. Any ideas? > > # demon.rb > begin > LOG_FILE = "C:\\demon_test.log" > LOG_HANDLE = File.open(LOG_FILE, 'a') > > STDIN.close > STDERR.reopen(LOG_HANDLE) > STDOUT.reopen(LOG_HANDLE) > > require 'win32/daemon' > include Win32 > > class Daemon > def service_main > while running? > sleep 3 > puts "service is running" > end > end > > def service_stop > exit! > end > end > > Daemon.mainloop > rescue Exception => err > puts "ERROR: #{err}" > puts > puts "Our Daemon blowed up: " + err.backtrace.join("\n") > raise > ensure > LOG_HANDLE.close if LOG_HANDLE && !LOG_HANDLE.closed? > end > > # demo_ctl.rb > require 'win32/service' > require 'rbconfig' > include Config > include Win32 > > case ARGV.first.chomp > when 'install' > # Some path handling to deal with spaces and slashes > path = File.join(CONFIG['bindir'], 'ruby.exe') + ' ' > path += '"' + File.expand_path('demon.rb') + '"' > path = path.tr("/", "\\") > > Service.create('DemoService', nil, > :display_name => 'DemoService', > :service_type => Service::WIN32_OWN_PROCESS, > :description => 'Demo Service', > :binary_path_name => path, > :service_start_name => 'my_domain\my_userid', > :password => 'my_password' > ) > puts "Service created" > when 'stop' > Service.stop('DemoService') > puts "Service stopped" > when 'start' > Service.start('DemoService') > puts "Service started" > when 'uninstall' > Service.delete('DemoService') > puts "Service uninstalled" > else > STDERR.puts "Valid options are 'install', 'uninstall', 'stop' and > 'start'" > end > > In other news, it doesn't seem to like the default service_type. If I > don't explicitly pass it an option the CreateService() call at line 332 > will die. Maybe I should remove "interactive" as part of the default. > > Regards, > > Dan > In my test, I found two problems in the above demon.rb . First, your environment may has RUBYOPT and raised following error. ruby: no such file to load -- ubygems (LoadError) I have workarounded by modifing "RUBYOPT" to "RUBYOPTX" in ruby.c #755. Second, STDIN.close in demon.rb raise error. In my thought, STDIN.close is just a meaningless code. Regards, Park Heesob From Daniel.Berger at qwest.com Fri Oct 31 12:12:19 2008 From: Daniel.Berger at qwest.com (Berger, Daniel) Date: Fri, 31 Oct 2008 11:12:19 -0500 Subject: [Win32utils-devel] win32-daemon 0.6.1 problem In-Reply-To: References: <7524A45A1A5B264FA4809E2156496CFB04514E04@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <7524A45A1A5B264FA4809E2156496CFB04514E10@ITOMAE2KM01.AD.QINTRA.COM> > -----Original Message----- > From: win32utils-devel-bounces at rubyforge.org > [mailto:win32utils-devel-bounces at rubyforge.org] On Behalf Of > Heesob Park > Sent: Friday, October 31, 2008 4:52 AM > To: Development and ideas for win32utils projects > Subject: Re: [Win32utils-devel] win32-daemon 0.6.1 problem > > 2008/10/31 Berger, Daniel : > > Hi, > > > > Ruby 1.8.6-p114 built with VC++ 8 > > win32-service 0.6.1 (also built with VC++ 8) Windows XP Pro SP 2 > > > > I'm having trouble getting even this simple daemon to work. I can't > > even get it to log an error to the file. Any ideas? > > > > # demon.rb > > begin > > LOG_FILE = "C:\\demon_test.log" > > LOG_HANDLE = File.open(LOG_FILE, 'a') > > > > STDIN.close > > STDERR.reopen(LOG_HANDLE) > > STDOUT.reopen(LOG_HANDLE) > > > > require 'win32/daemon' > > include Win32 > > > > class Daemon > > def service_main > > while running? > > sleep 3 > > puts "service is running" > > end > > end > > > > def service_stop > > exit! > > end > > end > > > > Daemon.mainloop > > rescue Exception => err > > puts "ERROR: #{err}" > > puts > > puts "Our Daemon blowed up: " + err.backtrace.join("\n") > > raise > > ensure > > LOG_HANDLE.close if LOG_HANDLE && !LOG_HANDLE.closed? > > end > > > > # demo_ctl.rb > > require 'win32/service' > > require 'rbconfig' > > include Config > > include Win32 > > > > case ARGV.first.chomp > > when 'install' > > # Some path handling to deal with spaces and slashes > > path = File.join(CONFIG['bindir'], 'ruby.exe') + ' ' > > path += '"' + File.expand_path('demon.rb') + '"' > > path = path.tr("/", "\\") > > > > Service.create('DemoService', nil, > > :display_name => 'DemoService', > > :service_type => Service::WIN32_OWN_PROCESS, > > :description => 'Demo Service', > > :binary_path_name => path, > > :service_start_name => 'my_domain\my_userid', > > :password => 'my_password' > > ) > > puts "Service created" > > when 'stop' > > Service.stop('DemoService') > > puts "Service stopped" > > when 'start' > > Service.start('DemoService') > > puts "Service started" > > when 'uninstall' > > Service.delete('DemoService') > > puts "Service uninstalled" > > else > > STDERR.puts "Valid options are 'install', 'uninstall', > 'stop' and > > 'start'" > > end > > > > In other news, it doesn't seem to like the default > service_type. If I > > don't explicitly pass it an option the CreateService() call at line > > 332 will die. Maybe I should remove "interactive" as part > of the default. > > > > Regards, > > > > Dan > > > In my test, I found two problems in the above demon.rb . > First, your environment may has RUBYOPT and raised following error. > ruby: no such file to load -- ubygems (LoadError) I tried unsetting RUBYOPT on the command line and setting it to nil from within the daemon itself, but it still didn't work. I also don't get any output to the log file. > I have workarounded by modifing "RUBYOPT" to "RUBYOPTX" in > ruby.c #755. Eep! That seems a bit extreme. I wouldn't think we would need to. > Second, STDIN.close in demon.rb raise error. > In my thought, STDIN.close is just a meaningless code. Yeah, it was just me experimenting mostly. Removing it didn't help, though. On a related note, I've been thinking that perhaps Daemon.new should take an optional log file. If present, have STDERR and STDOUT reopen on that file instead of NUL. It would be the users job to properly close the handle in the service_stop method, although perhaps we could setup a finalizer. Does that sound like a good idea? Anyway, still no luck with running the Daemon itself. Now that we have callbacks working better in win32-api, I'm hoping to revisit the pure Ruby Win32::Daemon class again. :) Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. From phasis at gmail.com Fri Oct 31 20:13:38 2008 From: phasis at gmail.com (Park Heesob) Date: Sat, 1 Nov 2008 09:13:38 +0900 Subject: [Win32utils-devel] win32-daemon 0.6.1 problem References: <7524A45A1A5B264FA4809E2156496CFB04514E04@ITOMAE2KM01.AD.QINTRA.COM> <7524A45A1A5B264FA4809E2156496CFB04514E10@ITOMAE2KM01.AD.QINTRA.COM> Message-ID: <65462EE3D1784C808254062A59C1EC32@mycomputer> ----- Original Message ----- From: "Berger, Daniel" To: "Development and ideas for win32utils projects" Sent: Saturday, November 01, 2008 1:12 AM Subject: Re: [Win32utils-devel] win32-daemon 0.6.1 problem >> > >> In my test, I found two problems in the above demon.rb . >> First, your environment may has RUBYOPT and raised following error. >> ruby: no such file to load -- ubygems (LoadError) > > I tried unsetting RUBYOPT on the command line and setting it to nil from > within the daemon itself, but it still didn't work. I also don't get any > output to the log file. > >> I have workarounded by modifing "RUBYOPT" to "RUBYOPTX" in >> ruby.c #755. > > Eep! That seems a bit extreme. I wouldn't think we would need to. > Did you try it? You must have log file of size 0 when the log file does not exist. It is a proof of passing RUBYOPT barrier. >> Second, STDIN.close in demon.rb raise error. >> In my thought, STDIN.close is just a meaningless code. > > Yeah, it was just me experimenting mostly. Removing it didn't help, > though. > In Demon's rescue part, try LOG_HANDLE.print instead of puts to print error. > On a related note, I've been thinking that perhaps Daemon.new should > take an optional log file. If present, have STDERR and STDOUT reopen on > that file instead of NUL. It would be the users job to properly close > the handle in the service_stop method, although perhaps we could setup a > finalizer. > > Does that sound like a good idea? > It seems a good idea. Another possible option is using the win32-eventlog instead of the log file. > Anyway, still no luck with running the Daemon itself. Now that we have > callbacks working better in win32-api, I'm hoping to revisit the pure > Ruby Win32::Daemon class again. :) > It would be better to have pure Ruby version. But in this case, I have success to start Daemon. You should find out why it fails to work. :) Regards, Park Heesob