bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issue with 'src/utils.c'


From: Tim Rühsen
Subject: Re: Issue with 'src/utils.c'
Date: Sun, 23 Jun 2024 20:23:41 +0200
User-agent: Mozilla Thunderbird

Hi Gisle,

the wget ML is bug-wget@gnu.org ;)

These kind of compatibility issues should be handled by gnulib (ML is bug-gnulib@gnu.org).

In src/gnutls.c, the same code is done like this:

#ifdef F_GETFL
      int flags = fcntl (fd, F_GETFL, 0);
      if (flags >= 0) {
        if (fcntl (fd, F_SETFL, flags | O_NONBLOCK))
          return -1;
      }
#else
      /* XXX: Assume it was blocking before.  */
      const int one = 1;
      if (ioctl (fd, FIONBIO, &one) < 0)
        return -1;
#endif

Can you test something like the above, especially the ioctl call?

Regarding -DSTANDLONE - is this documented somewhere and what is it even good for? To me it looks like the biggest problem is that several object files are linked together that have their own main() function. Like in

/usr/bin/ld: main.o: in function `main':
/home/tim/src/wget/src/main.c:1362: multiple definition of `main'; html-parse.o:/home/tim/src/wget/src/html-parse.c:1193: first defined here
/usr/bin/ld: netrc.o: in function `main':
/home/tim/src/wget/src/netrc.c:550: multiple definition of `main'; html-parse.o:/home/tim/src/wget/src/html-parse.c:1193: first defined here

Btw, Wget2 has a library (libwget) that you can use in your application code. Let me know whatever you need, and we can possibly add it under examples/ .

Regards, Tim

On 6/22/24 11:26, Gisle Vanem wrote:
Hello Tim.

Since it seems Wget does not have a mailing-list
or Github repo (I'd wish), I send you this report.

Compiling latest Wget ('git pull' today) and using cl/clang-cl on Win-10,
I'm getting this compile error:
   utils.c(1306,29): error: use of undeclared identifier 'F_GETFL'
    1306 |       int flags = fcntl(fd, F_GETFL, 0);
         |                             ^
   utils.c(1307,17): error: use of undeclared identifier 'F_SETFL'
    1307 |       fcntl(fd, F_SETFL, flags | O_NONBLOCK);
         |                 ^
   2 errors generated.

--------------

Due to the commit
http://git.savannah.gnu.org/cgit/wget.git/commit/src/utils.c?id=196ce0abd67b9c905c600a217a7d2dd667216081
it seems.

One cannot do this on Windows. I patched it like this:
--- a/src/utils.c 2024-06-22 06:12:34
+++ b/utils.c     2024-06-22 11:05:50
@@ -1303,8 +1303,10 @@
    if (HYPHENP (file))
      {
        fd = fileno (stdin);
+#ifndef WIN32
        int flags = fcntl(fd, F_GETFL, 0);
        fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+#endif
        inhibit_close = true;
        /* Note that we don't inhibit mmap() in this case.  If stdin is
           redirected from a regular file, mmap() will still work.  */

----------------------------

And BTW, linking netrc.exe (-DSTANDALONE), causes a link-error:
   netrc.obj : error LNK2005: program_argstring already defined in main.obj

Fixed by:
--- a/src/netrc.c 2024-06-22 06:12:34
+++ b/netrc.c     2024-06-22 11:10:47
@@ -543,8 +543,6 @@
  #include <sys/stat.h>
  #include "exits.h"

-const char *program_argstring = NULL; /* Needed by warc.c */
-
  int
  main (int argc, char **argv)
  {


Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]