Esempio n. 1
0
void CSVDocument::parseColumns(const std::string &str, char target)
{
	const char *srcStr = str.c_str();
	if (NULL == srcStr)
		return;
	while (true)
	{
		const char *pBreak = strchr(srcStr, target);
		if (NULL == pBreak)
		{
			const char *tmp = srcStr;
			while (*tmp != '\0')
				tmp++;
			CSVColumn *newColumn = XNEW(CSVColumn)(std::string(srcStr, tmp - srcStr));
			m_ColumnMap[std::string(srcStr, tmp - srcStr)] = newColumn;
			m_ColumnList.push_back(newColumn);
			break;
		}
		if (*pBreak != *srcStr) //都不是','的情况
		{
			CSVColumn *newColumn = XNEW(CSVColumn)(std::string(srcStr, pBreak - srcStr));
			m_ColumnMap[std::string(srcStr, pBreak - srcStr)] = newColumn;
			m_ColumnList.push_back(newColumn);
		}
		srcStr = pBreak + 1;
	}

	m_dwColNum = m_ColumnList.size();
}
Esempio n. 2
0
bool Program::init()
{
    m_string_pool = XNEW(StringPool);
    m_entry_functions = XNEW(FunctionEntryMap);
    m_name_programs = XNEW(ProgramNameMap);
    m_obsoleted_programs = XNEW(ObsoletedProgramSet);

    std_new_critical_section(&m_program_cs);
    return true;
}
Esempio n. 3
0
void PacketHandler::RegsterExterPacketProc(uint16_t uCmd, void* pPacketProc)
{
	PACKET_PROC* poProc = XNEW(PACKET_PROC);
	poProc->uCmd = uCmd;
	poProc->pProc = (void*)pPacketProc;
	m_poExterPacketProcMap->insert(std::make_pair(uCmd, poProc));
}
Esempio n. 4
0
void
md_begin (void)
{
  const opcode_entry_type *opcode;
  int idx = -1;

  opcode_hash_control = hash_new ();

  for (opcode = z8k_table; opcode->name; opcode++)
    {
      /* Only enter unique codes into the table.  */
      if (idx != opcode->idx)
	hash_insert (opcode_hash_control, opcode->name, (char *) opcode);
      idx = opcode->idx;
    }

  /* Default to z8002.  */
  s_segm (z8k_target_from_cmdline ? z8k_target_from_cmdline - 1 : 0);

  /* Insert the pseudo ops, too.  */
  for (idx = 0; md_pseudo_table[idx].poc_name; idx++)
    {
      opcode_entry_type *fake_opcode;
      fake_opcode = XNEW (opcode_entry_type);
      fake_opcode->name = md_pseudo_table[idx].poc_name;
      fake_opcode->func = (void *) (md_pseudo_table + idx);
      fake_opcode->opcode = 250;
      hash_insert (opcode_hash_control, fake_opcode->name, fake_opcode);
    }
}
Esempio n. 5
0
//HTTP请求
static int HttpRequest(lua_State* pState)
{
	lua_settop(pState, 4);
	const char* t = luaL_checkstring(pState, 1);
	const char* url = luaL_checkstring(pState, 2);
	const char* d = lua_tostring(pState, 3);
	int luaref = LUA_NOREF;
	if (!lua_isnoneornil(pState, 4))
	{
		luaref = luaL_ref(pState, LUA_REGISTRYINDEX);
	}

	HTTPMSG* pMsg = XNEW(HTTPMSG)();
	pMsg->url = std::string(url);
	pMsg->data = std::string(d?d:"");
	pMsg->luaref = luaref;

	if (strcmp(t, "GET") == 0)
	{
		goHttpClient.HttpGet(pMsg);
	}
	else
	{
		goHttpClient.HttpPost(pMsg);
	}
	return 0;
}
Esempio n. 6
0
// Make an empty mapping
void Simulator::xMKEMAP()
{
    GET_P1; GET_P2;
    p1->m_type = MAPPING;
    p1->m_map = XNEW(MapImpl, (size_t)p2->m_int);
    m_domain->bind_value(p1->m_reference);
}
Esempio n. 7
0
static void
push_field_alignment (int bit_alignment,
		      int mac68k_alignment, int natural_alignment)
{
  align_stack *entry = XNEW (align_stack);

  entry->alignment = maximum_field_alignment;
  entry->mac68k = OPTION_ALIGN_MAC68K;
  entry->natural = OPTION_ALIGN_NATURAL;
  entry->prev = field_align_stack;
  field_align_stack = entry;

  maximum_field_alignment = bit_alignment;
  if (mac68k_alignment)
    darwin_alignment_flags |= OPTION_MASK_ALIGN_MAC68K;
  else
    darwin_alignment_flags &= ~OPTION_MASK_ALIGN_MAC68K;

  /* APPLE LOCAL begin radar 4679943 */
  if (natural_alignment == 1)
    darwin_alignment_flags |= OPTION_MASK_ALIGN_NATURAL;
  else if (natural_alignment == 0)
    darwin_alignment_flags &= ~OPTION_MASK_ALIGN_NATURAL;
  /* APPLE LOCAL end radar 4679943 */
}
Esempio n. 8
0
// Make an empty array
void Simulator::xMKEARR()
{
    GET_P1; GET_P2;
    p1->m_type = ARRAY;
    p1->m_array = XNEW(ArrayImpl, (size_t)p2->m_int);
    m_domain->bind_value(p1->m_reference);
}
Esempio n. 9
0
/* Initialize the diagnostic message outputting machinery.  */
void
diagnostic_initialize (diagnostic_context *context)
{
  /* Allocate a basic pretty-printer.  Clients will replace this a
     much more elaborated pretty-printer if they wish.  */
  context->printer = XNEW (pretty_printer);
  pp_construct (context->printer, NULL, 0);
  /* By default, diagnostics are sent to stderr.  */
  context->printer->buffer->stream = stderr;
  /* By default, we emit prefixes once per message.  */
  context->printer->wrapping.rule = DIAGNOSTICS_SHOW_PREFIX_ONCE;

  memset (context->diagnostic_count, 0, sizeof context->diagnostic_count);
  context->issue_warnings_are_errors_message = true;
  context->warning_as_error_requested = false;
  memset (context->classify_diagnostic, DK_UNSPECIFIED,
	  sizeof context->classify_diagnostic);
  context->show_option_requested = false;
  context->abort_on_error = false;
  context->internal_error = NULL;
  diagnostic_starter (context) = default_diagnostic_starter;
  diagnostic_finalizer (context) = default_diagnostic_finalizer;
  context->last_module = 0;
  context->last_function = NULL;
  context->lock = 0;
}
Esempio n. 10
0
void ldap_bind(int msgid, BindRequest_t *req, ev_loop *loop, ev_io *watcher)
{
	ev_tstamp delay = 0.0;
	LDAPMessage_t *res = XNEW0(LDAPMessage_t, 1);

	res->messageID = msgid;
	res->protocolOp.present = LDAPMessage__protocolOp_PR_bindResponse;
	BindResponse_t *bindResponse = &res->protocolOp.choice.bindResponse;
	OCTET_STRING_fromBuf(&bindResponse->matchedDN, (const char *)req->name.buf, req->name.size);

	if (setting_anonymous && req->name.size == 0) {
		/* allow anonymous */
		asn_long2INTEGER(&bindResponse->resultCode, BindResponse__resultCode_success);
	} else if (req->authentication.present == AuthenticationChoice_PR_simple) {
		/* simple auth */
		char *user = cn2name((const char *)req->name.buf);
		char *pw = (char *)req->authentication.choice.simple.buf;
		char *status = NULL;
		if (!user) {
			asn_long2INTEGER(&bindResponse->resultCode, BindResponse__resultCode_invalidDNSyntax);
		} else if (PAM_SUCCESS != auth_pam(user, pw, &status, &delay)) {
			asn_long2INTEGER(&bindResponse->resultCode, BindResponse__resultCode_invalidCredentials);
			OCTET_STRING_fromString(&bindResponse->diagnosticMessage, status);
		} else {	/* Success! */
			asn_long2INTEGER(&bindResponse->resultCode, BindResponse__resultCode_success);
		}
		free(user);
		free(status);
	} else {
		/* sasl or anonymous auth */
		asn_long2INTEGER(&bindResponse->resultCode, BindResponse__resultCode_authMethodNotSupported);
	}
	if (delay > 0.0) {
		ev_timer *delay_timer = XNEW(ev_timer, 1);
		delay_data_t *data = XNEW(delay_data_t, 1);
		data->message = res;
		data->watcher = watcher;
		ev_timer_init(delay_timer, delay_cb, delay, 0.0);
		delay_timer->data = data;
		/* Stop the connection watcher to stop other requests while delayed. */
		ev_io_stop(loop, watcher);
		ev_timer_start(loop, delay_timer);
	} else {
		ldap_send(res, loop, watcher);
		ldapmessage_free(res);
	}
}
Esempio n. 11
0
WorkerMgr* WorkerMgr::Instance()
{
	if (g_poWorkderMgr == NULL)
	{
		g_poWorkderMgr = XNEW(WorkerMgr);
	}
	return g_poWorkderMgr;
}
Esempio n. 12
0
// Make and initialize an array
void Simulator::xMKIARR()
{
    GET_P1; GET_P2; GET_P3;
    p1->m_type = ARRAY;
    p1->m_array = XNEW(ArrayImpl, (size_t)p2->m_int);
    p1->m_array->push_back_array(p3, (size_t)p2->m_int);
    m_domain->bind_value(p1->m_reference);
}
Esempio n. 13
0
// Make and initialize a mapping
void Simulator::xMKIMAP()
{
    GET_P1; GET_P2; GET_P3;
    p1->m_type = MAPPING;
    p1->m_map = XNEW(MapImpl, (size_t)p2->m_int);
    m_domain->bind_value(p1->m_reference);
    for (Integer i = 0; i < p2->m_int; i++)
        p1->m_map->set(p3[i * 2], p3[i * 2 + 1]);
}
Esempio n. 14
0
struct ui_out *
cli_out_new (struct ui_file *stream)
{
  int flags = ui_source_list;
  cli_out_data *data = XNEW (cli_out_data);

  cli_out_data_ctor (data, stream);
  return ui_out_new (&cli_ui_out_impl, data, flags);
}
Esempio n. 15
0
// Create local variable definition in function
LocalVariable* Function::define_local_variable(
    const String& name,
    ValueType type,
    LocalVariable::Attrib attrib)
{
    auto* local_variable = XNEW(LocalVariable, this, name, type, attrib);
    local_variable->m_type = type;
    local_variable->m_attrib = attrib;
    m_local_variables.push_back(local_variable);
    return local_variable;
}
Esempio n. 16
0
// Create object var in this program
ObjectVar* Program::define_object_var(const String& name, ValueType type)
{
    auto* object_var = XNEW(ObjectVar, this, name);
    object_var->m_type = type;
    object_var->m_no = (VariableNo)m_object_vars.size();
    m_object_vars.push_back(object_var);

    // Calcuate object size for using interpreter
    m_this_component_size += sizeof(Value);
    return object_var;
}
Esempio n. 17
0
static void
push_field_alignment (int bit_alignment)
{
  align_stack *entry = XNEW (align_stack);

  entry->alignment = maximum_field_alignment;
  entry->prev = field_align_stack;
  field_align_stack = entry;

  maximum_field_alignment = bit_alignment;
}
Esempio n. 18
0
// Create parameter definition in function
Parameter* Function::define_parameter(
    const String& name,
    ValueType type,
    Parameter::Attrib attrib)
{
    auto* parameter = XNEW(Parameter, this, name, type, attrib);
    parameter->m_type = type;
    parameter->m_attrib = attrib;
    m_parameters.push_back(parameter);
    return parameter;
}
Esempio n. 19
0
/* Construct a C++-aware pretty-printer for CONTEXT.  It is assumed
   that CONTEXT->printer is an already constructed basic pretty_printer.  */
void
cxx_initialize_diagnostics (diagnostic_context *context)
{
  pretty_printer *base = context->printer;
  cxx_pretty_printer *pp = XNEW (cxx_pretty_printer);
  memcpy (pp_base (pp), base, sizeof (pretty_printer));
  pp_cxx_pretty_printer_init (pp);
  context->printer = (pretty_printer *) pp;

  /* It is safe to free this object because it was previously malloc()'d.  */
  free (base);
}
Esempio n. 20
0
/* Construct a C++-aware pretty-printer for CONTEXT.  It is assumed
   that CONTEXT->printer is an already constructed basic pretty_printer.  */
void
cxx_initialize_diagnostics (diagnostic_context *context)
{
  c_common_initialize_diagnostics (context);

  pretty_printer *base = context->printer;
  cxx_pretty_printer *pp = XNEW (cxx_pretty_printer);
  context->printer = new (pp) cxx_pretty_printer ();

  /* It is safe to free this object because it was previously XNEW()'d.  */
  base->~pretty_printer ();
  XDELETE (base);
}
Esempio n. 21
0
// Add all predefines when initialized
int Lexer::init_predefines()
{
    // Create macro funcs map
    expand_builtin_macro_funcs = XNEW(ExpandFuncMap);

    Lexer::add_predefine("__FILE__",      expand_file_name);
    Lexer::add_predefine("__PURE_FILE__", expand_pure_file_name);
    Lexer::add_predefine("__DIR__",       expand_dir_name);
    Lexer::add_predefine("__LINE__",      expand_line_no);
    Lexer::add_predefine("__FUN__",       expand_function_name);
    Lexer::add_predefine("__COUNTER__",   expand_counter);
    return 0;
}
Esempio n. 22
0
// Initialize this module
bool Thread::init()
{
    std_allocate_tls(&m_thread_tls_id);

    // Set handler - This is only to prevent optimization
    m_get_stack_pointer_func = (GetStackPointerFunc)([]() { void *p; p = &p; return (void*)p; });

    // Start current thread
    Thread *thread = XNEW(Thread);
    thread->start();

    return true;
}
Esempio n. 23
0
simple_object_attributes *
simple_object_fetch_attributes (simple_object_read *sobj, const char **errmsg,
				int *err)
{
  void *data;
  simple_object_attributes *ret;

  data = sobj->functions->fetch_attributes (sobj, errmsg, err);
  if (data == NULL)
    return NULL;
  ret = XNEW (simple_object_attributes);
  ret->functions = sobj->functions;
  ret->data = data;
  return ret;
}
Esempio n. 24
0
void accept_cb(ev_loop *loop, ev_io *watcher, int revents)
{
	int client_sd;
	ev_io *w_client;

	if (EV_ERROR & revents)
		fail("got invalid event");

	if ((client_sd = accept(watcher->fd, NULL, NULL)) < 0)
		fail("accept error");

	w_client = XNEW(ev_io, 1);
	ev_io_init(w_client, read_cb, client_sd, EV_READ);
	ev_io_start(loop, w_client);
}
Esempio n. 25
0
struct ui_out *
tui_out_new (struct ui_file *stream)
{
  int flags = 0;

  tui_out_data *data = XNEW (tui_out_data);

  /* Initialize base "class".  */
  cli_out_data_ctor (&data->base, stream);

  /* Initialize our fields.  */
  data->line = -1;
  data->start_of_line = 0;

  return ui_out_new (&tui_ui_out_impl, data, flags);
}
Esempio n. 26
0
//HTTP响应
static int HttpResponse(lua_State* pState)
{
	lua_settop(pState, 2);
	if (!lua_islightuserdata(pState, 1))
	{
		return LuaWrapper::luaM_error(pState, "参数1错误");
	}
	struct mg_connection* c = (struct mg_connection*)lua_topointer(pState, 1);
	const char* d = luaL_checkstring(pState, 2);

	HTTPMSG* pMsg = XNEW(HTTPMSG)();
	pMsg->c = c;
	pMsg->data = std::string(d);
	goHttpServer.Response(pMsg);
	return 0;
}
Esempio n. 27
0
/* Initialize the diagnostic message outputting machinery.  */
void
diagnostic_initialize (diagnostic_context *context, int n_opts)
{
  int i;

  /* Allocate a basic pretty-printer.  Clients will replace this a
     much more elaborated pretty-printer if they wish.  */
  context->printer = XNEW (pretty_printer);
  new (context->printer) pretty_printer ();

  memset (context->diagnostic_count, 0, sizeof context->diagnostic_count);
  context->warning_as_error_requested = false;
  context->n_opts = n_opts;
  context->classify_diagnostic = XNEWVEC (diagnostic_t, n_opts);
  for (i = 0; i < n_opts; i++)
    context->classify_diagnostic[i] = DK_UNSPECIFIED;
  context->show_caret = false;
  diagnostic_set_caret_max_width (context, pp_line_cutoff (context->printer));
  for (i = 0; i < rich_location::STATICALLY_ALLOCATED_RANGES; i++)
    context->caret_chars[i] = '^';
  context->show_option_requested = false;
  context->abort_on_error = false;
  context->show_column = false;
  context->pedantic_errors = false;
  context->permissive = false;
  context->opt_permissive = 0;
  context->fatal_errors = false;
  context->dc_inhibit_warnings = false;
  context->dc_warn_system_headers = false;
  context->max_errors = 0;
  context->internal_error = NULL;
  diagnostic_starter (context) = default_diagnostic_starter;
  context->start_span = default_diagnostic_start_span_fn;
  diagnostic_finalizer (context) = default_diagnostic_finalizer;
  context->option_enabled = NULL;
  context->option_state = NULL;
  context->option_name = NULL;
  context->last_location = UNKNOWN_LOCATION;
  context->last_module = 0;
  context->x_data = NULL;
  context->lock = 0;
  context->inhibit_notes_p = false;
  context->colorize_source_p = false;
  context->show_ruler_p = false;
  context->parseable_fixits_p = false;
  context->edit_context_ptr = NULL;
}
Esempio n. 28
0
DCACHE *
dcache_init (void)
{
  DCACHE *dcache = XNEW (DCACHE);

  dcache->tree = splay_tree_new (dcache_splay_tree_compare,
				 NULL,
				 NULL);

  dcache->oldest = NULL;
  dcache->freelist = NULL;
  dcache->size = 0;
  dcache->line_size = dcache_line_size;
  dcache->ptid = null_ptid;

  return dcache;
}
Esempio n. 29
0
/* Initialize the diagnostic message outputting machinery.  */
void
diagnostic_initialize (diagnostic_context *context, int n_opts)
{
  int i;

  /* Allocate a basic pretty-printer.  Clients will replace this a
     much more elaborated pretty-printer if they wish.  */
  context->printer = XNEW (pretty_printer);
  pp_construct (context->printer, NULL, 0);
  /* By default, diagnostics are sent to stderr.  */
  context->printer->buffer->stream = stderr;
  /* By default, we emit prefixes once per message.  */
  context->printer->wrapping.rule = DIAGNOSTICS_SHOW_PREFIX_ONCE;

  memset (context->diagnostic_count, 0, sizeof context->diagnostic_count);
  context->some_warnings_are_errors = false;
  context->warning_as_error_requested = false;
  context->n_opts = n_opts;
  context->classify_diagnostic = XNEWVEC (diagnostic_t, n_opts);
  for (i = 0; i < n_opts; i++)
    context->classify_diagnostic[i] = DK_UNSPECIFIED;
  context->show_caret = false;
  diagnostic_set_caret_max_width (context, pp_line_cutoff (context->printer));
  context->show_option_requested = false;
  context->abort_on_error = false;
  context->show_column = false;
  context->pedantic_errors = false;
  context->permissive = false;
  context->opt_permissive = 0;
  context->fatal_errors = false;
  context->dc_inhibit_warnings = false;
  context->dc_warn_system_headers = false;
  context->max_errors = 0;
  context->internal_error = NULL;
  diagnostic_starter (context) = default_diagnostic_starter;
  diagnostic_finalizer (context) = default_diagnostic_finalizer;
  context->option_enabled = NULL;
  context->option_state = NULL;
  context->option_name = NULL;
  context->last_location = UNKNOWN_LOCATION;
  context->last_module = 0;
  context->x_data = NULL;
  context->lock = 0;
  context->inhibit_notes_p = false;
}
Esempio n. 30
0
simple_object_write *
simple_object_start_write (simple_object_attributes *attrs,
			   const char *segment_name, const char **errmsg,
			   int *err)
{
  void *data;
  simple_object_write *ret;

  data = attrs->functions->start_write (attrs->data, errmsg, err);
  if (data == NULL)
    return NULL;
  ret = XNEW (simple_object_write);
  ret->functions = attrs->functions;
  ret->segment_name = xstrdup (segment_name);
  ret->sections = NULL;
  ret->last_section = NULL;
  ret->data = data;
  return ret;
}