/* imisc.c - miscellaneous network service -- initiator */
static char *rcsid
= "$Header: /f/osi/imisc/RCS/imisc.c,v 7.3 91/02/22 09:26:17 mrose Interim $";
* $Header: /f/osi/imisc/RCS/imisc.c,v 7.3 91/02/22 09:26:17 mrose Interim $
* Revision 7.3 91/02/22 09:26:17 mrose
* Revision 7.2 90/07/09 14:38:45 mrose
* Revision 7.1 90/07/01 21:04:02 mrose
* Revision 7.0 89/11/23 21:57:35 mrose
* 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
#include "ryinitiator.h" /* for generic interactive initiators */
#include "IMISC-ops.h" /* IMISC operation definitions */
#include "IMISC-types.h" /* IMISC type definitions */
struct passwd
*getpwuid ();
static char *myservice
= "isode miscellany";/* should be something other
static char *mycontext
= "isode miscellany";
static char *mypci
= "isode miscellany pci";
static type_IMISC_Data
*data
= NULLPE
;
struct type_IMISC_IA5List
*vec2ia5list ();
int do_finger (), do_tell (), do_data (), do_help (), do_quit ();
#define gentime_result utctime_result
int utctime_result (), timeofday_result (), ia5_result (), tell_result (),
null_result (), echo_result ();
static struct dispatch dispatches
[] = {
"utctime", operation_IMISC_utcTime
,
utctime_result
, imisc_error
,
"gentime", operation_IMISC_genTime
,
gentime_result
, imisc_error
,
"time", operation_IMISC_timeOfDay
,
timeofday_result
, imisc_error
,
"the current time since the epoch",
"users", operation_IMISC_users
,
"the users logged in on the system",
"chargen", operation_IMISC_charGen
,
"the character generation pattern",
"qotd", operation_IMISC_qotd
,
"finger", operation_IMISC_finger
,
do_finger
, &_ZIMISC_mod
, _ZIA5ListIMISC
,
"the finger of users logged in",
"pwdgen", operation_IMISC_pwdGen
,
"some pseudo-randomly generated passwords",
"tell", operation_IMISC_tellUser
,
do_tell
, &_ZIMISC_mod
, _ZIA5ListIMISC
,
tell_result
, imisc_error
,
"send a message to a remote user",
"ping", operation_IMISC_ping
,
null_result
, imisc_error
,
"sink", operation_IMISC_sink
,
null_result
, imisc_error
,
"echo", operation_IMISC_echo
,
echo_result
, imisc_error
,
"print this information",
"terminate the association and exit",
ryinitiator (argc
, argv
, myservice
, mycontext
, mypci
,
table_IMISC_Operations
, dispatches
, do_quit
);
exit (0); /* NOTREACHED */
struct type_IMISC_IA5List
*vec2ia5list (vec
)
struct type_IMISC_IA5List
*ia5
;
register struct type_IMISC_IA5List
**ia5p
;
if ((*ia5p
= (struct type_IMISC_IA5List
*) calloc (1, sizeof **ia5p
))
adios (NULLCP
, "out of memory");
if (((*ia5p
) -> IA5String
= str2qb (*vec
, strlen (*vec
), 1)) == NULL
)
adios (NULLCP
, "out of memory");
ia5p
= &((*ia5p
) -> next
);
static print_ia5list (ia5
)
register struct type_IMISC_IA5List
*ia5
;
for (; ia5
; ia5
= ia5
-> next
) {
for (q
= p
-> qb_forw
; q
!= p
; q
= q
-> qb_forw
)
printf ("%*.*s", q
-> qb_len
, q
-> qb_len
, q
-> qb_data
);
static int do_finger (sd
, ds
, args
, ia5
)
struct type_IMISC_IA5List
**ia5
;
*ia5
= vec2ia5list (args
);
static int do_tell (sd
, ds
, args
, ia5
)
register struct type_IMISC_IA5List
**ia5
;
register struct type_IMISC_IA5List
*ia52
;
register struct passwd
*pw
;
if (args
[0] == NULL
|| args
[1] == NULL
) {
advise (NULLCP
, "usage: tell user message ...");
*ia5
= vec2ia5list (args
);
cp
= (pw
= getpwuid (getuid ())) ? pw
-> pw_name
: "anon";
if ((ia52
= (struct type_IMISC_IA5List
*) calloc (1, sizeof *ia52
))
adios (NULLCP
, "out of memory");
(void) sprintf (buffer
, "%s@%s", cp
, dp
);
if ((ia52
-> IA5String
= str2qb (buffer
, strlen (buffer
), 1)) == NULL
)
adios (NULLCP
, "out of memory");
/* kludge this arg onto front of list - HACK ATTACK */
static int do_data (sd
, ds
, args
, pep
)
register struct type_IMISC_Data
**pep
;
if ((cp
= malloc ((unsigned) length
)) == NULL
)
adios (NULLCP
, "no memory");
if ((data
= oct2prim (cp
, length
)) == NULLPE
)
adios (NULLCP
, "no memory");
static int do_help (sd
, ds
, args
, dummy
)
register struct dispatch
*ds
;
printf ("\nCommands are:\n");
for (ds
= dispatches
; ds
-> ds_name
; ds
++)
printf ("%s\t%s\n", ds
-> ds_name
, ds
-> ds_help
);
static int do_quit (sd
, ds
, args
, dummy
)
struct AcSAPrelease acrs
;
register struct AcSAPrelease
*acr
= &acrs
;
struct AcSAPindication acis
;
register struct AcSAPindication
*aci
= &acis
;
register struct AcSAPabort
*aca
= &aci
-> aci_abort
;
if (AcRelRequest (sd
, ACF_NORMAL
, NULLPEP
, 0, NOTOK
, acr
, aci
) == NOTOK
)
acs_adios (aca
, "A-RELEASE.REQUEST");
if (!acr
-> acr_affirmative
) {
(void) AcUAbortRequest (sd
, NULLPEP
, 0, aci
);
adios (NULLCP
, "release rejected by peer: %d", acr
-> acr_reason
);
static int utctime_result (sd
, id
, dummy
, result
, roi
)
register struct type_IMISC_UTCResult
*result
;
struct RoSAPindication
*roi
;
for (q
= result
-> qb_forw
; q
!= result
; q
= q
-> qb_forw
)
printf ("%*.*s", q
-> qb_len
, q
-> qb_len
, q
-> qb_data
);
static int timeofday_result (sd
, id
, dummy
, result
, roi
)
register struct type_IMISC_TimeResult
*result
;
struct RoSAPindication
*roi
;
s
= result
-> parm
- 2208988800L; /* UNIX epoch */
printf ("%s", ctime (&s
));
static int ia5_result (sd
, id
, dummy
, result
, roi
)
register struct type_IMISC_IA5List
*result
;
struct RoSAPindication
*roi
;
static int tell_result (sd
, id
, dummy
, result
, roi
)
struct RoSAPindication
*roi
;
static int null_result (sd
, id
, dummy
, result
, roi
)
struct RoSAPindication
*roi
;
static int echo_result (sd
, id
, dummy
, result
, roi
)
struct type_IMISC_Data
*result
;
struct RoSAPindication
*roi
;
if (pe_cmp (result
, data
))
advise (NULLCP
, "data mismatch");
static int imisc_error (sd
, id
, error
, parameter
, roi
)
register struct type_IMISC_IA5List
*parameter
;
struct RoSAPindication
*roi
;
register struct RyError
*rye
;
if (error
== RY_REJECT
) {
advise (NULLCP
, "%s", RoErrString ((int) parameter
));
if (rye
= finderrbyerr (table_IMISC_Errors
, error
))
advise (NULLCP
, "%s", rye
-> rye_name
);
advise (NULLCP
, "Error %d", error
);
print_ia5list (parameter
);