Commit Graph

86 Commits

Author SHA1 Message Date
4099757fbc * examples/getstream.c (header_callback): Use wget_malloc() instead of malloc() 2017-05-03 14:53:37 +02:00
7c1bebf9a0 Add new function wget_free()
* examples/check_url_types.c: Use wget_xfree() instead of free()
* examples/http_get2.c: Likewise
* examples/print_css_urls2.c: Likewise
* examples/print_html_urls.c: Likewise
* include/wget/wget.h: Add wget_free() and define wget_xfree()
* libwget/xalloc.c: Implement wget_free()

* include/wget/wget.h: Add declaration for wget_free()
* libwget/xalloc.c: Implement wget_free()
2017-05-03 14:47:04 +02:00
b3aede0e57 Remove gnulib dependencies from examples and wget.h
* cfg.mk: Add examples as excludes for config.h
* examples/Makefile.am: Remove -I to srcdir and builddir
* examples/*.c: Remove #include <config.h>
* include/wget/wget.h: Remove gettext include and defines
* libwget/private.h: Add gettext include and defines
* src/wget_main.h: Likewise
* tests/libtest.h: Likewise
* src/log.c: Add #include <string.h>
2017-04-30 21:37:39 +02:00
58f1274808 Do not include unused strings.h
* examples/getstream.c: Remove #include <strings.h>
* libwget/css.c: Likewise
* libwget/encoding.c: Likewise
* libwget/hashfile.c: Likewise
* libwget/metalink.c: Likewise
* libwget/net.c: Likewise
* libwget/robots.c: Likewise
* src/wget.c: Likewise
2017-04-29 20:24:19 +02:00
59222bbfda Ignore all anchor links instead of only '#'
* examples/check_url_types.c: Modified _normalize_uri() to ignore all anchor links
* examples/print_css_urls2.c: Removed check for anchor links
* src/wget.c: Modified _normalize_uri() and _convert_links() to ignore all anchor links
2017-04-19 14:57:08 +02:00
7e236be92d * examples/check_url_types.c: Fix clang warning 2017-04-07 20:36:36 +02:00
4ad6d68305 Fix libraries to use libtool variables
* examples/Makefile.am: Use $(LTLIBICONV) $(LTLIBINTL) $(LTLIBTHREAD)
* src/Makefile.am: Likewise
* tests/Makefile.am: Likewise
2017-04-06 12:25:07 +02:00
1de7114a15 * examples/check_url_types.c: Move #include <signal.h> further to the top 2017-03-25 21:05:21 +01:00
4d7238e282 Fix vpath builds
* examples/Makefile.am: Add -DWGETVER_FILE to AM_CPPFLAGS
* libwget/Makefile.am: Likewise
* src/Makefile.am: Likewise
* tests/Makefile.am: Likewise
* include/wget/wget.h: Include WGETVER_FILE if defined
2017-03-25 20:49:41 +01:00
5d6dc7c9f0 * examples/check_url_types.c (html_parse): Fix possible crash 2017-03-10 17:11:23 +01:00
e07854949e Add examples/check_url_types.c
* examples/Makefile.am: Add rule for examples/check_url_types
* examples/check_url_types.c: New file

This adds a Alexa top-X scanner to find out the numbers of
http:// links in landing pages retrieved via https://.
It follows and counts redirections separated by secure and insecure
ones, flags if the landing page was completely secure, counts links
in the landing HTML page (same-page, external, http, https).
2017-03-03 17:07:42 +01:00
ec396c577f Fix URLs to HTTPS where possible 2017-02-28 15:31:30 +01:00
7f66831d5e * examples/websequencediagram_high.c: Use https URLs 2017-02-28 12:57:47 +01:00
b9e65caf42 * examples/websequencediagram.c: Use HTTPS, fix functionality 2017-02-28 12:35:12 +01:00
1a3a000428 Fix memleak in cookie code
* examples/http_get2.c: Use wget_cookie_db_free() to free cookie db
* libwget/cookie.c (wget_cookie_db_init): Fix #ifdef around PSL code
* libwget/init.c (wget_global_deinit): Use wget_cookie_db_free()
2017-02-21 13:19:27 +01:00
0354295e03 Add network init function to bootstrap sockets on Windows
* bootstrap.conf: Add gnulib module 'sockets'
* examples/http_get2.c: Call wget_net_init()
* include/wget/wget.h: Add wget_net_init() and wget_net_deinit()
* libwget/init.c (wget_global_init): Call wget_net_init(),
  (wget_global_deinit): Call wget_net_deinit()
* libwget/net.c: Add wget_net_init() and wget_net_deinit()
2017-01-05 12:09:25 +01:00
8b1a701c21 Use wget_strdup() instead of strdup()
* examples/getstream.c: Use wget_strdup().
* libwget/cookie.c: Likewise.
* libwget/encoding.c: Likewise.
* libwget/http.c: Likewise.
* libwget/iri.c: Likewise.
* libwget/netrc.c: Likewise.
* src/options.c: Likewise.
* src/wget.c: Likewise.
* tests/test.c: Likewise.
2016-11-03 09:58:09 +01:00
b049eb6d3a Fix gcc/clang warnings from the new manywarnings feature
* configure.ac: Suppress -Wunsuffixed-float-constants for gcc,
  add -Wno-disabled-macro-expansion to clang flags
* examples/getstream.c: Removed 'unused' attributes from argc and argv.
* include/wget/wget.h: Fix slot to int for bar functions.
* libwget/bar.c: Fix slot to int for bar functions, cast to int,
  change type of bitfield 'redraw' to unsigned.
* libwget/hsts.c (wget_hsts_new): Fix int to bitfield conversion.
* libwget/http.c: Cast printf %p format to (void *).
* src/wget.c: Cast printf %p format to (void *),
  remove ACTION_DONE from enum actions.
* src/wget_host.h: Fix double declaration of host_remove_job()
* tests/libtest.c (wget_test_check_filesystem): Fix type of 'rc'.
* tests/test-idn-robots.c: Fix comma to semikolon at end of line.
* tests/test.c (test_strcasecmp_ascii): Fix type of loop variable.
2016-11-02 22:19:41 +01:00
9568b0c87e Rename include/libwget.h to include/wget/wget.h+wgetver.h 2016-09-30 09:47:32 +02:00
16f23ec328 * examples/print_html_urls.c (html_parse_localfile): Fix memleak
Reported-by: Coverity
2016-09-14 12:39:53 +02:00
4f632d29fe * examples/websequencediagram.c (main): Fix printf format string 2016-09-09 16:05:37 +02:00
79dd277c12 Refactoring to separate send, receive and HTTP state machine
* examples/websequencediagram.c (main): Call wget_http_request_set_body()
  and wget_http_send_request() instead of wget_http_send_request_with_body().
* include/libwget.h.in: Add WGET_HTTP_USER_DATA, wget_get_timemillis(),
  extend wget_thread_cond_wait(), add body, user_data, body_length to
  wget_http_request_t, remove wget_http_send_request_with_body(),
  add wget_http_request_get_int(), wget_http_request_set_ptr(),
  wget_http_request_get_ptr(), wget_http_request_set_body().
* libwget/http.c: Add wget_http_request_get_int(),
  wget_http_request_set_ptr(), wget_http_request_get_ptr(),
  wget_http_request_set_body(),
  remove wget_http_send_request_with_body(),
  (wget_http_request_to_buffer): add body to request buffer.
* libwget/http_highlevel.c (wget_http_get): Replace
  wget_http_send_request_with_body()
* libwget/iri.c: Use c-ctype.h instead of ctype.h
  (wget_iri_parse): Allow any numbers of / after scheme:
  (wget_iri_parse): Catch URIs without /after scheme:
* libwget/list.c (wget_list_browse): Small code rearrangement
* libwget/metalink.c (_add_mirror): Check mirror.iri for NULL
* libwget/ssl_gnutls.c (send_ocsp_request): Replace
  wget_http_send_request_with_body()
* libwget/thread.c (wget_thread_cond_signal): Add timeout param
* libwget/utils.c: New function wget_get_timemillis()
* src/blacklist.c: Include wget.h instead of log.h
* src/blacklist.h: Fix indentation
* src/host.c: Add queueing stuff
* src/host.h: Reflect changes in host.c
* src/job.c: Remove queueing stuff
* src/job.h: Reflect changes in job.c
* src/log.c: Sync stdout/stderr to correct output order
* src/log.h: Remove shortcuts of print functions
* src/wget.c: Remove download_part() and http_get().
  Add http_send_request(), http_receive_response(), try_connection(),
  establish_connection(), add_statistics(), process_response_header().
  Amend downloader_thread() to reflect the changes.
* src/wget.h: Add shortcut defines for print functions.
* tests/libtest.c (_http_server_thread): Fix compiler warning,
  fix debug message.
  New function _write_msg() to print server messages yellow.
  (wget_test) Add -d to wget command line.
* tests/test-metalink.c (main): Add tests for V3 and V4 metalink
  files read from command line (-i, --force-metalink)
* tests/test.c (test_iri_parse): Add test for slash-less mailto: URI
2016-07-11 14:53:36 +02:00
06c5f8911e API changes for HTTP/2 parallel/async requests
* .gitignore: New entry examples/http_multi_get
* Makefile.am: Move subdir 'examples' before 'src'
* examples/Makefile.am: Add http_multi_get
* examples/http_get2.c (main): Adapt code to API changes
* examples/http_multi_get.c: New example to show async/parallel
  requests
* examples/websequencediagram.c (main): Adapt code to API changes
* include/libwget.h.in: New functions wget_http_request_set_header_cb,
    wget_http_request_set_body_cb, wget_http_request_set_int.
  Changed params of wget_http_get_response.
  Removed wget_http_get_response_func, wget_http_get_response_stream,
    wget_http_get_response_fd.
  Changed params of wget_http_get_response_cb.
  Add members pending_requests, received_http2_responses,
    pending_http2_requests to wget_http_connection_t.
  Add member req to wget_http_response_t.
  Add members header_callback, body_callback, header_user_data,
    body_user_data, response_keepheader to wget_http_request_t.
  New function types wget_http_header_callback_t and
    wget_http_body_callback_t.
* libwget/http.c: Implementation of the changes in include/libwget.h.in.
* libwget/http_highlevel.c: Adapt code to API changes
* libwget/ssl_gnutls.c: Fixed defaults for SNI, OCSP and
  ALPN.
  Adapt code to API changes.
* src/options.c: Reflect changes in libwget/ssl_gnutls.c
* src/wget.c: Adapt code to API changes
2016-06-22 09:17:57 +02:00
a8d99227e8 Add gnulib module 'manywarnings'
* autogen.sh: Add module manywarnings
* configure.ac: Add ./configure option --enable-gcc-warnings to enable
 many warnings
* examples/Makefile.am: Add WERROR_CFLAGS and WARN_CFLAGS to AM_CFLAGS
* libwget/Makefile.am: Likewise
* src/Makefile.am: Likewise
* tests/Makefile.am: Likewise
2016-06-14 12:22:03 +02:00
64333b4924 Revert "Support direct mpeg streams in examples/getstream.c"
This reverts commit d3d7342e80.
2016-05-20 20:12:13 +02:00
d3d7342e80 Support direct mpeg streams in examples/getstream.c
* examples/getstream.c: Support direct mpeg streams
2016-05-20 16:38:51 +02:00
b9d930bde6 Support audio/x-scpls in examples/getstream.c
* examples/getstream.c (main): Fix m3u parsing, Add audio/x-scpls
2016-05-20 15:54:00 +02:00
acf5d564ea Fix and enhance examples/getstream.c
* autogen.sh: Add gnulib module 'c-strcasestr'
* examples/getstream.c: Support several playlist formats

getstream.c now supports .m3u, .wax, .asx, .pls, xspf playlist formats.
Playlist parsing is partly hackish - it is just an example after all.

The title information is displayed on stderr, the audio goes to stdout to
allow piping to mpg321, sox, etc. For details see the top comment in the
source file.
2016-05-15 18:23:59 +02:00
4aedab2d6d Adjust LDFLAGS for MinGW
* examples/Makefile.am: Add -no-install to AM_LDFLAGS
* libwget/Makefile.am: Add -no-undefined to libwget_la_LDFLAGS
2016-05-08 23:06:58 +02:00
483c304aef Support parsing of UTF-16 HTML documents
* examples/print_html_urls.c (html_parse_localfile):
  Detect BOM (Byte Order Mark), convert UTF-16 to UTF-8 before parsing.
* include/libwget.h.in: Remove wget_charset_transcode(),
  add wget_memiconv() and wget_striconv().
* libwget/encoding.c: Implement wget_memiconv() and wget_striconv()
* src/wget.c (html_parse): Add 'html_len' param,
  convert UTF-16 to UTF-8 before parsing.
* tests/test.c: New test for wget_memiconv().
2016-04-24 15:08:20 +02:00
fb734476c6 Add new examples websequencediagram[_highlevel]
* examples/websequencediagram.c: New file
* examples/websequencediagram_high.c: New file
* examples/Makefile.am: Add websequencediagram[_highlevel]

These examples show how to do two requests on one connection,
a POST and a GET, saving the downloaded body to disk.
websequencediagram uses the low-level API.
websequencediagram_highlevel uses the high-level API.
2016-03-14 17:34:56 +01:00
dd3c2f63b2 Updated copyright year for all relevant files 2016-01-25 13:06:21 +01:00
fb840427d2 Add $(LIB_PTHREAD) to makefiles
* examples/Makefile.am, libwget/Makefile.am, src/Makefile.am,
  tests/Makefile.am: Add $(LIB_PTHREAD)
2016-01-23 22:51:43 +01:00
7250e6ccb9 Add symbol visibility control to libwget
* autogen.sh: Add gnulib module lib-symbol-visibility,
  add --libtool to gnulib-tool invokation
* examples/Makefile.am: Remove -static from AM_LDFLAGS,
  remove ../lib/libgnu.a from LDADD
* include/libwget.h.in: Define LIBWGET_EXPORT,
  add LIBWGET_EXPORT to all visible symbols
* libwget/Makefile.am: Remove AM_CPPFLAGS and LDADD,
  add libwget_la_CPPFLAGS and libwget_la_LIBADD,
  add test_linking_CPPFLAGS, fix test_linking_LDADD
* libwget/iri.c: Add LIBWGET_EXPORT to wget_iri_schemes and iri_ports
* src/Makefile.am: Remove wget2_LDFLAGS, fix wget2_LDADD
* tests/Makefile.am: Fix LDADD, fix test_LDADD, fix test_parse_html_LDADD,
  fix libtest_la_CPPFLAGS and libtest_la_LIBADD
* tests/libtest.h: Add LIBWGET_EXPORT to symbols
2016-01-15 11:21:35 +01:00
69d1b3392c Add gnulib module setlocale
* autogen.sh: Add gnulib module setlocale
* configure.ac: Remove searching for setlocale, locale.h, sys/time.h
* src/wget.c: Move #include <locale.h> (cosmetics)
* examples/Makefile.am: Add $(LIBTHREAD), @INTL_MACOSX_LIBS@ to LDADD
* libwget/Makefile.am: Add to $(LTLIBTHREAD), @INTL_MACOSX_LIBS@ LDADD
* src/Makefile.am: Add $(LIBTHREAD), @INTL_MACOSX_LIBS@ to LDADD
* tests/Makefile.am: Add $(LIBTHREAD), @INTL_MACOSX_LIBS@ to LDADD
2016-01-12 17:08:29 +01:00
c6e0ba1dce Add gnulib module iconv
* autogen.sh: Add gnulib module iconv
* configure.ac: Remove AM_ICONV
* examples/Makefile.am: Add $(LIBICONV) to LDADD
* libwget/Makefile.am: Add $(LIBICONV) to LDADD
* src/Makefile.am: Add $(LIBICONV) to LDADD
* tests/Makefile.am: Add $(LIBICONV) to LDADD
2016-01-12 15:58:40 +01:00
dd9cb25fcc Cover network functions with gnulib modules
* autogen.sh: Add accept, bind, close, connect, getaddrinfo, getsockname,
  listen, netdb, netinet_in, open, read, send, sendto, servent, setsockopt,
  socket, sys_socket, write to modules
* configure.ac: Remove searching for ws2_32, libsocket, libnsl, netdb.h,
  netinet/in.h, sys/socket.h, socket.
  Add searching for netinet/tcp.h.
* examples/Makefile.am: Add additional libs.
* libwget/Makefile.am: Add additional libs.
* src/Makefile.am: Add additional libs.
* tests/Makefile.am: Add additional libs.
* libwget/http.c: Remove conditional code.
* libwget/net.c: Remove conditional code. Use c_isdgit().
* libwget/net.h: Remove conditional code.
2016-01-12 15:08:14 +01:00
e8fafdeb9f Add header file gnulib modules
* autogen.sh: Add gettext-h, inttypes, stdarg, stddef, stdint
* configure.ac: Remove check for inttypes.h, libintl.h, stddef.h
  Remove AC_TYPE_* checks
* include/libwget.h.in: Include gnulib gettext.h
* examples/Makefile.am: Fix AM_CPPFLAGS, add $(LIBINTL) to LDADD
* libwget/Makefile.am: Fix LDADD and test_linking_LDADD
* src/Makefile.am: Add $(LIBINTL) to wget2_LDADD
* tests/Makefile.am: Fix AM_CPPFLAGS and libtest_la_CPPFLAGS,
  add $(LIBINTL) to LDADD, test_LDADD and test_parse_html_LDADD
2016-01-12 10:18:09 +01:00
b770fc7197 Add $(LIB_POLL) to *_LDADD
* examples/Makefile.am, src/Makefile.am, tests/Makefile.am:
  Add $(LIB_POLL) to *_LDADD
2016-01-11 22:22:29 +01:00
1e8c3848d0 Call wget_str(n)casecmp_ascii instead of str(n)casecmp
* examples/print_css_urls2.c, libwget/cookie.c, libwget/css.c,
  libwget/html_url.c, libwget/http.c, libwget/iri.c, libwget/metalink.c,
  libwget/net.c, libwget/robots.c, libwget/ssl_gnutls.c,
  libwget/stringmap.c, libwget/xml.c, src/job.c, src/options.c, src/wget.c:
  Call wget_str(n)casecmp_ascii instead of str(n)casecmp
2016-01-11 16:26:25 +01:00
11c102fada Use nanosleep gnulib fallback
* autogen.sh: Add nanosleep to gnulib modules
* configure.ac: Remove searching for nanosleep
* examples/Makefile.am: Add $(LIBSOCKET) $(LIB_NANOSLEEP) $(LIB_SELECT)
* src/Makefile.am: Add $(LIBSOCKET) $(LIB_NANOSLEEP) $(LIB_SELECT)
* tests/Makefile.am: Add $(LIBSOCKET) $(LIB_NANOSLEEP) $(LIB_SELECT)
* libwget/utils.c: Remove conditional code
2016-01-11 11:36:34 +01:00
ad691f1f3f Remove API version from library file names
* .gitignore, Makefile.am, configure.ac, examples/Makefile.am,
  libwget.pc.in, libwget/Makefile.am, src/Makefile.am, tests/Makefile.am:
  Remove API version from library file names
2016-01-09 17:56:32 +01:00
e3b89db8c7 Hook gnulib into project 2016-01-09 16:04:25 +01:00
1cbb8ae9f7 Rename LIBWGET_API_VERSION to LIBWGET_VERSION 2016-01-06 16:25:27 +01:00
ed5835f446 Cleanup cookie code
Cookies: Add new function wget_cookie_set_keep_session_cookies()
         and adjust wget_cookie_db_load() and wget_cookie_db_save().
         Use wget_update_file() for loading and saving.
2015-11-23 16:43:27 +01:00
18bdc20576 Replaced strndup() by wget_strmemdup()
* examples/getstream.c, examples/print_css_urls2.c, libwget/cookie.c,
  libwget/css_url.c, libwget/encoding.c, libwget/hsts.c,
  libwget/html_url.c, libwget/http.c, libwget/metalink.c,
  libwget/ocsp.c, libwget/robots.c, libwget/ssl_gnutls.c,
  src/options.c, src/wget.c, tests/stringmap_perf.c,
  tests/test-wget-1.c

Strndup() calls an additional strlen() on the input string.
This is normally not needed, and thus just consumes CPU cycles.
All calls to strndup() could be replaced by wget_strmemdup, which
basically allocates len+1 memory, calls memcpy and terminates with
a 0 byte.
2015-11-10 10:55:30 +01:00
0f8e49128a Transfer copyright to Free Software Foundation, Inc. 2015-09-22 11:50:06 +02:00
c6b0e461a1 Transform Mget into Wget 2015-09-19 22:54:38 +02:00
b71abda2b0 Rearrange HTTP header API 2015-09-07 12:26:21 +02:00
8706d962c4 fixing two more Coverity issues 2015-03-13 11:14:31 +01:00