• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ep_alloc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ep_alloc函数的典型用法代码示例。如果您正苦于以下问题:C++ ep_alloc函数的具体用法?C++ ep_alloc怎么用?C++ ep_alloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ep_alloc函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ResolveWin32UUID

/* XXX - might be better to fill all interfaces into our database at startup instead of searching each time */
int
ResolveWin32UUID(e_guid_t if_id, char *uuid_name, int uuid_name_max_len)
{
	TCHAR *reg_uuid_name;
	HKEY hKey = NULL;
	DWORD uuid_max_size = MAX_PATH;
	TCHAR *reg_uuid_str;

	reg_uuid_name=ep_alloc(MAX_PATH*sizeof(TCHAR));
	reg_uuid_str=ep_alloc(MAX_PATH*sizeof(TCHAR));

	if(uuid_name_max_len < 2){
		return 0;
	}
	reg_uuid_name[0] = '\0';
	_snwprintf(reg_uuid_str, MAX_PATH, _T("SOFTWARE\\Classes\\Interface\\{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}"),
			if_id.data1, if_id.data2, if_id.data3,
			if_id.data4[0], if_id.data4[1],
			if_id.data4[2], if_id.data4[3],
			if_id.data4[4], if_id.data4[5],
			if_id.data4[6], if_id.data4[7]);
	if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, reg_uuid_str, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) {
		if (RegQueryValueEx(hKey, NULL, NULL, NULL, (LPBYTE)reg_uuid_name, &uuid_max_size) == ERROR_SUCCESS && uuid_max_size <= MAX_PATH) {
			g_snprintf(uuid_name, uuid_name_max_len, "%s", utf_16to8(reg_uuid_name));
			RegCloseKey(hKey);
			return (int) strlen(uuid_name);
		}
		RegCloseKey(hKey);
	}
	return 0; /* we didn't find anything anyhow. Please don't use the string! */

}
开发者ID:hubolo,项目名称:wireshark-1.8.0,代码行数:33,代码来源:guid-utils.c


示例2: verify_password

static gboolean
verify_password(tvbuff_t *tvb, const char *password)
{
	/* 1. pad non-terminated password-string to a length of 32 bytes
	 *    (padding: 0x01, 0x02, 0x03...)
	 * 2. Calculate MD5 of padded password and write it to offset 12 of packet
	 * 3. Calculate MD5 of resulting packet and write it to offset 12 of packet
	 */

	gboolean      is_valid = TRUE;
	const guint8 *packetdata;
	guint32       length;
	guint8       *workbuffer;
	guint         i;
	guint8        byte;
	md5_state_t   md_ctx;
	md5_byte_t   *digest;

	workbuffer=ep_alloc(32);
	digest=ep_alloc(16);

	length = tvb_get_ntohs(tvb, 6);
	packetdata = tvb_get_ptr(tvb, 0, length);
	for (i = 0; i<32 && *password; i++, password++) {
		workbuffer[i] = *password;
	}
	for (byte = 1; i<32; i++, byte++) {
		workbuffer[i] = byte;
	}
	md5_init(&md_ctx);
	md5_append(&md_ctx, workbuffer, 32);
	md5_finish(&md_ctx, digest);
	md5_init(&md_ctx);
	md5_append(&md_ctx, packetdata, 12);
	md5_append(&md_ctx, digest, 16);
	md5_append(&md_ctx, packetdata + 28, length - 28);
	md5_finish(&md_ctx, digest);
	fprintf(stderr, "Calculated digest: "); /* debugging */
	for (i = 0; i < 16; i++) {
		fprintf(stderr, "%02X", digest[i]); /* debugging */
		if (digest[i] != *(packetdata + 12 + i)) {
			is_valid = FALSE;
			break;
		}
	}
	fprintf(stderr, " (%d)\n", is_valid); /* debugging */

	return is_valid;
}
开发者ID:nehaahir,项目名称:wireshark,代码行数:49,代码来源:packet-3com-njack.c


示例3: new_tok

static tvbparse_elem_t* new_tok(tvbparse_t* tt,
                                int id,
                                int offset,
                                int len,
                                const tvbparse_wanted_t* wanted) {
    tvbparse_elem_t* tok;

#ifdef TVBPARSE_DEBUG
    if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_NEWTOK) g_warning("new_tok: id=%i offset=%u len=%u",id,offset,len);
#endif

    tok = (tvbparse_elem_t *)ep_alloc(sizeof(tvbparse_elem_t));

    tok->tvb = tt->tvb;
    tok->id = id;
    tok->offset = offset;
    tok->len = len;
    tok->data = NULL;
    tok->sub = NULL;
    tok->next = NULL;
    tok->wanted = wanted;
    tok->last = tok;

    return tok;
}
开发者ID:CTSRD-CHERI,项目名称:wireshark,代码行数:25,代码来源:tvbparse.c


示例4: ep_mca_attach

static int
ep_mca_attach(device_t dev)
{
	struct ep_softc *sc = device_get_softc(dev);
	int error = 0;

	if ((error = ep_alloc(dev)))
		goto bad;
	sc->stat = F_ACCESS_32_BITS;

	ep_get_media(sc);

	GO_WINDOW(sc, 0);
	SET_IRQ(sc, rman_get_start(sc->irq));

	if ((error = ep_attach(sc)))
		goto bad;
	if ((error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE, NULL, ep_intr,
		    sc, &sc->ep_intrhand))) {
		device_printf(dev, "bus_setup_intr() failed! (%d)\n", error);
		goto bad;
	}
	return (0);
bad:
	ep_free(dev);
	return (error);
}
开发者ID:syedzubairahmed,项目名称:FreeBSD-7.3-dyntick,代码行数:27,代码来源:if_ep_mca.c


示例5: optsstr

static const char *
optsstr(guint8 opts)
{
	char *msg;
	gint  returned_length, idx = 0;
	const int MAX_STR_LEN = 256;

	if (opts == 0)
		return("");

	msg=ep_alloc(MAX_STR_LEN);
	if (opts & PGM_OPT){
		returned_length = g_snprintf(&msg[idx], MAX_STR_LEN-idx, "Present");
		idx += MIN(returned_length, MAX_STR_LEN-idx);
	}
	if (opts & PGM_OPT_NETSIG){
		returned_length = g_snprintf(&msg[idx], MAX_STR_LEN-idx, "%sNetSig", (!idx)?"":",");
		idx += MIN(returned_length, MAX_STR_LEN-idx);
	}
	if (opts & PGM_OPT_VAR_PKTLEN){
		returned_length = g_snprintf(&msg[idx], MAX_STR_LEN-idx, "%sVarLen", (!idx)?"":",");
		idx += MIN(returned_length, MAX_STR_LEN-idx);
	}
	if (opts & PGM_OPT_PARITY){
		returned_length = g_snprintf(&msg[idx], MAX_STR_LEN-idx, "%sParity", (!idx)?"":",");
		idx += MIN(returned_length, MAX_STR_LEN-idx);
	}
	if (!idx) {
		g_snprintf(&msg[idx], MAX_STR_LEN-idx, "0x%x", opts);
	}
	return(msg);
}
开发者ID:hubolo,项目名称:wireshark-1.8.0,代码行数:32,代码来源:packet-pgm.c


示例6: ntp_fmt_ts

/* ntp_fmt_ts - converts NTP timestamp to human readable string.
 * reftime - 64bit timestamp (IN)
 * returns pointer to filled buffer.  This buffer will be freed automatically once
 * dissection of the next packet occurs.
 */
const char *
ntp_fmt_ts(const guint8 *reftime)
{
	guint32 tempstmp, tempfrac;
	time_t temptime;
	struct tm *bd;
	double fractime;
	char *buff;

	tempstmp = pntohl(&reftime[0]);
	tempfrac = pntohl(&reftime[4]);
	if ((tempstmp == 0) && (tempfrac == 0)) {
		return "NULL";
	}

	temptime = tempstmp - (guint32) NTP_BASETIME;
	bd = gmtime(&temptime);
	if(!bd){
		return "Not representable";
	}

	fractime = bd->tm_sec + tempfrac / 4294967296.0;
	buff=ep_alloc(NTP_TS_SIZE);
	g_snprintf(buff, NTP_TS_SIZE,
                 "%s %2d, %d %02d:%02d:%09.6f UTC",
		 mon_names[bd->tm_mon],
		 bd->tm_mday,
		 bd->tm_year + 1900,
		 bd->tm_hour,
		 bd->tm_min,
		 fractime);
	return buff;
}
开发者ID:AkhilaAG,项目名称:gluster-wireshark-1.4,代码行数:38,代码来源:packet-ntp.c


示例7: add_message_data

static void
add_message_data(tvbuff_t * tvb, gint offset, gint data_len, proto_tree * tree)
{
	gchar *data = NULL;
	gchar tmp;
	int i;

	if (!tree)
		return;

	data = tvb_memcpy(tvb, ep_alloc(data_len + 1), offset, data_len);
	data[data_len] = '\0';

	for (i = 0; i < data_len; i += 2) {
		/*
		 * There must be a better way to tell
		 * Wireshark not to stop on null bytes
		 * as the length is known
		 */
		if (!data[i])
			data[i] = ' ';

		if (!data[i+1])
			data[i+1] = ' ';

		/* Armagetronad swaps unconditionally */
		tmp = data[i];
		data[i] = data[i+1];
		data[i+1] = tmp;
	}

	proto_tree_add_string(tree, hf_armagetronad_data, tvb, offset,
			      data_len, (gchar *) data);
}
开发者ID:kailiu-bupt2005,项目名称:wireshark,代码行数:34,代码来源:packet-armagetronad.c


示例8: if

static guint8 *unhexbytes(const char *si, guint len, guint *len_p, const char** err) {
	guint8	     *buf;
	guint8	     *p;
	const guint8 *s = (const guint8 *)si;
	guint	      i;

	if (len % 2) {
		*err = ep_strdup_printf("Uneven number of chars hex string %u \n'%s'", len, si);
		return NULL;
	}

	buf = (guint8 *)ep_alloc(len/2+1);
	p = buf;

	for (i = 0; i<len ; i += 2) {
		guint8 lo = s[i+1];
		guint8 hi = s[i];

		if (hi >= '0' && hi <= '9') {
			hi -= '0';
		} else if (hi >= 'a' && hi <= 'f') {
			hi -=  'a';
			hi += 0xa;
		} else if (hi >= 'A' && hi <= 'F') {
			hi -=  'A';
			hi += 0xa;
		} else {
			goto on_error;
		}

		if (lo >= '0' && lo <= '9') {
			lo -= '0';
		} else if (lo >= 'a' && lo <= 'f') {
			lo -=  'a';
			lo += 0xa;
		} else if (lo >= 'A' && lo <= 'F') {
			lo -=  'A';
			lo += 0xa;
		} else {
			goto on_error;
		}

		*(p++) = (hi*0x10) + lo;
	}

	len /= 2;

	if (len_p) *len_p = len;

	buf[len] = '\0';

	*err = NULL;
	return buf;

on_error:
	*err = "Error parsing hex string";
	return NULL;
}
开发者ID:P1sec,项目名称:LTE_monitor_c2xx,代码行数:58,代码来源:uat_gui.c


示例9: atalk_addr_to_str

gchar *
atalk_addr_to_str(const struct atalk_ddp_addr *addrp)
{
  gchar	*cur;

  cur=ep_alloc(14);
  atalk_addr_to_str_buf(addrp, cur, 14);
  return cur;
}
开发者ID:AkhilaAG,项目名称:gluster-wireshark-1.4,代码行数:9,代码来源:atalk-utils.c


示例10: PIDL_dissect_uint32

int
PIDL_dissect_uint32 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
                    proto_tree *tree, guint8 *drep,
                    int hfindex, guint32 param)
{
    dcerpc_info *di;
    guint32 val;

    di=pinfo->private_data;
    if(di->conformant_run){
      /* just a run to handle conformant arrays, no scalars to dissect */
      return offset;
    }


    if (offset % 4) {
        offset += 4 - (offset % 4);
    }
    offset=dissect_dcerpc_uint32 (tvb, offset, pinfo,
                                  tree, drep, hfindex, &val);

    if(param&PIDL_SET_COL_INFO){
        header_field_info *hf_info;
        char *valstr;

        hf_info=proto_registrar_get_nth(hfindex);

        valstr=ep_alloc(64);
        valstr[0]=0;

        switch(hf_info->display){
        case BASE_DEC:
            if(hf_info->strings){
                g_snprintf(valstr, 64, "%s(%d)",val_to_str(val, hf_info->strings, "Unknown:%u"), val);
            } else {
                g_snprintf(valstr, 64, "%d", val);
            }
            break;
        case BASE_HEX:
            if(hf_info->strings){
                g_snprintf(valstr, 64, "%s(0x%08x)",val_to_str(val, hf_info->strings, "Unknown:%u"), val);
            } else {
                g_snprintf(valstr, 64, "0x%08x", val);
            }
            break;
        default:
            REPORT_DISSECTOR_BUG("Invalid hf->display value");
        }

        if (check_col(pinfo->cinfo, COL_INFO)) {
            col_append_fstr(pinfo->cinfo, COL_INFO," %s:%s", hf_info->name, valstr);
        }
    }

    return offset;
}
开发者ID:RazZziel,项目名称:wireshark-dplay,代码行数:56,代码来源:packet-dcerpc-ndr.c


示例11: unicode_to_str

/* Turn a little-endian Unicode '\0'-terminated string into a string we
   can display.
   XXX - for now, we just handle the ISO 8859-1 characters.
   If exactlen==TRUE then us_lenp contains the exact len of the string in
   bytes. It might not be null terminated !
   bc specifies the number of bytes in the byte parameters; Windows 2000,
   at least, appears, in some cases, to put only 1 byte of 0 at the end
   of a Unicode string if the byte count
*/
static gchar *
unicode_to_str(tvbuff_t *tvb, int offset, int *us_lenp, gboolean exactlen,
		   guint16 bc)
{
  gchar *cur;
  gchar        *p;
  guint16       uchar;
  int           len;
  int           us_len;
  gboolean      overflow = FALSE;

  cur=ep_alloc(MAX_UNICODE_STR_LEN+3+1);
  p = cur;
  len = MAX_UNICODE_STR_LEN;
  us_len = 0;
  for (;;) {
    if (bc == 0)
      break;
    if (bc == 1) {
      /* XXX - explain this */
      if (!exactlen)
        us_len += 1;	/* this is a one-byte null terminator */
      break;
    }
    uchar = tvb_get_letohs(tvb, offset);
    if (uchar == 0) {
      us_len += 2;	/* this is a two-byte null terminator */
      break;
    }
    if (len > 0) {
      if ((uchar & 0xFF00) == 0)
        *p++ = (gchar) uchar;	/* ISO 8859-1 */
      else
        *p++ = '?';	/* not 8859-1 */
      len--;
    } else
      overflow = TRUE;
    offset += 2;
    bc -= 2;
    us_len += 2;
    if(exactlen){
      if(us_len>= *us_lenp){
        break;
      }
    }
  }
  if (overflow) {
    /* Note that we're not showing the full string.  */
    *p++ = '.';
    *p++ = '.';
    *p++ = '.';
  }
  *p = '\0';
  *us_lenp = us_len;
  return cur;
}
开发者ID:flaub,项目名称:HotFuzz,代码行数:65,代码来源:packet-smb-common.c


示例12: atalkid_to_str

static gchar *
atalkid_to_str(const guint8 *ad) {
  gint node;
  gchar *cur;

  cur=ep_alloc(16);
  node=ad[1]<<8|ad[2];
  g_snprintf(cur, 16, "%d.%d",node,ad[3]);
  return cur;
}
开发者ID:AkhilaAG,项目名称:gluster-wireshark-1.4,代码行数:10,代码来源:packet-aarp.c


示例13: prism_rate_return

static gchar *
prism_rate_return(guint32 rate)
{
    gchar *result=NULL;
    result = (gchar *)ep_alloc(SHORT_STR);
    result[0] = '\0';
    prism_rate_base_custom(result, rate);

    return result;
}
开发者ID:labx-technologies-llc,项目名称:wireshark,代码行数:10,代码来源:packet-ieee80211-prism.c


示例14: tvb_atalkid_to_str

static gchar *
tvb_atalkid_to_str(tvbuff_t *tvb, gint offset)
{
  gint node;
  gchar *cur;

  cur=ep_alloc(16);
  node=tvb_get_guint8(tvb, offset)<<8|tvb_get_guint8(tvb, offset+1);
  g_snprintf(cur, 16, "%d.%d",node,tvb_get_guint8(tvb, offset+2));
  return cur;
}
开发者ID:giuliano108,项目名称:wireshark-rtpmon,代码行数:11,代码来源:packet-aarp.c


示例15: guids_get_guid_name

/* retrieve the registered name for this GUID */
const gchar *
guids_get_guid_name(e_guid_t *guid)
{
	emem_tree_key_t guidkey[2];
	guint32 g[4];
	char *name;
#ifdef _WIN32
	static char *uuid_name;
#endif

	g[0]=guid->data1;

	g[1]=guid->data2;
	g[1]<<=16;
	g[1]|=guid->data3;

	g[2]=guid->data4[0];
	g[2]<<=8;
	g[2]|=guid->data4[1];
	g[2]<<=8;
	g[2]|=guid->data4[2];
	g[2]<<=8;
	g[2]|=guid->data4[3];

	g[3]=guid->data4[4];
	g[3]<<=8;
	g[3]|=guid->data4[5];
	g[3]<<=8;
	g[3]|=guid->data4[6];
	g[3]<<=8;
	g[3]|=guid->data4[7];

	guidkey[0].key=g;
	guidkey[0].length=4;
	guidkey[1].length=0;

	if((name = pe_tree_lookup32_array(guid_to_name_tree, &guidkey[0]))){
		return name;
	}

#ifdef _WIN32
	/* try to resolve the mapping from the Windows registry */
	/* XXX - prefill the resolving database with all the Windows registry entries once at init only (instead of searching each time)? */
	uuid_name=ep_alloc(128);
	if(ResolveWin32UUID(*guid, uuid_name, 128)) {
		return uuid_name;
	}
#endif

	return NULL;
}
开发者ID:hubolo,项目名称:wireshark-1.8.0,代码行数:52,代码来源:guid-utils.c


示例16: dissect_xml

static void
dissect_xml(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	tvbparse_t* tt;
	tvbparse_elem_t* tok = NULL;
	static GPtrArray* stack = NULL;
	xml_frame_t* current_frame;
	char* colinfo_str;
	
	if (stack != NULL)
		g_ptr_array_free(stack,TRUE);

	stack = g_ptr_array_new();
	current_frame = ep_alloc(sizeof(xml_frame_t));
	current_frame->type = XML_FRAME_ROOT;
	current_frame->name = NULL;
	current_frame->name_orig_case = NULL;
	current_frame->value = NULL;
	insert_xml_frame(NULL, current_frame);
	g_ptr_array_add(stack,current_frame);

	tt = tvbparse_init(tvb,0,-1,stack,want_ignore);
	current_frame->start_offset = 0;

	root_ns = NULL;

	if (pinfo->match_string)
		root_ns = g_hash_table_lookup(media_types,pinfo->match_string);

	if (! root_ns ) {
		root_ns = &xml_ns;
		colinfo_str = "/XML";
	} else {
		colinfo_str = ep_strdup_printf("/%s",root_ns->name);
		ascii_strup_inplace(colinfo_str);
	}

	if (check_col(pinfo->cinfo, COL_PROTOCOL))
		col_append_str(pinfo->cinfo, COL_PROTOCOL, colinfo_str);

	current_frame->ns = root_ns;

	current_frame->item = proto_tree_add_item(tree,current_frame->ns->hf_tag,tvb,0,-1,FALSE);
	current_frame->tree = proto_item_add_subtree(current_frame->item,current_frame->ns->ett);
	current_frame->last_item = current_frame->item;

	while(( tok = tvbparse_get(tt, want) )) ;

	pinfo->private_data = current_frame;  /* pass XML structure to the dissector calling XML */
}
开发者ID:RazZziel,项目名称:wireshark-dplay,代码行数:50,代码来源:packet-xml.c


示例17: ep_pccard_probe

/*
 * Initialize the device - called from Slot manager.
 */
static int
ep_pccard_probe(device_t dev)
{
	struct ep_softc *	sc = device_get_softc(dev);
	struct ep_board *	epb = &sc->epb;
	const char *		desc;
	int			error;

	error = ep_alloc(dev);
	if (error)
		return error;

	/*
	 * XXX - Certain (newer?) 3Com cards need epb->cmd_off ==
	 * 2. Sadly, you need to have a correct cmd_off in order to
	 * identify the card.  So we have to hit it with both and
	 * cross our virtual fingers.  There's got to be a better way
	 * to do this.  [email protected] 09/11/1999 
	 */

	epb->cmd_off = 0;
	epb->prod_id = get_e(sc, EEPROM_PROD_ID);
	if ((desc = ep_pccard_identify(epb->prod_id)) == NULL) {
		if (bootverbose) 
			device_printf(dev, "Pass 1 of 2 detection "
			    "failed (nonfatal)\n");
		epb->cmd_off = 2;
		epb->prod_id = get_e(sc, EEPROM_PROD_ID);
		if ((desc = ep_pccard_identify(epb->prod_id)) == NULL) {
			device_printf(dev, "Unit failed to come ready or "
			    "product ID unknown! (id 0x%x)\n", epb->prod_id);
			ep_free(dev);
			return (ENXIO);
		}
	}
	device_set_desc(dev, desc);

	/*
	 * For some reason the 3c574 needs this.
	 */
	ep_get_macaddr(sc, (u_char *)&sc->arpcom.ac_enaddr);

	ep_free(dev);
	return (0);
}
开发者ID:juanfra684,项目名称:DragonFlyBSD,代码行数:48,代码来源:if_ep_pccard.c


示例18: dissect_ms_compressed_string

int dissect_ms_compressed_string(tvbuff_t *tvb, proto_tree *tree, int offset, int hf_index,
				 gboolean prepend_dot, char **data)
{
	int old_offset=offset;
	char *str;
	int len;

	len = MAX_UNICODE_STR_LEN+3+1;
	str=ep_alloc(len);

	offset=dissect_ms_compressed_string_internal(tvb, offset, str, len, prepend_dot);
	proto_tree_add_string(tree, hf_index, tvb, old_offset, offset-old_offset, str);

	if (data)
		*data = str;

	return offset;
}
开发者ID:flaub,项目名称:HotFuzz,代码行数:18,代码来源:packet-smb-common.c



注:本文中的ep_alloc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ep_index函数代码示例发布时间:2022-05-30
下一篇:
C++ ep函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap