wget bug

2003-09-26 Thread Jack Pavlovsky
It's probably a bug:
bug: when downloading 
wget -mirror ftp://somehost.org/somepath/3acv14~anivcd.mpg, 
 wget saves it as-is, but when downloading
wget ftp://somehost.org/somepath/3*, wget saves the files as 3acv14%7Eanivcd.mpg

--
The human knowledge belongs to the world


Re: wget bug

2003-09-26 Thread DervishD
Hi Jack :)

 * Jack Pavlovsky [EMAIL PROTECTED] dixit:
 It's probably a bug:
 bug: when downloading 
 wget -mirror ftp://somehost.org/somepath/3acv14~anivcd.mpg, 
  wget saves it as-is, but when downloading
 wget ftp://somehost.org/somepath/3*, wget saves the files as 
 3acv14%7Eanivcd.mpg

Yes, it *was* a bug. The lastest prerelease has it fixed. Don't
know if the tarball has the latest patches, ask Hvroje. But if you
are not in a hurry, just wait for 1.9 to be released.

 The human knowledge belongs to the world

True ;))

Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net  http://raul.pleyades.net/


Windows patches

2003-09-26 Thread Gisle Vanem
Some more patches for wget on Windows.

1) config.h.ms: DMC already have usleep() and sleep().
2) mswindows.c: 
- Removed read_registry() as it's not needed.
- Added set_sleep_mode() to prevent Windows entering sleep-mode
  or hibernation on long transfers. Console mode programs doesn't seem
  to reset the idle-counter (as GUI programs do).

Patches against latest CVS version:

--- orig/windows/config.h.msFri Sep 26 00:39:37 2003
+++ windows/config.h.ms  Sat Sep 27 01:12:43 2003
@@ -139,9 +139,10 @@
 #undef HAVE_UNISTD_H
 #endif

-/* None except Digital Mars have usleep function */
+/* None except Digital Mars have sleep/usleep functions */
 #if defined(__DMC__)
 #define HAVE_USLEEP
+#define HAVE_SLEEP
 #endif

diff -u3 -H -B orig/src/mswindows.c ./mswindows.c
--- orig/src/mswindows.c Fri Sep 26 00:39:35 2003
+++ ./mswindows.c Sat Sep 27 01:58:57 2003
@@ -57,13 +57,25 @@
 extern int errno;
 #endif

+#ifndef ES_SYSTEM_REQUIRED
+#define ES_SYSTEM_REQUIRED  0x0001
+#endif
+
+#ifndef ES_CONTINUOUS
+#define ES_CONTINUOUS   0x8000
+#endif
+
+
 /* Defined in log.c.  */
 void log_request_redirect_output PARAMS ((const char *));

-static int windows_nt_p;
+static DWORD set_sleep_mode (DWORD mode);

+static DWORD pwr_mode = 0;
+static int windows_nt_p;

 #ifndef HAVE_SLEEP
+
 /* Emulation of Unix sleep.  */

 unsigned int
@@ -92,21 +105,6 @@
 }
 #endif  /* HAVE_USLEEP */

-static char *
-read_registry (HKEY hkey, char *subkey, char *valuename, char *buf, int *len)
-{
-  HKEY result;
-  DWORD size = *len;
-  DWORD type = REG_SZ;
-  if (RegOpenKeyEx (hkey, subkey, 0, KEY_READ, result) != ERROR_SUCCESS)
-return NULL;
-  if (RegQueryValueEx (result, valuename, NULL, type, (LPBYTE)buf, size) != 
ERROR_SUCCESS)
-buf = NULL;
-  *len = size;
-  RegCloseKey (result);
-  return buf;
-}
-
 void
 windows_main_junk (int *argc, char **argv, char **exec_name)
 {
@@ -125,6 +123,9 @@
 ws_cleanup (void)
 {
   WSACleanup ();
+  if (pwr_mode)
+ set_sleep_mode (pwr_mode);
+  pwr_mode = 0;
 }

 static void
@@ -170,7 +171,7 @@
 case CTRL_CLOSE_EVENT:
 case CTRL_LOGOFF_EVENT:
 default:
-  WSACleanup ();
+  ws_cleanup ();
   return FALSE;
 }
   return TRUE;
@@ -266,6 +267,7 @@
   exit (1);
 }
   atexit (ws_cleanup);
+  pwr_mode = set_sleep_mode (0);
   SetConsoleCtrlHandler (ws_handler, TRUE);
 }

@@ -295,3 +297,31 @@
   return res;
 }
 #endif
+
+/*
+ * Prevent Windows entering sleep/hibernation-mode while wget is doing a lengthy 
transfer.
+ * Windows does by default not consider network activity in console-programs as 
activity !
+ * Works on Win-98/ME/2K and up.
+ */
+static
+DWORD set_sleep_mode (DWORD mode)
+{
+  HMODULE mod = LoadLibrary (kernel32.dll);
+  DWORD (*_SetThreadExecutionState) (DWORD) = NULL;
+  DWORD rc = (DWORD)-1;
+
+  if (mod)
+ (void*)_SetThreadExecutionState = GetProcAddress ((HINSTANCE)mod, 
SetThreadExecutionState);
+
+  if (_SetThreadExecutionState)
+{
+  if (mode == 0)  /* first time */
+ mode = (ES_SYSTEM_REQUIRED | ES_CONTINUOUS);
+  rc = (*_SetThreadExecutionState) (mode);
+}
+  if (mod)
+ FreeLibrary (mod);
+  DEBUGP ((set_sleep_mode(): mode 0x%08lX, rc 0x%08lX\n, mode, rc));
+  return (rc);
+}
+

diff -u3 -H -B orig/src/mswindows.h ./mswindows.h
--- orig/src/mswindows.h Fri Sep 26 00:39:35 2003
+++ ./mswindows.h Sat Sep 27 02:01:13 2003
@@ -125,11 +125,6 @@
 #define ESTALE  WSAESTALE
 #define EREMOTE WSAEREMOTE

-#ifdef __DMC__
-# define HAVE_SLEEP 1
-# define HAVE_USLEEP 1
-#endif
-
 /* Public functions.  */


Gisle V.

# rm /bin/laden 
/bin/laden: Not found



Re: wget bug

2003-09-26 Thread Hrvoje Niksic
Jack Pavlovsky [EMAIL PROTECTED] writes:

 It's probably a bug: bug: when downloading wget -mirror
 ftp://somehost.org/somepath/3acv14~anivcd.mpg, wget saves it as-is,
 but when downloading wget ftp://somehost.org/somepath/3*, wget saves
 the files as 3acv14%7Eanivcd.mpg

Thanks for the report.  The problem here is that Wget tries to be
helpful by encoding unsafe characters in file names to %XX, as is
done in URLs.  Your first example works because of an oversight (!) 
that actually made Wget behave as you expected.

The good news is that the helpfulness has been rethought for the
next release and is no longer there, at least not for ordinary
characters like ~ and  .  Try getting the latest CVS sources, they
should work better in this regard.  (http://wget.sunsite.dk/ explains
how to download the source from CVS.)


Re: Windows patches

2003-09-26 Thread Hrvoje Niksic
Thanks for the patch, I've now applied it using the following
ChangeLog entry:

2003-09-26  Gisle Vanem  [EMAIL PROTECTED]

* mswindows.c (read_registry): Removed.
(set_sleep_mode): New function.
(windows_main_junk): Call it.

BTW, unless you want your patch to be reviewed by a wider audience,
you might want to send the patch to [EMAIL PROTECTED] instead.
This, as well as the ChangeLog policy and some other things, is
explained in the PATCHES document at the top level of Wget's
distribution.