Exemplo n.º 1
0
static int run_remote(int fd, const char *command)
{
	fflush(stdout);

	if (!ctl_send_chars(fd, command, -1)) {
		printf("\r[%sFAIL%s]\n", c(RED, use_colors), c(CLEAR, use_colors));
		return COMMAND_FAILED;
	}

	struct luadebug_user *readline_user = luadebug_user_readline();
	if (!readline_user) {
		printf(": %ls", clear_error());
		printf("\r[%sFAIL%s]\n", c(RED, use_colors), c(CLEAR, use_colors));
	}

	if (check_status(fd, NULL) == COMMAND_SUCCESS) {
		luadebug_user_remote_server(fd, readline_user);
		if (check_error()) {
			message(HAKA_LOG_FATAL, L"debug", clear_error());
			return COMMAND_FAILED;
		}
		return COMMAND_SUCCESS;
	}
	else {
		return COMMAND_FAILED;
	}
}
Exemplo n.º 2
0
static char *vacuum1_thread_writer(int iTid, void *pArg){
  Error err = {0};                /* Error code and message */
  Sqlite db = {0};                /* SQLite database connection */
  opendb(&err, &db, "test.db", 0);
  i64 i = 0;

  while( !timetostop(&err) ){
    i++;

    /* Insert lots of rows. Then delete some. */
    execsql(&err, &db, 
        "WITH loop(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM loop WHERE i<100) "
        "INSERT INTO t1 SELECT randomblob(50), randomblob(2500) FROM loop"
    );

    /* Delete lots of rows */
    execsql(&err, &db, "DELETE FROM t1 WHERE rowid = :i", &i);
    clear_error(&err, SQLITE_LOCKED);

    /* Select the rows */
    execsql(&err, &db, "SELECT * FROM t1 ORDER BY x");
    clear_error(&err, SQLITE_LOCKED);
  }

  closedb(&err, &db);
  print_and_free_err(&err);
  return sqlite3_mprintf("ok");
}
Exemplo n.º 3
0
inline int fcntl(int d, long cmd, long arg, boost::system::error_code& ec)
{
    clear_error(ec);
    int result = error_wrapper(::fcntl(d, cmd, arg), ec);
    if (result != -1)
        clear_error(ec);
    return result;
}
Exemplo n.º 4
0
inline int open(const char* path, int flags, boost::system::error_code& ec)
{
    clear_error(ec);
    int result = error_wrapper(::open(path, flags), ec);
    if (result >= 0)
        clear_error(ec);
    return result;
}
Exemplo n.º 5
0
inline int close(int d, boost::system::error_code& ec)
{
    clear_error(ec);
    int result = error_wrapper(::close(d), ec);
    if (result == 0)
        clear_error(ec);
    return result;
}
Exemplo n.º 6
0
inline int ioctl(int d, long cmd, ioctl_arg_type* arg,
                 boost::system::error_code& ec)
{
    clear_error(ec);
    int result = error_wrapper(::ioctl(d, cmd, arg), ec);
    if (result >= 0)
        clear_error(ec);
    return result;
}
Exemplo n.º 7
0
inline int scatter_read(int d, buf* bufs, size_t count,
                        boost::system::error_code& ec)
{
    clear_error(ec);
    int result = error_wrapper(::readv(d, bufs, static_cast<int>(count)), ec);
    if (result >= 0)
        clear_error(ec);
    return result;
}
Exemplo n.º 8
0
inline int gather_write(int d, const buf* bufs, size_t count,
                        boost::system::error_code& ec)
{
    clear_error(ec);
    int result = error_wrapper(::writev(d, bufs, static_cast<int>(count)), ec);
    if (result >= 0)
        clear_error(ec);
    return result;
}
inline int poll_write(int d, boost::system::error_code& ec)
{
  clear_error(ec);
  pollfd fds;
  fds.fd = d;
  fds.events = POLLOUT;
  fds.revents = 0;
  clear_error(ec);
  return error_wrapper(::poll(&fds, 1, -1), ec);
}
Exemplo n.º 10
0
inline int poll_read(int d, boost::system::error_code& ec)
{
    clear_error(ec);
    pollfd fds;
    fds.fd = d;
    fds.events = POLLIN;
    fds.revents = 0;
    clear_error(ec);
    int result = error_wrapper(::poll(&fds, 1, -1), ec);
    if (result >= 0)
        clear_error(ec);
    return result;
}
Exemplo n.º 11
0
int
hstcpcli::request_send()
{
  if (error_code < 0) {
    return error_code;
  }
  clear_error();
  if (fd.get() < 0) {
    close();
    return set_error(-1, "write: closed");
  }
  if (num_req_bufd == 0 || num_req_sent > 0 || num_req_rcvd > 0) {
    close();
    return set_error(-1, "request_send: protocol out of sync");
  }
  const size_t wrlen = writebuf.size();
  const ssize_t r = send(fd.get(), writebuf.begin(), wrlen, MSG_NOSIGNAL);
  if (r <= 0) {
    close();
    return set_error(-1, r < 0 ? "write: failed" : "write: eof");
  }
  writebuf.erase_front(r);
  if (static_cast<size_t>(r) != wrlen) {
    close();
    return set_error(-1, "write: incomplete");
  }
  num_req_sent = num_req_bufd;
  num_req_bufd = 0;
  DBG(fprintf(stderr, "REQSEND 0\n"));
  return 0;
}
Exemplo n.º 12
0
/* call a request handler */
static void call_req_handler( struct thread *thread )
{
    union generic_reply reply;
    enum request req = thread->req.request_header.req;

    current = thread;
    current->reply_size = 0;
    clear_error();
    memset( &reply, 0, sizeof(reply) );

    if (debug_level) trace_request();

    if (req < REQ_NB_REQUESTS)
        req_handlers[req]( &current->req, &reply );
    else
        set_error( STATUS_NOT_IMPLEMENTED );

    if (current)
    {
        if (current->reply_fd)
        {
            reply.reply_header.error = current->error;
            reply.reply_header.reply_size = current->reply_size;
            if (debug_level) trace_reply( req, &reply );
            send_reply( &reply );
        }
        else
        {
            current->exit_code = 1;
            kill_thread( current, 1 );  /* no way to continue without reply fd */
        }
    }
    current = NULL;
}
Exemplo n.º 13
0
struct stumpless_element *
stumpless_new_element( const char *name ) {
  struct stumpless_element *element;

  clear_error(  );

  if( !name ) {
    raise_argument_empty( "name is NULL" );
    goto fail;
  }

  element = alloc_mem( sizeof( *element ) );
  if( !element ) {
    goto fail;
  }

  element->name = cstring_to_sized_string( name, &( element->name_length ) );
  if( !element->name ) {
    goto fail_name;
  }

  element->params = NULL;
  element->param_count = 0;

  return element;

fail_name:
  free_mem( element );

fail:
  return NULL;
}
Exemplo n.º 14
0
status_t
rdef_compile(const char *outputFile)
{
	clear_error();

	if (outputFile == NULL || outputFile[0] == '\0') {
		rdef_err = B_BAD_VALUE;
		return rdef_err;
	}

	rsrc_file = outputFile;
	rdef_err = open_output_file();
	if (rdef_err != B_OK)
		return rdef_err;

	for (ptr_iter_t i = input_files.begin(); 
			(i != input_files.end()) && (rdef_err == B_OK); ++i) {
		char *path = (char *)*i;

		AddIncludeDir add(path);
		compile_file(path);
	}

	close_output_file();
	return rdef_err;
}
Exemplo n.º 15
0
struct stumpless_entry *
stumpless_add_element( struct stumpless_entry *entry,
                       struct stumpless_element *element ) {

  struct stumpless_element **new_elements;
  size_t old_elements_size;
  size_t new_elements_size;

  clear_error(  );

  if( !entry ) {
    raise_argument_empty( "entry is NULL" );
    return NULL;
  }

  if( !element ) {
    raise_argument_empty( "element is NULL" );
    return NULL;
  }
  // todo need to check for duplicates first

  old_elements_size = sizeof( element ) * entry->element_count;
  new_elements_size = old_elements_size + sizeof( element );

  new_elements = realloc_mem( entry->elements, new_elements_size );
  if( !new_elements ) {
    return NULL;
  }

  new_elements[entry->element_count] = element;
  entry->elements = new_elements;
  entry->element_count++;

  return entry;
}
Exemplo n.º 16
0
struct stumpless_entry *
vstumpless_set_entry_message( struct stumpless_entry *entry,
                              const char *message,
                              va_list subs ) {
  char *formatted_message;
  size_t message_length;

  clear_error(  );

  if( !entry ) {
    raise_argument_empty( "entry is NULL" );
    return NULL;
  }

  if( !message ) {
    free_mem( entry->message );
    entry->message = NULL;
    entry->message_length = 0;

  } else {
    formatted_message = config_format_string( message, subs, &message_length );
    if( !formatted_message ) {
      return NULL;

    } else {
      free_mem( entry->message );
      entry->message = formatted_message;
      entry->message_length = message_length;

    }
  }

  return entry;
}
Exemplo n.º 17
0
struct stumpless_element *
stumpless_add_param( struct stumpless_element *element,
                     struct stumpless_param *param ) {

  struct stumpless_param **new_params;
  size_t old_params_size;
  size_t new_params_size;

  clear_error(  );

  if( !element ) {
    raise_argument_empty( "element is NULL" );
    return NULL;
  }

  if( !param ) {
    raise_argument_empty( "param is NULL" );
    return NULL;
  }

  old_params_size = sizeof( param ) * element->param_count;
  new_params_size = old_params_size + sizeof( param );

  new_params = realloc_mem( element->params, new_params_size );
  if( !new_params ) {
    return NULL;
  }

  new_params[element->param_count] = param;
  element->param_count++;
  element->params = new_params;

  return element;
}
Exemplo n.º 18
0
	void radc_compiler::begin(const char * str, const radc_varlist * _varlist)
	{
		clear_error();

		_break = false;
		_options = 0;
		_cache_program = programs.Find(str);
		if (_cache_program == -1)
		{
			int length = strlen(str);

			buffer.Resize(length + 1);

			int i = 0;
			while (*str)
			{
				buffer[i++] = charmap[*str++];
			}

			buffer[i] = 0;
		}

		inputlist = _varlist;

		outputlist->clear();
	}
Exemplo n.º 19
0
int c_syb_make (int m_size)
{
  int count;
  
  error_message = (char *) malloc (sizeof (char) * (m_size + ERROR_MESSAGE_SIZE));
  clear_error ();
  max_size = m_size;
  
  if (dbinit () == FAIL)
    {
      return error_number;
      /* exit(ERREXIT); */
    }
  
  dberrhandle ((EHANDLEFUNC)err_handler);
  dbmsghandle ((MHANDLEFUNC)msg_handler);
  
  if (login == NULL)
    {
		login = safe_alloc (dblogin());
		DBSETLCHARSET (login, "utf8");
    }
 
  for (count = 0; count < MAX_DESCRIPTOR; count++)
    {
      descriptor[count] = NULL;
    }
  
  return error_number;
}
Exemplo n.º 20
0
void legacy_image_device_base::unload()
{
	if (is_loaded()) {
		call_unload();
	}
    clear();
	clear_error();
}
Exemplo n.º 21
0
int syb_exec_immediate (char *order)
{
  DBPROCESS * dbp = descriptor[PRIVATE_DESCRIPTOR];
  clear_error ();
  dbcmd (dbp, order);
  dbsqlexec (dbp);
  return error_number;
}
Exemplo n.º 22
0
int
hstcpcli::response_recv(size_t& num_flds_r)
{
  if (error_code < 0) {
    return error_code;
  }
  clear_error();
  if (num_req_bufd > 0 || num_req_sent == 0 || num_req_rcvd > 0 ||
    response_end_offset != 0) {
    close();
    return set_error(-1, "response_recv: protocol out of sync");
  }
  cur_row_offset = 0;
  num_flds_r = num_flds = 0;
  if (fd.get() < 0) {
    return set_error(-1, "read: closed");
  }
  size_t offset = 0;
  while (true) {
    const char *const lbegin = readbuf.begin() + offset;
    const char *const lend = readbuf.end();
    const char *const nl = memchr_char(lbegin, '\n', lend - lbegin);
    if (nl != 0) {
      offset = (nl + 1) - readbuf.begin();
      break;
    }
    if (read_more() <= 0) {
      close();
      return set_error(-1, "read: eof");
    }
  }
  response_end_offset = offset;
  --num_req_sent;
  ++num_req_rcvd;
  char *start = readbuf.begin();
  char *const finish = start + response_end_offset - 1;
  const size_t resp_code = read_ui32(start, finish);
  skip_one(start, finish);
  num_flds_r = num_flds = read_ui32(start, finish);
  if (resp_code != 0) {
    skip_one(start, finish);
    char *const err_begin = start;
    read_token(start, finish);
    char *const err_end = start;
    std::string e = std::string(err_begin, err_end - err_begin);
    if (e.empty()) {
      e = "unknown_error";
    }
    return set_error(resp_code, e);
  }
  cur_row_offset = start - readbuf.begin();
  DBG(fprintf(stderr, "[%s] ro=%zu eol=%zu\n",
    std::string(readbuf.begin(), readbuf.begin() + response_end_offset)
      .c_str(),
    cur_row_offset, response_end_offset));
  DBG(fprintf(stderr, "RES 0\n"));
  return 0;
}
Exemplo n.º 23
0
/* accept a socket (creates a new fd) */
static struct sock *accept_socket( obj_handle_t handle )
{
    struct sock *acceptsock;
    struct sock *sock;
    int	acceptfd;

    sock = (struct sock *)get_handle_obj( current->process, handle, FILE_READ_DATA, &sock_ops );
    if (!sock)
        return NULL;

    if ( sock->deferred )
    {
        acceptsock = sock->deferred;
        sock->deferred = NULL;
    }
    else
    {
        if ((acceptfd = accept_new_fd( sock )) == -1)
        {
            release_object( sock );
            return NULL;
        }
        if (!(acceptsock = alloc_object( &sock_ops )))
        {
            close( acceptfd );
            release_object( sock );
            return NULL;
        }

        init_sock( acceptsock );
        /* newly created socket gets the same properties of the listening socket */
        acceptsock->state  = FD_WINE_CONNECTED|FD_READ|FD_WRITE;
        if (sock->state & FD_WINE_NONBLOCKING)
            acceptsock->state |= FD_WINE_NONBLOCKING;
        acceptsock->mask    = sock->mask;
        acceptsock->proto   = sock->proto;
        acceptsock->type    = sock->type;
        acceptsock->family  = sock->family;
        acceptsock->window  = sock->window;
        acceptsock->message = sock->message;
        if (sock->event) acceptsock->event = (struct event *)grab_object( sock->event );
        acceptsock->flags = sock->flags;
        if (!(acceptsock->fd = create_anonymous_fd( &sock_fd_ops, acceptfd, &acceptsock->obj,
                                                    get_fd_options( sock->fd ) )))
        {
            release_object( acceptsock );
            release_object( sock );
            return NULL;
        }
    }
    clear_error();
    sock->pmask &= ~FD_ACCEPT;
    sock->hmask &= ~FD_ACCEPT;
    sock_reselect( sock );
    release_object( sock );
    return acceptsock;
}
Exemplo n.º 24
0
int
loop()
{
	/* receive events */
	while(1) {
		il_octet_string_t *msg;
		long offset;
		int ret;

		do_handle_signal();
		if(killflg)
			return (0);

		clear_error();
		if((ret = input_queue_get(&msg, &offset, INPUT_TIMEOUT)) < 0)
		{
			if(error_get_maj() == IL_PROTO) {
				glite_common_log(IL_LOG_CATEGORY, LOG_PRIORITY_DEBUG, 
						 "  premature EOF while receiving event");
				/* problems with socket input, try to catch up from files */
#ifndef PERF_EMPTY
				event_store_recover_all();
#endif
				continue;
			} else
				return(-1);
		}
		else if(ret == 0) {
			continue;
		}

#ifdef PERF_EMPTY
		glite_wll_perftest_consumeEventString(msg->data);
		free(msg->data);
		continue;
#endif

#ifdef INTERLOGD_HANDLE_CMD
		ret = handle_cmd(msg, offset);
		if(ret == 0)
#endif
			ret = handle_msg(msg, offset);
		if(msg->data) free(msg->data);
		if(ret < 0)
			switch (error_get_maj()) {
				case IL_SYS:
				case IL_NOMEM:
					return (ret);
					break;
				default:
    					glite_common_log(IL_LOG_CATEGORY, LOG_PRIORITY_ERROR, 
							 "Error: %s", 
							 error_get_msg());
					break;
			}
	} /* while */
}
Exemplo n.º 25
0
void device_image_interface::unload()
{
	if (is_loaded() || m_software_info_ptr)
	{
		call_unload();
	}
    clear();
	clear_error();
}
Exemplo n.º 26
0
int syb_trancount ()
{
  syb_init_order (PRIVATE_DESCRIPTOR, "select @@trancount");
  syb_start_order (PRIVATE_DESCRIPTOR);
  syb_result_order (PRIVATE_DESCRIPTOR);
  clear_error ();
  syb_next_row (PRIVATE_DESCRIPTOR);
  return syb_get_integer_data (PRIVATE_DESCRIPTOR, 1);
}
Exemplo n.º 27
0
void device_image_interface::seterror(image_error_t err, const char *message)
{
    clear_error();
    m_err = err;
    if (message != NULL)
    {
        m_err_message = message;
    }
}
Exemplo n.º 28
0
	void CParser::reset_state(void)
	{
		output_line.str("");
		output_line.clear();
		clear_error();
		while(!current_mode.empty()) current_mode.pop();
		current_mode.push(SParserMode(ESM_CREATE,EM_COMMAND));
		primitive.clear();
		custom.clear();
	}
Exemplo n.º 29
0
int
hstcpcli::reconnect()
{
  clear_error();
  close();
  std::string err;
  if (socket_connect(fd, sargs, err) != 0) {
    set_error(-1, err);
  }
  return error_code;
}
Exemplo n.º 30
0
int syb_results_order (int no_des)
{
  DBPROCESS * dbp = descriptor[no_des];
  
  clear_error ();
  while (dbresults (dbp) != NO_MORE_RESULTS)
    {
      /* empty */
    }
  return error_number;
}