static char *rcsid
= "$Header: /f/osi/quipu/dish/RCS/dishlib.c,v 7.5 91/03/09 11:56:17 mrose Exp $";
* $Header: /f/osi/quipu/dish/RCS/dishlib.c,v 7.5 91/03/09 11:56:17 mrose Exp $
* Revision 7.5 91/03/09 11:56:17 mrose
* Revision 7.4 91/02/22 09:40:29 mrose
* Revision 7.3 90/07/09 14:47:06 mrose
* Revision 7.2 90/04/18 08:49:37 mrose
* Revision 7.1 90/03/15 11:18:23 mrose
* Revision 7.1 89/12/19 16:21:01 mrose
* Revision 7.0 89/11/23 22:20:01 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
DN dn
= NULLDN
; /* This actually stores the current position. */
#define OPT (!frompipe || rps -> ps_byteno == 0 ? opt : rps)
#define RPS (!frompipe || opt -> ps_byteno == 0 ? rps : opt)
unsigned cache_time
= 3600; /* time to keep process alive */
unsigned connect_time
= 120; /* time to keep connection open */
char search_result
; /* another horrid global ! */
extern int call_list (), call_compare (), call_search (),
call_add (), call_delete (), call_showentry (), call_showname (),
call_showattribute (), call_unbind (), call_help (), call_ds (),
unknown_cmd (), dsa_control (), call_modify (), call_modifyrdn (),
call_quit (), call_bind (), call_moveto (), call_fred ();
char defaults
[LINESIZE
];
add_dish_command (name
,func
,len
)
Commands
[num_cmd
].command
= name
;
Commands
[num_cmd
].handler
= func
;
Commands
[num_cmd
].unique
= (len
== 0 ? strlen(name
) : len
);
bzero (Commands
[num_cmd
].defaults
,LINESIZE
);
add_dish_command ("list", call_list
, 1);
add_dish_command ("compare", call_compare
, 1);
add_dish_command ("search", call_search
, 2);
add_dish_command ("add", call_add
, 1);
add_dish_command ("delete", call_delete
, 2);
add_dish_command ("modify", call_modify
, 3);
add_dish_command ("modifyrdn", call_modifyrdn
, 7);
add_dish_command ("showentry", call_showentry
, 2);
add_dish_command ("showname", call_showname
, 5);
add_dish_command ("bind", call_bind
, 1);
add_dish_command ("unbind", call_unbind
, 1);
add_dish_command ("moveto", call_moveto
, 3);
add_dish_command ("dsacontrol", dsa_control
, 2);
add_dish_command ("quit", call_quit
, 1); /* quick way out for interactive program */
add_dish_command ("squid", call_ds
, 2);
add_dish_command ("?", call_help
, 1);
add_dish_command ("help", call_help
, 1);
add_dish_command ("fred", call_fred
, 4);
"dad.log", NULLCP
, NULLCP
, LLOG_FATAL
| LLOG_EXCEPTIONS
| LLOG_NOTICE
,
LLOG_NONE
, -1, LLOGCLS
| LLOGCRT
| LLOGZER
, NOTOK
LLog
*dad_log
= &_dad_log
;
char *ttyname (), *getenv();
(void) signal (SIGHUP
, dish_quit
);
(void) signal (SIGQUIT
, dish_quit
);
(void) signal (SIGILL
, dish_quit
);
(void) signal (SIGBUS
, dish_quit
);
(void) signal (SIGSEGV
, dish_quit
);
(void) signal (SIGSYS
, dish_quit
);
(void) signal (SIGTERM
, dish_quit
);
if (test_arg (argv
[i
],"-dad",1)) {
ll_hdinit (dad_log
, argv
[0]);
shuffle_up (argc
--, argv
, i
);
if (test_arg (argv
[i
],"-fast",1)) {
shuffle_up (argc
--, argv
, i
);
if (test_arg (argv
[i
],"-help",1)) {
if ((opt
= ps_alloc (std_open
)) == NULLPS
)
fatal (-62, "ps_alloc failed");
if (std_setup (opt
, stderr
) == NOTOK
)
fatal (-63, "std_setup failed");
if ((rps
= ps_alloc (std_open
)) == NULLPS
)
fatal (-64, "ps_alloc 2 failed");
if (std_setup (rps
, stdout
) == NOTOK
)
fatal (-65, "std_setup 2 failed");
if (test_arg(argv
[i
],"-tailor",1)) {
shuffle_up (argc
--, argv
, i
);
fatal (-66,"Tailor file name missing");
shuffle_up (argc
--, argv
, i
);
if ( (argc
>1) && (test_arg (argv
[1], "-pipe",3))) {
if ((opt
= ps_alloc (std_open
)) == NULLPS
)
fatal (-62, "ps_alloc failed");
if (std_setup (opt
, stderr
) == NOTOK
)
fatal (-63, "std_setup failed");
if ((rps
= ps_alloc (std_open
)) == NULLPS
)
fatal (-64, "ps_alloc 2 failed");
if (std_setup (rps
, stdout
) == NOTOK
)
fatal (-65, "std_setup 2 failed");
(void) printf ("Welcome to Dish (DIrectory SHell)\n");
want_oc_hierarchy (); /* for add/modify ! */
log_stat
-> ll_file
= "dish.log";
log_stat
-> ll_stat
&= ~LLOGCRT
;
log_dsap
-> ll_stat
&= ~LLOGCRT
;
ll_hdinit (log_stat
,vec
[0]);
if (user_tailor () != OK
) {
(void) fprintf (stderr
, "Tailoring failed\n");
(void) strcat (buf
,argv
[i
]);
if (test_arg (argv
[i
], "-password",2) && ++i
< argc
)
(void) strcat (buf
, "????");
LLOG (log_stat
,LLOG_NOTICE
,("%s",buf
));
if (call_bind (argc
,argv
) != OK
)
ps_print (opt
,"Serious dish error\n");
if (print_arg_error (opt
) != OK
)
ps_print (opt
,"Unknown command --- type '?' for help\n");
extern int rl_bind_key ();
extern int *rl_insert ();
rl_bind_key ( '\t', rl_insert
);
static char *gnu_gets ( buf
, len
)
extern char *readline ();
gets_line
= readline ( "Dish -> " );
if ( gets_line
&& *gets_line
)
add_history ( gets_line
);
strncpy ( buf
, gets_line
, strlen(gets_line
) + 1 );
Commands
[num_cmd
].command
= NULLCP
;
Commands
[num_cmd
].handler
= unknown_cmd
;
Commands
[num_cmd
].unique
= 0;
(void) signal (SIGINT
, dish_intr
);
if (setjmp (dish_env
) == 1)
if (read_pipe (inbuf
,sizeof inbuf
) == -1)
(void) signal (SIGALRM
, SIG_IGN
);
command
= index (inbuf
, ':');
if ((opt
= ps_alloc (fdx_open
)) == NULLPS
) {
fatal (-68, "ps_alloc failed");
if (fdx_setup (opt
, sd_current
) == NOTOK
) {
fatal (-69, "fdx_setup failed");
(void) (*opt
-> ps_writeP
) (opt
, "2", 1, 0);
if ((rps
= ps_alloc (fdx_open
)) == NULLPS
) {
fatal (-70, "ps_alloc 2 failed");
if (fdx_setup (rps
, sd_current
) == NOTOK
) {
fatal (-71, "fdx_setup 2 failed");
(void) (*rps
-> ps_writeP
) (rps
, "1", 1, 0);
if ((opt
= ps_alloc (str_open
)) == NULLPS
) {
fatal (-68, "ps_alloc failed");
if (str_setup (opt
, NULLCP
, BUFSIZ
, 0) == NOTOK
) {
fatal (-69, "str_setup failed");
opt
->ps_ptr
++, opt
->ps_cnt
--;
if ((rps
= ps_alloc (str_open
)) == NULLPS
) {
fatal (-70, "ps_alloc 2 failed");
if (str_setup (rps
, NULLCP
, BUFSIZ
, 0) == NOTOK
) {
fatal (-71, "str_setup 2 failed");
rps
->ps_ptr
++, rps
->ps_cnt
--;
if (gnu_gets ( inbuf
, sizeof inbuf
) == 0)
(void) printf ("Dish -> ");
if (fgets (inbuf
, sizeof inbuf
, stdin
) == 0)
for (ptr
= inbuf
; isspace (*ptr
); ptr
++)
(void) signal (SIGALRM
, SIG_IGN
); /* unset alarm */
command
= TidyString(inbuf
);
for (x
= 0; Commands
[x
].command
!= 0; x
++)
if (test_arg (command
, Commands
[x
].command
, Commands
[x
].unique
))
if (* Commands
[x
].defaults
!= 0) {
(void) sprintf (cmd_buf
,"%s %s",Commands
[x
].command
,Commands
[x
].defaults
);
(void) sprintf (cmd_buf
,"%s %s %s",Commands
[x
].command
,Commands
[x
].defaults
,ptr
);
if (strncmp (command
, "fred -ufn ",
sizeof "fred -ufn " - 1) == 0) {
command
[4] = command
[9] = ',';
if ((no_of_args
= sstr2arg (command
, MAXARGS
, vector
, brkset
)) == NOTOK
)
ps_printf (OPT
, "Too many arguments... Can't cope.\n");
vector
[0] = Commands
[x
].command
;
if (vector
[0] != NULLCP
) {
(void) strcpy (buf
,vector
[0]);
for (y
=1; y
<no_of_args
; y
++) {
(void) strcat (buf
,vector
[y
]);
if (test_arg (vector
[y
], "-password",2) && y
+1 < no_of_args
) {
(void) strcat (buf
, "????");
if (test_arg (vector
[y
],"-help",1)) {
LLOG (log_stat
,LLOG_NOTICE
,("%s",buf
));
&& strncmp (buf
, "moveto ",
(void) ll_log (dad_log
, LLOG_NOTICE
, NULLCP
,
(*Commands
[x
].handler
) (no_of_args
, vector
);
/* if from pipe, return results */
if (frompipe
&& !remote_prob
) {
if (rps
-> ps_byteno
> 0) {
if (opt
-> ps_byteno
> 0)
if (opt
->ps_byteno
== 0) {
send_pipe (rps
->ps_base
);
*opt
->ps_base
= '3'; /* Signal search ok but >1 hit, with -hitone option */
send_pipe (opt
->ps_base
);
(void) close_tcp_socket (sd_current
);
/* can only get called if run interactively - dont worry about pipe */
(void) signal (SIGINT
, SIG_DFL
);
DLOG (log_dsap
, LLOG_DEBUG
, ("Dish:- Exiting Dish successfully..."));
set_cmd_default (cmd
, dflt
)
for (x
= 0; Commands
[x
].command
!= 0; x
++)
if (strcmp (cmd
, Commands
[x
].command
) == 0) {
if (* Commands
[x
].defaults
!= 0)
(void) strcat (Commands
[x
].defaults
, " ");
(void) strcat (Commands
[x
].defaults
, dflt
);
(void) signal (SIGINT
, dish_intr
);
ps_printf (OPT
, "(Interrupted)\n");
(void) _ll_log (log_dsap
, code
, ap
);