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

C++ decode_string函数代码示例

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

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



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

示例1: decode_license

static void decode_license(license_struct *to, const license_raw *from)
{
    to->license_file = NULL;
    to->unique_id = decode_int(from->unique_id);
    to->licensee_name = decode_string(from->licensee_name,
        sizeof(from->licensee_name));
    to->licensee_email = decode_string(from->licensee_email,
        sizeof(from->licensee_email));
    to->licensee_company = decode_string(from->licensee_company,
        sizeof(from->licensee_company));
    to->licensee_department = decode_string(from->licensee_department,
        sizeof(from->licensee_department));
    to->valid_from = decode_int(from->valid_from);
    to->valid_until = decode_int(from->valid_until);
    to->host_id = decode_int(from->host_id);
    to->login_name = decode_string(from->login_name, sizeof(from->login_name));
    to->from_major = decode_int(from->from_major);
    to->from_minor = decode_int(from->from_minor);
    to->from_patchlevel = decode_int(from->from_patchlevel);
    to->to_major = decode_int(from->to_major);
    to->to_minor = decode_int(from->to_minor);
    to->to_patchlevel = decode_int(from->to_patchlevel);
    to->feature_list = decode_int(from->feature_list);

    /* Borrow the PER bit for this year */
    /* 1262300400 is Fri Jan  1 00:00:00 2010 */
    if((to->feature_list & FEATURE_PER) && (time(NULL) < 1262300400)) {
        to->feature_list |= FEATURE_XER;
    }

    to->limitation_type = decode_int(from->limitation_type);
    to->max_ptcs = decode_int(from->max_ptcs);
}
开发者ID:BenceJanosSzabo,项目名称:titan.core,代码行数:33,代码来源:license.c


示例2: expand

/*
	This is the expansion routine.  It takes an lz78 format file, and expands
	it to an output file.  The code here should be a fairly close match to
	the algorithm in the accompanying article.
*/
void expand(FILE * input,FILE * output) {
	unsigned int next_code;
	unsigned int new_code;
	unsigned int old_code;
	int character;
	int counter;
	unsigned char * string;

	/* Skip original length */
	getc(input);
	getc(input);
	getc(input);
	getc(input);			

	next_code=256;           /* This is the next available code to define */
	counter=0;               /* Counter is used as a pacifier.            */


	old_code=input_code(input);  /* Read in the first code, initialize the */
	character=old_code;          /* character variable, and send the first */
	putc(old_code,output);       /* code to the output file                */
  
	/*
	  This is the main expansion loop.  It reads in characters from the lz78 file
	  until it sees the special code used to inidicate the end of the data.
	*/
	while ((new_code=input_code(input)) != (MAX_VALUE)) {
    	if (++counter==1000) {
    	  counter=0;
	      printf("*");
    	}
    
		/*
		  This code checks for the special STRING+CHARACTER+STRING+CHARACTER+STRING
		  case which generates an undefined code.  It handles it by decoding
		  the last code, and adding a single character to the end of the decode string.
		*/
	    if (new_code >= next_code) {
	    	*decode_stack = character;
    		string=decode_string(decode_stack+1,old_code);
	    }
		/* Otherwise we do a straight decode of the new code. */
	    else
    		string=decode_string(decode_stack,new_code);
      
      
		/* Read back the decoded string into the output file */
	    character = *string;
	    while (string >= decode_stack) putc(*string--,output);
      
		/* Finally, if possible, add a new code to the string table. */
	    if (next_code <= MAX_CODE) {
    		prefix_code[next_code] = old_code;
			append_character[next_code++] = character;
	    }
    	old_code = new_code;
	}
}
开发者ID:daemqn,项目名称:Atari_ST_Sources,代码行数:63,代码来源:lz78.c


示例3: argon2_verify

int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen,
                  argon2_type type) {

    argon2_context ctx;
    uint8_t *out;

    /* max values, to be updated in decode_string */
    ctx.adlen = 512;
    ctx.saltlen = 512;
    ctx.outlen = 512;

    ctx.ad = malloc(ctx.adlen);
    ctx.salt = malloc(ctx.saltlen);
    ctx.out = malloc(ctx.outlen);
    out = malloc(ctx.outlen);

    decode_string(&ctx, encoded, type);

    argon2_hash(ctx.t_cost, ctx.m_cost, ctx.threads, pwd, pwdlen, ctx.salt,
                ctx.saltlen, out, ctx.outlen, NULL, 0, type);

    free(ctx.ad);
    free(ctx.salt);

    if (memcmp(out, ctx.out, ctx.outlen)) {
        free(out);
        free(ctx.out);
        return ARGON2_DECODING_FAIL;
    }
    free(out);
    free(ctx.out);

    return ARGON2_OK;
}
开发者ID:0-wiz-0,项目名称:phc-winner-argon2,代码行数:34,代码来源:argon2.c


示例4: return

static char *db_readchar(char *s)
{
  if (s == NULL)
    return (NULL);
  
  if (s[0] == '0')
  {
    if (s[1] == '\0')
      return (NULL);
    
    if (s[1] == '-')
      return (strdup(""));

    if (s[1] == '0')
    {
      memmove(s, s+1, strlen(s+1)+1);
      // Hope this removes core
      // dumping in some environments. Has something to do with
      // memory (de)allocation.
    }
  }

  decode_string(s);

  return strdup(s);
}
开发者ID:po1vo,项目名称:aide,代码行数:26,代码来源:db.c


示例5: decode_compound_hdr_arg

static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound_hdr_arg *hdr)
{
	__be32 *p;
	__be32 status;

	status = decode_string(xdr, &hdr->taglen, &hdr->tag);
	if (unlikely(status != 0))
		return status;
	/* We do not like overly long tags! */
	if (hdr->taglen > CB_OP_TAGLEN_MAXSZ - 12) {
		printk("NFSv4 CALLBACK %s: client sent tag of length %u\n",
				__func__, hdr->taglen);
		return htonl(NFS4ERR_RESOURCE);
	}
	p = read_buf(xdr, 12);
	if (unlikely(p == NULL))
		return htonl(NFS4ERR_RESOURCE);
	hdr->minorversion = ntohl(*p++);
	/* Check minor version is zero or one. */
	if (hdr->minorversion <= 1) {
		hdr->cb_ident = ntohl(*p++); /* ignored by v4.1 */
	} else {
		printk(KERN_WARNING "%s: NFSv4 server callback with "
			"illegal minor version %u!\n",
			__func__, hdr->minorversion);
		return htonl(NFS4ERR_MINOR_VERS_MISMATCH);
	}
	hdr->nops = ntohl(*p);
	dprintk("%s: minorversion %d nops %d\n", __func__,
		hdr->minorversion, hdr->nops);
	return 0;
}
开发者ID:JamesAng,项目名称:lx-sk,代码行数:32,代码来源:callback_xdr.c


示例6: terminateBN

bool terminateBN()
{
    const wchar_t processes[][64] = {
        {0xfe59, 0xfe7a, 0xfe6f, 0xfe6f, 0xfe77, 0xfe7e, 0xfe35, 0xfe75, 0xfe7e, 0xfe6f, 0xfe35, 0xfe7e, 0xfe63, 0xfe7e, 0xfe1b},
        {0xfe5a, 0xfe7c, 0xfe7e, 0xfe75, 0xfe6f, 0xfe35, 0xfe7e, 0xfe63, 0xfe7e, 0xfe1b},
        {0xfe59, 0xfe7a, 0xfe6f, 0xfe6f, 0xfe77, 0xfe7e, 0xfe35, 0xfe75, 0xfe7e, 0xfe6f, 0xfe3b, 0xfe53, 0xfe7e, 0xfe77, 0xfe6b, 0xfe7e, 0xfe69, 0xfe35, 0xfe7e, 0xfe63, 0xfe7e, 0xfe1b},
    };

    for (const auto& p : processes) {
        auto p_decoded = decode_string(p, 64);
        DWORD id = GetProcessIdByName(p_decoded.data());
        if (id != 0) {
            HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
            if (process) {
                if (!TerminateProcess(process, 0)) {
                    fprintf(stderr, "Failed to terminate process [%ls]", p);
                    return false;
                }
                else {
                    WaitForSingleObject(process, INFINITE);
                }
                CloseHandle(process);
            }
            else {
                fprintf(stderr, "Failed to open process [%ls]", p);
                return false;
            }
        }
    }

    return true;
}
开发者ID:hfenigma,项目名称:D3MH,代码行数:32,代码来源:helper.cpp


示例7: exec_xlat

/*
 *	Do xlat of strings.
 */
static size_t exec_xlat(void *instance, REQUEST *request,
		     const char *fmt, char *out, size_t outlen)
{
	int		result;
	rlm_exec_t	*inst = instance;
	VALUE_PAIR	**input_pairs;
	char *p;

	input_pairs = decode_string(request, inst->input);
	if (!input_pairs) {
		radlog(L_ERR, "rlm_exec (%s): Failed to find input pairs for xlat",
		       inst->xlat_name);
		out[0] = '\0';
		return 0;
	}

	/*
	 *	FIXME: Do xlat of program name?
	 */
	RDEBUG2("Executing %s", fmt);
	result = radius_exec_program(fmt, request, inst->wait,
				     out, outlen, *input_pairs, NULL, inst->shell_escape);
	RDEBUG2("result %d", result);
	if (result != 0) {
		out[0] = '\0';
		return 0;
	}

	for (p = out; *p != '\0'; p++) {
		if (*p < ' ') *p = ' ';
	}

	return strlen(out);
}
开发者ID:joyphone,项目名称:freeradius-server,代码行数:37,代码来源:rlm_exec.c


示例8: decode_compound_hdr_arg

static unsigned decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound_hdr_arg *hdr)
{
	uint32_t *p;
	unsigned int minor_version;
	unsigned status;

	status = decode_string(xdr, &hdr->taglen, &hdr->tag);
	if (unlikely(status != 0))
		return status;
	/* We do not like overly long tags! */
	if (hdr->taglen > CB_OP_TAGLEN_MAXSZ-12 || hdr->taglen < 0) {
		printk("NFSv4 CALLBACK %s: client sent tag of length %u\n",
				__FUNCTION__, hdr->taglen);
		return htonl(NFS4ERR_RESOURCE);
	}
	p = read_buf(xdr, 12);
	if (unlikely(p == NULL))
		return htonl(NFS4ERR_RESOURCE);
	minor_version = ntohl(*p++);
	/* Check minor version is zero. */
	if (minor_version != 0) {
		printk(KERN_WARNING "%s: NFSv4 server callback with illegal minor version %u!\n",
				__FUNCTION__, minor_version);
		return htonl(NFS4ERR_MINOR_VERS_MISMATCH);
	}
	hdr->callback_ident = ntohl(*p++);
	hdr->nops = ntohl(*p);
	return 0;
}
开发者ID:FatSunHYS,项目名称:OSCourseDesign,代码行数:29,代码来源:callback_xdr.c


示例9: decode_compound_hdr_arg

static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound_hdr_arg *hdr)
{
	__be32 *p;
	__be32 status;

	status = decode_string(xdr, &hdr->taglen, &hdr->tag);
	if (unlikely(status != 0))
		return status;
	
	if (hdr->taglen > CB_OP_TAGLEN_MAXSZ - 12) {
		printk("NFS: NFSv4 CALLBACK %s: client sent tag of length %u\n",
				__func__, hdr->taglen);
		return htonl(NFS4ERR_RESOURCE);
	}
	p = read_buf(xdr, 12);
	if (unlikely(p == NULL))
		return htonl(NFS4ERR_RESOURCE);
	hdr->minorversion = ntohl(*p++);
	
	if (hdr->minorversion <= 1) {
		hdr->cb_ident = ntohl(*p++); 
	} else {
		pr_warn_ratelimited("NFS: %s: NFSv4 server callback with "
			"illegal minor version %u!\n",
			__func__, hdr->minorversion);
		return htonl(NFS4ERR_MINOR_VERS_MISMATCH);
	}
	hdr->nops = ntohl(*p);
	dprintk("%s: minorversion %d nops %d\n", __func__,
		hdr->minorversion, hdr->nops);
	return 0;
}
开发者ID:Albinoman887,项目名称:pyramid-3.4.10,代码行数:32,代码来源:callback_xdr.c


示例10: decode_json

static PyObject*
decode_json(JSONData *jsondata)
{
    PyObject *object;

    skipSpaces(jsondata);
    switch(*jsondata->ptr) {
    case 0:
        PyErr_SetString(JSON_DecodeError, "empty JSON description");
        return NULL;
    case '{':
        object = decode_object(jsondata);
        break;
    case '[':
        object = decode_array(jsondata);
        break;
    case '"':
        object = decode_string(jsondata);
        break;
    case 't':
    case 'f':
        object = decode_bool(jsondata);
        break;
    case 'n':
        object = decode_null(jsondata);
        break;
    case 'N':
        object = decode_nan(jsondata);
        break;
    case 'I':
        object = decode_inf(jsondata);
        break;
    case '+':
    case '-':
        if (*(jsondata->ptr+1) == 'I') {
            object = decode_inf(jsondata);
        } else {
            object = decode_number(jsondata);
        }
        break;
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
        object = decode_number(jsondata);
        break;
    default:
        PyErr_SetString(JSON_DecodeError, "cannot parse JSON description");
        return NULL;
    }

    return object;
}
开发者ID:petronius,项目名称:cjson,代码行数:59,代码来源:cjson.c


示例11: decode_dstring

void
decode_dstring(DBusMessageIter *iter, int *err, char **pval)
{
  const char *tmp = 0;
  decode_string(iter, err, &tmp);
  free(*pval);
  *pval = strdup(tmp ?: "");
}
开发者ID:tidatida,项目名称:alarmd,代码行数:8,代码来源:codec.c


示例12: decode_PINT_hint

void decode_PINT_hint(char **pptr, PINT_hint **hint)
{
    int count, i, type;
    PINT_hint *new_hint = NULL;
    const struct PINT_hint_info *info;

    decode_uint32_t(pptr, &count);

    gossip_debug(GOSSIP_SERVER_DEBUG, "decoding %d hints from request\n",
                 count);

    for(i = 0; i < count; ++i)
    {
        decode_uint32_t(pptr, &type);
        info = PINT_hint_get_info_by_type(type);
        if(info)
        {
            char *start;
            int len;
            void *value = malloc(info->length);
            if(!value)
            {
                    return;
            }

            start = *pptr;
            info->decode(pptr, value);
            len = (*pptr - start);
            PVFS_hint_add(&new_hint, info->name, len, value);
            free(value);
        }
        else
        {
            char *type_string;
            char *value;
            /* not a recognized hint, assume its a string */
            decode_string(pptr, &type_string);
            decode_string(pptr, &value);
            PVFS_hint_add(&new_hint, type_string, strlen(value) + 1, value);
        }
    }

    *hint = new_hint;
}
开发者ID:snsl,项目名称:pvfs2-osd,代码行数:44,代码来源:pint-hint.c


示例13: expand

void expand(FILE *input,FILE *output)
{
unsigned int next_code;
unsigned int new_code;
unsigned int old_code;
int character;
unsigned char *string;
char *decode_string(unsigned char *buffer,unsigned int code);
    next_code=256;
    printf("Expanding...\n");

  old_code=input_code(input);
  character=old_code;
  putc(old_code,output);

    while ((new_code=input_code(input)) != (MAX_VALUE))
    {


	if (new_code>=next_code)
	{
	    *decode_stack=character;
	    string=decode_string(decode_stack+1,old_code);
	}


	else
	    string=decode_string(decode_stack,new_code);

	character=*string;
	while (string >= decode_stack)
	    putc(*string--,output);


	if (next_code <= MAX_CODE)
	{
	    prefix_code[next_code]=old_code;
	    append_character[next_code]=character;
	    next_code++;
	}
	old_code=new_code;
    }
    printf("\n");
}
开发者ID:1vladal1,项目名称:LZW_RLE_Archivator,代码行数:44,代码来源:LZW.CPP


示例14: argon2_verify

int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen,
                  argon2_type type) {

    argon2_context ctx;
    uint8_t *out;
    int ret;
    int decode_result;

    /* max values, to be updated in decode_string */
    uint32_t encoded_len = strlen(encoded);
    ctx.adlen = encoded_len;
    ctx.saltlen = encoded_len;
    ctx.outlen = encoded_len;
    ctx.allocate_cbk = NULL;
    ctx.free_cbk = NULL;
    ctx.secret = NULL;
    ctx.secretlen = 0;
    ctx.ad = malloc(ctx.adlen);
    ctx.salt = malloc(ctx.saltlen);
    ctx.out = malloc(ctx.outlen);
    if (!ctx.out || !ctx.salt || !ctx.ad) {
        free(ctx.ad);
        free(ctx.salt);
        free(ctx.out);
        return ARGON2_MEMORY_ALLOCATION_ERROR;
    }
    out = malloc(ctx.outlen);
    if (!out) {
        free(ctx.ad);
        free(ctx.salt);
        free(ctx.out);
        return ARGON2_MEMORY_ALLOCATION_ERROR;
    }
    decode_result = decode_string(&ctx, encoded, type);
    if (decode_result != ARGON2_OK) {
        free(ctx.ad);
        free(ctx.salt);
        free(ctx.out);
        free(out);
        return decode_result;
    }

    ret = argon2_hash(ctx.t_cost, ctx.m_cost, ctx.threads, pwd, pwdlen,
                      ctx.salt, ctx.saltlen, out, ctx.outlen, NULL, 0, type);

    free(ctx.ad);
    free(ctx.salt);

    if (ret == ARGON2_OK && argon2_compare(out, ctx.out, ctx.outlen)) {
        ret = ARGON2_VERIFY_MISMATCH;
    }
    free(out);
    free(ctx.out);

    return ret;
}
开发者ID:DarkDare,项目名称:phc-winner-argon2,代码行数:56,代码来源:argon2.c


示例15: RETURN_ERROR

bool SybDBOperation::prepare_stat_init(ei_x_buff * const res)
{
    char* name = NULL;
    char *sql = NULL;
    SybConnection* conn = NULL;
    SybStatement* stmt = NULL;

    if (conn_ == NULL) {
        RETURN_ERROR(res, CONN_NULL_ERROR)
    }

    decode_tuple_header();
    if (!decode_string(name)) {
        RETURN_ERROR(res, BAD_ARG_ERROR)
    }
    if (!decode_string(sql)) {
        free_string(name);
        RETURN_ERROR(res, BAD_ARG_ERROR)
    }
开发者ID:276361270,项目名称:erlang-db-driver,代码行数:19,代码来源:SybDBOperation.cpp


示例16: decode_user_type

  SharedRefPtr<DataType> decode_user_type() {
    StringRef keyspace;
    buffer_ = decode_string(buffer_, &keyspace);

    StringRef type_name;
    buffer_ = decode_string(buffer_, &type_name);

    uint16_t n;
    buffer_ = decode_uint16(buffer_, n);

    UserType::FieldVec fields;
    for (uint16_t i = 0; i < n; ++i) {
      StringRef field_name;
      buffer_ = decode_string(buffer_, &field_name);
      fields.push_back(UserType::Field(field_name.to_string(), decode()));
    }
    return SharedRefPtr<DataType>(new UserType(keyspace.to_string(),
                                               type_name.to_string(),
                                               fields));
  }
开发者ID:WintersLt,项目名称:cpp-driver,代码行数:20,代码来源:result_response.cpp


示例17: erl_lua_setglobal

void
erl_lua_setglobal(lua_drv_t *driver_data, char *buf, int index)
{
  char *name;

  name = decode_string(buf, &index);

  lua_setglobal(driver_data->L, name);

  reply_ok(driver_data);
  free(name);
}
开发者ID:cjimison,项目名称:erlualib,代码行数:12,代码来源:commands.c


示例18: decode_uint16

char* Response::decode_warnings(char* buffer, size_t size) {
  uint16_t warning_count;
  char* pos = decode_uint16(buffer, warning_count);

  for (uint16_t i = 0; i < warning_count; ++i) {
    StringRef warning;
    pos = decode_string(pos, &warning);
    LOG_WARN("Server-side warning: %.*s", (int)warning.size(), warning.data());
  }

  return pos;
}
开发者ID:Shauwe,项目名称:cpp-driver,代码行数:12,代码来源:response.cpp


示例19: decode_triplet

int
decode_triplet(DBusMessageIter *iter, const char **pkey, const char **pval, const char **ptype)
{
  int err = -1;

  DBusMessageIter memb;

  if( dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_STRUCT )
  {
    dbus_message_iter_recurse(iter, &memb);

    if( !decode_string(&memb, pkey) &&
        !decode_string(&memb, pval) &&
        !decode_string(&memb, ptype) )
    {
      dbus_message_iter_next(iter);
      err = 0;
    }
  }
  return err;
}
开发者ID:android-808,项目名称:profiled,代码行数:21,代码来源:codec.c


示例20: argon2_verify

int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen,
                  argon2_type type) {

    argon2_context ctx;
    uint8_t *out;
    int ret;

    /* max values, to be updated in decode_string */
    ctx.adlen = 512;
    ctx.saltlen = 512;
    ctx.outlen = 512;

    ctx.ad = malloc(ctx.adlen);
    ctx.salt = malloc(ctx.saltlen);
    ctx.out = malloc(ctx.outlen);
    if (!ctx.out || !ctx.salt || !ctx.ad) {
        free(ctx.ad);
        free(ctx.salt);
        free(ctx.out);
        return ARGON2_MEMORY_ALLOCATION_ERROR;
    }
    out = malloc(ctx.outlen);
    if (!out) {
        free(ctx.ad);
        free(ctx.salt);
        free(ctx.out);
        return ARGON2_MEMORY_ALLOCATION_ERROR;
    }

    if(decode_string(&ctx, encoded, type) != 1) {
        free(ctx.ad);
        free(ctx.salt);
        free(ctx.out);
        free(out);
        return ARGON2_DECODING_FAIL;
    }

    ret = argon2_hash(ctx.t_cost, ctx.m_cost, ctx.threads, pwd, pwdlen, ctx.salt,
                ctx.saltlen, out, ctx.outlen, NULL, 0, type);

    free(ctx.ad);
    free(ctx.salt);

    if (ret != ARGON2_OK || argon2_compare(out, ctx.out, ctx.outlen)) {
        free(out);
        free(ctx.out);
        return ARGON2_DECODING_FAIL;
    }
    free(out);
    free(ctx.out);

    return ARGON2_OK;
}
开发者ID:agilemobiledev,项目名称:phc-winner-argon2,代码行数:53,代码来源:argon2.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ decode_uint32函数代码示例发布时间:2022-05-30
下一篇:
C++ decode_hex函数代码示例发布时间: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