|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T f
Length: 8238 (0x202e)
Types: TextFile
Names: »ftam-assoc.c«
└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
└─⟦eba4602b1⟧ »./isode-5.0.tar.Z«
└─⟦d3ac74d73⟧
└─⟦this⟧ »isode-5.0/ftam2/ftam-assoc.c«
/* ftam-assoc.c - interactive initiator FTAM -- association management */
#ifndef lint
static char *rcsid = "$Header: /f/osi/ftam2/RCS/ftam-assoc.c,v 6.0 89/03/18 23:31:09 mrose Rel $";
#endif
/*
* $Header: /f/osi/ftam2/RCS/ftam-assoc.c,v 6.0 89/03/18 23:31:09 mrose Rel $
*
*
* $Log: ftam-assoc.c,v $
* Revision 6.0 89/03/18 23:31:09 mrose
* Release 5.0
*
*/
/*
* NOTICE
*
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
* this agreement.
*
*/
#include <stdio.h>
#include "ftamuser.h"
/* \f
*/
int f_open (vec)
char **vec;
{
register int i;
int manage;
char *p;
#ifndef BRIDGE
char buffer[BUFSIZ],
prompt[BUFSIZ];
#endif
AEI aei;
register struct vfsmap *vf;
register struct PSAPaddr *pa;
struct FTAMcontentlist fcs;
register struct FTAMcontentlist *fc = &fcs;
register struct FTAMcontent *fx;
struct FTAMconnect ftcs;
register struct FTAMconnect *ftc = &ftcs;
struct FTAMindication ftis;
register struct FTAMindication *fti = &ftis;
if (*++vec == NULL) {
#ifdef BRIDGE
return NOTOK;
#else
if (getline ("host: ", buffer) == NOTOK || str2vec (buffer, vec) < 1)
return OK;
#endif
}
if (host)
free (host);
host = strdup (*vec);
if (*++vec == NULL) {
#ifdef BRIDGE
return NOTOK;
#else
if (user == NULL)
user = strdup (myuser ? myuser : "");
(void) sprintf (prompt, "user (%s:%s): ", host, user);
if (getline (prompt, buffer) == NOTOK)
return OK;
if (str2vec (buffer, vec) < 1)
*vec = user, user = NULL;
#endif
}
if (user)
free (user);
user = strdup (*vec);
if (*++vec) {
if (account)
free (account);
#ifdef BRIDGE
account = (**vec) ? strdup (*vec) : "";
#else
account = strdup (*vec);
#endif
}
#ifdef BRIDGE
if (!strcmp (user, "anonymous") || !strcmp (user, "ANONYMOUS") ){
free (user);
user = strdup ("ANON");
}
#endif
if (strcmp (user, "anon") == 0) {
free (user);
user = strdup ("ANON");
}
#ifdef BRIDGE
if (strcmp (user, "ANON") && !*++vec)
return NOTOK;
else
p = *vec ? strdup(*vec) : "";
#else
if (strcmp (user, "ANON")) {
(void) sprintf (prompt, "password (%s:%s): ", host, user);
p = getpassword (prompt);
}
else
p = myuser ? myuser : "";
#endif
#ifdef BRIDGE
if ((aei = str2aei (host, "filestore")) == NULLAEI) {
advise (NULLCP, "%s-filestore: unknown application-entity", host);
#else
if ((aei = str2aei (host, storename)) == NULLAEI) {
advise (NULLCP, "%s-%s: unknown application-entity",
host, storename);
#endif
return NOTOK;
}
if ((pa = aei2addr (aei)) == NULLPA) {
advise (NULLCP, "address translation failed");
return NOTOK;
}
manage = 0;
fqos = FQOS_NORECOVERY;
class = FCLASS_TM | FCLASS_TRANSFER | FCLASS_MANAGE;
units |= FUNIT_READ | FUNIT_WRITE | FUNIT_LIMITED | FUNIT_ENHANCED
| FUNIT_GROUPING;
attrs = FATTR_STORAGE;
fc -> fc_ncontent = 0;
for (vf = vfs; vf -> vf_entry; vf++)
if (vf -> vf_oid)
fc -> fc_contents[fc -> fc_ncontent++].fc_dtn = vf -> vf_oid;
#ifndef BRIDGE
if (verbose) {
fprintf (stderr, "%s... ", host);
(void) fflush (stderr);
}
#endif
if (FInitializeRequest (NULLOID, NULLAEI, aei, NULLPA, pa, manage, class,
units, attrs, NULLPE, fqos, fc,
*user ? user : NULL, account, *p ? p : NULL,
strlen (p), NULLQOS, trace ? FTraceHook : NULLIFP,
ftc, fti)
== NOTOK) {
#ifndef BRIDGE
if (verbose)
fprintf (stderr, "loses big\n");
#endif
ftam_advise (&fti -> fti_abort, "F-INITIALIZE.REQUEST");
return NOTOK;
}
switch (ftc -> ftc_state) {
case FSTATE_SUCCESS:
#ifndef BRIDGE
if (verbose)
fprintf (stderr, "connected\n");
#endif
#ifdef DEBUG
if (debug)
advise (NULLCP,
"responding AE title: %s, responding PSAP address: %s",
sprintaei (&ftc -> ftc_respondtitle),
paddr2str (&ftc -> ftc_respondaddr, NULLNA));
#endif
ftamfd = ftc -> ftc_sd;
context = ftc -> ftc_context, ftc -> ftc_context = NULLOID;
fqos = ftc -> ftc_fqos;
class = ftc -> ftc_class;
units = ftc -> ftc_units;
attrs = ftc -> ftc_attrs;
for (fx = ftc -> ftc_contents.fc_contents,
i = ftc -> ftc_contents.fc_ncontent - 1;
i >= 0;
fx++, i--) {
if (fx -> fc_result != PC_ACCEPT)
continue;
for (vf = vfs; vf -> vf_entry; vf++)
if (oid_cmp (vf -> vf_oid, fx -> fc_dtn) == 0) {
vf -> vf_flags |= VF_OK;
vf -> vf_id = fx -> fc_id;
break;
}
}
for (vf = vfs; vf -> vf_entry; vf++)
if (vf -> vf_oid
&& !(vf -> vf_flags & VF_OK)
&& (vf -> vf_flags & VF_WARN))
advise (NULLCP,
"warning: virtual filestore has no support for %ss",
vf -> vf_text);
vf = &vfs[VFS_UBF];
if (vf -> vf_oid == NULLOID || !(vf -> vf_flags & VF_OK))
advise (NULLCP,
"%s files not negotiated, suggest you quit now!",
vf -> vf_entry);
if ((vf = &vfs[tmode]) != &vfs[VFS_DEF]
&& (vf -> vf_oid == NULLOID
|| !(vf -> vf_flags & VF_OK))) {
advise (NULLCP, "negotiation prevents transfer of %ss",
vf -> vf_text);
tmode = VFS_DEF;
}
for (vf = vfs; vf -> vf_entry; vf++) /* prime the pump */
if (vf -> vf_peek)
(void) (*vf -> vf_peek) (vf, NOTOK, NULLCP,
(struct stat *) 0, ftamfd);
if ((fadusize = ftc -> ftc_ssdusize) < 0)
fadusize = 0;
break;
default:
#ifndef BRIDGE
if (verbose)
fprintf (stderr, "failed\n");
#endif
break;
}
ftam_diag (ftc -> ftc_diags, ftc -> ftc_ndiag,
ftamfd != NOTOK || fti -> fti_abort.fta_peer,
ftc -> ftc_action);
FTCFREE (ftc);
if (ftamfd != NOTOK) {
vec[0] = "sd";
vec[1] = NULLCP;
(void) f_cd (vec);
}
return (ftamfd != NOTOK ? OK : NOTOK);
}
/* \f
*/
/* ARGSUSED */
int f_close (vec)
char **vec;
{
struct FTAMrelease ftrs;
register struct FTAMrelease *ftr = &ftrs;
struct FTAMindication ftis;
register struct FTAMindication *fti = &ftis;
#ifdef BRIDGE
if (ftamfd == NOTOK)
return OK;
#endif
if (FTerminateRequest (ftamfd, NULLPE, ftr, fti) == NOTOK) {
ftam_advise (&fti -> fti_abort, "F-TERMINATE.REQUEST");
(void) FUAbortRequest (ftamfd, FACTION_PERM,
(struct FTAMdiagnostic *) 0, 0, &ftis);
ftamfd = NOTOK;
return NOTOK;
}
ftam_chrg (&ftr -> ftr_charges);
FTRFREE (ftr);
ftamfd = NOTOK;
if (rcwd) {
free (rcwd);
rcwd = NULL;
}
return OK;
}
/* \f
*/
int f_quit (vec)
char **vec;
{
if (ftamfd != NOTOK)
(void) f_close (vec);
return DONE;
}
/* \f
*/
#define AMASK "\020\01STORAGE\02SECURITY\03PRIVATE"
/* ARGSUSED */
#ifndef BRIDGE
int f_status (vec)
char **vec;
{
int hit;
register struct vfsmap *vf;
printf ("associated with virtual filestore on \"%s\" as user \"%s\"\n",
host, user);
if (account)
printf (" using account \"%s\"\n", account);
printf ("application-context: %s\nservice class: ", oid2ode (context));
switch (class) {
case FCLASS_TRANSFER:
printf ("transfer");
break;
case FCLASS_ACCESS:
printf ("access");
break;
case FCLASS_MANAGE:
printf ("management");
break;
case FCLASS_TM:
printf ("transfer-and-management");
break;
case FCLASS_UNCONS:
printf ("unconstrained");
break;
default:
printf ("%d", class);
}
printf (", ftam-QoS: ");
switch (fqos) {
case FQOS_NORECOVERY:
printf ("no-recovery");
break;
default:
printf ("class-%d-recovery", fqos);
break;
}
printf ("\nfunctional units: %s\n", sprintb (units, UMASK));
printf ("attribute groups: %s\n", sprintb (attrs, AMASK));
printf ("document types:");
hit = 0;
for (vf = vfs; vf -> vf_entry; vf++)
if (vf -> vf_oid && (vf -> vf_flags & VF_OK)) {
printf ("\n %-16.16s %s (%s)", sprintoid (vf -> vf_oid),
vf -> vf_text, vf -> vf_entry);
hit = 1;
}
if (!hit)
printf (" none negotiated!");
printf ("\nestimated integral FADU size: %d\n", fadusize);
return OK;
}
#endif