Deleted Added
sdiff udiff text old ( 258267 ) new ( 264840 )
full compact
1if [ ! "$_MEDIA_HTTP_SUBR" ]; then _MEDIA_HTTP_SUBR=1
2#
3# Copyright (c) 2012-2013 Devin Teske
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:

--- 10 unchanged lines hidden (view full) ---

19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
27# $FreeBSD: head/usr.sbin/bsdconfig/share/media/http.subr 258267 2013-11-17 17:53:55Z dteske $
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." media/http.subr
34f_include $BSDCFG_SHARE/device.subr
35f_include $BSDCFG_SHARE/dialog.subr

--- 174 unchanged lines hidden (view full) ---

210 # Set the name of the HTTP device to the URL
211 f_struct_new DEVICE device_http
212 device_http set name "$url"
213
214 if ! f_struct device_network ||
215 ! f_dialog_yesno "$msg_youve_already_done_the_network_configuration"
216 then
217 f_struct device_network &&
218 f_device_shutdown network
219 if ! f_device_select_tcp; then
220 unset $VAR_HTTP_PATH
221 return $FAILURE
222 fi
223 local dev
224 f_getvar $VAR_NETWORK_DEVICE dev
225 f_struct_copy "device_$dev" device_network
226 fi
227 if ! f_device_init network; then
228 f_dprintf "f_media_set_http: %s" "$msg_net_device_init_failed"
229 unset $VAR_HTTP_PATH
230 return $FAILURE
231 fi
232
233 local hostname="${url#*://}" port=80 dir=/
234 case "$hostname" in
235 #

--- 66 unchanged lines hidden (view full) ---

302 f_validate_ipaddr6 "$hostname"
303 }; then
304 f_show_info "$msg_looking_up_host" "$hostname"
305 f_dprintf "%s: Looking up hostname, %s, using host(1)" \
306 "f_media_set_http" "$hostname"
307 if ! f_quietly f_host_lookup "$hostname"; then
308 f_show_msg "$msg_cannot_resolve_hostname" "$hostname"
309 f_struct device_network &&
310 f_device_shutdown network
311 f_struct_free device_network
312 unset $VAR_HTTP_PATH
313 return $FAILURE
314 fi
315 f_dprintf "Found DNS entry for %s successfully." "$hostname"
316 fi
317
318 setvar $VAR_HTTP_HOST "$hostname"
319 setvar $VAR_HTTP_PORT "$port"
320 setvar $VAR_HTTP_DIR "$dir"
321
322 device_http set type $DEVICE_TYPE_HTTP
323 device_http set init f_media_init_http
324 device_http set get f_media_get_http
325 device_http set shutdown f_media_shutdown_http
326 device_http set private network
327 f_struct_copy device_http device_media
328 f_struct_free device_http
329
330 return $SUCCESS
331}
332
333# f_http_check_access [$connect_only]
334#

--- 225 unchanged lines hidden (view full) ---

560#
561# Example usage:
562# f_media_set_http
563# f_media_get_http media $file
564#
565f_media_get_http()
566{
567 local dev="$1" file="$2" probe_type="$3" hosts=
568
569 f_dprintf "f_media_get_http: dev=[%s] file=[%s] probe_type=%s" \
570 "$dev" "$file" "$probe_type"
571
572 local http_host http_port
573 f_getvar $VAR_HTTP_HOST http_host
574 f_getvar $VAR_HTTP_PORT http_port
575
576 if [ ! "$HTTP_INITIALIZED" ]; then
577 f_dprintf "No HTTP connection open, can't get file %s" "$file"
578 return $FAILURE

--- 112 unchanged lines hidden ---