Exemplo n.º 1
0
/* Standard variable set, given context
 */
int
prmvp_set(struct prmvcx_s *px)
{
    struct prmvar_s *p = px->prmvcx_var;
    union prmval *vp = &px->prmvcx_val;
    FILE *of = px->prmvcx_of;
    FILE *ef = px->prmvcx_ef;

    if (of)
	fprintf(of,"   %s: ", p->prmv_name);
    switch (p->prmv_typf & PRMVF_TYPE) {
    case PRMVT_BOO:
	printf("%s  =>  %s\n", *(int *)(p->prmv_loc) ? "On" : "Off",
			vp->vi ? "On" : "Off");
	*(int *)(p->prmv_loc) = vp->vi;
	break;
    case PRMVT_OCT:
	printf("%#.0o  =>  %#.0o\n", *(int *)(p->prmv_loc), vp->vi);
	*(int *)(p->prmv_loc) = vp->vi;
	break;
    case PRMVT_DEC:
	printf("%d.  =>  %d.\n", *(int *)(p->prmv_loc), vp->vi);
	*(int *)(p->prmv_loc) = vp->vi;
	break;
    case PRMVT_WRD:
	printf("%lo,,%lo  =>  %lo,,%lo\n",
		(long)LHGET(*(w10_t *)(p->prmv_loc)),
		(long)RHGET(*(w10_t *)(p->prmv_loc)),
		(long)LHGET(vp->vw), (long)RHGET(vp->vw));
	*(w10_t *)(p->prmv_loc) = vp->vw;
	break;
    case PRMVT_STR:
	if (*(char **)(p->prmv_loc)) printf("\"%s\"", *(char **)(p->prmv_loc));
	else printf("NULL");
	if (vp->vs) printf("  =>  \"%s\"\n", vp->vs);
	else printf("NULL\n");

	{	/* Ensure have new string before flushing old one! */
	    char *tmp = NULL;

	    if (vp->vs && !(tmp = s_dup(vp->vs))) {
		printf(" Error: malloc failed for new string, var not set!\n");
		return FALSE;
	    }
	    /* OK, free up old if necessary */
	    if ((p->prmv_typf & PRMVF_DYNS) && *(char **)(p->prmv_loc))
		free(*(char **)(p->prmv_loc));
	    *(char **)(p->prmv_loc) = tmp;
	}
	p->prmv_typf |= PRMVF_DYNS;
	break;
    }

    return TRUE;
}
Exemplo n.º 2
0
static pcinc_t dorstf(register w10_t w, vaddr_t e)
# define IJ_DO_RSTF(w, e, pcsf) dorstf(w, e)
#endif
{
    register uint18 newf;	/* New flags to restore */

#if KLH10_DEBUG
    if (cpu.mr_debug) {
	putc('[', stderr);
	pishow(stderr); pcfshow(stderr, cpu.mr_pcflags);
#if KLH10_EXTADR
	if (pcsf) fprintf(stderr, "(PCS:%o)", pag_pcsget());
#endif
	fprintf(stderr,"%lo: -> ", (long) PC_30);
    }
#endif
    newf = LHGET(w);		/* Get flags into easy-access reg */

    if (PCFTEST(PCF_USR)) {		/* Currently in user mode? */
	newf |= PCF_USR;		/* Never permit USR clearing */
	if (!PCFTEST(PCF_UIO))		/* If not already in UIO, */
	    newf &= ~PCF_UIO;		/* don't permit UIO setting */
    }
#if KLH10_CPU_KL || KLH10_CPU_KI
    if (PCFTEST(PCF_PUB)		/* If trying to clear Public, */
      && (newf & PCF_PUB)==0) {		/* Must be EXEC, setting USER too. */
	if (PCFTEST(PCF_USR) || !(newf&PCF_USR))
	    newf |= PCF_PUB;		/* Nope, don't clear it */
    }
#endif /* KL || KI */

    /* For XJRSTF/XJEN, a new PCS is loaded from the flag word only if
    ** the new flags specify EXEC mode.
    ** (PRM 2-66, 2nd sentence from bottom).
    */
#if KLH10_EXTADR		/* If going into EXEC mode, restore PCS */
    if (pcsf && !(newf & PCF_USR)) {
	pag_pcsset(RHGET(w) & UBR_PCS);	/* For now, ignore too-big PCS */
    }
#endif

    cpu.mr_pcflags = newf & PCF_MASK;	/* Set new flags!! */
    PC_JUMP(e);				/* Take the jump... */
    apr_pcfcheck();			/* Check flags for any changes. */
	/* NOTE! It is important to check AFTER the PC has changed, so that
	** if there is a user/exec context change, the saved JPC will be the
	** appropriate one for the previous context.
	*/
#if KLH10_DEBUG
    if (cpu.mr_debug) {
	pishow(stderr); pcfshow(stderr, cpu.mr_pcflags);
#if KLH10_EXTADR
	if (pcsf) fprintf(stderr, "(PCS:%o)", pag_pcsget());
#endif
	fprintf(stderr,"%lo:]\r\n", (long) PC_30);
    }
#endif
    return PCINC_0;
}
Exemplo n.º 3
0
int
prm_varshow(register struct prmvar_s *p,
	    FILE *of)
{
    int res = TRUE;

    fprintf(of, "  %-10s= ", p->prmv_name);
    switch (p->prmv_typf & PRMVF_TYPE) {
    case PRMVT_BOO:
	fprintf(of, "%s", *(int *)p->prmv_loc ? "On" : "Off");
	break;
    case PRMVT_DEC:
	fprintf(of, "%d.", *(int *)p->prmv_loc);
	break;
    case PRMVT_OCT:
	fprintf(of, ((*(int *)p->prmv_loc) ? "%#.0o" : "0"),
			*(int *)p->prmv_loc);
	break;
    case PRMVT_STR:
	fprintf(of, "\"%s\"", *(char **)p->prmv_loc);
	break;
    case PRMVT_WRD:
      {
	w10_t w = *(w10_t *)p->prmv_loc;

	if (LHGET(w)) fprintf(of, "%lo,,", (long)LHGET(w));
	fprintf(of, "%lo", (long)RHGET(w));
      }
	break;
    default:
	fprintf(of,"<Unknown variable type %#.0o\?\?>", p->prmv_typf);
	res = FALSE;
    }
    if (p->prmv_help)
	fprintf(of, " \t%s", p->prmv_help);
    fprintf(of, "\n");
    return res;
}