/* $NetBSD: net.c,v 1.4 1997/10/07 04:01:33 phil Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. * All rights reserved. * * Written by Philip A. Nelson for Piermont Information Systems Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software develooped for the NetBSD Project by * Piermont Information Systems Inc. * 4. The name of Piermont Information Systems Inc. may not be used to endorse * or promote products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * */ /* net.c -- routines to fetch files off the network. */ #include #include #include #include #include #include "defs.h" #include "md.h" #include "msg_defs.h" #include "menu_defs.h" #include "txtwalk.h" static void get_ifconfig_info (void) { char *textbuf; int textsize; char *t; /* Get ifconfig information */ textsize = collect (T_OUTPUT, &textbuf, "/sbin/ifconfig -l 2>/dev/null"); if (textsize < 0) { endwin(); (void) fprintf (stderr, "Could not run ifconfig."); exit (1); } (void) strtok(textbuf,"\n"); strncpy (net_devices, textbuf, textsize /dev/null 2> /dev/null"); run_prog ("/sbin/route add default %s 2> /dev/null", net_defroute); return run_prog ("/sbin/ping -c 2 %s > /dev/null", net_defroute) || run_prog ("/sbin/ping -c 2 %s > /dev/null", net_namesvr); } int get_via_ftp (void) { char **list; char realdir[STRSIZE]; int ret; while (config_network ()) { msg_display (MSG_netnotup); process_menu (MENU_yesno); if (!yesno) return 0; } strncat (ftp_dir, ftp_prefix, STRSIZE-strlen(ftp_dir)); process_menu (MENU_ftpsource); msg_prompt (MSG_netdir, dist_dir, dist_dir, STRSIZE, "ftp"); snprintf (realdir, STRSIZE, "/mnt/%s", dist_dir); strcpy (dist_dir, realdir); run_prog ("/bin/mkdir %s", realdir); clean_dist_dir = 1; #ifndef DEBUG if (chdir(realdir)) { endwin(); (void)fprintf(stderr, msg_string(MSG_realdir), realdir); exit(1); } #else printf ("chdir (%s)\n", realdir); #endif list = ftp_list; endwin(); while (*list) { if (strcmp ("ftp", ftp_user) == 0) ret = run_prog("/usr/bin/ftp -a ftp://%s/%s/%s%s%s", ftp_host, ftp_dir, *list, rels, ftp_postfix); else ret = run_prog("/usr/bin/ftp ftp://%s:%s@%s/%s/%s%s%s", ftp_user, ftp_pass, ftp_host, ftp_dir, *list, rels, ftp_postfix); if (ret) { /* Error getting the file. Bad host name ... ? */ wrefresh (stdscr); msg_display (MSG_ftperror); process_menu (MENU_yesno); if (yesno) process_menu (MENU_ftpsource); else return 0; endwin(); } else list++; } puts (CL); /* Just to make sure. */ wrefresh (stdscr); #ifndef DEBUG chdir("/"); #endif return 1; } void get_via_nfs(void) { config_network (); /* Get server and filepath */ /* Mount it */ }