Exemplo n.º 1
0
cce()
{
    $DESCRIPTOR(prompt,"CCE> ");
    int status;
    char buff[512];
    $DESCRIPTOR(command,buff);
    unsigned short outlen;
    mstr	lnm$group = {9, "LNM$GROUP"};
    int CCE_CMD(), CLI$DCL_PARSE(), CLI$DISPATCH();
    DCL_THREADGBL_ACCESS;

    GTM_THREADGBL_INIT;			/* This is the first C routine in the cce so do init here */
    gtm_env_init();	/* read in all environment variables before any function call (particularly malloc) */
    getjobnum();
    get_page_size();
    dfntmpmbx (lnm$group.len, lnm$group.addr);
    status = lib$get_foreign(&command,0,&outlen,0);
    if ((status & 1) && outlen > 0)
    {   command.dsc$w_length = outlen;
        status = CLI$DCL_PARSE(&command ,&CCE_CMD, &lib$get_input, 0, 0);
        if (status == CLI$_NORMAL)
            CLI$DISPATCH();
    } else
    {   while (!cce_done)
        {
            status = CLI$DCL_PARSE(0 ,&CCE_CMD, &lib$get_input
                                   , &lib$get_input, &prompt);
            if (status == RMS$_EOF)
                cce_done = TRUE;
            else if (status == CLI$_NORMAL)
            {
                ret_status = 1;
                CLI$DISPATCH();
            }
        }
    }
    return ret_status;
}
Exemplo n.º 2
0
static void lke_process(void)
{
	uint4		status;
	$DESCRIPTOR	(prompt, "LKE> ");

	ESTABLISH(util_ch);
	status = CLI$DCL_PARSE(0, &lke_cmd, &lib$get_input, &lib$get_input, &prompt);
	if (RMS$_EOF == status)
		lke_exit();
	else if (CLI$_NORMAL == status)
	{
		util_out_open(&output_qualifier);
		CLI$DISPATCH();
		util_out_close();
	}
}
Exemplo n.º 3
0
void lke(void)
{
	char		buff[MAX_LINE];
	$DESCRIPTOR	(command, buff);
	uint4		status;
	short		len;
	bool		dcl;
	DCL_THREADGBL_ACCESS;

	GTM_THREADGBL_INIT;
	gtm_imagetype_init(LKE_IMAGE);
	gtm_env_init();	/* read in all environment variables */
	util_out_open(0);
	SET_EXIT_HANDLER(exi_blk, generic_exit_handler, exi_condition);	/* Establish exit handler */
	ESTABLISH(util_base_ch);
	status =lp_id(&lkid);
	if (SS$_NORMAL != status)
		rts_error(VARLSTCNT(1) status);
	get_page_size();
	stp_init(STP_INITSIZE);
	rts_stringpool = stringpool;
	getjobname();
	INVOKE_INIT_SECSHR_ADDRS;
	ast_init();
	initialize_pattern_table();
	gvinit();
	region_init(TRUE);
	getjobnum();
	status = lib$get_foreign(&command, 0, &len, 0);
	if ((status & 1) && len > 0)
	{
		command.dsc$w_length = len;
		status = CLI$DCL_PARSE(&command, &lke_cmd, &lib$get_input, 0, 0);
		if (CLI$_NORMAL == status)
		{
			util_out_open(&output_qualifier);
			CLI$DISPATCH();
			util_out_close();
		}
		lke_exit();
	}
	for (;;)
		lke_process();
}
Exemplo n.º 4
0
Arquivo: dfu.c Projeto: rroart/freevms
main(int argc, char *argv[])

/*	MAIN

	Purpose : 1 Get privilege mask
		  2 Setup SMG environment unless no VT or DFU$NOSMG is set
		  3 Get and Parse command (syntax only)
		  4 Dispatch to correct subroutine

	Inputs  : Command line (if specified through foreign command)

	Outputs : returns last status code to DCL in  case
		  of single command processing. In interactive mode
		  always returns SS$_NORMAL.
*/
{
    const rms_eof=98938,smg$_eof=1213442;
    struct
    {
        short status, count;
        int extra ;
    } iosb;
    static char command_line[255], *e;
    unsigned int out_len,ret_len,prvmask;
    void reset_ctrl(), clean_ctrlc(),
         prev_screen(), next_screen(), dump_screen(), toggle_width() ;
    int smg_flag, x, y, i, ttype;
    int cursor_on = SMG$M_CURSOR_ON;
    $DESCRIPTOR(input_line , command_line);
    $DESCRIPTOR(prompt,"DFU> ");
    $DESCRIPTOR(terminal,"SYS$COMMAND");
    $DESCRIPTOR(top_txt,"< DFU V2.2 (Freeware) >");
    $DESCRIPTOR(status_txt,"Statistics");
    $DESCRIPTOR(do_key,"DO");
    $DESCRIPTOR(pf2,"PF2");
    $DESCRIPTOR(pf4,"PF4");
    $DESCRIPTOR(prev,"PREV_SCREEN");
    $DESCRIPTOR(next,"NEXT_SCREEN");
    $DESCRIPTOR(select,"SELECT");
    $DESCRIPTOR(help,"HELP");

    /* First find out how we got called ( by RUN, or a foreign command */
    ret_len = 0;
#if 0
    status = lib$get_foreign(&input_line,0,&ret_len,0);
#else
    status = 1;
#if 0
    strcpy(command_line,argv[1]);
#endif
#endif
    out_len = ret_len;

    smg$enable = TRUE;
    key_tab = 0;
    disp2_id = 0;
    cip = 0;

    setvbuf(stdout, NULL, _IONBF, 0);      // need this to see i/o at all
#if 0
    smg$enable = FALSE;
    vms_mm = check_vms_mm();
#else
    /* Now create the SMG environment */

    colls=80;
    rows=24;
    SMG$CREATE_PASTEBOARD(&paste_id, 0, &rows,
                          &colls,&SMG$M_KEEP_CONTENTS,&ttype,0);
    if ((e = (char *) getenv("DFU$NOSMG")) && *e) smg$enable = FALSE;
    else
    {
        if (ttype != SMG$K_VTTERMTABLE) smg$enable = FALSE;
        if (ttype != SMG$K_VTTERMTABLE) SMG$DELETE_PASTEBOARD(&paste_id,&i0);
    }

    SMG$CREATE_VIRTUAL_KEYBOARD(&keyb_id,0,0,0,0);
    if (smg$enable)
        /* Setup key table */
    {
        SMG$ERASE_PASTEBOARD(&paste_id, 0, 0, 0, 0, 0, 0);
        SMG$CREATE_KEY_TABLE(&key_tab);
        colls -=2;
        orig_colls = colls;
        smg_flag = SMG$M_KEY_NOECHO + SMG$M_KEY_TERMINATE;
        SMG$ADD_KEY_DEF(&key_tab,&do_key,0, &smg_flag, &do_key,0);
        SMG$ADD_KEY_DEF(&key_tab,&pf4,0, &smg_flag,&pf4,0);
        SMG$ADD_KEY_DEF(&key_tab,&prev,0, &smg_flag, &prev,0);
        SMG$ADD_KEY_DEF(&key_tab,&next,0, &smg_flag, &next,0);
        SMG$ADD_KEY_DEF(&key_tab,&pf2,0, &smg_flag, &help,0);
        SMG$ADD_KEY_DEF(&key_tab,&help,0, &smg_flag, &help,0);
        SMG$ADD_KEY_DEF(&key_tab,&select,0, &smg_flag, &select,0);
        SMG$CREATE_VIRTUAL_DISPLAY(&i500, &colls , &disp1_id, &SMG$M_BORDER,
                                   0, 0);
        x = 508 - rows;
        y = rows - 7;
        SMG$CREATE_VIEWPORT(&disp1_id,&x,&i1,&y,&colls);
        SMG$CREATE_VIRTUAL_DISPLAY(&i2, &colls, &status_id, 0 , 0, 0);
        SMG$CREATE_VIRTUAL_DISPLAY(&i2, &colls, &disp2_id, 0 , 0, 0);
        SMG$SET_BROADCAST_TRAPPING(&paste_id,brdcst_ast,0);
        SMG$LABEL_BORDER(&disp1_id, &top_txt, 0, 0,&SMG$M_BOLD, 0, 0);
        SMG$LABEL_BORDER(&status_id, &status_txt, 0, 0,&SMG$M_BOLD, 0, 0);
        SMG$PASTE_VIRTUAL_DISPLAY(&disp1_id, &paste_id, &i2,&i2,0);
        x = rows - 4;
        SMG$PASTE_VIRTUAL_DISPLAY(&status_id, &paste_id, &x,&i2,0);
        x = rows - 1;
        SMG$PASTE_VIRTUAL_DISPLAY(&disp2_id, &paste_id, &x,&i2,0);
        x = 508 - rows;
        SMG$SET_CURSOR_ABS(&disp1_id,&x,&i1);
        SMG$SET_CURSOR_ABS(&disp2_id,&i1,&i1);
        SMG$BEGIN_PASTEBOARD_UPDATE(&paste_id);
    }
#endif

    sprintf(outbuf,"\n     Disk and File Utilities for OpenVMS DFU V2.2");
    put_disp();
    sprintf(outbuf,"     Freeware version");
    put_disp();
    sprintf(outbuf,"     Copyright © 1995 Digital Equipment Corporation\n");
    put_disp();

    if (smg$enable)
    {
        /* Enter additional info */
        sprintf(outbuf,"     DFU functions are : \n");
        put_disp();
        sprintf(outbuf,"     DEFRAGMENT : Defragment files");
        put_disp();
        sprintf(outbuf,"     DELETE     : Delete files by File-ID; delete directory (trees)");
        put_disp();
        sprintf(outbuf,"     DIRECTORY  : Manipulate directories");
        put_disp();
        sprintf(outbuf,"     REPORT     : Generate a complete disk report");
        put_disp();
        sprintf(outbuf,"     SEARCH     : Fast file search");
        put_disp();
        sprintf(outbuf,"     SET        : Modify file attributes");
        put_disp();
        sprintf(outbuf,"     UNDELETE   : Recover deleted files");
        put_disp();
        sprintf(outbuf,"     VERIFY     : Check and repair disk structure");
        put_disp();
        SMG$END_PASTEBOARD_UPDATE(&paste_id);
    }

    prvmask = 0;
    status = dfu_check_access(&prvmask);  /*Get the privilege mask */

    /* Setup terminal channel for control purposes; get the terminal chars */
    status = SYS$ASSIGN(&terminal, &tchan, 0,0);
    status = SYS$QIOW(0,tchan, IO$_SENSEMODE,0,0,0,&orgttchar,12,0,0,0,0);
    for (i = 0; i < 3; i++) ttchar[i] = orgttchar[i];
    ttchar[2] &= ~TT2$M_EDITING; /* Clear line edit bit */
    clean_ctrlc(); /* Enable CTRL/W if needed */

    if (ret_len==0)
    {
        if (smg$enable)
            status = SMG$READ_COMPOSED_LINE(&keyb_id,&key_tab,&input_line,&prompt,
                                            &out_len,&disp2_id,0,0,0,0,0);
        else
            status = SMG$READ_COMPOSED_LINE(&keyb_id,0,&input_line,&prompt,
                                            &out_len,0,0,0,0,0,0);
    }

    memcpy (command_line, input_line.dsc$a_pointer, input_line.dsc$w_length);
    cip = 1;

    /* Main loop starts here. Get a command and pasre it*/
    for (;;)
    {
        /* loop forever until EXIT is entered */
        if(status==smg$_eof) status = exit_command(prvmask);
        if ((status&1) != 1) goto endfor;
        if (out_len == 0) goto endfor;

        /* First catch special screen commands */
        if (smg$enable)
        {
            status = strncmp(command_line, "PREV_SCREEN", 11);
            if (status == 0)
            {
                prev_screen();
                goto endfor;
            }
            status = strncmp(command_line, "DO",2);
            if (status == 0)
            {
                status = spawn_command(prvmask);
                goto endfor;
            }
            status = strncmp(command_line, "PF4",3);
            if (status == 0)
            {
                dump_screen();
                goto endfor;
            }
            status = strncmp(command_line, "NEXT_SCREEN", 11);
            if (status == 0)
            {
                next_screen();
                goto endfor;
            }
            status = strncmp(command_line, "SELECT", 6);
            if (status == 0)
            {
                toggle_width();
                goto endfor;
            }

            SMG$ERASE_DISPLAY(&disp1_id, 0, 0, 0, 0);
            SMG$ERASE_DISPLAY(&status_id, 0, 0, 0, 0);
            SMG$CHANGE_VIEWPORT(&disp1_id,&x,&i1,&y,&colls);
            SMG$SET_CURSOR_ABS(&disp1_id,&x,&i1);
        }

        /* Catch the CLI errors do avoid disrupting the SMG screen... */
#if 0
        VAXC$ESTABLISH(prim_hand);
#endif
        status = CLI$DCL_PARSE(&input_line,&dfu_tables,0 /* not yet lib$get_input*/,0,&prompt); // check added & before dfu_tables
#if 0
        VAXC$ESTABLISH(NULL);
#endif
        if (status == CLI$_NOCOMD) singlemsg(0,status);
        if ((status & 1 ) != 1) goto endfor;
        else
            /* Now dispatch if no errors */
        {
            reset_ctrl();
            CLI$DISPATCH(prvmask);
            clean_ctrlc();
            cip = 0;
            status = brdcst_ast();
            if (smg$enable) SMG$SET_CURSOR_MODE(&paste_id, &cursor_on);
        }
endfor:
        if (ret_len !=0)
        {
            /* Single command processing , so exit here */
            status += 0x10000000; /* Do not echo the error on DCL level */
            if (smg$enable)
            {
                if (colls != orig_colls) toggle_width();
                SMG$SET_CURSOR_ABS(&disp2_id,&i2,&i1);
            }
            exit(status);
        }
        /* Get next line */
        cip = 0;
#if 1
        if (smg$enable)
        {
            SMG$ERASE_LINE(&disp2_id, &i1, &i1);
            SMG$SET_CURSOR_ABS(&disp2_id,&i1,&i1);
            status = SMG$READ_COMPOSED_LINE(&keyb_id,&key_tab,&input_line,
                                            &prompt,&out_len,&disp2_id,0,0,0,0,0); /*Get next command */
            cip = 1;
        }
        else
            status = SMG$READ_COMPOSED_LINE(&keyb_id,0,&input_line,
                                            &prompt,&out_len,0,0,0,0,0,0); /*Get next command */
#else
        printf("%s",prompt.dsc$a_pointer);
        out_len = read(0,command_line,254);
        out_len--;
        command_line[out_len]=0;
        if (strncmp(command_line,"exit",4)==0)
            return 0;
#endif
    }
}  /* END of MAIN */