本文整理汇总了C++中ep_alloc函数的典型用法代码示例。如果您正苦于以下问题:C++ ep_alloc函数的具体用法?C++ ep_alloc怎么用?C++ ep_alloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ep_alloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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! */
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}