text:
/* Process PDF for terminal monitor.
 *
 * CHANGE LOG:
 *
 *	11-jul-83	Purged change log, deleted checkout records,
 *			and audited global definitions...jtm
 *	12-jul-83	Rewrote process()...dm
 *	14-jul-83	Display host error code in subprocess related
 *			messages...dm
 *	29-jul-83	Clear "receive" event flag in process()...dm
 *	15-aug-83	Fix comment to align with delgbl_do fix...peb
 *	02-sep-83	Fix error msg in opnpdf (PR 432)...palm
 *			Also, new dynget calling sequence...palm
 *	08-sep-83	Set $status into $skey if DCL command...palm
 *	12-sep-83	Build global symbol table in alphabetic order...dm
 *	12-sep-83	Condititional compilation on function 'process'
 *			preparing for UNIX (where it will be cnp)...palm
 *	25-sep-83	Accept output variables from exit handlers of
 *			an aborted task...palm
 *	10-oct-83	Fix unix compilation errors...palm
 *	21-oct-83	Fix stdout reset bug...dm
 *	03-feb-84	Update for full-blown proc interrupt mode...ne
 *	22-feb-84	In pdftab(): save curproc explicitly...peb
 *	27-feb-84	In process():  Add message handshake...peb
 *	03-mar-84	In process(): Handle param request while in async...nhe
 *	11-mar-84	Make parblk relative before sending back to process
 *			for handsake...dm
 *	12-mar-84	Make outputs and interrupt EXTERN for UNIX...palm
 *	13-mar-84	Update to accomodate bldcmd changes...dm
 *	15-mar-84	Move logging of dyn pars to elsewhere...nhe
 *	04-may-84	VALUE_x to xVAL ... ces
 *	07-may-84	Clean-up the IMPORT declarations...lim
 *			'toprefs'-->'numrefs'...nhe
 *	17-mar-84	New hierarchy and f_crack calling sequence...palm
 *	8-jun-84	TCL-99: avoid global conflicts with
 *			level 0 locals...palm
 *	12-jun-84	TCL-21: CONTROL/C handling in procedure...palm
 *	21-jun-84	pr706: get errmsgs from process into stdout for async...nhe
 *	09-jul-84	pr664: move call to pt_ins(), in run_proc...peb
 *	13-jul-84	errmsgs-->process(),errmsg-->CODE_ERR in tminc...nhe
 *	01-aug-84	file_name-->file_spec in struct MON_MSG...nhe
 *	03-aug-84	pr396: give proc name on set_outval failure...peb
 *	16-aug-84	pr396: TAE-COMOPN --> TAE-COMOPEN...peb
 *	22-aug-84	Pass proc context to logmsg...lia
 *	08-oct-84	Update opnpdf to handle remote case...nhe
 *	11-oct-84	Add conditional compilation for c_snpa/c_sndp call
 *			as implemented for UNIX 1.2...dm
 *	12-oct-84	Conditional compilation for get_pblk_remote()...dm
 *	14-oct-84	Changes for internal procs...nhe
 *	17-oct-84	TCL 117: pdftab logic for compiled PDFs...peb
 *	18-oct-84	Enhancements to internal procs...nhe
 *	23-oct-84	TCL 117: compilation of SUBCMDs...peb
 *	07-dec-84	PR 908: incomplete reinit of VARIABLE struct in
 *			converting the parm to a global in make_gbl...lia
 *	11-dec-84	TCL 97: maintain flag for executing onfail cmd...lia
 *	18-dec-84	Fix infinite loop on bad onfail cmd...lia
 *
 ***************************************************************************
 * CHANGES MADE IN THE RCJM TREE:
 *
 *	06-feb-85	Check for link-abort event for remote jobs...dm
 *	09-feb-85	At CTL/C  abort_remote if processing an rpd...dm
 *	13-mar-85	Update for new member names of MON_MSG...dm
 *	06-apr-85	Update get_pblk_remote() for remote jobs; delete
 *			reference to ASYNCINC...dm
 *	17-apr-85	Add _DYNPDF for remote process's dynpar block...dm
 *
 ***********************************************************************
 *
 *	25-jul-85	Fix UNIX lint compilation errors...dm
 *	01-aug-85	Delete ecb_link reference due to link-abort
 *			redesign...dm
 *	26-aug-85	PR 806: recognize user exit from dynamic tutor after
 *			call to get_parm_locpar...dab
 *	09-sep-85	PR 961: Call to 'dynget' by 'process' indicates that
 *			will be tutoring for sync proc (to prevent HOLD)...dab
 *	03-oct-85	PR 946: Added "not compiling" (FALSE) parameter to
 *			calling sequence of 'chk_vector'...dab
 *	17-feb-86	Honor OPTIONS=INTERRUPT for procedures; Honor
 *			int_enabled flag (as set by DISABLE-INTERRUPT and
 *			ENABLE-INTERRUPT).
 *	24-mar-86	Pass current contxt to interrupt from procedure and
 *			process...palm
 *	28-may-86	Fix bug in make_gbl whereby adding a variable to
 *			BEGINNING of global table caused crash (we forgot
 *			to unlink the VARIABLE from the parmst before linking
 *			into glbtab)...palm
 *	16-jul-86	Honor ACTION= on parmset execution...palm
 *	05-sep-86	PR 1129 fix.  PDF line number now correct in
 *			error messages when comments, null lines precede
 *			erroroneous statement...peb
 *	05-sep-86	Remove anachronous null str
 *			check after getpst calls...peb
 *	11-sep-86	PR 1100 fix.  Modified process() to check for entry via
 *			menu.  If so, request for prompt before repaint...lia
 *	28-mar-87	New calling sequence for package in process. Also
 *			we use LARGE_PARBLK for sending to subprocess...palm
 *	19-jul-87	Fix make_gbl to pick up qualifiers...palm
 *	02-aug-87	Fix missing key in deep_value_copy tmmmsg...palm
 *	19-aug-87	Maintain consistency with old executables wrt
 *			the M_KILLED flag:  The V1.3 outboard library checks for
 *			M_KILLED PARBLK.msgtyp to determine that the tutor
 *			user typed "EXIT".  The V1.4 library and beyond check
 *			for either M_KILLED or M_DYNEXIT, and dynget sets
 *			msgtyp to M_DYNEXIT.   Here, we convert from
 *			M_DYNEXIT to M_KILLED before sending a parblk to an
 *			application process so that old executables work.
 *			This mess started with PR806...palm
 *	26-aug-87	Fix qualptr casting and definition in opnpdf...palm
 *      08-sep-87       Add size in call to dynget...tpl
 *	17-dec-87	Executable PAR files...palm
 *	18-dec-87	Add CheckXEvent call to run_proc...palm
 *	24-feb-88	PR 1504: Change label dimension to LABELSIZ+1...ljn
 *	26-feb-88	Reset EventProcCtx when coming out of a procedure
 *			that has an event loop (using WPT-EVENT)...palm
 *	17-mar-88	PR 1499: Add call to isTerm()...ljn
 *	24-mar-88	Delete TAE_RCJM conditionals...ljn
 *	02-may-88	Remove restriction that only files with type .PAR
 *			can be executed as PAR files.  See call to IsParFile.
 *			...palm
 *	05-may-88	isTerm() -> f_isterm()...ljn
 *	01-dec-88	package valids for SELFTUTOR...palm
 *	13-feb-89	Zero parblk header before sending to process...palm
 *	01-may-89	disallow process execution while process already
 *			running...palm
 *	12-sep-89	Port PM's 1-may-89 fix on UNIX...ljn
 *      20-dec-89       Fixed handling of M_COMMAND for VMS...tpl
 *	23-may-90	Remove RCJM stuff referring to old TAE_RCJM...ljn
 *	27-jun-90	Remove Facelift code...ljn
 *	11-may-92	Used P_BIGSENTINEL instead of P_SENTINEL...tpl
 *	11-sep-92 PR875 In getpst, changed inbuf size to CMDLINSIZ instead of
 *			STRINGSIZ and use f_readstring instead of f_read...tpl
 *	22-oct-92	Prototype of tae_alloc unnecessary and Ultrix 4.3 does
 *			 not like it...rt
 *	13-may-93	LARGE_PARBLK is larger then max VMS record size.
 *			Use Vm_parbwrite and Vm_parbread instead of f_bwrite
 *			and f_bread to work-around this limitation...cew
 */

#include	"taeconf.inp"	/* TAE configuration definitions	*/
#include	"terminc.inc"	/* terminal package definitions		*/
#include	"syninc.inc"	/* syntax package structure and defs	*/
#include	"eventinc.inp"	/* e_ package defs & structs		*/
#include	"taskinc.inp"	/* c_ package defs & structs		*/
#include	"symtab.inc"
#include	"tmhost.inp"
#include	"parblk.inc"
#include	"tminc.inc"	/* TM-only host-independent definitions	*/
#include "taeintproto.h"

FUNCTION static CODE chk_onfail
(
    TEXT		cmdstr[]	/* in:  command string			*/

 );
FUNCTION static CODE make_gbl
(
    struct CONTXT	*pctx		/* in/out: global proc context	*/
 );
FUNCTION static CODE procedure
(
    struct CONTXT	*pctx,		/* in:  context for this procedure	*/
    struct ECB		*ecbi		/* in:  event blk for operator interr.	*/

 );
FUNCTION static CODE set_outval
(
    struct VARIABLE	*v,		/* in/out: VARIABLE to set	*/
    struct PARBLK	*parblk	/* in: PARBLK from process	*/

 );

FUNCTION static VOID msg_subs
(
    struct CONTXT	*ctx		/* in:  proc context			*/

 );

#define	BC_PARMST	1
#define	BC_LOCST	2
#define	BC_GLOBREFS	3

/* build_prompt - Build a new prompt string, "<old prompt>-INTERRUPT>"
 *
 */
FUNCTION static VOID build_prompt
(
    TEXT		prompt[]	/* out: the prompt built	*/

 )
    {
    IMPORT  struct  VARIABLE    *prompt_gbl;	/* pointer to $prompt	*/

    COUNT		i;

    i = s_copy(SVAL(*prompt_gbl, 0), prompt); /* get current prompt	*/
    prompt[i++] = '-';
    i += s_copy("INTERRUPT", &prompt[i]);	/* add 'INTERRUPT'	*/
    prompt[i++] = '>';
    prompt[i] = EOS;
    return;
    }

/*
 *	chk_onfail - check a command to make sure it is an
 *	allowed _ONFAIL command.
 *
 */

FUNCTION static CODE chk_onfail
(
    TEXT		cmdstr[]	/* in:  command string			*/

 )
    {
    struct SYNBLK	sb;		/* syntax block				*/
    TEXT		verb[TOKESIZ+1];
    struct ITRCMD	*itrcmd;	/* pointer to intrinsic table		*/

    initok(&sb, cmdstr);		/* init syntax block for syntax pkg	*/
    if (getvrb(&sb, verb) == S_SYNERR) 	/* get verb from cmd str		*/
	{
        tmmsg(PROCFAIL, "Incorrect command format in _ONFAIL command: %s.",
    	      "TAE-ONFAIL", (uintptr_t)sb.errmsg,0,0,0,0);
	return(FAIL);			/* DO_RETURN avoids _ONFAIL loop	*/
	}
    itrcmd = intrin(verb);		/* get pointer to ITRCMD entry		*/
    if (itrcmd != NULL)
	if (((*itrcmd).flags & Y_ONFAIL)  != 0)
	    return (SUCCESS);
    tmmsg(PROCFAIL, "'%s' not allowed as _ONFAIL command.", "TAE-ONFAIL", (uintptr_t)verb,0,0,0,0);
    return (FAIL);
    }

/*
 *	clssav - close a proc and save the position.
 */

FUNCTION VOID clssav
(
    struct CONTXT	*pctx		/* in/out: proc context			*/

 )
    {
    IMPORT struct SFILE	prcfil;		/* proc file context			*/

    f_movpos(&(prcfil.posctx), &((*pctx).prcpos));
    f_close(&prcfil, F_KEEP);
    return;
    }

#ifdef TAE_ASYNC
/*  get_pblk_remote - Get parameter values for a parblk from parent monitor
 *
 *  Input is an 'absolute' parblk and output is a 'relative' parblk (imitates
 *  dynget in this).
 *
 *  Returns SUCCESS/FAIL
 */
FUNCTION CODE get_pblk_remote
(
    struct CONTXT	*proc_ctx,	/* in: Context of executing proc    */
    struct PARBLK	*parblk,	/* in/out: parameter block	*/
    struct CODE_ERR	*(*errmsg)	/* out: pointer to err msg	*/

 )
    {
    IMPORT TEXT		comm_file[];	/* name of mon-to-mon comm'n file    */
    IMPORT CODE		parent_runtype; /* run_type of parent monitor	     */
    TEXT		recv_file[FSPECSIZ+1];	/* file received from parent */
    struct SFILE	sf;
    struct PARHDR	ph;
    CODE		code;
    CODE		send_stat, recv_stat;
    COUNT		recsize;

    static struct CODE_ERR er_asyparm=
    	{"Async jobs may request parms only if invoked interactively.",
    	 "TAE-ASYPARM", 0};

    static struct CODE_ERR er_comopn=
    	{"Error opening async communication file.",
    	 "TAE-COMOPEN", 0};

    static struct CODE_ERR er_comwrt=
    	{"Error writing to async communication file.",
    	 "TAE-COMWRT", 0};

    static struct CODE_ERR er_comread=
    	{"Error reading async communication file.",
    	 "TAE-COMREAD", 0};

    static struct CODE_ERR er_fmtcomm=
    	{"Async communication file not properly formatted.",
	 "TAE-FMTCOMM", 0};

    static struct CODE_ERR er_asysnd=
    	{"Error sending message to parent monitor.  Host error code = %d.",
    	 "TAE-ASYSND", 0};

    static struct CODE_ERR er_asyrcv=
    	{"Error receiving message from parent monitor.  Host error code = %d.",
    	 "TAE-ASYRCV", 0};

    if (parent_runtype == ASYNC || parent_runtype == BATCH)
    	{
    	*errmsg = &er_asyparm;
    	return (FAIL);
    	}

/* Save the parblk in the communication file				*/

    code = f_opnspc (&sf, SAVELUN, comm_file, "", "", ASY_TYPE, F_WRITE);
    if (code != SUCCESS) goto open_err;
    code = save_pfile (&sf, (*parblk).msgtyp, NULL, 0, &(*parblk).symtab, 0, 0);	/* write parmst to file */
    if (code != SUCCESS) goto write_err;
    f_close (&sf, F_KEEP);

/* Send the message to the parent monitor and receive return reply	*/

    code = get_parm_locpar(comm_file, recv_file, TRUE,
	    &send_stat, &recv_stat);		/* get parm from local parent */
    if (code == KILLED)				/* user wants to exit the job */
	{
	(*parblk).msgtyp = M_KILLED;
	return (SUCCESS);
	}
    else if (code == DO_EXIT)			/* user exited from dyn tutor */
	{
	(*parblk).msgtyp = M_DYNEXIT;
	return (SUCCESS);
	}
    if (code != SUCCESS) goto comm_err;		/* communication error      */

    code = f_opnspc(&sf, SAVELUN, recv_file, "", "",
		    ASY_TYPE, F_READ);		/* open for read	    */
    if (code != SUCCESS)  goto open_err;	/* report error		    */
    code = f_bread(&sf, (GENPTR) &ph, sizeof(struct PARHDR), &recsize);
    if (code != SUCCESS)  goto read_err;
    if (!s_equal(ph.sentinel, P_BIGSENTINEL)) goto format_err;	/* not proper format	    */
#if defined(vms) || defined(__VMS)
    code = Vm_parbread(&sf, (GENPTR) parblk, sizeof(struct PARBLK), &recsize);
#else
    code = f_bread(&sf, (GENPTR) parblk, sizeof(struct PARBLK), &recsize);
#endif
    if (code != SUCCESS) goto read_err;
    f_close (&sf, F_DELETE);
    return(SUCCESS);

/*  on errors we point to an error msg in front of this module		*/
open_err:
    *errmsg = &er_comopn;
    return(FAIL);

write_err:
    *errmsg = &er_comwrt;
    f_close(&sf, F_DELETE);
    return(FAIL);

read_err:
    *errmsg = &er_comread;
    f_close(&sf, F_KEEP);
    return(FAIL);

format_err:
    *errmsg = &er_fmtcomm;
    f_close(&sf, F_KEEP);
    return (FAIL);

comm_err:
    if (send_stat != SUCCESS)		/* msg could not be sent	*/
    	{
	*errmsg = &er_asysnd;
    	er_asysnd.code = send_stat;
	}
    else				/* error in receiving reply	*/
	{
	*errmsg = &er_asyrcv;
	er_asyrcv.code = recv_stat;
	}
    return(FAIL);
    }
#endif

/*	getpst - get one PDF statement.
 *	Skips comments & null lines.
 *	The statement may result from multiple single PDF lines, all
 *	but the last ending in "+".  As these multiple lines are concatenated,
 *	each continuation "+" is replaced with a blank.
 */

FUNCTION CODE getpst
(
    struct SFILE	*pdffil,	/* in/out: PDF file context	*/
    TEXT		sttmt[],	/* out: PDF statement		*/
    COUNT		*records,	/* out: number of records read	*/
    COUNT		*num_prec,	/* out: # comments, null lines	*/
					/*      preceding 1st real sttmt rec*/
    struct POSCTX	*first_rec	/* out: position of 1st record	*/

 )
    {
    CODE		code;
    CODE		cmdcode;	/* SUCCESS, CONTINUE, or FAIL	*/
    COUNT		nrec;		/* number of records flushed	*/
    BOOL		cont;
    BOOL		in_sttmt;	/* TRUE if actual statement started*/
    TEXT		inbuf[CMDLINSIZ+1];

    *records  = 0;
    *num_prec = 0;
    in_sttmt  = FALSE;
    sttmt[0]  = EOS;
    cont = FALSE;
    do
	{
	if ((code = f_readstring (pdffil,CMDLINSIZ, inbuf)) != SUCCESS)	/* get single PDF line	*/
	    goto gp_rderr;
	(*records)++;
	if (!in_sttmt) (*num_prec)++;		/* assume comment or null line*/
    	if (!cont) f_movpos (&(*pdffil).posctx, first_rec);  /* save pos'n of 1st rec */
	if (NULLSTR(inbuf))
	    {
	    cont = TRUE;
	    continue;
	    }
	cmdcode = bldcmd(inbuf, sttmt);		/* append to any previous line	*/
	if (!in_sttmt  &&  !NULLSTR(sttmt))
	    {
	    in_sttmt = TRUE;			/* no more preceding comments	*/
	    (*num_prec)--;			/* this line wasn't comment	*/
	    }
	if (cmdcode == FAIL)			/* no more space		*/
	    {
	    flush_cmd(pdffil, inbuf, &nrec);	/* flush the rest of statement	*/
	    *records = *records+nrec;
	    cont = FALSE;
	    }
	else if (cmdcode == CONTINUE)
	    cont = TRUE;
	else					/* if SUCCESS return		*/
	    cont = NULLSTR(sttmt);		/* continue if comment recs	*/
	}
    while (cont);
    return (SUCCESS);

gp_rderr:
    if (code == F_EOF)
      tmmsg(PROCFAIL, "Premature end of proc definition file.", "TAE-PREEOF",0,0,0,0,0);
    else
	tmmsg(PROCFAIL, "Error reading proc definition file. %s",
	      "TAE-RDERR", (uintptr_t)(*pdffil).errmsg,0,0,0,0);
    sttmt[0] = EOS;
    return(FAIL);
    }

/*
 *	ini_status- initialize $SFI and $SKEY
 */

    FUNCTION VOID ini_status (void)

    {
    IMPORT struct VARIABLE *sfi_gbl;	/* pointer to global $SFI	*/
    IMPORT struct VARIABLE *skey_gbl;	/* pointer to global $SKEY	*/

    static TAEINT	one   = 1;	/* value for $SFI		*/

    IVAL(*sfi_gbl,0) = one;
    set_string (skey_gbl, "");
    return;
    }

/*	interrupt - handle TAE interrupt mode processing.
 *
 */

FUNCTION CODE interrupt
(
	struct CONTXT	*ctx		/* in: context of executing proc  */

 )
    {
    IMPORT CODE		cmd_mode;	/* dynamic vs interrupt vs norm	*/
    IMPORT CODE		usermode;	/* for prccmd loop; menu or cmd	*/
    IMPORT struct SFILE	prcfil;		/* context of proc that requested parms	*/
    IMPORT struct CONTXT *curproc;		/* pointer to cur proc	*/
    IMPORT TEXT		next_cmd[];
    IMPORT struct CONTXT primctx;		/* primary context	*/
    IMPORT struct SFILE	*pstdo_fil, *saved_pstd;/* ptr to stdout SFILE	*/
    IMPORT struct VARIABLE  *skey_gbl, *sfi_gbl;
    IMPORT	  BOOL  int_enabled;		/* TRUE if ENABLE-INT	  */

    struct SFILE	saved_fil;
    CODE		saved_mode;
    CODE		saved_user;
    TEXT		cmdstr[CMDLINSIZ+1];
    CODE		code = 0;
    TEXT		new_prompt[STRINGSIZ+1];
    TEXT		skey_save[STRINGSIZ+1];
    TAEINT		sfi_save;
    struct CONTXT	*saved_cur;

    if (!(*ctx).interrupt)			/* proc inhibits intrpt mode? */
	return (DO_CONTINUE);
    if (!int_enabled)				/* intrpt mode not allowed? */
	return (DO_ABORT);			/* if not, do an abort	    */
    s_copy (SVAL(*skey_gbl,0), skey_save);	/* save status globals	    */
    sfi_save = IVAL (*sfi_gbl,0);
    saved_mode = cmd_mode;			/* save old command mode    */
    cmd_mode   = INTMODE;			/* proc interr mode	    */
    saved_user = usermode;			/* saved old user mode	    */
    usermode   = CMDMODE;			/* stay here until 'MENU'   */
    saved_cur  = curproc;			/* save ptr to 'current' ctx*/
    curproc    = &primctx;			/* for err msgs		    */
    MOVE_STRUCT(prcfil, saved_fil);		/* save the calling file    */
    saved_pstd = pstdo_fil;
    pstdo_fil = NULL;				/* implies term'l, by convention */
    build_prompt(new_prompt);			/* build interrupt prompt */
    next_cmd[0] = EOS;				/* null help cmd to start */
    do
    	{
    	if (NULLSTR(next_cmd))			/* no saved HELP cmd?	*/
    	    {
	    if (usermode == CMDMODE)
		cmd_noscreen (A_LASTCMD, new_prompt, cmdstr);
	    else				/* assume menu mode	*/
		menmod(cmdstr);			/* display menu 	*/
    	    }
	else
    	    {					/* HELP supplied the lin*/
    	    s_copy(next_cmd, cmdstr);
    	    next_cmd[0] = EOS;
    	    }
	if (NULLSTR(cmdstr))			/* if null input...	*/
	    continue;				/* get command again	*/
	history_save (cmdstr);
    	code = prccmd(cmdstr, &primctx);	/* process the command	*/
    	}
    while ( (code != DO_ABORT) && (code != DO_CONTINUE));
    MOVE_STRUCT(saved_fil, prcfil);		/* restore prcfil	*/
    cmd_mode = saved_mode;			/* restore old mode	*/
    usermode = saved_user;
    curproc = saved_cur;			/* restore the cur proc	*/
    pstdo_fil = saved_pstd;			/* go back to old stdout */
    set_string (skey_gbl, skey_save);		/* restore status	*/
    IVAL(*sfi_gbl,0) = sfi_save;
    return(code);
    }

/*	int_find - Find an internal proc the specified name
 *
 *	returns the address of its ipblock or NULL
 */
FUNCTION struct IPBLOCK *int_find
(
    struct CONTXT	*ctx,		/* in: proc context 		    */
    TEXT 		name[]		/* in: name of proc to find	    */

 )
    {
    struct IPBLOCK	*ipbpt;
    struct CONTXT	*tmpctx;

/* keep looking in outer nested contexts until we're not in an internal procs */
    tmpctx=ctx;
    for (tmpctx=ctx;(s_equal((*tmpctx).pdf.libr, "/LOCAL/")); tmpctx=(*tmpctx).backlink)
    	{
	if ((*tmpctx).int_procs == NULL)
	    continue;
	for (ipbpt = (struct IPBLOCK *) (*tmpctx).int_procs; ipbpt != NULL; ipbpt = (*ipbpt).flink)
	    if (s_equal ((*ipbpt).procname, name))
		return(ipbpt);
    	}

    if ((*tmpctx).int_procs == NULL)		/* check the first non-local */
	return(NULL);
    for (ipbpt = (struct IPBLOCK *) (*tmpctx).int_procs; ipbpt != NULL; ipbpt = (*ipbpt).flink)
	if (s_equal ((*ipbpt).procname, name))
	    return(ipbpt);
    return (NULL);
    }

/*	make_gbl. Move values of all PARMs to corresponding globals.
 *		  This is "execution" of a GLOBAL PDF.
 *
 *	NOTE: 	New variables are inserted to the global symbol table
 *		in alphabetically ascending order.
 *
 *	We don't have to chk_vector here: the declaration of
 *	a PARM in a GLOBAL PDF makes sure that the PARM and
 *	the corresponding global are compatible.  (See gbl_defaults
 *	in DECLARE.C.)
 */
FUNCTION static CODE make_gbl
(
    struct CONTXT	*pctx		/* in/out: global proc context	*/
 )
    {
    IMPORT struct SYMTAB glbtab;	/* global symbol table		*/
    IMPORT struct CONTXT primctx;	/* level 0 context		*/

    struct  VARIABLE	*pv;		/* current PARM			*/
    struct  VARIABLE	*ppv;		/* previous PARM in parmst	*/
    struct  VARIABLE	*lgv;		/* last global in glbtab	*/
    struct  VARIABLE	*gv;		/* current global		*/
    struct  DEFPDF	*defpdf;

    defpdf = NULL;
    ppv = (struct VARIABLE *) &(*pctx).parmst.link;	/* previous pointer */
    for (pv=(*pctx).parmst.link; pv != NULL; )
	{
	gv = lookex (&glbtab, (*pv).v_name);
	if (gv == NULL)				/* define new global	*/
	    {
	    if (lookex (&primctx.locst, (*pv).v_name) != NULL)
		{
		tmmsg (PROCFAIL,
		"Global variable name '%s' conflicts with level 0 variable.",
		       "TAE-LOCCONFLICT", (uintptr_t)(*pv).v_name,0,0,0,0);
		ppv = pv;				/* previous PARM  */
		pv = (*pv).v_link;			/* current PARM	  */
		continue;
		}
            (*ppv).v_link = (*pv).v_link;	/* unlink from parmst	*/
	    lgv = find_slot((*pv).v_name, &glbtab); /* find slot in tbl */
    	    if (lgv == NULL)
    		{
    		(*pv).v_link = glbtab.link;
    		glbtab.link = pv;		/* link at beginning	*/
    		}
    	    else
    		{
    		(*pv).v_link = (*lgv).v_link;
		(*lgv).v_link = pv;		/* link into glbtab	*/
    		}
	    deltut(pv);				/* delete tutor extent	*/
	    (*pv).v_class = V_GLOBAL;
	    (*pv).v_protect = FALSE;
	    (*pv).v_intrinsic = FALSE;
	    (*pv).v_implicit = FALSE;
	    (*pv).v_refcnt = 0;
	    if (defpdf == NULL)			/* build DEFPDF		*/
	        {
		defpdf =
		    (struct DEFPDF *) tae_alloc (1, sizeof(struct DEFPDF));
		(*defpdf).refcount = 0;
		MOVE_STRUCT ((*pctx).pdf, (*defpdf).pdf);
		}
	    (*defpdf).refcount ++;
	    (*pv).v_pdf = defpdf;
	    pv = (*ppv).v_link;			/* next parm; ppv same	*/
	    }
	else
	    {
	    deep_value_copy (pv, gv, (*pv).v_name, (*gv).v_name);
	    ppv = pv;				/* previous PARM	*/
	    pv = (*pv).v_link;			/* current PARM		*/
	    }
	}
    return (DO_SUCCESS);
    }

/*	deep_value_copy
 *
 *	Does a value copy from source variable to
 *	destination variable, including qualifiers
 *	to any level.
 *
 *	The return code here is a chk_vector return code
 *	or SUCCESS.
 *
 */
FUNCTION CODE deep_value_copy
(
    	struct VARIABLE	*sv,			/* in: source variable	*/
        struct VARIABLE *dv,			/* in: dest variable	*/
        TEXT		sname[],		/* in: source name	*/
        TEXT		dname[]		/* in: dest name	*/

 )
    {
    CODE		code, worst_code;
    struct VARIABLE	*dvq;			/* dest qualifier	*/
    struct VARIABLE	*svq;			/* source qualifier	*/
    TEXT		qsname[STRINGSIZ+1];
    TEXT		qdname[STRINGSIZ+1];

    dv = RESOLVE(dv);
    code = chk_vector (dv, (*sv).v_type, (*sv).v_cvp, (*sv).v_count, FALSE);
    if (code == SUCCESS)
        set_value (dv, (*sv).v_cvp, (*sv).v_count);
    else
	{
	tmmsg (PROCFAIL,
		"Variable '%s' not compatible with variable '%s'.",
	       "TAE-MISMATCH", (uintptr_t)dname, (uintptr_t)sname,0,0,0);
        return (code);
	}

    /*  Now do qualifiers (the "deep" part)				*/

    worst_code = SUCCESS;
    for (dvq = (*dv).v_qualst.link; dvq != NULL;  dvq = (*dvq).v_link)
    	{
    	svq = lookex (&(*sv).v_qualst, (*dvq).v_name);
	if (svq == NULL)
	    continue;		/* exact structure match not required	*/

	/* build variable names for recursive call to deep_value_copy	*/

	s_copy (sname, qsname);
	s_append (".", qsname);
	s_append ((*svq).v_name, qsname);
	s_copy (dname, qdname);
	s_append (".", qdname);
	s_append ((*dvq).v_name, qdname);

	code = deep_value_copy 	(svq, dvq, qsname, qdname);
	if (code != SUCCESS)
            worst_code = code;
    	}
    return (worst_code);
    }

/*
 *	outputs.   Set output values from a process.
 *
 *	A process has sent a parblk containing output values.
 *
 */

FUNCTION CODE outputs
(
    struct CONTXT	*procctx,	/* in: proc context		*/
    struct PARBLK	*parblk	/* in: PARBLK from process	*/

 )
    {
    COUNT		i;
    struct VARIABLE	*v;
    CODE		code;

    /* Strategy: the 'candidates' for output are global refs and parameters
     * of TYPE=NAME.  For each candidate, check to see if the parblk
     * contains a corresponding value.
     */

    for (i=0; i < (*procctx).numrefs; i++)
	{
	v = (*procctx).refs[i];
        code = set_outval(v, parblk);
	if (code != SUCCESS)
	    goto outval_error;
	}
    for (v=(*procctx).parmst.link; v != NULL; v=(*v).v_link)
        {
	if ((*v).v_type == V_NAME)
	    {
	    code = set_outval(v, parblk);
	    if (code != SUCCESS)
		goto outval_error;
	    }
	}
    return (SUCCESS);

outval_error:
    tmmsg(PROCFAIL, "Invalid output value for '%s' in proc '%s'.",
	  "TAE-INVOUT", (uintptr_t)(*v).v_name, (uintptr_t)(*procctx).pdf.name,
	  0,0,0);
    return(FAIL);
    }

/*
 *	 prsstt - parse statement and build symbol table for this statement.
 *
 *	For context reasons, we don't do substitution here; the impact
 *	is that introductory commands cannot have substitution if
 *	HELP is to work.
 *
 */

FUNCTION CODE prsstt
(
    TEXT		sttmt[CMDLINSIZ+1],	/* in/out:  PDF statement*/
    struct ITRCMD	**itrcmd,		/* out: ITRCMD for cmd	 */
    struct SYMTAB	*pdfstb		/* out: cmd symbol table */

 )
    {
    struct SYNBLK	sb;			/* syntax block 	*/
    TEXT		cmd[FSPECSIZ+1];
    TEXT		subcmd[SUBCMDSIZ+1];
    TEXT		label[LABELSIZ+1];
    CODE		code;

    code = cmd_parse(&sb, sttmt, label, cmd, subcmd);
    if (code != SUCCESS)
        goto pd_synerr;
    *itrcmd = intrin(cmd);			/* find command in tables*/
    if (*itrcmd == NULL)
        goto pd_niter;
    *itrcmd = itrsub(subcmd, *itrcmd);		/* find subcommand 	*/
    if (*itrcmd == NULL)
        goto pd_niter;
    if (memtab((**itrcmd).partab, (**itrcmd).numprm, pdfstb) != SUCCESS)
        return(FAIL);
    if (updtab(pdfstb, &sb) != SUCCESS)		/* update from cmd string*/
        return(FAIL);
    return(SUCCESS);

pd_synerr:
    tmmsg(PROCFAIL, sb.errmsg, "TAE-FMTERR",0,0,0,0,0);
    return(FAIL);

pd_niter:
    tmmsg(PROCFAIL, "Unrecognized command '%s'.",
	  "TAE-UNRECCMD", (uintptr_t)cmd,0,0,0,0);
    return(FAIL);
    }

/*
 *	set_outval.    Set output variable if a corresponding
 *	value exists in the PARBLK.
 */

FUNCTION static CODE set_outval
(
    struct VARIABLE	*v,		/* in/out: VARIABLE to set	*/
    struct PARBLK	*parblk	/* in: PARBLK from process	*/

 )
    {
    struct VARIABLE	*pv, *rv;
    CODE		code;

    pv = lookex(&(*parblk).symtab, (*v).v_name);
    if (pv == NULL)
        return (SUCCESS);
    rv = RESOLVE(v);
    code = chk_vector(rv, (*pv).v_type, (*pv).v_cvp, (*pv).v_count, FALSE);
    if (code != SUCCESS)
	return (FAIL);
    code = set_value(rv, (*pv).v_cvp, (*pv).v_count);
    if (code != SUCCESS)
	return (FAIL);
    return (SUCCESS);
    }

/*
 *	 opnpdf - find PDF and open it.
 *
 *	Return code:
 *
 *	SUCCESS -- pdf opened successfully.
 *	FAIL --  pdf cannot be opened
 *
 *	Upon successful return, (*pctx).pdf is the FSBLOCK of the PDF.
 */

FUNCTION CODE opnpdf
(
    struct CONTXT	*parctx,	/* in: parent proc context		*/
    struct CONTXT	*pctx,		/* in/out: proc context			*/
    TEXT		cmdstring[],	/* in: command string: may be a file spec */
    struct SFILE	*file		/* out: the file control block		*/

 )
    {
    CODE		code;
    struct CONTXT	*ctx;
    TEXT		errstr[STRINGSIZ+1];
    struct IPBLOCK	*ipbpt;

/* before hierarchy search, see if the proc is internal		*/
    if ((ipbpt = int_find (parctx, cmdstring)) != NULL)
    	{		/* first find the file spec ("/LOCAL/" --> internal ) */
        for (ctx = parctx; (s_equal((*ctx).pdf.libr,"/LOCAL/")); ctx = (*ctx).backlink);
	code = f_opnblk (file, PDFLUN, &(*ctx).pdf, F_READ);  	/* open it   */
	if (code != SUCCESS)
	    {
	    tmmsg (PROCFAIL, "Error finding internal proc. Code '%s'.",
		   "TAE-INTPDF", (uintptr_t)(*file).errmsg,0,0,0,0);
	    return (FAIL);
	    }
    	f_setpos (file, &(*ipbpt).position);	/* position to int'l proc   */
    	(*file).posctx.possav = TRUE;
    	s_copy ((*ipbpt).procname, (*pctx).pdf.name); /* retain file name	    */
    	s_copy ("/LOCAL/", (*pctx).pdf.libr); 	/* flag for local	    */
    	(*pctx).pdf_line = 0;			/* line # relative to int'l proc */
    	return (SUCCESS);
    	}
    code = hierarchy(file, cmdstring, PDF_TYPE, PDFLUN, &(*pctx).pdf, errstr);
    if (code == SUCCESS)
	{
	if (f_isterm (file)) 			/* if terminal 	           */
	    code = FAIL;			/* request TAE-PROCSYN err */
	if (code == SUCCESS)			/* TBD: fix this kludge	*/
	    {
 	    (*pctx).parfile = IsParFile (file);
            return(SUCCESS);
	    }
    	}
    if (code == FAIL)	/* syntax error in file spec: */
	{
	tmmsg (PROCFAIL, "Error in proc name at or near '%s'.",
	       "TAE-PROCSYN", (uintptr_t)errstr,0,0,0,0);
	return (FAIL);
	}
    else if (code == F_FILERR)
	{
	tmmsg(PROCFAIL, "Proc '%s' in '%s':  %s.",
	      "TAE-PDFRD", (uintptr_t)(*pctx).pdf.name,
	      (uintptr_t)(*pctx).pdf.libr,
	      (uintptr_t)(*file).errmsg,0,0);
	return (FAIL);
	}
    else
	{
	tmmsg(PROCFAIL, "Unable to locate proc '%s'.", "TAE-NOPROC",
	      (uintptr_t)cmdstring,0,0,0,0);
	return (FAIL);
	}
    }

/*
 *	opnsav - open (actually, reopen) a proc and position to the previously
 *	saved position.
 *
 *	If pdf.libr is "\LOCAL\", the proc is internal, and we backlink
 */

FUNCTION CODE opnsav
(
    struct CONTXT	*pctx		/* in/out: proc context			*/

 )
    {
    IMPORT struct SFILE	prcfil;		/* proc file context			*/

    CODE		code;
    TEXT		buf[STRINGSIZ+1];
    struct CONTXT	*ctx;

/* first find the pdf spec */
    for (ctx = pctx; (s_equal((*ctx).pdf.libr,"/LOCAL/")); ctx = (*ctx).backlink);
    code = f_opnblk(&prcfil, PDFLUN, &(*ctx).pdf, F_READ);
    if (code != SUCCESS)		/* reopen the proc		*/
	return(code);
/* now use the file position from the original, possibly internal, proc	*/
    f_setpos(&prcfil, &((*pctx).prcpos));	/* posit to where we left off		*/
    prcfil.posctx.possav = TRUE;	/* mark file position known		*/
    (*pctx).prcpos.possav = FALSE;	/* posit no longer saved		*/
    code = f_read(&prcfil, buf);	/* & then to next record		*/
    return(code);
    }

/*
 *	pdftab - build symbol table from PDF.
 *	If a GLOBAL PDF, the parm_do function will define the globals along
 *	the way.
 */

FUNCTION CODE pdftab
(
    struct CONTXT	*pctx,		/* in:  proc context			*/
    struct SFILE	*file		/* in/out: PDF file control block	*/

 )
    {
    IMPORT struct CONTXT *curproc;
    IMPORT struct VARIABLE *sfi_gbl;

    TEXT		sttmt[CMDLINSIZ+1];	/* PDF statement		*/
    CODE		cmdcod;		/* command code				*/
    COUNT		records;	/* number records read for statement	*/
    COUNT		num_prec;	/* # comment, null lines preceding sttmt*/
    struct CONTXT	*save_curproc;
    CODE		startmode;	/* init search mode: SUB_SEARCH or NOT_SPECIAL*/
    CODE		code;

    startmode = (*pctx).special;
    code      = SUCCESS;
    save_curproc = curproc;
    curproc   = pctx;			/* so errors reported correctly	*/
    while (FOREVER)
	{
	if ((*pctx).parfile)  		/* executing PAR file? */
	    {
            code = prc_par_file (file, pctx);
            if (code != SUCCESS)
    		goto fail;
            break;
	    }
	if (getpst(file, sttmt, &records, &num_prec, &(*pctx).prcpos)
		    != SUCCESS)			/* get statement	*/
	    goto fail;
	(*pctx).pdf_line += num_prec;		/* adj for comment,null lines */
	cmdcod = prccmd(sttmt, pctx);		/* process the statement*/
	if ((*pctx).compiled)			/* if PROCESS-COMPILED, etc.	*/
	    {
	    code = prc_compiled(file, pctx);	/* PDF is compiled -- process it*/
	    if (code != SUCCESS)
		goto fail;
	    break;
	    }
 	(*pctx).pdf_line += records - num_prec;
	if (IVAL(*sfi_gbl,0) < 0)
	    goto fail;
        if ((*pctx).inbody || cmdcod == DO_RETURN)
    	    break;					/* end of declarations	*/
        if (cmdcod != DO_SUCCESS)
	    goto fail;
	}
    (*pctx).body_line = (*pctx).pdf_line;
    curproc = save_curproc;				/* back to prev context	*/
    if (startmode != SUB_SEARCH  &&  startmode != TUTOR_ATTEMPT  &&
	startmode != COMPILING)
	{
	if (NULLSTR((*pctx).subcmd)  &&  (*pctx).special != SUB_SEARCH)	/* subcommand present?	*/
	    {
	    if (!(*pctx).subfnd && (*pctx).subs)
		{
		  tmmsg(PROCFAIL, "Subcommand required.", "TAE-SUBREQ",0,0,0,0,0);
		code = FAIL;
		}
	    }
	else
	    if ((*pctx).special == SUB_SEARCH)		/* if mode changed by subcmd_do*/
		{
		(*pctx).special = NOT_SPECIAL;
		code = FAIL;
		}
	    else if (!(*pctx).subfnd)			/* and not found...	*/
		{
		tmmsg(PROCFAIL, "Unrecognized subcommand '%s'.", "TAE-UNRECSUB",
		      (uintptr_t)(*pctx).subcmd,0,0,0,0);
		code = FAIL;
		}
	if (code == FAIL)
	    msg_subs(pctx);				/* disp avail subcmds	*/
	}
    else if (startmode == TUTOR_ATTEMPT)
	if (NULLSTR((*pctx).subcmd)  &&  (*pctx).special != SUB_SEARCH)	/* subcommand present?	*/
	    {
	    if (!(*pctx).subfnd && (*pctx).subs)
		(*pctx).special = SUB_SEARCH;		/* force tutor subc display*/
	    }
    return(code);

fail:
    curproc = save_curproc;				/* back to prev context	*/
    return (FAIL);
    }

/* msg_subs - display a list of available subcommands.
 */

FUNCTION static VOID msg_subs
(
    struct CONTXT	*ctx		/* in:  proc context			*/

 )
    {
    struct SUBCMD	*s;
    TEXT		buf[STRINGSIZ+1];
    BOOL		still_adding;
    COUNT		len;

    static TEXT		inibuf[] = "Valid subcommands:  ";

    still_adding = TRUE;
    s_copy(inibuf, buf);
    for (s = (*ctx).subptr; s != NULL; s = (*s).link)
      if (still_adding) {
	    if (s_length((*s).name) + s_length(buf) + 5 > STRINGSIZ)
		{
		s_append("...", buf);
		still_adding = FALSE;
		}
	    else
		{
		s_append((*s).name, buf);
		s_append(", ", buf);
		}
      }
    if (still_adding  &&  (*ctx).subptr != NULL)
	{
	len = s_length(buf);			/* strip trailing ", "		*/
	buf[len-2] = EOS;
	}
    if (!s_equal(buf, inibuf))
      tmmsg(PROCFAIL, buf, "TAE-SUBAVL",0,0,0,0,0);
    return;
    }

/*
 *	procedure - interpret procedure.
 */

FUNCTION static CODE procedure
(
    struct CONTXT	*pctx,		/* in:  context for this procedure	*/
    struct ECB		*ecbi		/* in:  event blk for operator interr.	*/

 )
    {
    IMPORT struct SFILE	prcfil;			/* proc file context		*/
    IMPORT struct VARIABLE *sfi_gbl, *skey_gbl;
    TEXT		cmdstr[CMDLINSIZ+1];	/* command string		*/
    struct VARIABLE	*on;			/* onfail VARIABLE		*/
    CODE		cmdcod;			/* command return code		*/
    COUNT		records;
    COUNT		num_prec;	/* # comment, null lines preced sttmt	*/
    COUNT		onfail;			/* _ONFAIL index to execute	*/
    CODE		code;

    on = lookex(&((*pctx).locst), "_ONFAIL");	/* _ONFAIL VARIABLE	*/
    code = cmdcod = DO_SUCCESS;
    while (FOREVER)
	{
	if ((e_occur(ecbi) && interrupt (pctx) == DO_ABORT)
		|| cmdcod == DO_ABORT)
	    {
    	    e_clear (ecbi);
	    if ((*on).v_count > 1)	/* this proc handles ABORT? */
		onfail = 1;
 	    else
    	        {
	        IVAL (*sfi_gbl, 0) = -10;		/* set abort indicator	*/
	        set_string (skey_gbl, "TAE-ABORT");	/* set abort status	*/
	        return (DO_ABORT);		        /* pass up 		*/
		}
	    }					/* proc handle it	    */
	else if (cmdcod != DO_SUCCESS &&  IVAL(*sfi_gbl,0) < 0)
    	    onfail = 0;					/* proc failed 		*/
        else
    	    onfail = -1;				/* command executed ok	*/
        if (onfail >= 0)				/* execute _ONFAIL?	*/
	    {
	    s_copy (SVAL(*on, onfail), cmdstr);
	    if (chk_onfail(cmdstr) != SUCCESS)		/* check command	*/
		return (DO_CHECK);			/* quit if bad command	*/
	    (*pctx).onfailcmd = TRUE;			/* set executing onfail	*/
	    cmdcod = prccmd(cmdstr, pctx);		/* process the command	*/
	    if (cmdcod == DO_CHECK && IVAL(*sfi_gbl,0) < 0)
		return (DO_CHECK);
	    }
	else						/* execute next command	*/
	    {
	    (*pctx).onfailcmd = FALSE;			/* clear onfailcmd indicator */
	    if (getpst(&prcfil, cmdstr, &records, &num_prec, &(*pctx).prcpos)
			!= SUCCESS)			/* get cmd line */
    		return (DO_CHECK);			/* terminate if error	*/
	    (*pctx).pdf_line += num_prec;	/* adj for comment, null lines*/
	    cmdcod = prccmd(cmdstr, pctx);		/* process the command	*/
	    (*pctx).pdf_line += records - num_prec;
	    }
        if (cmdcod == DO_STOP)
    	    return (DO_STOP);
        else if (cmdcod == DO_RETURN)			/* convert for invoker	*/
    	    return (DO_CHECK);

	/* NOTE: all other return codes are handled as
	   DO_CHECK on next interation	*/
	}
    }

#ifndef PROCESS_CNP
/*
 *	process - run a TAE process.
 *
 *	This function sends a message received handshake to the subprocess
 *	if the message received was of type M_HLOGMSG.  This allows application
 *	software linked before TAE V1.2 to run without the handshake, since
 *	the older software uses the message code M_LOGMSG.
 *
 *	(The compilation of this function may be suppressed by
 *	defining PROCESS_CNP, in which case a host-dependent version
 *	may be written in a process.cnp module, for example, UNIX.)
 */

FUNCTION CODE process
(
    struct CONTXT	*pctx,		/* in:  proc context			*/
    struct ECB		*ecbi,		/* in/out: event blk for interrupts	*/
    struct CODE_ERR	*(*errmsg)	/* out: error msg if CODE is FAIL, else "" */

 )
    {
    IMPORT CODE		run_type;	/* ASYNC or BATCH or INTER		*/
    IMPORT CODE		menu_screen;	/* menu screen status indicator		*/
    IMPORT CODE		usermode;	/* user mode: CMDMODE or MENUMODE	*/
    IMPORT struct VARIABLE *skey_gbl, *sfi_gbl;
#ifdef VAX_VMS
    IMPORT TEXT 	*dcl_string;	/* ptr to dcl string to run		*/
    TEXT		*value[1];	/* scrach value vector			*/
#endif
    struct LARGE_PARBLK	parblk;		/* message block to send to subprocess	*/
    struct TCB		tcb;		/* task control block (for c_ package)	*/
    CODE		comcod;		/* task wait completion code		*/
    CODE		status;
    TEXT		exespec[FSPECSIZ+1];
    struct FSBLOCK	fsblock;
    CODE		code, code2, ret_code;
    TEXT		errstr[STRINGSIZ+1];
    TEXT		deflibe[FLIBRSIZ+1];
    struct CONTXT	*ctx;
    BOOL		asytut_req;	/* tutor for async job ? (false here) */
    struct VARIABLE	*_tutor;
    CODE		packageFlag;	/* used to package valid lists for    */
					/* SELFTUTOR			      */

/* error messages from function process().  We have them here because
   process cannot output them, having no standard output to output them to
 */

    static struct CODE_ERR er_over=
	{"Parameter values overflow capacity of message to block.",
	"TAE-PSETOVER", 0};

    static struct CODE_ERR er_ini=
    	{"Unable to initiate process; host code = %d.",
	"TAE-PRCSINI", 0};

    static struct CODE_ERR er_notfnd =
	{"Process cannot be found or activated; host code = %d.",
	"TAE-PRCSACT", 0};

    static struct CODE_ERR er_term=
    	{"Abnormal process termination; host code = %d.",
	"TAE-PRCSTRM", 0};

    static struct CODE_ERR er_imsg=
    	{"Error sending initiation message to process; host code = %d.",
	"TAE-IMSGERR", 0};

    static struct CODE_ERR er_rcv=
    	{"Error receiving message from process; host code = %d.",
	 "TAE-RCVERR", 0};

    static struct CODE_ERR er_par=
    	{"Message from process incorrectly formatted.",
	 "TAE-PARBLK", 0};

    static struct CODE_ERR er_snd=
    	{"Error sending message to process, host code = %d.",
	 "TAE-SNDERR", 0};

/* first make sure we get a good library name by finding the parent pdf */
    for (ctx = pctx; (s_equal((*ctx).pdf.libr,"/LOCAL/")); ctx = (*ctx).backlink);
    s_copy ((*ctx).pdf.libr, deflibe);
    f_crack((*pctx).exe_spec, deflibe, (*pctx).pdf.name,
             EXE_TYPE, &fsblock, errstr);	/* apply defaults...	   */
    f_spec(&fsblock, exespec);			/* build file spec to run  */
    zero_block ((GENPTR) &parblk, (GENPTR) parblk.pool - (GENPTR) &parblk);
    parblk.last = FALSE;
    parblk.msgtyp = M_INIPAR;			/* initial parameter block */
    _tutor = lookex (&(*pctx).locst, "_TUTOR");
    packageFlag = (_tutor && IVAL(*_tutor,0)) ? VM_VALID : 0;
    if (package(pctx, &parblk, sizeof parblk.pool, packageFlag) != SUCCESS)
	goto rp_overr;
    code = c_act(&tcb, exespec);		/* activate task	   */
    if (code !=SUCCESS) goto rp_tiner;		/* error in queing for activation */
    code = c_snds(&tcb, (GENPTR) &parblk, parblk.blksiz);  /* send init msg blk*/
    if (code != SUCCESS) goto rp_msger;
    e_clear(&tcb.ecbrcv);			/* clear receive efn       */

/* Task started.  Now wait on completion, event, or message.
 * NOTE: We queue to receive the next message from subtask only
 * after a send is complete, or after a message is received from it.
 * So a subtask can not send a message to tm until it has read the
 * block sent to it from tm. (An attempt to do so will hang the subtask).
 */

    *errmsg = NULL;				/* no err msg yet		*/
    ret_code = DO_CHECK;
    while (FOREVER)
	{
    	e_wait(4, &tcb.ecbsnd, &tcb.ecbrcv, &tcb.ecbtsk, ecbi);
			/* wait on send, receive, completion, or event		*/

	if (e_occur(&(tcb.ecbtsk)))		/* if task completion, no more loop */
	    {
	    if (usermode == MENUMODE)		/* if process activate by menu */
		menu_screen = PROMPT_PAINT;	/* prompt before repaint menu  */
#ifdef VAX_VMS
	    if (dcl_string != NULL)
		{				/* DCL command finished		*/
		value[0] = &(tcb.statmsg[2]);   /* (ignore the %x on front)	*/
		set_value(skey_gbl, (GENPTR)value, 1);	/* move $STATUS to $SKEY	*/
		IVAL(*sfi_gbl,0) = (tcb.compcd == C_NORMAL) ? 1 : -1;
		break;
		}
#endif
	    if (ret_code == DO_ABORT || tcb.compcd == C_NORMAL)
	        break;			/* normal or expected abnormal     */
	    goto rp_wterr;		/* unexpected abnormal termination */
	    }
	else if (e_occur(ecbi))			/* operator attention */
	    {
	    e_clear (ecbi);			/* clear the event    */
	    if ((*pctx).interrupt)		/* interrupt allowed? */
    		{
		c_suspend(&tcb);
		code = interrupt (pctx);	/* do interrupt commands */
		if (code == DO_ABORT)
		    {
		    /* here we initiate an abort but continue the while loop
		       so that messages from exit handlers in the process
		       will be received (especially, output variables).
		    */
		    if (c_iabort(&tcb) != SUCCESS)		/* initiate abort   */
			m_put("Unable to abort process; host code = %d.",
			      "TAE-PRCSABT", tcb.hostcode);
		    e_clear(ecbi);	/* so nested levels won't hit proc int	*/
		    IVAL (*sfi_gbl, 0) = -10;
		    set_string (skey_gbl, "TAE-ABORT");
		    ret_code = DO_ABORT;			/* return code	*/
		    }
		else
		    c_resume(&tcb);
    		}
	    }
	else if (e_occur(&tcb.ecbsnd))			/* if a send 	    */
	    {
	    e_clear(&tcb.ecbsnd);			/* clear  ECB       */
	    code = c_recs(&tcb, (GENPTR)&parblk, sizeof parblk);
	    if (code != SUCCESS) goto rp_rcver;
	    }
	else if (e_occur(&tcb.ecbrcv))			/* a message received */
	    {
	    e_clear(&tcb.ecbrcv);
	    makeabs(&parblk.symtab, parblk.pool);	/* make pointers absolute*/
	    if (chk_parblk (&parblk) != SUCCESS)
	    	goto rp_badparblk;
	    if (parblk.msgtyp == M_FULLPDF  ||  parblk.msgtyp == M_SUBPDF)
		{
    		if (run_type == ASYNC)
    		    {
#ifdef TAE_ASYNC
    		    code = get_pblk_remote (pctx, &parblk, errmsg);
						/* get parms from parent mon */
    		    if (code != SUCCESS) goto rp_rmerr;
#endif
    		    }
    		else
		    {
		    asytut_req = FALSE;			/* tutor for sync proc */
		    dynget(pctx, &parblk, sizeof ( parblk.pool ),
                                    asytut_req);	/* dynamic parameter 	    */
		    }
		if (parblk.msgtyp == M_DYNEXIT)		/* see change log   */
		    parblk.msgtyp = M_KILLED;		/* for comments     */
		code = c_snds(&tcb, (GENPTR)&parblk, parblk.blksiz);
		if (code != SUCCESS) goto rp_dmser;
		}
	    else if (parblk.msgtyp == M_COMMAND)	/* execute a command line */
		{
		dyncommand (pctx, &parblk, sizeof parblk.pool);
		code = c_snds(&tcb, (GENPTR)&parblk, parblk.blksiz);
		if (code != SUCCESS) goto rp_msger;
		}
	    else if (parblk.msgtyp == M_LOGMSG  ||  parblk.msgtyp == M_HLOGMSG)
	  	{
		logmsg(pctx, &parblk);		/* log the message	*/
		if (parblk.msgtyp == M_HLOGMSG)
		    {				/* handshake		*/
		    parblk.msgtyp = M_CONTINUE;
    		    makerel(&parblk.symtab, parblk.pool);   /* make relative */
		    code = c_snds(&tcb, (GENPTR)&parblk, parblk.blksiz);
		    if (code != SUCCESS) goto rp_msger;
		    }
		else				/* for old applic compatibility	*/
		    {
		    code = c_recs(&tcb, (GENPTR)&parblk, sizeof parblk);
		    if (code != SUCCESS) goto rp_rcver;
		    }
		}
	    else if (parblk.msgtyp == M_OUTPUT)
	        {
	        outputs(pctx, &parblk);		/* apply output values	    */
		code = c_recs(&tcb, (GENPTR)&parblk, sizeof parblk);
		if (code != SUCCESS) goto rp_rcver;
		}
	    else
		{
		dynamic_ins (pctx, &parblk);	/* installation exit	    */
		code = c_recs(&tcb, (GENPTR)&parblk, sizeof parblk);
		if (code != SUCCESS) goto rp_rcver;
		}
	    }
	}
    return (ret_code);

rp_overr:
    *errmsg = &er_over;
    return (FAIL);

rp_tiner:
    *errmsg = &er_ini;
    er_ini.code = tcb.hostcode;
    return(FAIL);

rp_wterr:
    if (tcb.compcd == C_ACTERR)
    	{
    	*errmsg = &er_notfnd;
    	er_notfnd.code = tcb.hostcode;
    	}
    else
    	{
    	*errmsg = &er_term;
    	er_term.code = tcb.hostcode;
    	}
    return(FAIL);

rp_msger:
    *errmsg = &er_imsg;
    er_imsg.code = tcb.hostcode;
    c_abort(&tcb);
    return(FAIL);

rp_rcver:
    *errmsg = &er_rcv;
    er_rcv.code = tcb.hostcode;
    c_abort(&tcb);
    return(FAIL);

rp_badparblk:
    *errmsg = &er_par;
    c_abort(&tcb);
    return(FAIL);

rp_dmser:
    *errmsg = &er_snd;
    er_snd.code = tcb.hostcode;
    c_abort(&tcb);
    return(FAIL);

rp_rmerr:		/* error on getting parms from remote monitor */
    c_abort(&tcb);
    return(FAIL);
    }
#endif

/*	run_proc - run a proc.
 *
 *	Note that if tutor runs from deep level, run_proc will not
 *	produce a session log of the parameters supplied -- this is
 *	because we only log primary level.
 */

FUNCTION CODE run_proc
(
    struct CONTXT	*pctx		/* in:  proc context			*/

 )
    {
    IMPORT struct CONTXT  *curproc;	/* current proc context	(for errs)	*/
    IMPORT struct ECB	ecbi;		/* event block for operator interrupts	*/
    struct CODE_ERR	*errmsg;	/* ptr to an errmsg defined statically */
    CODE		code;
    CODE		code1, code2;
    static	int processRunning = FALSE;

    code1 = code2 = SUCCESS;    /* in case batch mode: they don't get set */

#ifdef SESSION_LOG
    if ((*pctx).prclevel <= 1)			/* if activating from level 0	*/
	slproc(pctx);				/* log the activation		*/
#endif
    pa_ins (pctx);				/* installation exit	*/
    code = DO_CHECK;

#if defined(VICAR_BATCH_LOG) && defined(VAX_VMS)
    if (run_type != BATCH)
    {
        code1 = chg_stdout(pctx);                       /* set new stdout   */
        if (code1 != SUCCESS)
            goto reset;                         /* error exit           */
    }
#else
    code1 = chg_stdout(pctx);                   /* set new stdout       */
    if (code1 != SUCCESS)
	goto reset;				/* error exit		*/
#endif

    if ((*pctx).proctype == Y_PROCEDURE)	/* if a procedure	*/
	{
	curproc = pctx;				/* for error messages	*/
	code = procedure(pctx, &ecbi);		/* interpret procedure	*/
	curproc = (*pctx).backlink;		/* nest up		*/
	}
    else if ((*pctx).proctype == Y_PROCESS)	/* proc is a process	*/
	{
	if (processRunning)
	    {
	    tmmsg (PROCFAIL,
		   "Attempt to nest process execution.", "TAE-NOSYNC",0,0,0,0,0);
	    return (DO_CHECK);
	    }
	processRunning = TRUE;
	code = process(pctx, &ecbi, &errmsg);	/* run the process	*/
	processRunning = FALSE;
	}
    else if ((*pctx).proctype == Y_GLOBAL)	/* proc is GLOBAL	*/
   	code = make_gbl (pctx);			/* make parms globals	*/
    else if ((*pctx).proctype == Y_PARMSET)
	code = action_run (pctx);		/* honor ACTION=	*/

reset:
    code2 = re_stdout(pctx);			/* reset stdout		*/
    pt_ins (pctx);				/* installation exit	*/
#ifdef SESSION_LOG
    if ((*pctx).prclevel <= 1)			/* if activated from level 0	*/
	slterm();				/* log the termination		*/
#endif
    if (code1 != SUCCESS || code2 != SUCCESS)	/* stdout related error	*/
	return(DO_CHECK);
    if ((*pctx).proctype == Y_PROCESS && code ==FAIL)	/* if process was run, saved errmsg */
      tmmsg(PROCFAIL, (*errmsg).text, (*errmsg).key, (uintptr_t)(*errmsg).code,0,0,0,0);

    /*
     *	A proc only returns one of the following codes:
     *
     *	   DO_STOP means "return to primary level".
     *	   DO_CHECK means invoker must check the $SFI/$SKEY.
     *	   DO_ABORT means pi mode ABORT has been done.
     *
     *	The following code is for safety to enforce this rule.
     *
     *	Note that a proc does not have the capability to return DO_RETURN
     *	or DO_SUCCESS -- these are special codes reserved for intrinsics.
     */

    if (code == DO_STOP || code == DO_ABORT)
        return (code);
    return (DO_CHECK);
    }


text: start msiexec /uninstall MyProduct.msi

redpajama_set_name: RedPajamaGithub


text:
u = User.new(
    username: "admin",
    email: "admin@example.com",
    password: "1234",
    password_confirmation: "1234",
    admin: true
)
u.skip_confirmation!
u.save!


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Schweiz. Z. Pilzk. 49(9): 120 (1971)

#### Original name
Dermoloma coryleti Singer & Clémençon

### Remarks
null


text:
class CMEModule:
    '''
        Uses WMI to gather information on all endpoint protection solutions installed on the the remote host(s)
        Module by @byt3bl33d3r

    '''

    name = 'enum_avproducts'
    description = 'Gathers information on all endpoint protection solutions installed on the the remote host(s) via WMI'
    supported_protocols = ['smb']
    opsec_safe= True
    multiple_hosts = True

    def options(self, context, module_options):
        pass

    def on_admin_login(self, context, connection):
        output = connection.wmi('Select * From AntiSpywareProduct', 'root\\SecurityCenter2')
        if output:
            context.log.success('Found Anti-Spyware product:')
            for entry in output:
                for k,v in entry.iteritems():
                    context.log.highlight('{} => {}'.format(k,v['value']))

        output = connection.wmi('Select * from AntiVirusProduct', 'root\\SecurityCenter2')
        if output:
            context.log.success('Found Anti-Virus product:')
            for entry in output:
                for k,v in entry.iteritems():
                    context.log.highlight('{} => {}'.format(k,v['value']))


text:
<?xml version="1.0" encoding="UTF-8"?>
<Tokens version="1.0">
	<File path="Constants/MBMLFunctionOutputType.html">

		<Token>
			<TokenIdentifier>//apple_ref/c/tdef/MBMLFunctionOutputType</TokenIdentifier>
			<Abstract type="html">Specifies the type of output an MBMLFunction implementation returns.</Abstract>
			<DeclaredIn>MBMLFunction.h</DeclaredIn>

			<NodeRef refid="48"/>
		</Token>

        <Token>
            <TokenIdentifier>//apple_ref/c/econst/MBMLFunctionOutputUnset</TokenIdentifier>
            <Abstract type="html">The function output type hasn't yet been set. Used as an initial value
        when processing MBML <Function> declarations. </Abstract>
            <Declaration>MBMLFunctionOutputUnset</Declaration>

            <DeclaredIn>MBMLFunction.h</DeclaredIn>

            <NodeRef refid="48"/>
        </Token>

        <Token>
            <TokenIdentifier>//apple_ref/c/econst/MBMLFunctionOutputNone</TokenIdentifier>
            <Abstract type="html">The function returns no output. The implementing method should
        return void; any return value is ignored. </Abstract>
            <Declaration>MBMLFunctionOutputNone</Declaration>

            <DeclaredIn>MBMLFunction.h</DeclaredIn>

            <NodeRef refid="48"/>
        </Token>

        <Token>
            <TokenIdentifier>//apple_ref/c/econst/MBMLFunctionOutputObject</TokenIdentifier>
            <Abstract type="html">The function returns an object instance as output.</Abstract>
            <Declaration>MBMLFunctionOutputObject</Declaration>

            <DeclaredIn>MBMLFunction.h</DeclaredIn>

            <NodeRef refid="48"/>
        </Token>

        <Token>
            <TokenIdentifier>//apple_ref/c/econst/MBMLFunctionOutputDefault</TokenIdentifier>
            <Abstract type="html">The function input type used by default: MBMLFunctionOutputObject.</Abstract>
            <Declaration>MBMLFunctionOutputDefault</Declaration>

            <DeclaredIn>MBMLFunction.h</DeclaredIn>

            <NodeRef refid="48"/>
        </Token>

	</File>
</Tokens>


text:
import test from 'ava'
import Helpers from '../test_helper.js'
import {generateCar} from '../test_fixtures'
import dotenv from 'dotenv'

dotenv.config()

var car, ticket, owner, reset

test.before(t => {
    car = new Helpers.Car()
    ticket  = new Helpers.Ticket(car)
    owner = new Helpers.Owner(ticket)
    reset = new Helpers.Reset()
})

test.beforeEach(t => {
    car.clear()
    ticket.clear()
    owner.clear()
    reset.get()
})

test('It should GET data for car with id 1', async t => {
    var response = await car.get(1)
    t.is(response[0].id, 1)
})

test('It should POST new car', async t => {
    var new_car = generateCar(1)[0]
    new_car.id  = 11
    var response = await car.post(new_car)
    t.is(new_car.color, response.color)
})

test('It should delete car with id 1', async t => {
    var response = await car.delete(1)
    t.is(9, response.length)
})

test('Fetching a resource should assign attributes from that resource to the API object', async t => {
    await car.fetch_resource(1)
    t.true(car.object.hasOwnProperty('color'))
})


text:
__m64 test1(__m64 a, __m64 b, int c) {
   // FIXME: The "incompatible result type" error is due to pr10112 and should
   // be removed when that is fixed.
   return _mm_alignr_pi8(a, b, c); // expected-error {{argument to '__builtin_ia32_palignr' must be a constant integer}} expected-error {{incompatible result type}}
}

int test2(int N) {
 __m128i white2;
 white2 = __builtin_ia32_pslldqi128(white2, N); // expected-error {{argument to '__builtin_ia32_pslldqi128' must be a constant integer}}
 return 0;
}


text:
//
//  STTarget.h
//  StomtiOS
//
//  Created by Leonardo Cascianelli on 11/09/15.
//  Copyright (c) 2015 Leonardo Cascianelli. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "block_declarations.h"

@class STCategory;
@class UIImage;
@class STStats;

/*!
 * STTarget class represents a Target, one of the most important objects in stomt.
 * Almost any object that this library handles inherits from STTarget class or contains an instance of it.
 */
@interface STTarget : NSObject <NSCoding>

/*!
 * @brief Unique id of the target, also referred in stomt API as 'slug'.
 */
@property (nonatomic,strong) NSString* identifier;

/*!
 * @brief The name of the target displayed on stomt.
 */
@property (nonatomic,strong) NSString* displayName;

/*!
 * @brief Category of the target. (Stomt, Users, Games...).
 */
@property (nonatomic,strong) STCategory* category;

 /*!
  * @brief The profile image of the target.
  */
@property (nonatomic,strong) NSURL* profileImage;

 /*!
  * @brief Statistics of the target. A comprehensive explanation can be found in the STStats class.
  */
@property (nonatomic,strong) STStats* stats;

 /*!
  * @brief BOOL to check whether the target is a verified or not.
  */
@property (nonatomic) BOOL isVerified;

/*!
 * @brief Create a STTarget instance with a given target dictionary.
 *
 * @param data Target dictionary
 *
 * @return A newly created STTarget instance
 */
+ (instancetype)initWithDataDictionary:(NSDictionary*)data;

/*!
 * @brief Create a STTarget instance with target dictionary representation.
 * @discussion This method should be used exclusively to retrieve a target previously stored into an NSDictionary with the 'dictionaryRepresentation' instance method.
 *
 * @param dict representation of the target
 *
 * @return A newly created STTarget instance
 */
+ (instancetype)initWithDictionaryRepresentation:(NSDictionary*)dict;

/*!
 * @brief Create a STTarget instance with given paramenters.
 *
 * @param displayName The extended name of the target.
 * @param identifier The identifier of the target.
 *
 * @return A newly created STTarget instance.
 */
+ (instancetype)targetWithDisplayName:(NSString*)displayName identifier:(NSString*)identifier;

/*!
 * @brief Retrieve an instance of STTarget with base properties.
 * @discussion Retrieve an instance of STTarget containing its identifier, display name, images array and category.
 *
 * @param identifier The identifier of the desired target
 * @param completion A completion block to be called when the request is completed.
 */
+ (void)retrieveEssentialTargetWithTargetID:(NSString*)identifier completionBlock:(TargetRequestBlock)completion;
/*!
 * @brief (Private!) Create a STTarget instance with a given target dictionary.
 *
 * @param data Target dictionary
 *
 * @return A newly created STTarget instance
 */
- (instancetype)initWithDataDictionary:(NSDictionary*)data;

/*!
 * @brief The NSDictionary representation of the target.
 * @discussion The dictionary representation can be useful to easely store an instance of a target when dealing with non object graph databases. The naming convention for keys conforms to the names convention used in the target properties.
 *
 * @return An instance of NSDictionary.
 */
- (NSDictionary*)dictionaryRepresentation;

@end


text:
"""Basic robot control to test motors and drive"""

# Choose whether to test the bot with a controller
IGNORE_CONTROLLER = False

# Update motor values below
left_motor = ""
right_motor = ""
assert left_motor and right_motor, "Insert the motor IDs from Dawn"

def autonomous_setup():
    print("Autonomous mode has started!")

def autonomous_main():
    pass

def teleop_setup():
    print("Tele-operated mode has started!")

def teleop_main():
    if USE_CONTROLLER:
        # Drive straight; ignore controller input
        Robot.set_value(left_motor, "duty_cycle", 1)
        Robot.set_value(right_motor, "duty_cycle", -1)
    else:
        # Use controller input
        left_read = Gamepad.get_value("joystick_left_y")
        right_read = Gamepad.get_value("joystick_right_y")
        Robot.set_value(left_motor, "duty_cycle", right_read)
        Robot.set_value(right_motor, "duty_cycle", -left_read)

async def async_action():
    """Spin the robot for a second.

    Demonstrate the syntax necessary for an async function.
    """
    print("Async action")
    Robot.set_value(left_motor, "duty_cycle", 1)
    Robot.set_value(right_motor, "duty_cycle", 1)
    await Actions.sleep(1.0)
    Robot.set_value(left_motor, "duty_cycle", 0)
    Robot.set_value(right_motor, "duty_cycle", 0)
    print("1 second has passed in autonomous mode")


text:
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where

#if !MIN_VERSION_base(4,11,0)
import Data.Semigroup ((<>))
#endif
import Data.ProtoLens (defMessage)
import Data.Proxy (Proxy(..))
import Lens.Family ((&), (.~))
import Proto.Required (Foo, Bar)
import Proto.Required_Fields (a, b)
import Test.Tasty (testGroup)

import Data.ProtoLens.TestUtil

defFoo :: Foo
defFoo = defMessage

failedFoo :: Maybe Foo
failedFoo = Nothing

main :: IO ()
main = testMain
    [ empty
    , onlyRequired
    , onlyOptional
    , both
    , multipleRequired
    ]

empty, onlyRequired, onlyOptional, both,
    multipleRequired :: TestTree

empty = testGroup "empty"
    [ deserializeFrom "wire" failedFoo mempty
    , readFrom "text" failedFoo ""
    ]

onlyRequired = testGroup "only-required"
    [ deserializeFrom "wire" target $ tagged 1 $ VarInt 42
    , readFrom "text-by-name" target "a: 42"
    , readFrom "text-by-tag" target "1: 42"
    ]
  where
    target = Just $ defFoo & a .~ 42

onlyOptional = testGroup "only-optional"
    [ deserializeFrom "wire" failedFoo $ tagged 2 $ VarInt 42
    , readFrom "text-by-name" failedFoo "b: 42"
    , readFrom "text-by-tag" failedFoo "2: 42"
    ]

both = testGroup "both"
    [ deserializeFrom "wire" target
        $ tagged 1 (VarInt 42) <> tagged 2 (VarInt 17)
    , readFrom "text-by-name" target "a: 42  b: 17"
    , readFrom "text-by-tag" target "1: 42  2: 17"
    ]
  where
    target = Just $ defFoo & a .~ 42 & b .~ 17

multipleRequired = testGroup "multiple"
    [ deserializeFromExpectingError "both missing"
        (Proxy :: Proxy Bar)
        "\"first_reqd\",\"second_reqd\""
        mempty
    , deserializeFromExpectingError "first missing"
        (Proxy :: Proxy Bar)
        "first_reqd"
        $ tagged 2 (VarInt 42)
    , deserializeFromExpectingError "second missing"
        (Proxy :: Proxy Bar)
        "second_reqd"
        $ tagged 1 (VarInt 42)
    ]


text:
package net.tacks_a.ankicard.fragment;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.support.v4.app.Fragment;
import android.widget.TextView;

import net.tacks_a.ankicard.R;
import net.tacks_a.ankicard.manager.AnkiCardCsv;
import net.tacks_a.ankicard.model.AnkiCardModel;
import net.tacks_a.ankicard.model.AnkiFolderModel;
import net.tacks_a.ankicard.model.PointHistoryModel;
import net.tacks_a.ankicard.util.LogUtil;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.ViewById;

import java.io.InputStream;
import java.io.InputStreamReader;

@SuppressWarnings("WeakerAccess")
@EFragment(R.layout.fragment_home)
public class HomeFragment extends Fragment {

    @ViewById(R.id.txvAppInfo)
    protected TextView mTxvAppInfo;
    @ViewById(R.id.txvTodayPoint)
    protected TextView mTxvTodayPoint;
    @ViewById(R.id.txvTotalPoint)
    protected TextView mTxvTotalPoint;
    @ViewById(R.id.txvAnkiCardCount)
    protected TextView mTxvAnkiCardCount;

    @Bean
    protected AnkiFolderModel mAnkiFolderModel;
    @Bean
    protected AnkiCardModel mAnkiCardModel;
    @Bean
    protected PointHistoryModel mPointHistoryModel;
    @Bean
    protected AnkiCardCsv mAnkiCardCsv;

    @AfterViews
    protected void initViews() {
        LogUtil.logDebug();

        // メニュー名を設定
        getActivity().setTitle(R.string.menu_home);

        // 初期データ
        createInitData();

        // 画面表示
        PackageInfo packageInfo = null;
        try {
            packageInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), PackageManager.GET_META_DATA);
        } catch (PackageManager.NameNotFoundException e) {
            LogUtil.logError("packageInfo not found", e);
        }
        if (packageInfo != null) {
            mTxvAppInfo.setText(getString(R.string.msg_app_info,
                    getString(R.string.app_name),
                    packageInfo.versionName));
        }
        mTxvTodayPoint.setText(Integer.toString(mPointHistoryModel.getTodayPoint()));
        mTxvTotalPoint.setText(Integer.toString(mPointHistoryModel.getTotalPoint()));
        mTxvAnkiCardCount.setText(Integer.toString(mAnkiCardModel.getCount()));
    }

    @Background
    protected void createInitData() {
        LogUtil.logDebug();
        try {

            if (mAnkiFolderModel.findAll().size() == 0) {
                mAnkiFolderModel.deleteAll();
                mAnkiCardModel.deleteAll();

                AssetManager assets = getResources().getAssets();
                InputStream in = assets.open("init_data.csv");
                InputStreamReader f = new InputStreamReader(in);
                mAnkiCardCsv.importAnkiCardCsv(f);
            }
        } catch (Exception e) {
            LogUtil.logError("create init data exception", e);
        }
    }
}


text:
package AM.Episode;

import org.openqa.selenium.WebDriver;

public class BillingSummary {

	public static void VerifyBillingTask(WebDriver driver, String TaskDetails){

	}

	public static void VerifyNonBillingTask(WebDriver driver, String TaskDetails){

	}

}


text:
  Given two numbers represented as strings, return multiplication of the numbers as a string.

  Note: The numbers can be arbitrarily large and are non-negative.

## Source:
[Leetcode](https://leetcode.com/problems/multiply-strings/)


text:
Authors of the original protocol: Nicolas Clairis and Mathias Pessiglione

Author of the current implementation: Ana Luisa Pinho
e-mail address: ana.pinho@inria.fr

Compatibility: Psychophysics Toolbox Version 3 (PTB-3), aka Psychtoolbox-3, for GNU Octave or MATLAB.

To run the protocol, typewrite in the command window of Octave or MATLAB:

`ratings_full_Nspin`

Before the launch of the protocol, you'll be asked:

1. the subject id;
2. the number of the run (according to the nomenclature of the protocol: session number);
3. the category of the stimuli, and;
4. which of the two available sequences within category you want to run.

The current response-box setup allows for two levels of scrolling speed of the rating scale in both sideways, i.e. both left and right. Please, make sure the key-code configuration of the script is in agreement with the setup of your equipment.

Always check the device number assigned to your keyboard, by running in the command window of Octave/MATLAB:

`GetKeyboardIndices`

This value may change if you restart your machine.

There are some non-ascii characters in some strings. Make sure you have configured, in your editor, "UTF-8" as the default text encoding. Additionally, if you're running the protocol in Win OS, you may have to uncomment the following line, in order to prevent bad decoding of non-ascii characters:

`Screen('Preference','TextEncodingLocale','UTF-8');`

The present protocol was implemented for 4 categories of images (*aka* four different tasks): __food__, __paintings__, __faces__ and __houses__. Two sets of images are provided per category and each set is to be presented in one run. There are thus 8 available runs, each of them containing a unique set of images. The sequence of display of each set is randomized upon launching the protocol.

Due to copyright restrictions, the images pertaining to the face category could not be provided.

In addition, note that the images of the food category are available in the french market. Adaptation of these stimuli might be required in future implementations, depending where the experiment is taking place.


text:
module SpreePos
  module Generators
    class InstallGenerator < Rails::Generators::Base

      def add_javascripts
        append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require admin/spree_pos\n"
      end

      def add_stylesheets
        inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require admin/spree_pos\n", :before => /\*\//, :verbose => true
      end

      def add_migrations
        run 'bundle exec rake railties:install:migrations FROM=spree_pos'
      end

      def run_migrations
         res = ask "Would you like to run the migrations now? [Y/n]"
         if res == "" || res.downcase == "y"
           run 'bundle exec rake db:migrate'
         else
           puts "Skiping rake db:migrate, don't forget to run it!"
         end
      end
    end
  end
end


text:
/**
 * Write a description of class Frage here.
 *
 * @author (your name)
 * @version (a version number or a date)
 */
public class Frage
{
    public Frage(String text, Antwort[] antworten)
    {

    }

    public int vergleicheAntworten()
    {
        return 0;
    }
}


text:
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
                        unicode_literals, with_statement)

from pkg_resources import Requirement

class PythonRequirement(object):
  """Pants wrapper around pkg_resources.Requirement

  Describes an external dependency as understood by ``easy_install`` or
  ``pip``. It takes
  a single non-keyword argument of the `Requirement`-style string, e.g. ::

      python_requirement('django-celery')
      python_requirement('tornado==2.2')
      python_requirement('kombu>=2.1.1,<3.0')

  Pants resolves the dependency *and its transitive closure*.
  For example, `django-celery` pulls also pulls down its
  dependencies: `celery>=2.5.1`, `django-picklefield>=0.2.0`, `ordereddict`,
  `python-dateutil`,
  `kombu>=2.1.1,<3.0`, `anyjson>=0.3.1`, `importlib`, and `amqplib>=1.0`.

  To let other Targets depend on this ``python_requirement``, put it in a
  `python_requirement_library <#python_requirement_library>`_.
  """

  def __init__(self, requirement, name=None, repository=None, version_filter=None, use_2to3=False,
               compatibility=None):
    # TODO(wickman) Allow PythonRequirements to be specified using pip-style vcs or url identifiers,
    # e.g. git+https or just http://...
    self._requirement = Requirement.parse(requirement)
    self._repository = repository
    self._name = name or self._requirement.project_name
    self._use_2to3 = use_2to3
    # TODO(pl): Change version_filter into a hashable flag instead of a lambda.
    # It definitely belongs in the invalidation hash, and it's only ever used
    # for differentiating between py3k and py2
    self._version_filter = version_filter or (lambda py, pl: True)
    # TODO(wickman) Unify this with PythonTarget .compatibility
    self.compatibility = compatibility or ['']

  def should_build(self, python, platform):
    return self._version_filter(python, platform)

  @property
  def use_2to3(self):
    return self._use_2to3

  @property
  def repository(self):
    return self._repository

  # duck-typing Requirement interface for Resolver, since Requirement cannot be
  # subclassed (curses!)
  @property
  def key(self):
    return self._requirement.key

  @property
  def extras(self):
    return self._requirement.extras

  @property
  def specs(self):
    return self._requirement.specs

  @property
  def project_name(self):
    return self._requirement.project_name

  @property
  def requirement(self):
    return self._requirement

  def __contains__(self, item):
    return item in self._requirement

  def cache_key(self):
    return str(self._requirement)

  def __repr__(self):
    return 'PythonRequirement(%s)' % self._requirement


text:
'use strict';

var mongoose = require('mongoose'),
	errorHandler = require('./errors'),
	_ = require('lodash'),
	User = mongoose.model('User'),
	modo = require('../../app/libraries/modo'),
	Modoaccount = mongoose.model('Modoaccount');

exports.getList = function(req, res){
	console.log('reached getList...');
	User.findById(req.user._id, function(err, resp){
		console.log(resp);
		// var modoAccounts = resp;
		res.send(resp);
	});

};

exports.addCard = function(req, res){
	console.log('reached addCard');
	console.log('user: ', req.user);
	console.log('body:', req.body);
	console.log('state: ', req.body.state.abbr);

	var params = {
		consumer_key: modo.apiKey,
		access_token: modo.token,
		account_id: req.user.accountID,
		card_number: req.body.cardNumber,
		expiry: req.body.expiry,
		card_security: req.body.cardSecurity,
		zip_code: req.body.zipcode.replace(/-/g, ''),
		card_address: req.body.address + ' ' + req.body.city
	};

	// console.log('params: ', params);

	modo.postRequest('card', 'add', params, function (err, resp){
		if(err){console.log(err);}

		resp = JSON.parse(resp);
		// console.log('user id: ', req.user._id);
		User.findById(req.user._id, function(err, user){
			// console.log('new user: ', user);

			// var newUser = user.toObject();

			// console.log(user.modoAccounts);

			// console.log(user.modoAccounts);
			// user.modoAccounts.push('hello');

			user.save(function(err, something){
				if(err){console.log(err);}
			});

			user.modoAccounts.push({
				card_number: req.body.cardNumber,
				expiry: req.body.expiry,
				card_security: req.body.cardSecurity,
				zip_code: req.body.zipcode.replace(/-/g, ''),
				card_address: req.body.address + ' ' + req.body.city,
				state: req.body.state.abbr
			});

			user.save(function(){
				console.log('saved, I think.');
			});
		});
		// var accounts = user.toObject();

		// accounts.push({
		// 	card_number: req.body.cardNumber,
		// 	expiry: req.body.expiry,
		// 	card_security: req.body.cardSecurity,
		// 	zip_code: req.body.zipcode.replace(/-/g, ''),
		// 	card_address: req.body.address + ' ' + req.body.city + req.body.state
		// });

//		user.save();

		console.log('resp', resp);

		res.status(200).jsonp(resp);
	});
};

exports.testModoRoute = function(req, res){
	console.log('modo');

	var params = {
		'credentials': (new Buffer('c98de17fddf04304d1964e9166479037:6c35adce2d5f1d4a9f6a4de381d05f848bb8f823e069b330058ebc025b3c9acb').toString('base64'))
	};

	console.log('params: ',params);

	modo.postRequest('token', null, params, function (err, response){
		if(err){console.log(err);}
		res.status(200).send(response);
	});
};


text:
using UnityEngine;
using System.Collections;

public class Stage4Button : MonoBehaviour {

	// Use this for initialization
	void Start () {

	}

	// Update is called once per frame
	void Update () {

	}

	public void goToStage(){
		UnityEngine.SceneManagement.SceneManager.LoadScene ("Stage4");
	}
}


text:
module Regit
  module Commands
    module Imitate
      extend Discordrb::Commands::CommandContainer

      command(:imitate, min_args: 0, max_args: 1, description: 'Imitate you.', usage: '`!imitate`', permission_level: 1) do |event|
        #event.message.delete
        return if event.channel.private?

        target = event.user.on(event.server)

        quotes = Regit::Database::Quote.where(author_username: target.info.username)
        #return event.channel.send_temporary_message('You don\'t have enough quotes!', 5) if quotes.count < 5

        source = quotes.map { |m| m.text }.join('. ') + event.channel.history(100).select { |m| m.author == target }.map(&:content).join(". ")

        markov = MarkyMarkov::TemporaryDictionary.new
        markov.parse_string(source)

        markov.generate_n_sentences(rand(5))
      end
    end
  end
end


text:
module awk.grid {

    var _ = Utils;

    export class RenderedRow {

        public vPinnedRow: any;
        public vBodyRow: any;

        private renderedCells: {[key: number]: RenderedCell} = {};
        private scope: any;
        private node: any;
        private rowIndex: number;

        private cellRendererMap: {[key: string]: any};

        private gridOptionsWrapper: GridOptionsWrapper;
        private parentScope: any;
        private angularGrid: Grid;
        private columns: Column[];
        private expressionService: ExpressionService;
        private rowRenderer: RowRenderer;
        private selectionRendererFactory: SelectionRendererFactory;
        private $compile: any;
        private templateService: TemplateService;
        private selectionController: SelectionController;
        private pinning: boolean;
        private eBodyContainer: HTMLElement;
        private ePinnedContainer: HTMLElement;

        constructor(gridOptionsWrapper: GridOptionsWrapper,
                    parentScope: any,
                    angularGrid: Grid,
                    columnModel: any,
                    expressionService: ExpressionService,
                    cellRendererMap: {[key: string]: any},
                    selectionRendererFactory: SelectionRendererFactory,
                    $compile: any,
                    templateService: TemplateService,
                    selectionController: SelectionController,
                    rowRenderer: RowRenderer,
                    eBodyContainer: HTMLElement,
                    ePinnedContainer: HTMLElement,
                    node: any,
                    rowIndex: number) {
            this.gridOptionsWrapper = gridOptionsWrapper;
            this.parentScope = parentScope;
            this.angularGrid = angularGrid;
            this.expressionService = expressionService;
            this.columns = columnModel.getDisplayedColumns();
            this.cellRendererMap = cellRendererMap;
            this.selectionRendererFactory = selectionRendererFactory;
            this.$compile = $compile;
            this.templateService = templateService;
            this.selectionController = selectionController;
            this.rowRenderer = rowRenderer;
            this.pinning = this.columns[0].pinned;
            this.eBodyContainer = eBodyContainer;
            this.ePinnedContainer = ePinnedContainer;

            var groupHeaderTakesEntireRow = this.gridOptionsWrapper.isGroupUseEntireRow();
            var rowIsHeaderThatSpans = node.group && groupHeaderTakesEntireRow;

            this.vBodyRow = this.createRowContainer();
            if (this.pinning) {
                this.vPinnedRow = this.createRowContainer();
            }

            this.rowIndex = rowIndex;
            this.node = node;
            this.scope = this.createChildScopeOrNull(node.data);

            if (!rowIsHeaderThatSpans) {
                this.drawNormalRow();
            }

            this.addDynamicStyles();
            this.addDynamicClasses();

            this.vBodyRow.setAttribute('row', this.rowIndex.toString());
            if (this.pinning) {
                this.vPinnedRow.setAttribute('row', this.rowIndex.toString());
            }

            // if showing scrolls, position on the container
            if (!this.gridOptionsWrapper.isDontUseScrolls()) {
                this.vBodyRow.style.top = (this.gridOptionsWrapper.getRowHeight() * this.rowIndex) + "px";
                if (this.pinning) {
                    this.vPinnedRow.style.top = (this.gridOptionsWrapper.getRowHeight() * this.rowIndex) + "px";
                }
            }
            this.vBodyRow.style.height = (this.gridOptionsWrapper.getRowHeight()) + "px";
            if (this.pinning) {
                this.vPinnedRow.style.height = (this.gridOptionsWrapper.getRowHeight()) + "px";
            }

            // if group item, insert the first row
            if (rowIsHeaderThatSpans) {
                this.createGroupRow();
            }

            this.bindVirtualElement(this.vBodyRow);
            if (this.pinning) {
                this.bindVirtualElement(this.vPinnedRow);
            }

            if (this.scope) {
                this.$compile(this.vBodyRow.getElement())(this.scope);
                if (this.pinning) {
                    this.$compile(this.vPinnedRow.getElement())(this.scope);
                }
            }

            this.eBodyContainer.appendChild(this.vBodyRow.getElement());
            if (this.pinning) {
                this.ePinnedContainer.appendChild(this.vPinnedRow.getElement());
            }
        }

        public onRowSelected(selected: boolean): void {
            _.iterateObject(this.renderedCells, (key: any, renderedCell: RenderedCell)=> {
                renderedCell.setSelected(selected);
            });
        }

        public softRefresh(): void {
            _.iterateObject(this.renderedCells, (key: any, renderedCell: RenderedCell)=> {
                if (renderedCell.isVolatile()) {
                    renderedCell.refreshCell();
                }
            });
        }

        public getRenderedCellForColumn(column: Column): any {
            return this.renderedCells[column.index];
        }

        public getCellForCol(column: Column): any {
            var renderedCell = this.renderedCells[column.index];
            if (renderedCell) {
                return renderedCell.getVGridCell().getElement();
            } else {
                return null;
            }
        }

        public destroy(): void {
            this.destroyScope();

            if (this.pinning) {
                this.ePinnedContainer.removeChild(this.vPinnedRow.getElement());
            }
            this.eBodyContainer.removeChild(this.vBodyRow.getElement());
        }

        private destroyScope(): void {
            if (this.scope) {
                this.scope.$destroy();
                this.scope = null;
            }
        }

        public isDataInList(rows: any[]): boolean {
            return rows.indexOf(this.node.data) >= 0;
        }

        public isGroup(): boolean {
            return this.node.group === true;
        }

        private drawNormalRow() {
            for (var i = 0; i<this.columns.length; i++) {
                var column = this.columns[i];
                var firstCol = i === 0;

                var renderedCell = new RenderedCell(firstCol, column,
                    this.$compile, this.rowRenderer, this.gridOptionsWrapper, this.expressionService,
                    this.selectionRendererFactory, this.selectionController, this.templateService,
                    this.cellRendererMap, this.node, this.rowIndex, this.scope);

                var vGridCell = renderedCell.getVGridCell();

                if (column.pinned) {
                    this.vPinnedRow.appendChild(vGridCell);
                } else {
                    this.vBodyRow.appendChild(vGridCell);
                }

                this.renderedCells[column.index] = renderedCell;
            }
        }

        private bindVirtualElement(vElement: awk.vdom.VHtmlElement): void {
            var html = vElement.toHtmlString();
            var element: Element = <Element> _.loadTemplate(html);
            vElement.elementAttached(element);
        }

        private createGroupRow() {
            var eGroupRow = this.createGroupSpanningEntireRowCell(false);

            if (this.pinning) {
                this.vPinnedRow.appendChild(eGroupRow);
                var eGroupRowPadding = this.createGroupSpanningEntireRowCell(true);
                this.vBodyRow.appendChild(eGroupRowPadding);
            } else {
                this.vBodyRow.appendChild(eGroupRow);
            }
        }

        private createGroupSpanningEntireRowCell(padding: any) {
            var eRow: any;
            // padding means we are on the right hand side of a pinned table, ie
            // in the main body.
            if (padding) {
                eRow = document.createElement('span');
            } else {
                var params = {
                    node: this.node,
                    data: this.node.data,
                    rowIndex: this.rowIndex,
                    api: this.gridOptionsWrapper.getApi(),
                    colDef: {
                        cellRenderer: {
                            renderer: 'group',
                            innerRenderer: this.gridOptionsWrapper.getGroupRowInnerRenderer()
                        }
                    }
                };
                eRow = this.cellRendererMap['group'](params);
            }

            if (this.node.footer) {
                _.addCssClass(eRow, 'ag-footer-cell-entire-row');
            } else {
                _.addCssClass(eRow, 'ag-group-cell-entire-row');
            }

            return eRow;
        }

        public setMainRowWidth(width: number) {
            this.vBodyRow.addStyles({width: width + "px"});
        }

        private createChildScopeOrNull(data: any) {
            if (this.gridOptionsWrapper.isAngularCompileRows()) {
                var newChildScope = this.parentScope.$new();
                newChildScope.data = data;
                return newChildScope;
            } else {
                return null;
            }
        }

        private addDynamicStyles() {
            if (this.gridOptionsWrapper.getRowStyle()) {
                var cssToUse: any;
                var rowStyle = this.gridOptionsWrapper.getRowStyle();
                if (typeof rowStyle === 'function') {
                    var params = {
                        data: this.node.data,
                        node: this.node,
                        api: this.gridOptionsWrapper.getApi(),
                        context: this.gridOptionsWrapper.getContext(),
                        $scope: this.scope
                    };
                    cssToUse = rowStyle(params);
                } else {
                    cssToUse = rowStyle;
                }

                this.vBodyRow.addStyles(cssToUse);
                if (this.pinning) {
                    this.vPinnedRow.addStyles(cssToUse);
                }
            }
        }

        private createRowContainer() {
            var vRow = new awk.vdom.VHtmlElement('div');
            var that = this;
            vRow.addEventListener("click", function (event) {
                that.angularGrid.onRowClicked(event, Number(this.getAttribute("row")), that.node)
            });

            return vRow;
        }

        public getRowNode(): any {
            return this.node;
        }

        public getRowIndex(): any {
            return this.rowIndex;
        }

        private addDynamicClasses() {
            var classes: string[] = [];

            classes.push('ag-row');

            classes.push(this.rowIndex % 2 == 0 ? "ag-row-even" : "ag-row-odd");

            if (this.selectionController.isNodeSelected(this.node)) {
                classes.push("ag-row-selected");
            }

            if (this.node.group) {
                classes.push("ag-row-group");
                // if a group, put the level of the group in
                classes.push("ag-row-level-" + this.node.level);

                if (!this.node.footer && this.node.expanded) {
                    classes.push("ag-row-group-expanded");
                }
                if (!this.node.footer && !this.node.expanded) {
                    // opposite of expanded is contracted according to the internet.
                    classes.push("ag-row-group-contracted");
                }
                if (this.node.footer) {
                    classes.push("ag-row-footer");
                }
            } else {
                // if a leaf, and a parent exists, put a level of the parent, else put level of 0 for top level item
                if (this.node.parent) {
                    classes.push("ag-row-level-" + (this.node.parent.level + 1));
                } else {
                    classes.push("ag-row-level-0");
                }
            }

            // add in extra classes provided by the config
            if (this.gridOptionsWrapper.getRowClass()) {
                var gridOptionsRowClass = this.gridOptionsWrapper.getRowClass();

                var classToUse: any;
                if (typeof gridOptionsRowClass === 'function') {
                    var params = {
                        node: this.node,
                        data: this.node.data,
                        rowIndex: this.rowIndex,
                        context: this.gridOptionsWrapper.getContext(),
                        api: this.gridOptionsWrapper.getApi()
                    };
                    classToUse = gridOptionsRowClass(params);
                } else {
                    classToUse = gridOptionsRowClass;
                }

                if (classToUse) {
                    if (typeof classToUse === 'string') {
                        classes.push(classToUse);
                    } else if (Array.isArray(classToUse)) {
                        classToUse.forEach(function (classItem: any) {
                            classes.push(classItem);
                        });
                    }
                }
            }

            this.vBodyRow.addClasses(classes);
            if (this.pinning) {
                this.vPinnedRow.addClasses(classes);
            }
        }
    }

}


text:
This application was written as part of the MediaScape EU project, to demonstrate some of the project's
capabilities. The idea is that you can find controllable devices on the same network and send audio
streams to them using your browser. It uses mDNS in a Chrome app with a Chrome extension and a [Radiodan](http://radiodan.net/)
installed on the same network.

See [a short blog post](http://www.bbc.co.uk/rd/blog/2014-09-control-radio-mediascape) for more detail

To install it as a simple demonstration, do the following:

## Install and run the example radio app and chrome extensions.

Clone each of the repositories.

    git clone https://github.com/mediascape/discovery-extension
    git clone https://github.com/mediascape/discovery-helper-app
    git clone https://github.com/mediascape/discovery-bbc-radio

Go to chrome://extensions in your Chrome browser (or open up the Chrome menu by clicking the icon to the far right of the Omnibox:  The menu's icon is three horizontal bars. Then select Extensions under the Tools menu to get to the same place).

Ensure that the Developer mode checkbox in the top right-hand corner is checked.

Click "Load unpacked extension..." to pop up a file-selection dialog.

Navigate to the directory in which your extension files live, and select it. Do this for all three.

Click "launch" on MediaScape Discovery Helper

## Install the "Radiodan" and run control interface app and audio server

This is an example application that responds to `_mediascape-http._tcp.local` and plays streams of audio.
On a machine on the same network, install the prerequisites.

On OS X:

    brew install zmq mpd nodejs

On raspbian/debian/ubuntu:

    apt-get install mpd libzmq3 libzmq3-dev nodejs

And then on all platforms:

    git clone https://github.com/mediascape/discovery-audio-stream-controller
    cd discovery-audio-stream-controller/
    cp config/radiodan-config.json.example config/radiodan-config.json
    npm install
    npm start

## Running

And after a few moments you should see the MDNS discovery update in the toolbar of the Chrome browser:

Clicking on the name of the device takes you to a remote control page:

which you can then use as a web-based remote control to control the audio coming through mpd on your computer:


text:
=================
Salt Vagrant Demo
=================

A Salt Demo using Vagrant.

Instructions
============

Run the following commands in a terminal. Git, VirtualBox and Vagrant must
already be installed.

.. code-block:: bash

    git clone https://github.com/UtahDave/salt-vagrant-demo.git
    cd salt-vagrant-demo
    vagrant up

This will download Ubuntu and Windows Server 2012R2 Hyper-V VirtualBox images and create five virtual machines for you. One will be a Salt Master named `master`, two will be Ubuntu Salt Minions named 'minion1' and 'minion2' and two will be Windows Server minions named 'winion1' and 'winion2'. The Salt Minions will point to the Salt Master and the Minion's keys will already be accepted. Because the keys are pre-generated and reside in the repo, please be sure to regenerate new keys if you use this for production purposes.

You can then run the following commands to log into the Salt Master and begin
using Salt.

.. code-block:: bash

    vagrant ssh master
    sudo salt \* test.ping
Notes
=====
The Windows minions (winions) are Windows Server 2012 R2 Hyper V Vagrant boxes from here:
https://github.com/msabramo/vagrant_hyperv_server_free