Sync with RELENG_2_2 changes.

This commit is contained in:
Jordan K. Hubbard 1997-01-30 06:38:19 +00:00
parent 2955fda458
commit 6bc6b19ae5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=22113
2 changed files with 56 additions and 22 deletions

View File

@ -47,13 +47,34 @@ Boolean ftpInitted = FALSE;
static FILE *OpenConn;
int FtpPort;
/* Brings up attached network device, if any - takes FTP device as arg */
static Boolean
netUp(Device *dev)
{
Device *netdev = (Device *)dev->private;
if (netdev)
return netdev->init(netdev);
else
return TRUE; /* No net == happy net */
}
/* Brings down attached network device, if any - takes FTP device as arg */
static void
netDown(Device *dev)
{
Device *netdev = (Device *)dev->private;
if (netdev)
netdev->shutdown(netdev);
}
Boolean
mediaInitFTP(Device *dev)
{
int i, code;
char *cp, *rel, *hostname, *dir;
char *user, *login_name, password[80];
Device *netdev = (Device *)dev->private;
if (ftpInitted)
return TRUE;
@ -67,7 +88,7 @@ mediaInitFTP(Device *dev)
}
/* If we can't initialize the network, bag it! */
if (netdev && !netdev->init(netdev))
if (!netUp(dev))
return FALSE;
try:
@ -75,8 +96,7 @@ try:
if (!cp) {
if (DITEM_STATUS(mediaSetFTP(NULL)) == DITEM_FAILURE || (cp = variable_get(VAR_FTP_PATH)) == NULL) {
msgConfirm("Unable to get proper FTP path. FTP media not initialized.");
if (netdev)
netdev->shutdown(netdev);
netDown(dev);
return FALSE;
}
}
@ -85,8 +105,7 @@ try:
dir = variable_get(VAR_FTP_DIR);
if (!hostname || !dir) {
msgConfirm("Missing FTP host or directory specification. FTP media not initialized,");
if (netdev)
netdev->shutdown(netdev);
netDown(dev);
return FALSE;
}
user = variable_get(VAR_FTP_USER);
@ -145,12 +164,12 @@ try:
return TRUE;
punt:
ftpInitted = FALSE;
if (OpenConn != NULL) {
fclose(OpenConn);
OpenConn = NULL;
}
if (netdev)
netdev->shutdown(netdev);
netDown(dev);
variable_unset(VAR_FTP_PATH);
return FALSE;
}
@ -177,6 +196,7 @@ mediaGetFTP(Device *dev, char *file, Boolean probe)
variable_unset(VAR_FTP_PATH);
/* If we can't re-initialize, just forget it */
if (!dev->init(dev)) {
netDown(dev);
fclose(OpenConn);
OpenConn = NULL;
return NULL;
@ -216,8 +236,6 @@ mediaGetFTP(Device *dev, char *file, Boolean probe)
void
mediaShutdownFTP(Device *dev)
{
/* Device *netdev = (Device *)dev->private; */
if (!ftpInitted)
return;
@ -226,6 +244,5 @@ mediaShutdownFTP(Device *dev)
fclose(OpenConn);
OpenConn = NULL;
}
/* if (netdev) netdev->shutdown(netdev); */
ftpInitted = FALSE;
}

View File

@ -47,13 +47,34 @@ Boolean ftpInitted = FALSE;
static FILE *OpenConn;
int FtpPort;
/* Brings up attached network device, if any - takes FTP device as arg */
static Boolean
netUp(Device *dev)
{
Device *netdev = (Device *)dev->private;
if (netdev)
return netdev->init(netdev);
else
return TRUE; /* No net == happy net */
}
/* Brings down attached network device, if any - takes FTP device as arg */
static void
netDown(Device *dev)
{
Device *netdev = (Device *)dev->private;
if (netdev)
netdev->shutdown(netdev);
}
Boolean
mediaInitFTP(Device *dev)
{
int i, code;
char *cp, *rel, *hostname, *dir;
char *user, *login_name, password[80];
Device *netdev = (Device *)dev->private;
if (ftpInitted)
return TRUE;
@ -67,7 +88,7 @@ mediaInitFTP(Device *dev)
}
/* If we can't initialize the network, bag it! */
if (netdev && !netdev->init(netdev))
if (!netUp(dev))
return FALSE;
try:
@ -75,8 +96,7 @@ try:
if (!cp) {
if (DITEM_STATUS(mediaSetFTP(NULL)) == DITEM_FAILURE || (cp = variable_get(VAR_FTP_PATH)) == NULL) {
msgConfirm("Unable to get proper FTP path. FTP media not initialized.");
if (netdev)
netdev->shutdown(netdev);
netDown(dev);
return FALSE;
}
}
@ -85,8 +105,7 @@ try:
dir = variable_get(VAR_FTP_DIR);
if (!hostname || !dir) {
msgConfirm("Missing FTP host or directory specification. FTP media not initialized,");
if (netdev)
netdev->shutdown(netdev);
netDown(dev);
return FALSE;
}
user = variable_get(VAR_FTP_USER);
@ -145,12 +164,12 @@ try:
return TRUE;
punt:
ftpInitted = FALSE;
if (OpenConn != NULL) {
fclose(OpenConn);
OpenConn = NULL;
}
if (netdev)
netdev->shutdown(netdev);
netDown(dev);
variable_unset(VAR_FTP_PATH);
return FALSE;
}
@ -177,6 +196,7 @@ mediaGetFTP(Device *dev, char *file, Boolean probe)
variable_unset(VAR_FTP_PATH);
/* If we can't re-initialize, just forget it */
if (!dev->init(dev)) {
netDown(dev);
fclose(OpenConn);
OpenConn = NULL;
return NULL;
@ -216,8 +236,6 @@ mediaGetFTP(Device *dev, char *file, Boolean probe)
void
mediaShutdownFTP(Device *dev)
{
/* Device *netdev = (Device *)dev->private; */
if (!ftpInitted)
return;
@ -226,6 +244,5 @@ mediaShutdownFTP(Device *dev)
fclose(OpenConn);
OpenConn = NULL;
}
/* if (netdev) netdev->shutdown(netdev); */
ftpInitted = FALSE;
}