コード例 #1
0
ファイル: uaccess.c プロジェクト: gnensis/linux-2.6.15
static void do_buffer_op(void *jmpbuf, void *arg_ptr)
{
	va_list args;
	unsigned long addr;
	int len, is_write, size, remain, n;
	int (*op)(unsigned long, int, void *);
	void *arg;
	int *res;

	va_copy(args, *(va_list *)arg_ptr);
	addr = va_arg(args, unsigned long);
	len = va_arg(args, int);
	is_write = va_arg(args, int);
	op = va_arg(args, void *);
	arg = va_arg(args, void *);
	res = va_arg(args, int *);
	va_end(args);
	size = min(PAGE_ALIGN(addr) - addr, (unsigned long) len);
	remain = len;

	current->thread.fault_catcher = jmpbuf;
	n = do_op(addr, size, is_write, op, arg);
	if(n != 0){
		*res = (n < 0 ? remain : 0);
		goto out;
	}

	addr += size;
	remain -= size;
	if(remain == 0){
		*res = 0;
		goto out;
	}

	while(addr < ((addr + remain) & PAGE_MASK)){
		n = do_op(addr, PAGE_SIZE, is_write, op, arg);
		if(n != 0){
			*res = (n < 0 ? remain : 0);
			goto out;
		}

		addr += PAGE_SIZE;
		remain -= PAGE_SIZE;
	}
	if(remain == 0){
		*res = 0;
		goto out;
	}

	n = do_op(addr, remain, is_write, op, arg);
	if(n != 0)
		*res = (n < 0 ? remain : 0);
	else *res = 0;
 out:
	current->thread.fault_catcher = NULL;
}
コード例 #2
0
ファイル: sort_stack.c プロジェクト: ftriquet/push_swap
void		check_bottom(t_stack *a, t_stack *b)
{
	int		t[2];

	if (a->size <= 2)
		return ;
	get_min_max(a, t, t + 1);
	if (a->bottom->prev->value == t[1])
	{
		do_op(a, b, "rra");
		do_op(a, b, "rra");
		do_op(a, b, "sa");
		do_op(a, b, "ra");
		do_op(a, b, "ra");
	}
}
コード例 #3
0
ファイル: sort_stack.c プロジェクト: ftriquet/push_swap
int		check_last_push(t_stack *a, t_stack *b)
{
	int		min_max[2];

	if (is_sort(a))
	{
		while (!empty(b))
			do_op(a, b, "pa");
		get_min_max(a, min_max, min_max + 1);
		while (a->top->value != min_max[0])
			do_op(a, b, "ra");
	}
	else
		return (0);
	return (1);
}
コード例 #4
0
ファイル: bf_main.cpp プロジェクト: CzechsMix/FungePP
int main(int argc, char **argv)
{
  if(argc <= 1)
  {
    cout << "Usage: F++ <file>" << endl;
    cout << "  Loads and runs the befunge program <file>" << endl;
    return 0;
  }
  
  init_rand();
  init_grid(argv[1]);

  while(_RUN)
  {
    char C = _GRID[_Y][_X];

    if(C != 0 && (_MODE == _NORMAL || C == '"'))
    {
      //cout << "in normal mode, doing op " << C << endl;
      do_op(C);
    }
    else if(C != 0)
    {
      //cout << "in string mode, pushing " << C << endl;
      push(C);
    }
    
    move();
    //sleep(1);
  }
  cout << endl;
  return 0;
}
コード例 #5
0
ファイル: textarea.c プロジェクト: Efreak/elinks
static enum frame_event_status
textarea_op(struct form_state *fs, struct form_control *fc, int utf8,
	    int (*do_op)(struct form_state *, struct line_info *, int, int))
{
	struct line_info *line;
	int current, state;
	int state_cell;

	assert(fs && fs->value && fc);
	if_assert_failed return FRAME_EVENT_OK;

	if (utf8)
		line = format_textutf8(fs->value, fc->cols, fc->wrap, 0);
	else
		line = format_text(fs->value, fc->cols, fc->wrap, 0);
	if (!line) return FRAME_EVENT_OK;

	current = get_textarea_line_number(line, fs->state);
	state = fs->state;
	state_cell = fs->state_cell;
	if (do_op(fs, line, current, utf8)) {
		mem_free(line);
		return FRAME_EVENT_IGNORED;
	}

	mem_free(line);
	return (fs->state == state && fs->state_cell == state_cell)
		? FRAME_EVENT_OK : FRAME_EVENT_REFRESH;
}
コード例 #6
0
ファイル: sort_stack.c プロジェクト: ftriquet/push_swap
int		check_top(t_stack *a, t_stack *b)
{
	if (a->size >= 2 && a->size <= 10 &&
			a->top->value > a->top->next->value)
	{
		do_op(a, b, "sa");
	}
	return (1);
}
コード例 #7
0
int node_depth(node *n)    
{
    node *parent = loop_containing(n);
    if( parent != Entry ) {
	assert(do_op(parent->nodeop));
	return parent->nodevalue;
    }
    else
	return 0;
}
コード例 #8
0
ファイル: do-op.c プロジェクト: kmaillar/Piscine
int		main(int argc, char** argv)
{
	if(!check_params(argc, argv))
	{
		putline("0");
		return (0);
	}
	do_op(argv[i], argv[2], argv[3]);
	return (0);
}
コード例 #9
0
ファイル: do_op.c プロジェクト: mcuer/test
int		main(int argc, char **argv)
{
    if (argc < 2)
    {
        return (-1);
    }
    else
    {
        do_op(argv[1],argv[2],argv[3]);
    }
    return (0);
}
コード例 #10
0
ファイル: cs_mkick.c プロジェクト: fish-guts/reefmaster
/**
 * kick every user off the channel
 */
void do_mkick(channel *c, char *reason) {
	if(c != NULL) {
		do_join(cs_name,c->name);
		do_op(cs_name,cs_name,c->name);
		chanuser *cu = c->users;
		while(cu) {
			kick(cs_name,cu->u->nick,c->name,reason);
			cu = cu->next;
		}
		do_part(cs_name,c->name,"Leaving");
	}
}
コード例 #11
0
ファイル: eval.c プロジェクト: eldy/other
/* Evaluate one level */
static int do_paren(void)
{
      int op;
      if (1 > parens--)
	    return E_ERROR;
      do
      {
	    if (SUCCESS > (op = do_op()))
		  break;
      } while (getprec((char)op));
      return op;
}
コード例 #12
0
ファイル: sort_stack.c プロジェクト: ftriquet/push_swap
void	rot_to_min(t_stack *a, t_stack *b, int *min_max, int rev)
{
	while (a->top->value != min_max[0])
	{
		if (a->top->value == min_max[1])
		{
			do_op(a, b, "pb");
			if (rev == 0)
				do_op(a, b, "rr");
			else
				do_op(a, b, "rb");
			min_max[1]--;
		}
		if (a->top && a->top->value == min_max[1])
			continue ;
		if (rev == 1)
			do_op(a, b, "rra");
		else if (rev == 0)
			do_op(a, b, "ra");
		if (rev == -1)
			rev = 0;
	}
	if (is_sort(a))
		return ;
	do_op(a, b, "pb");
}
コード例 #13
0
ファイル: eval.c プロジェクト: AshishKumar4/quafios
int eval(linkedlist *expr, double *val) {

    int i;
    stack_t stk; /* operator stack */

    stack_init(&stk);

    for(i = 0; i < linkedlist_size(expr); i++) {
        token_t *t = linkedlist_get(expr, i);
        token_t *n2, *n1, *res;

        /* if number, push to stack: */
        if (t->type == TOKEN_NUMBER) {
            stack_push(&stk, t);
            continue;
        }

        /* all operators in the postfix expression are binary. */
        if (stack_size(&stk) < 2) {
            while(!stack_isEmpty(&stk))
                free(stack_pop(&stk));
            /* free the remaining tokens in expr: */
            while(i < linkedlist_size(expr))
                free(linkedlist_get(expr, i++));
            return -1; /* error. */
        }
        n2 = stack_pop(&stk);
        n1 = stack_pop(&stk);

        res = malloc(sizeof(token_t));
        res->type = TOKEN_NUMBER;
        res->op   = 0;
        res->num  = do_op(n1->num, n2->num, t->op);
        stack_push(&stk, res);

        free(n2);
        free(n1);
        free(t);
    }

    if (stack_size(&stk) != 1) {
        while(!stack_isEmpty(&stk)) {
            free(stack_pop(&stk));
        }
        return -1; /* error. */
    }

    *val = ((token_t *) stack_peek(&stk))->num;
    free(stack_pop(&stk));
    return 0;

}
コード例 #14
0
ファイル: ffsb_thread.c プロジェクト: Mellanox/arc_ltp
void *ft_run(void *data)
{
	ffsb_thread_t *ft = (ffsb_thread_t *)data;
	tg_op_params_t params;
	unsigned wait_time = tg_get_waittime(ft->tg);
	int stopval = tg_get_stopval(ft->tg);

	ffsb_barrier_wait(tg_get_start_barrier(ft->tg));

	while (tg_get_flagval(ft->tg) != stopval) {
		tg_get_op(ft->tg, &ft->rd, &params);
		do_op(ft, params.fs, params.opnum);
		ffsb_milli_sleep(wait_time);
	}
	return NULL;
}
コード例 #15
0
ファイル: do_op.c プロジェクト: dary10/projects
int		main(int ac, char **av)
{
	int		*x;
	int		*y;

	if (ac != 4)
		ft_putchar('\n');
	else
	{
		x = (int *)malloc(sizeof(int));
		y = (int *)malloc(sizeof(int));
		*x = atoi(av[1]);
		*y = atoi(av[3]);
		do_op(*x, *av[2], *y);
	}
	return (0);
}
コード例 #16
0
ファイル: expr.c プロジェクト: ArtemioUrbina/huc
int
push_op(int op)
{
	if (op != OP_OPEN) {
		while (op_pri[op_stack[op_idx]] >= op_pri[op]) {
			if (!do_op())
				return (0);
		}
	}
	if (op_idx == 63) {
		error("Expression too complex!");
		return (0);
	}
	op_idx++;
	op_stack[op_idx] = op;
	need_operator = 0;
	return (1);
}
コード例 #17
0
ファイル: deal_op.c プロジェクト: Morefaya/push_swap
void	deal_op(int opt, t_list **lst_a, t_list **lst_b)
{
	t_list	*op_lst;

	op_lst = NULL;
	if (!opt)
	{
		if (!(op_lst = get_op_lst()))
			return ;
		do_allop(lst_a, lst_b, &op_lst);
		ft_lstdel(&op_lst, (void(*)(void*, size_t))del_op);
	}
	else if (opt & OPT_A)
	{
		print_lst(*lst_a);
		ft_putchar('\n');
		do_op(lst_a, lst_b);
	}
}
コード例 #18
0
ファイル: doop.c プロジェクト: omegahat/RGCCTranslationUnit
SEXP
R_do_op(SEXP r_a, SEXP r_b, SEXP r_op)
{
	
		SEXP r_ans = R_NilValue;
		int a ;
		int b ;
		int  (* op ) ( int, int ) ;
		 int ans ;
	
		 a  =  asInteger( r_a ) ;
		 b  =  asInteger( r_b ) ;
		 op  =  ( int  (*) ( int, int ) ) R_asFunctionPointer( r_op ,  do_op_fun ,  do_op_stack ); ;
	
		ans =  do_op ( a, b, op );
		 r_ans =  ScalarInteger ( ans ) ;
	
		 return(r_ans);
}
コード例 #19
0
ファイル: cs_op.c プロジェクト: fish-guts/reefmaster
/**
 * handle the OP command
 */
void cs_op(char *src, int ac, char **av) {
	char *nick,*chan;
	int level_src,level_target;
	user *u,*u1;
	ChanInfo *c;
	if(ac<3) {
		notice(cs_name,src,CS_OP_ERR_USAGE,"OP");
		notice(cs_name,src,CS_RPL_HLP,cs_name, "OP");
		return;
	}
	nick = sstrdup(av[2]);
	chan = sstrdup(av[1]);
	if(!isregcs(chan)) {
		notice(cs_name,src,CS_ERR_NOTREG,chan);
		return;
	}
	u = finduser(src);
	u1 = finduser(nick);
	c = findchan(chan);
	level_src = cs_xop_get_level(u,c);
	level_target = cs_xop_get_level(u1,c);
	if(level_src<AOP_LIST) {
		notice(cs_name,src,CS_XOP_ERR_HIGHERACCESS,"Aop");
		return;
	}
	if(level_target<AOP_LIST) {
		if(stricmp(src,nick)==0) {
			notice(cs_name,src,CS_XOP_ERR_HIGHERACCESS,"Aop");
			return;
		} else {
			notice(cs_name,src,CS_XOP_ERR_HIGHERACCESS2,nick);
			return;
		}
	}
	do_op(cs_name,nick,chan);
	return;
}
コード例 #20
0
ファイル: expr.c プロジェクト: ArtemioUrbina/huc
int
evaluate(int *ip, char last_char)
{
	int end, level;
	int op, type;
	int arg;
	int i;
	unsigned char c;

	end = 0;
	level = 0;
	undef = 0;
	op_idx = 0;
	val_idx = 0;
	value = 0;
	val_stack[0] = 0;
	need_operator = 0;
	expr_lablptr = NULL;
	expr_lablcnt = 0;
	op = OP_START;
	func_idx = 0;

	/* array index to pointer */
	expr = &prlnbuf[*ip];

	/* skip spaces */
cont:
	while (isspace(*expr))
		expr++;

	/* search for a continuation char */
	if (*expr == '\\') {
		/* skip spaces */
		i = 1;
		while (isspace(expr[i]))
			i++;

		/* check if end of line */
		if (expr[i] == ';' || expr[i] == '\0') {
			/* output */
			if (!continued_line) {
				/* replace '\' with three dots */
				strcpy(expr, "...");

				/* store the current line */
				strcpy(tmplnbuf, prlnbuf);
			}

			/* ok */
			continued_line++;

			/* read a new line */
			if (readline() == -1)
				return (0);

			/* rewind line pointer and continue */
			expr = &prlnbuf[SFIELD];
			goto cont;
		}
	}

	/* parser main loop */
	while (!end) {
		c = *expr;

		/* number */
		if (isdigit(c)) {
			if (need_operator)
				goto error;
			if (!push_val(T_DECIMAL))
				return (0);
		}

		/* symbol */
		else
		if (isalpha(c) || c == '_' || c == '.') {
			if (need_operator)
				goto error;
			if (!push_val(T_SYMBOL))
				return (0);
		}

		/* operators */
		else {
			switch (c) {
			/* function arg */
			case '\\':
				if (func_idx == 0) {
					error("Syntax error in expression!");
					return (0);
				}
				expr++;
				c = *expr++;
				if (c < '1' || c > '9') {
					error("Invalid function argument index!");
					return (0);
				}
				arg = c - '1';
				expr_stack[func_idx++] = expr;
				expr = func_arg[func_idx - 2][arg];
				break;

			/* hexa prefix */
			case '$':
				if (need_operator)
					goto error;
				if (!push_val(T_HEXA))
					return (0);
				break;

			/* character prefix */
			case '\'':
				if (need_operator)
					goto error;
				if (!push_val(T_CHAR))
					return (0);
				break;

			/* round brackets */
			case '(':
				if (need_operator)
					goto error;
				if (!push_op(OP_OPEN))
					return (0);
				level++;
				expr++;
				break;
			case ')':
				if (!need_operator)
					goto error;
				if (level == 0)
					goto error;
				while (op_stack[op_idx] != OP_OPEN) {
					if (!do_op())
						return (0);
				}
				op_idx--;
				level--;
				expr++;
				break;

			/* not equal, left shift, lower, lower or equal */
			case '<':
				if (!need_operator)
					goto error;
				expr++;
				switch (*expr) {
				case '>':
					op = OP_NOT_EQUAL;
					expr++;
					break;
				case '<':
					op = OP_SHL;
					expr++;
					break;
				case '=':
					op = OP_LOWER_EQUAL;
					expr++;
					break;
				default:
					op = OP_LOWER;
					break;
				}
				if (!push_op(op))
					return (0);
				break;

			/* right shift, higher, higher or equal */
			case '>':
				if (!need_operator)
					goto error;
				expr++;
				switch (*expr) {
				case '>':
					op = OP_SHR;
					expr++;
					break;
				case '=':
					op = OP_HIGHER_EQUAL;
					expr++;
					break;
				default:
					op = OP_HIGHER;
					break;
				}
				if (!push_op(op))
					return (0);
				break;

			/* equal */
			case '=':
				if (!need_operator)
					goto error;
				if (!push_op(OP_EQUAL))
					return (0);
				expr++;
				break;

			/* one complement */
			case '~':
				if (need_operator)
					goto error;
				if (!push_op(OP_COM))
					return (0);
				expr++;
				break;

			/* sub, neg */
			case '-':
				if (need_operator)
					op = OP_SUB;
				else
					op = OP_NEG;
				if (!push_op(op))
					return (0);
				expr++;
				break;

			/* not, not equal */
			case '!':
				if (!need_operator)
					op = OP_NOT;
				else {
					op = OP_NOT_EQUAL;
					expr++;
					if (*expr != '=')
						goto error;
				}
				if (!push_op(op))
					return (0);
				expr++;
				break;

			/* binary prefix, current PC */
			case '%':
			case '*':
				if (!need_operator) {
					if (c == '%')
						type = T_BINARY;
					else
						type = T_PC;
					if (!push_val(type))
						return (0);
					break;
				}

			/* modulo, mul, add, div, and, xor, or */
			case '+':
			case '/':
			case '&':
			case '^':
			case '|':
				if (!need_operator)
					goto error;
				switch (c) {
				case '%': op = OP_MOD; break;
				case '*': op = OP_MUL; break;
				case '+': op = OP_ADD; break;
				case '/': op = OP_DIV; break;
				case '&': op = OP_AND; break;
				case '^': op = OP_XOR; break;
				case '|': op = OP_OR;  break;
				}
				if (!push_op(op))
					return (0);
				expr++;
				break;

			/* skip immediate operand prefix if in macro */
			case '#':
				if (expand_macro)
					expr++;
				else
					end = 3;
				break;

			/* space or tab */
			case ' ':
			case '\t':
				expr++;
				break;

			/* end of line */
			case '\0':
				if (func_idx) {
					func_idx--;
					expr = expr_stack[func_idx];
					break;
				}
			case ';':
				end = 1;
				break;
			case ',':
				end = 2;
				break;
			default:
				end = 3;
				break;
			}
		}
	}

	if (!need_operator)
		goto error;
	if (level != 0)
		goto error;
	while (op_stack[op_idx] != OP_START) {
		if (!do_op())
			return (0);
	}

	/* get the expression value */
	value = val_stack[val_idx];

	/* any undefined symbols? trap that if in the last pass */
	if (undef) {
		if (pass == LAST_PASS)
			error("Undefined symbol in operand field!");
	}

	/* check if the last char is what the user asked for */
	switch (last_char) {
	case ';':
		if (end != 1)
			goto error;
		expr++;
		break;
	case ',':
		if (end != 2) {
			error("Argument missing!");
			return (0);
		}
		expr++;
		break;
	}

	/* convert back the pointer to an array index */
	*ip = expr - prlnbuf;

	/* ok */
	return (1);

	/* syntax error */
error:
	error("Syntax error in expression!");
	return (0);
}
コード例 #21
0
ファイル: eval.c プロジェクト: eldy/other
int evaluate(char *line, double *val)
//--------------------------------------------------------------------
// Evaluates an ASCII mathematical expression
// INPUT:  line:  String to evaluate
//         val:   Storage to receive double result
//   
// RETURN: SUCCESS =  0 if successful  
//         E_ERROR = -1 if syntax error  
//         R_ERROR = -2 if runtime error 
//         DUV_ZERO= -3 Division by 0    
// 
// Side effects: Removes all whitespace from the string and converts
//               it to U.C.
//--------------------------------------------------------------------
{
double arg;
char *ptr = line, *str, *endptr;
int ercode;
struct operator *op;

strupr(line);
rmallws(line);
state = op_sptr = arg_sptr = parens = 0;

while (*ptr)
      {
	    switch (state)
	    {
	    case 0:
		  if (NULL != (str = get_exp(ptr)))
		  {
			if (NULL != (op = get_op(str)) &&
			      strlen(str) == op->taglen)
			{
			      push_op(op->token);
			      ptr += op->taglen;
			      break;
			}

			if (SUCCESS == strcmp(str, "-"))
			{
			      push_op(*str);
			      ++ptr;
			      break;
			}

			if (SUCCESS == strcmp(str, "PI"))
			      push_arg(Pi);

			else
			{
			      if (0.0 == (arg = strtod(str, &endptr)) &&
				    NULL == strchr(str, '0'))
			      {
				    return E_ERROR;
			      }
			      push_arg(arg);
			}
			ptr += strlen(str);
		  }
		  else  return E_ERROR;

		  state = 1;
		  break;

	    case 1:
		  if (NULL != (op = get_op(ptr)))
		  {
			if (')' == *ptr)
			{
			      if (SUCCESS > (ercode = do_paren()))
				    return ercode;
			}
			else
			{
			      while (op_sptr &&
				    op->precedence <= getTOSprec())
			      {
				    do_op();
			      }
			      push_op(op->token);
			      state = 0;
			}

			ptr += op->taglen;
		  }
		  else  return E_ERROR;

		  break;
	    }
      }

      while (1 < arg_sptr)
      {
	    if (SUCCESS > (ercode = do_op()))
		  return ercode;
      }
      if (!op_sptr)
	    return pop_arg(val);
      else  return E_ERROR;
}
コード例 #22
0
ファイル: testLcp.cpp プロジェクト: 4T-Shirt/mysql
int 
main(int argc, char ** argv){
  ndb_init();
  require(!init_ndb(argc, argv));
  if(parse_args(argc, argv))
    return -1;
  require(!connect_ndb());
  
  if(g_setup_tables){
    require(!drop_all_tables());
    
    if(NDBT_Tables::createTable(g_ndb, g_tablename) != 0){
      exit(-1);
    }
  }
  
  g_table = g_ndb->getDictionary()->getTable(g_tablename);
  if(g_table == 0){
    g_err << "Failed to retreive table: " << g_tablename << endl;
    exit(-1);
  }
  require(g_hugo_ops = new HugoOperations(* g_table));
  require(!g_hugo_ops->startTransaction(g_ndb));
  
  g_ops= new CASE[g_rows];
  
  const int use_ops = g_use_ops;
  for(size_t i = 0; i<OP_COUNT; i++)
  {
    if(g_one_op_at_a_time){
      while(i < OP_COUNT && (use_ops & (1 << i)) == 0) i++;
      if(i == OP_COUNT)
	break;
      ndbout_c("-- loop\noperation: %c use_ops: %x", 'a'+i, use_ops);
      g_use_ops = (1 << i);
    } else {
      i = OP_COUNT - 1;
    }
    
    size_t test_case = 0;
    if((1 << test_case++) & g_cases)
    {
      for(size_t tl = 0; tl<g_case_loop; tl++){
	g_info << "Performing all ops wo/ inteference of LCP" << endl;
	
	g_info << "Testing pre LCP operations, ZLCP_OP_WRITE_RT_BREAK" << endl;
	g_info << "  where ZLCP_OP_WRITE_RT_BREAK is "
	  " finished before SAVE_PAGES" << endl;
	require(!load_table());
	require(!pause_lcp(5900));
	for(size_t j = 0; j<g_rows; j++){
	  require(!do_op(j));
	}
	require(!continue_lcp(5900));
	require(!commit());
	require(!pause_lcp(5900));
	require(!restart());
	require(!validate());
      }  
    }
    
    if((1 << test_case++) & g_cases)
    {
      for(size_t tl = 0; tl<g_case_loop; tl++){
	g_info << "Testing pre LCP operations, ZLCP_OP_WRITE_RT_BREAK" << endl;
	g_info << "  where ZLCP_OP_WRITE_RT_BREAK is finished after SAVE_PAGES"
	       << endl;
	require(!load_table());
	require(!pause_lcp(5901));
	for(size_t j = 0; j<g_rows; j++){
	  require(!do_op(j));
	}
	require(!continue_lcp(5901));
	require(!commit());
	require(!pause_lcp(5900));
	require(!restart());
	require(!validate());
      }    
    }

    if((1 << test_case++) & g_cases)
    {
      for(size_t tl = 0; tl<g_case_loop; tl++){
	g_info << "Testing pre LCP operations, undo-ed at commit" << endl;
	require(!load_table());
	require(!pause_lcp(5902));
	for(size_t j = 0; j<g_rows; j++){
	  require(!do_op(j));
	}
	require(!continue_lcp(5902));
	require(!commit());
	require(!continue_lcp(5903));
	require(!pause_lcp(5900));
	require(!restart());
	require(!validate());
      }
    }
    
    if((1 << test_case++) & g_cases)
    {
      for(size_t tl = 0; tl<g_case_loop; tl++){
	g_info << "Testing prepared during LCP and committed after" << endl;
	require(!load_table());
	require(!pause_lcp(5904));    // Start LCP, but don't save pages
	for(size_t j = 0; j<g_rows; j++){
	  require(!do_op(j));
	}
	require(!continue_lcp(5904)); // Start ACC save pages
	require(!pause_lcp(5900));    // Next LCP
	require(!commit());
	require(!restart());
	require(!validate());
      }
    }
  }
}
コード例 #23
0
ファイル: msgcmds.c プロジェクト: vap0r/wraith
static int msg_op(char *nick, char *host, struct userrec *u, char *par)
{
  struct chanset_t *chan = NULL;
  char *pass = NULL;
  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0 };

  if (match_my_nick(nick))
    return BIND_RET_BREAK;
  pass = newsplit(&par);

  bd::String msg;

  if (homechan[0]) {
    struct chanset_t *hchan = NULL;

    hchan = findchan_by_dname(homechan);

    if (hchan && channel_active(hchan) && !ismember(hchan, nick)) {
      putlog(LOG_CMDS, "*", "(%s!%s) !*! failed OP %s (not in %s)", nick, host, par, homechan);
      if (par[0]) 
        msg = bd::String::printf("---- (%s!%s) attempted to OP for %s but is not currently in %s.", nick, host, par, homechan);
      else
        msg = bd::String::printf("---- (%s!%s) attempted to OP but is not currently in %s.", nick, host, homechan);
      privmsg(homechan, msg.c_str(), DP_SERVER);
      return BIND_RET_BREAK;
    }
  }

  if (u_pass_match(u, pass)) {
    if (!u_pass_match(u, "-")) {
      if (par[0]) {
        chan = findchan_by_dname(par);
        if (chan && channel_active(chan)) {
          get_user_flagrec(u, &fr, par, chan);
          if (chk_op(fr, chan)) {
            if (do_op(nick, chan, 0, 1)) {
              stats_add(u, 0, 1);
              putlog(LOG_CMDS, "*", "(%s!%s) !%s! OP %s", nick, host, u->handle, par);
              if (manop_warn && chan->manop) {
                msg = bd::String::printf("%s is currently set to punish for manual op.", chan->dname);
                notice(nick, msg.c_str(), DP_HELP);
              }
            }
          }
          return BIND_RET_BREAK;
        }
      } else {
        int stats = 0;
        for (chan = chanset; chan; chan = chan->next) {
          get_user_flagrec(u, &fr, chan->dname, chan);
          if (chk_op(fr, chan)) {
            if (do_op(nick, chan, 0, 1)) {
              stats++;
              if (manop_warn && chan->manop) {
                msg = bd::String::printf("%s is currently set to punish for manual op.", chan->dname);
                notice(nick, msg.c_str(), DP_HELP);
              }
            }
          }
        }
        putlog(LOG_CMDS, "*", "(%s!%s) !%s! OP", nick, host, u->handle);
        if (stats)
          stats_add(u, 0, 1);
        return BIND_RET_BREAK;
      }
    }
  }
  putlog(LOG_CMDS, "*", "(%s!%s) !*! failed OP", nick, host);
  return BIND_RET_BREAK;
}
コード例 #24
0
ファイル: gf8calc.c プロジェクト: AarhusCrypto/MiniAES
gf8 read_op(char op, char * s, int * index) {
  gf8 left = do_read(s,index);
  gf8 right = do_read(s,index);
  return do_op(op, left, right);
}
コード例 #25
0
ファイル: tncon.cpp プロジェクト: hoangduit/reactos
int telProcessConsole(NetParams *pParams, KeyTranslator &KeyTrans,
					  TConsole &Console, TNetwork &Network, TMouse &Mouse,
					  Tnclip &Clipboard, HANDLE hThread)
{
	KeyDefType_const keydef;
	const char *p;
	int p_len;
	unsigned int i;
	int opval;
	HANDLE hConsole = GetStdHandle(STD_INPUT_HANDLE);

	SetConsoleMode(hConsole, ini.get_enable_mouse() ? ENABLE_MOUSE_INPUT : 0);

	const DWORD nHandle = 2;
	HANDLE hHandle[nHandle] = {hConsole, pParams->hExit};

	for (;;) {
		DWORD dwInput;
		switch (WaitForMultipleObjects(nHandle, hHandle, FALSE, INFINITE)) {
        case WAIT_OBJECT_0: {

			// Paul Brannan 7/29/98
			if(ini.get_input_redir()) {
				char InputBuffer[10];

				// Correction from Joe Manns <*****@*****.**>
				// to fix race conditions (4/13/99)
				int bResult;
				bResult = ReadFile(hConsole, InputBuffer, 10, &dwInput, 0);
				if(bResult && dwInput == 0) return TNNOCON;

				// no key translation for redirected input
				Network.WriteString(InputBuffer, dwInput);
				break;
			}

			INPUT_RECORD InputRecord[11];
			if (!ReadConsoleInput(hConsole, &InputRecord[0], 10, &dwInput))
				return TNPROMPT;

			for (i = 0; (unsigned)i < dwInput; i++){
				switch (InputRecord[i].EventType) {
				case KEY_EVENT:{
					if (KEYEVENT.bKeyDown) {

						WORD  keyCode  = KEYEVENT.wVirtualKeyCode;
						DWORD keyState = KEYEVENT.dwControlKeyState;

						// Paul Brannan 5/27/98
						// Moved the code that was here to FindClosestKey()
						keydef.szKeyDef = FindClosestKey(keyCode,
							keyState, KeyTrans);

						if(keydef.szKeyDef) {
							if(!keydef.op->sendstr)
								if((opval = do_op(keydef.op->the_op, Network,
									Clipboard)) != 0)
									return opval;
						}

						if(Network.get_line_mode()) {
							if(DoLineModeSpecial(KEYEVENT_CHAR, Console, Network, pParams))
								continue;
						}

						p = keydef.szKeyDef;
						if (p == NULL) { // if we don't have a translator
							if(!KEYEVENT_CHAR) continue;
							p_len = 1;
							p = KEYEVENT_PCHAR;
						} else {
							p_len = strlen(p);
						}

						// Local echo (Paul Brannan 5/16/98)
						DoEcho(p, p_len, Console, Network, pParams);
						// Line mode (Paul Brannan 12/31/98)
						DoLineMode(p, p_len, Console, Network);
					}
							   }
					break;

				case MOUSE_EVENT:
					if(!InputRecord[i].Event.MouseEvent.dwEventFlags) {
						ResetEvent(pParams->hUnPause);
						SetEvent(pParams->hPause);
						while (!*pParams->bNetPaused);	// thread paused
						// SuspendThread(hThread);

						// Put the mouse's X and Y coords back into the
						// input buffer
						DWORD Result;
						WriteConsoleInput(hConsole, &InputRecord[i], 1,
							&Result);

						Mouse.doMouse();

						SetEvent(pParams->hUnPause);
						// ResumeThread(hThread);
					}
					break;

				case FOCUS_EVENT:
					break;
				case WINDOW_BUFFER_SIZE_EVENT:
					// FIX ME!!  This should take care of the window re-sizing bug
					// Unfortunately, it doesn't.
					Console.sync();
					Network.do_naws(Console.GetWidth(), Console.GetHeight());
					break;
				}

			} // keep going until no more input
			break;
							}
        default:
			return TNNOCON;
		}
	}
}