Esempio n. 1
0
chat_list_users_func( int indx, USEREC *urec, struct _chatlist *cl )
{
  indx++;    /* Start counting at one, not zero. */
  if (indx < cl->start) return S_OK;
  else if (cl->stop && (indx > cl->stop)) return ENUM_QUIT;
  if (cl->verbose) {
    char fromhost[24];
    memset(fromhost, '\0', sizeof fromhost);
    strncpy(fromhost, urec->fromhost, sizeof(fromhost)-1);
    sprintf(cl->buf, "*** %-14s %-25s %c%-8s %-23s", 
  	    urec->userid, urec->username,
	    BITISSET(urec->flags, FLG_CLOAK) ? '#' : ' ',
	    ModeToString(urec->mode), fromhost);
    printchatline(cl->buf);
  }
  else {
    if (cl->col == 0) {
      strcpy(cl->buf, "*** ");
      cl->col = 4;
    }     
    sprintf(cl->buf+cl->col, "[%c]%s%-13s ", ModeToChar(urec->mode), 
            BITISSET(urec->flags, FLG_CLOAK) ? " #" : " ", urec->userid);
    if ((cl->col += 18) > 70) {
      printchatline(cl->buf);
      cl->col = 0;
    }          
  }
  return S_OK;
}
Esempio n. 2
0
/*ARGSUSED*/
AllUsersFunc( int indx, ACCOUNT *acct, struct enum_info *info )
{
  if (info->topline == info->currline) {
    move(info->topline-1, 0);
    prints("%-14s %-30s   %s\n","User Id", "User Name", "Last Login");
  }

  prints("%-14s %-30s %c %s", acct->userid, acct->username,
   BITISSET(acct->flags, FLG_EXEMPT) ? 'X': ' ',
   (acct->lastlogin == 0) ? "\n":ctime((time_t *)&acct->lastlogin));

  info->currline++;
  info->count++;

  if (info->currline > info->bottomline) {
    int ch;
    standout();
    prints("--MORE--");
    standend();
    clrtoeol();
    while((ch = igetch()) != EOF) {
      if(ch == '\n' || ch == '\r' || ch == ' ')
	break;
      if(toupper(ch) == 'Q') {
	move(info->currline, 0);
	clrtoeol();
	return ENUM_QUIT;
      }
      else bell();
    }
    info->currline = info->topline;
  }
  return S_OK;
}
Esempio n. 3
0
/*ARGSUSED*/
OnlineUsersFunc( int indx, USEREC *urec, struct enum_info *info )
{
  if (info->topline == info->currline) {
    move(info->topline-1, 0);
    prints("%-12s    %-25s %-25s %s %s\n", 
	   "User Id", "User Name", "From", "P", "Mode");
  }

  prints("%-12s  %c %-25s %-25s %c %s\n", urec->userid, 
	 BITISSET(urec->flags, FLG_CLOAK) ? '#': ' ', 
	 urec->username, urec->fromhost, 
	 BITISSET(urec->flags, FLG_NOPAGE) ? 'N': ' ', 
         ModeToString(urec->mode));

  info->currline++;
  info->count++;

  if (info->currline > info->bottomline) {
    int ch;
    standout();
    prints("--MORE--");
    standend();
    clrtoeol();
    while((ch = igetch()) != EOF) {
      if(ch == '\n' || ch == '\r' || ch == ' ')
	break;
      if(toupper(ch) == 'Q') {
	move(info->currline, 0);
	clrtoeol();
	return ENUM_QUIT;
      }
      else bell();
    }
    info->currline = info->topline;
  }
  return S_OK;
}
Esempio n. 4
0
DoShortUserList()
{
  int i, y = 3, x = 0, ucount = 0;
  time_t now;

  for (i=0; i<global_ulist_sz; i++) {
    global_ulist[i].wasfound = global_ulist[i].found;
    global_ulist[i].found = 0;
  }
  move(y, x);
  clrtobot();
  time(&now);
  bbs_enum_users(global_ulist_sz, 0, NULL, FillShortUserList, NULL);
  for (i=0; i<global_ulist_sz; i++)
    {
      if (global_ulist[i].found)
	{
	  prints("[%c]%s%-14s", ModeToChar(global_ulist[i].mode), 
                 BITISSET(global_ulist[i].flags, FLG_CLOAK) ? " #" : " ",
		 global_ulist[i].userid);
	  ucount++;
	}
      else if (global_ulist[i].wasfound) prints("%18s", " ");

      x+=18;
      if ((x+18) > t_columns)
	{
	  x=0; y++;
	}
      move(y, x);
    }
  move(t_lines-1, 0);
  prints("%d user%s online at %s", ucount, (ucount==1?"":"s"), ctime(&now));
  refresh();
  return ucount;
}
Esempio n. 5
0
int
depmap_isset(cflow_depmap_t dmap, size_t row, size_t col)
{
     unsigned *rptr = depmap_rowptr(dmap, row);
     return BITISSET(rptr, col);
}
Esempio n. 6
0
int
proc_err(pb_t *ppb, int pc, paramv_t *pv)
{
	register func_t	*f;
	register int		i;
	register ctx_t		*ctx;

#ifdef xCTR2
	if (tTf(6, 8))
		lprintf("proc_err: new = %d\n", Ctx.ctx_new);
#endif
	pb_prime(ppb, PB_ERR);

	/*
	**  Scan back on the list of context dependencies.
	**	If we come to someone who can process this message,
	**	we go ahead and do it.  We also take this
	**	opportunity to unwind the context list & call the
	**	cleanup functions.
	*/

	for (ctx = &Ctx; ctx != NULL; ctx = ctx->ctx_link) {
		setprocname(ctx->ctx_name);
		f = ctx->ctx_fn;
#ifdef xCTR2
		if (tTf(6, 9))
			lprintf("proc_err: unwinding %s: errfn=%x, ppb=%x, link=%x, resp=%d, fn=%x\n",
			    getprocname(), ctx->ctx_errfn, ctx->ctx_ppb,
			    ctx->ctx_link, ctx->ctx_resp, f);
#endif

		/*  Do the actual error processing. */
		ppb->pb_proc = ctx->ctx_resp;
		if (ctx->ctx_errfn != NULL)
			i = (*ctx->ctx_errfn)(pc, pv);
		else
			i = -1;

#ifdef xCTR2
		if (tTf(6, 11))
			lprintf("proc_err: errcode %d\n", i);
#endif
		if (i == 0)
			break;
		else if (i > 0) {
			/* turn into nonfatal error */
			ppb->pb_stat |= PB_INFO;
			ppb->pb_proc = PB_FRONT;
		} else {
			/* call the cleanup function */
			if (f != NULL && f->fn_active > 0) {
				(*f->fn_cleanup)(1);
			}
		}

		/* arrange to leave if parent not in this process */
		if (ppb->pb_proc != Cm.cm_myproc) {
			send_off(ppb, pc, pv);
			pb_flush(ppb);

			/* throw away dead contexts and exit */
			break;
		}
	}
	if (ctx == NULL) {
		syserr("proc_err: no parent");
	}

#ifdef xCTR3
	MonPpb = getmonppb();
	if (tTf(6, 12)) {
		lprintf("proc_err: cleanup: ctx=%x, ->_link=%x, MonPpb = ", ctx, ctx->ctx_link);
		pb_dump(MonPpb, TRUE);
	}
#endif
	/* pop contexts down to ctx and exit */
	ctx = ctx->ctx_link;
	while (Ctx.ctx_link != ctx) {
		if (Ctx.ctx_link == NULL)
			syserr("proc_err: underflow");
		Ctx.ctx_new = TRUE;
		resetp();
	}

	/*
	**  Flush input pipe.
	**	THIS CODE IS ONLY NEEDED TO MAKE READMON WORK, AND
	**	SHOULD BE REMOVED WHEN READMON GOES AWAY!!
	*/

	if (ctx == NULL) {
		Cm.cm_input = Cm.cm_rinput;
		MonPpb = getmonppb();
		while (!BITISSET(PB_EOF, MonPpb->pb_stat)) {
			pb_read(MonPpb);
		}
		MonPpb->pb_st = PB_UNKNOWN;
	}

	longjmp(Ctx.ctx_jbuf, 1);
}
Esempio n. 7
0
/*
**	IIgettup is called to retrieve one instance
**	of the target list into the c-variables.
**
**	Integers and Floating point numbers can be converted
**	to other numbers.
**
**	Characters fields must match other character fields.
*/
int
IIgettup(char *file_name, int line_no)
{
	register int		length, domain;
	register struct retsym	*ret;
	struct retsym		sym;
	char			temp[256], *s;



	if ((IIproc_name = file_name) != 0)
		IIline_no = line_no;

	while (IIpb.pb_type != PB_REG) {
		IIreadinput(&IIpb);
		if (BITISSET(IIpb.pb_stat, PB_INFO))
			IIpb_prime(&IIpb, PB_NOTYPE);
		else
			return (0);
	}

	if (IIerrflag)
		return (0);	/* error. no data will be coming */

	ret = IIretsym;
	domain = 0;

	for (;;) {
		if (IIpb_get(&IIpb, &sym, 2) != 2)
			IIsyserr("IIgettup bad rdpipe 1");
		if ((length = sym.len & 0377) != 0)
			if (IIpb_get(&IIpb, temp, length) != length)
				IIsyserr("IIgettup bad rdpipe-2 %d", length);
#ifdef xETR1
		if (IIdebug) {
			printf("%s ent ", IIproc_name ? IIproc_name : "");
			printf("gettup type %d len %d\n", sym.type, length);
		}
#endif
		domain++;
		switch (sym.type) {

		  case INT_CONST:
		  case FLOAT_CONST:
			if (ret->type == CHAR_CONST) {
				s = IIitos(domain);
				IIerror(NUMINTOCHAR, 1, &s);
				return (0);
			}
			if (IIconvert(temp, ret->addr, sym.type, length, ret->type, ret->len & 0377) < 0) {
					s = IIitos(domain);
					IIerror(NUMOVFLO, 1, &s);
			}
			break;

		  case CHAR_CONST:
			if (ret->type != CHAR_CONST) {
				s = IIitos(domain);
				IIerror(CHARINTONUM, 1, &s);
				return (0);
			}
			IIbmove(temp, ret->addr, length);
			ret->addr[length] = '\0';	/* null terminate string */
			break;

		  case EOTUP:
			return (1);

		  case EXIT:
			return (0);
		}
		ret++;
	}
}
Esempio n. 8
0
int
d_prot(int pc, paramv_t *pv)
{
	protect_t	protup;
	struct tup_id	protid;
	protect_t	prokey;
	protect_t	proxtup;
	char		ubuf[MAX_LINE_SIZE + 1];
	register int	i;
	short	ix;
	register qtree_t	*t;
	qtree_t		*root;
	register char	*p;
	relation_t	reltup;
	relation_t	relkey;
	struct tup_id	reltid;
	int		relstat;
	int		all_pro;

	/*
	**  Fill in the protection tuple with the information
	**	from the parser, validating as we go.
	**
	**	Also, determine if we have a PERMIT xx to ALL
	**	with no further qualification case.  The variable
	**	'all_pro' is set to reflect this.
	*/

	clr_tuple(&Prodes, (char *) &protup);
	all_pro = TRUE;

	/* read operation set */
	if (pv->pv_type != PV_INT)
		syserr("d_prot: opset");
	protup.p_opset = pv->pv_val.pv_int;
	if ((protup.p_opset & PRO_RETR) != 0)
		protup.p_opset |= PRO_TEST | PRO_AGGR;
	pv++;

	/* read relation name */
	if (pv->pv_type != PV_STR)
		syserr("d_prot: relid");
	pmove(pv->pv_val.pv_str, protup.p_rel, MAX_NAME_SIZE, ' ');
	pv++;

	/* read relation owner */
	if (pv->pv_type != PV_STR)
		syserr("d_prot: relid");
	bmove(pv->pv_val.pv_str, protup.p_owner, sizeof(protup.p_owner));
	pv++;

	/* read user name */
	if (pv->pv_type != PV_STR)
		syserr("d_prot: user");
	if (strcmp(pv->pv_val.pv_str, "all") == 0)
		bmove("  ", protup.p_user, sizeof(protup.p_user));
	else {
		/* look up user in 'users' file */
		if (getnuser(pv->pv_val.pv_str, ubuf))
			qmerror(BADUSRNAME, -1, Qt.qt_resvar, pv->pv_val.pv_str, 0);
		for (p = ubuf; *p != ':' && *p != 0; p++)
			continue;
		bmove(++p, protup.p_user, sizeof(protup.p_user));
		/* XXX - agc assumes only 2 chars */
		if (p[0] == ':' || p[1] == ':' || p[2] != ':')
			syserr("d_prot: users %s", ubuf);
		all_pro = FALSE;
	}
	pv++;

	/* read terminal id */
	if (pv->pv_type != PV_STR) {
		syserr("d_prot: user");
	}
	if (strcmp(pv->pv_val.pv_str, "all") == 0) {
		pmove("", protup.p_term, sizeof(protup.p_term), ' ');
	} else {
		pmove(pv->pv_val.pv_str, protup.p_term, sizeof(protup.p_term), ' ');
		if (!isttyname(pv->pv_val.pv_str))
			qmerror(BADTERM, -1, Qt.qt_resvar, pv->pv_val.pv_str, 0);
		all_pro = FALSE;
	}
	pv++;

	/* read starting time of day */
	if (pv->pv_type != PV_INT)
		syserr("d_prot: btod");
	protup.p_tbegin = pv->pv_val.pv_int;
	if (pv->pv_val.pv_int > 0)
		all_pro = FALSE;
	pv++;
	
	/* read ending time of day */
	if (pv->pv_type != PV_INT)
		syserr("d_prot: etod");
	protup.p_tend = pv->pv_val.pv_int;
	if (pv->pv_val.pv_int < 24 * 60 - 1)
		all_pro = FALSE;
	pv++;

	/* read beginning day of week */
	if (pv->pv_type != PV_STR)
		syserr("d_prot: bdow");
	i = cvt_dow(pv->pv_val.pv_str);
	if (i < 0)
		qmerror(BADDOW, -1, Qt.qt_resvar, pv->pv_val.pv_str, 0);	/* bad dow */
	protup.p_dbegin = i;
	if (i > 0)
		all_pro = FALSE;
	pv++;

	/* read ending day of week */
	if (pv->pv_type != PV_STR)
		syserr("d_prot: edow");
	i = cvt_dow(pv->pv_val.pv_str);
	if (i < 0)
		qmerror(BADDOW, -1, Qt.qt_resvar, pv->pv_val.pv_str, 0);	/* bad dow */
	protup.p_dend = i;
	if (i < 6)
		all_pro = FALSE;
	pv++;

	/*
	**  Check for valid tree:
	**	There must be a tree defined, and all variables
	**	referenced must be owned by the current user; this
	**	is because you could otherwise get at data by
	**	mentioning it in a permit statement; see protect.c
	**	for a better explanation of this.
	*/

	if (pv->pv_type != PV_QTREE)
		syserr("d_prot: tree");
	root = (qtree_t *) pv->pv_val.pv_qtree;
	pv++;

	for (i = 0; i < MAX_VARS + 1; i++) {
		if (Qt.qt_rangev[i].rngvdesc == NULL)
			continue;
		if (!bequal(Qt.qt_rangev[i].rngvdesc->d_r.r_owner, Usercode, USERCODE_SIZE))
			qmerror(OWNEDNOT, -1, i, 0);
	}

	/* test for dba */
	if (!bequal(Usercode, Admin.ad_h.adm_owner, USERCODE_SIZE))
		qmerror(NOTDBA, -1, Qt.qt_resvar, 0);
	
	/* get domain reference set from target list */
	/* (also, find the TREE node) */
	t = root->left;
	if (t->sym.type == TREE) {
		for (i = 0; i < 8; i++)
			protup.p_domset[i] = -1;
	} else {
		for (i = 0; i < 8; i++)
			protup.p_domset[i] = 0;
		for (; t->sym.type != TREE; t = t->left) {
			if (t->right->sym.type != VAR ||
			    t->sym.type != RESDOM ||
			    t->right->sym.value.sym_var.varno != Qt.qt_resvar)
				syserr("d_prot: garbage tree");
			lsetbit(t->right->sym.value.sym_var.attno, protup.p_domset);
		}
		all_pro = FALSE;
	}

	/* trim off the target list, since it isn't used again */
	root->left = t;

	/*
	**  Check out the target relation.
	**	We first save the varno of the relation which is
	**	getting the permit stuff.  Also, we check to see
	**	that the relation mentioned is a base relation,
	**	and not a view, since that tuple would never do
	**	anything anyway.  Finally, we clear the Qt.qt_resvar
	**	so that it does not get output to the tree catalog.
	**	This would result in a 'syserr' when we tried to
	**	read it.
	*/

	protup.p_result = Qt.qt_resvar;
#ifdef xQTR3
	if (Qt.qt_resvar < 0)
		syserr("d_prot: Rv %d", Qt.qt_resvar);
#endif
	if (BITISSET(S_VIEW, Qt.qt_rangev[Qt.qt_resvar].rngvdesc->d_r.r_status))
		qmerror(NOTREALREL, -1, Qt.qt_resvar, 0);	/* is a view */

	/* clear the (unused) Qt.qt_qmode */
#ifdef xQTR3
	if (Qt.qt_qmode != mdPROT)
		syserr("d_prot: Qt.qt_qmode %d", Qt.qt_qmode);
#endif
	Qt.qt_qmode = -1;

	/*
	**  Check for PERMIT xx to ALL case.
	**	The r_status bits will be adjusted as necessary
	**	to reflect these special cases.
	**
	**	This is actually a little tricky, since we cannot
	**	afford to turn off any permissions.  If we already
	**	have some form of PERMIT xx to ALL access, we must
	**	leave it.
	*/

	relstat = Qt.qt_rangev[Qt.qt_resvar].rngvdesc->d_r.r_status;
	if (all_pro && (protup.p_opset & PRO_RETR) != 0) {
		if (protup.p_opset == -1)
			relstat &= ~S_PROTALL;
		else {
			relstat &= ~S_PROTRET;
			if ((protup.p_opset & ~(PRO_RETR|PRO_AGGR|PRO_TEST)) != 0) {
				/* some special case: still insert prot tuple */
				all_pro = FALSE;
			}
		}
	}
	else
		all_pro = FALSE;

	/* see if we are adding any tuples */
	if (!all_pro)
		relstat |= S_PROTUPS;
	
	/*
	**  Change relstat field in relation catalog if changed
	*/

	if (relstat != Qt.qt_rangev[Qt.qt_resvar].rngvdesc->d_r.r_status) {
		opencatalog("relation", OR_WRITE);
		ingres_setkey(&Reldes, &relkey, Qt.qt_rangev[Qt.qt_resvar].rngvdesc->d_r.r_id, RELID);
		ingres_setkey(&Reldes, &relkey, Qt.qt_rangev[Qt.qt_resvar].rngvdesc->d_r.r_owner, RELOWNER);
		i = getequal(&Reldes, &relkey, &reltup, &reltid);
		if (i != 0)
			syserr("d_prot: geteq %d", i);
		reltup.r_status = relstat;
		i = replace(&Reldes, &reltid, &reltup, FALSE);
		if (i != 0)
			syserr("d_prot: repl %d", i);
		if (noclose(&Reldes) != 0)
			syserr("d_prot: noclose(rel)");
	}

	Qt.qt_resvar = -1;

	if (!all_pro) {
		/*
		**  Output the created tuple to the protection catalog
		**  after making other internal adjustments and deter-
		**  mining a unique sequence number (with the protect
		**  catalog locked).
		*/

		if (root->right->sym.type != QLEND)
			protup.p_tree = puttree(root, protup.p_rel, protup.p_owner, mdPROT);
		else
			protup.p_tree = -1;

		/* compute unique permission id */
		opencatalog("protect", OR_WRITE);
		setrll(A_SLP, &Prodes.d_tid, M_EXCL);
		ingres_setkey(&Prodes, &prokey, protup.p_rel, PRORELID);
		ingres_setkey(&Prodes, &prokey, protup.p_owner, PRORELOWN);
		for (ix = 2; ; ix++) {
			ingres_setkey(&Prodes, &prokey, &ix, PROPERMID);
			i = getequal(&Prodes, &prokey, &proxtup, &protid);
			if (i < 0)
				syserr("d_prot: geteq");
			else if (i > 0)
				break;
		}
		protup.p_perm = ix;

		/* do actual insert */
		i = insert(&Prodes, &protid, &protup, FALSE);
		if (i < 0)
			syserr("d_prot: insert");
		if (noclose(&Prodes) != 0)
			syserr("d_prot: noclose(pro)");
		
		/* clear the lock */
		unlrl(&Prodes.d_tid);
	}
	return(0);
}