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

C++ BUF_strlcat函数代码示例

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

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



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

示例1: append_buf

static int append_buf(char **buf, const char *s, int *size, int step)
	{
	int l = strlen(s);

	if (*buf == NULL)
		{
		*size = step;
		*buf = OPENSSL_malloc(*size);
		if (*buf == NULL)
			return 0;
		**buf = '\0';
		}

	if (**buf != '\0')
		l += 2;		/* ", " */

	if (strlen(*buf) + strlen(s) >= (unsigned int)*size)
		{
		*size += step;
		*buf = OPENSSL_realloc(*buf, *size);
		}

	if (*buf == NULL)
		return 0;

	if (**buf != '\0')
		BUF_strlcat(*buf, ", ", *size);
	BUF_strlcat(*buf, s, *size);

	return 1;
	}
开发者ID:oss-forks,项目名称:openssl,代码行数:31,代码来源:engine.c


示例2: sizeof

char *UI_construct_prompt(UI *ui, const char *object_desc,
                          const char *object_name)
{
    char *prompt = NULL;

    if (ui->meth->ui_construct_prompt)
        prompt = ui->meth->ui_construct_prompt(ui, object_desc, object_name);
    else {
        char prompt1[] = "Enter ";
        char prompt2[] = " for ";
        char prompt3[] = ":";
        int len = 0;

        if (object_desc == NULL)
            return NULL;
        len = sizeof(prompt1) - 1 + strlen(object_desc);
        if (object_name)
            len += sizeof(prompt2) - 1 + strlen(object_name);
        len += sizeof(prompt3) - 1;

        prompt = OPENSSL_malloc(len + 1);
        if (prompt == NULL)
            return NULL;
        BUF_strlcpy(prompt, prompt1, len + 1);
        BUF_strlcat(prompt, object_desc, len + 1);
        if (object_name) {
            BUF_strlcat(prompt, prompt2, len + 1);
            BUF_strlcat(prompt, object_name, len + 1);
        }
        BUF_strlcat(prompt, prompt3, len + 1);
    }
    return prompt;
}
开发者ID:crypto-org-ua,项目名称:openssl-ua,代码行数:33,代码来源:ui_lib.c


示例3: BUF_strlcpy

const char *RAND_file_name(char *buf, size_t size)
	{
	char *s=NULL;
	int ok = 0;
#ifdef __OpenBSD__
	struct stat sb;
#endif

	if (OPENSSL_issetugid() == 0)
		s=getenv("RANDFILE");
	if (s != NULL && *s && strlen(s) + 1 < size)
		{
		if (BUF_strlcpy(buf,s,size) >= size)
			return NULL;
		}
	else
		{
		if (OPENSSL_issetugid() == 0)
			s=getenv("HOME");
#ifdef DEFAULT_HOME
		if (s == NULL)
			{
			s = DEFAULT_HOME;
			}
#endif
		if (s && *s && strlen(s)+strlen(RFILE)+2 < size)
			{
			BUF_strlcpy(buf,s,size);
#ifndef OPENSSL_SYS_VMS
			BUF_strlcat(buf,"/",size);
#endif
			BUF_strlcat(buf,RFILE,size);
			ok = 1;
			}
		else
		  	buf[0] = '\0'; /* no file name */
		}

#ifdef __OpenBSD__
	/* given that all random loads just fail if the file can't be 
	 * seen on a stat, we stat the file we're returning, if it
	 * fails, use /dev/arandom instead. this allows the user to 
	 * use their own source for good random data, but defaults
	 * to something hopefully decent if that isn't available. 
	 */

	if (!ok)
		if (BUF_strlcpy(buf,"/dev/arandom",size) >= size) {
			return(NULL);
		}	
	if (stat(buf,&sb) == -1)
		if (BUF_strlcpy(buf,"/dev/arandom",size) >= size) {
			return(NULL);
		}	

#endif
	return(buf);
	}
开发者ID:S0043640wipro,项目名称:RiCRiPInt,代码行数:58,代码来源:randfile.c


示例4: PEM_proc_type

void PEM_proc_type(char *buf, int type)
  {
  const char *str;

  if (type == PEM_TYPE_ENCRYPTED)
    str="ENCRYPTED";
  else if (type == PEM_TYPE_MIC_CLEAR)
    str="MIC-CLEAR";
  else if (type == PEM_TYPE_MIC_ONLY)
    str="MIC-ONLY";
  else
    str="BAD-TYPE";
    
  BUF_strlcat(buf,"Proc-Type: 4,",PEM_BUFSIZE);
  BUF_strlcat(buf,str,PEM_BUFSIZE);
  BUF_strlcat(buf,"\n",PEM_BUFSIZE);
  }
开发者ID:yyyyyao,项目名称:Slicer3-lib-mirrors,代码行数:17,代码来源:pem_lib.c


示例5: PEM_dek_info

void PEM_dek_info(char *buf, const char *type, int len, char *str)
{
    static const unsigned char map[17] = "0123456789ABCDEF";
    long i;
    int j;

    BUF_strlcat(buf, "DEK-Info: ", PEM_BUFSIZE);
    BUF_strlcat(buf, type, PEM_BUFSIZE);
    BUF_strlcat(buf, ",", PEM_BUFSIZE);
    j = strlen(buf);
    if (j + (len * 2) + 1 > PEM_BUFSIZE)
        return;
    for (i = 0; i < len; i++) {
        buf[j + i * 2] = map[(str[i] >> 4) & 0x0f];
        buf[j + i * 2 + 1] = map[(str[i]) & 0x0f];
    }
    buf[j + i * 2] = '\n';
    buf[j + i * 2 + 1] = '\0';
}
开发者ID:endlessm,项目名称:shim,代码行数:19,代码来源:pem_lib.c


示例6: strlen

static ASN1_INTEGER *x509_load_serial (char *CAfile, char *serialfile, int create)
{
    char *buf = NULL, *p;

    ASN1_INTEGER *bs = NULL;

    BIGNUM *serial = NULL;

    size_t len;

    len = ((serialfile == NULL) ? (strlen (CAfile) + strlen (POSTFIX) + 1) : (strlen (serialfile))) + 1;
    buf = OPENSSL_malloc (len);
    if (buf == NULL)
    {
        BIO_printf (bio_err, "out of mem\n");
        goto end;
    }
    if (serialfile == NULL)
    {
        BUF_strlcpy (buf, CAfile, len);
        for (p = buf; *p; p++)
            if (*p == '.')
            {
                *p = '\0';
                break;
            }
        BUF_strlcat (buf, POSTFIX, len);
    }
    else
        BUF_strlcpy (buf, serialfile, len);

    serial = load_serial (buf, create, NULL);
    if (serial == NULL)
        goto end;

    if (!BN_add_word (serial, 1))
    {
        BIO_printf (bio_err, "add_word failure\n");
        goto end;
    }

    if (!save_serial (buf, NULL, serial, &bs))
        goto end;

  end:
    if (buf)
        OPENSSL_free (buf);
    BN_free (serial);
    return bs;
}
开发者ID:274914765,项目名称:C,代码行数:50,代码来源:x509.c


示例7: ERR_load_crypto_strings

/**
 * @brief	Push an openssl-generated error onto the error stack.
 */
errinfo_t *_push_error_stack_openssl(const char *filename, const char *funcname, int lineno, unsigned int errcode, int xerrno) {

	const char *ssl_filename, *ssl_data;
	char auxmsg[512], tmpbuf[512], tmpbuf2[512];
	int ssl_line, ssl_flags, first_pass = 1;
	static int loaded = 0;

	if (!loaded) {
		ERR_load_crypto_strings();
		SSL_load_error_strings();
		loaded = 1;
	}

	memset(auxmsg, 0, sizeof(auxmsg));

	// Keep doing this as long as there's more errors there.
	while (ERR_peek_error_line_data(&ssl_filename, &ssl_line, &ssl_data, &ssl_flags)) {

		if (!first_pass) {
			BUF_strlcat(auxmsg, " | ", sizeof(auxmsg));
		} else {
			first_pass = 0;
		}

		memset(tmpbuf, 0, sizeof(tmpbuf));
		snprintf(tmpbuf, sizeof(tmpbuf), ":%s:%d", ssl_filename, ssl_line);

		memset(tmpbuf2, 0, sizeof(tmpbuf2));
		ERR_error_string_n(ERR_get_error(), tmpbuf2, sizeof(tmpbuf2));

		// Combine the two error strings and add them to the buffer.
		BUF_strlcat(auxmsg, tmpbuf2, sizeof(auxmsg));
		BUF_strlcat(auxmsg, tmpbuf, sizeof(auxmsg));
	}

	return (_push_error_stack(filename, funcname, lineno, errcode, xerrno, auxmsg));
}
开发者ID:0x4E0x650x6F,项目名称:libdime,代码行数:40,代码来源:error.c


示例8: defined

/* Add EFIAPI for UEFI version. */
void
#if defined(OPENSSL_SYS_UEFI)
EFIAPI
#endif
ERR_add_error_data(int num, ...)
	{
	va_list args;
	int i,n,s;
	char *str,*p,*a;

	s=80;
	str=OPENSSL_malloc(s+1);
	if (str == NULL) return;
	str[0]='\0';

	va_start(args, num);
	n=0;
	for (i=0; i<num; i++)
		{
		a=va_arg(args, char*);
		/* ignore NULLs, thanks to Bob Beck <[email protected]> */
		if (a != NULL)
			{
			n+=strlen(a);
			if (n > s)
				{
				s=n+20;
				p=OPENSSL_realloc(str,s+1);
				if (p == NULL)
					{
					OPENSSL_free(str);
					goto err;
					}
				else
					str=p;
				}
			BUF_strlcat(str,a,(size_t)s+1);
			}
		}
	ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING);

err:
	va_end(args);
	}
开发者ID:huaqli,项目名称:clover,代码行数:45,代码来源:err.c


示例9: BUF_strlcpy

/* Convert an ASN1_TIME structure to GeneralizedTime */
ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t,
                                                   ASN1_GENERALIZEDTIME **out)
{
    ASN1_GENERALIZEDTIME *ret;
    char *str;
    int newlen;

    if (!ASN1_TIME_check(t))
        return NULL;

    if (!out || !*out) {
        if (!(ret = ASN1_GENERALIZEDTIME_new()))
            return NULL;
        if (out)
            *out = ret;
    } else
        ret = *out;

    /* If already GeneralizedTime just copy across */
    if (t->type == V_ASN1_GENERALIZEDTIME) {
        if (!ASN1_STRING_set(ret, t->data, t->length))
            return NULL;
        return ret;
    }

    /* grow the string */
    if (!ASN1_STRING_set(ret, NULL, t->length + 2))
        return NULL;
    /* ASN1_STRING_set() allocated 'len + 1' bytes. */
    newlen = t->length + 2 + 1;
    str = (char *)ret->data;
    /* Work out the century and prepend */
    if (t->data[0] >= '5')
        BUF_strlcpy(str, "19", newlen);
    else
        BUF_strlcpy(str, "20", newlen);

    BUF_strlcat(str, (char *)t->data, newlen);

    return ret;
}
开发者ID:NickAger,项目名称:elm-slider,代码行数:42,代码来源:a_time.c


示例10: BIO_dump_indent_cb

int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u),
	void *u, const char *s, int len, int indent)
	{
	int ret=0;
	char buf[288+1],tmp[20],str[128+1];
	int i,j,rows,trc;
	unsigned char ch;
	int dump_width;

	trc=0;

#ifdef TRUNCATE
	for(; (len > 0) && ((s[len-1] == ' ') || (s[len-1] == '\0')); len--)
		trc++;
#endif

	if (indent < 0)
		indent = 0;
	if (indent)
		{
		if (indent > 128) indent=128;
		memset(str,' ',indent);
		}
	str[indent]='\0';

	dump_width=DUMP_WIDTH_LESS_INDENT(indent);
	rows=(len/dump_width);
	if ((rows*dump_width)<len)
		rows++;
	for(i=0;i<rows;i++)
		{
		buf[0]='\0';	/* start with empty string */
		BUF_strlcpy(buf,str,sizeof buf);
		BIO_snprintf(tmp,sizeof tmp,"%04x - ",i*dump_width);
		BUF_strlcat(buf,tmp,sizeof buf);
		for(j=0;j<dump_width;j++)
			{
			if (((i*dump_width)+j)>=len)
				{
				BUF_strlcat(buf,"   ",sizeof buf);
				}
			else
				{
				ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
				BIO_snprintf(tmp,sizeof tmp,"%02x%c",ch,
					j==7?'-':' ');
				BUF_strlcat(buf,tmp,sizeof buf);
				}
			}
		BUF_strlcat(buf,"  ",sizeof buf);
		for(j=0;j<dump_width;j++)
			{
			if (((i*dump_width)+j)>=len)
				break;
			ch=((unsigned char)*(s+i*dump_width+j)) & 0xff;
#ifndef CHARSET_EBCDIC
			BIO_snprintf(tmp,sizeof tmp,"%c",
				((ch>=' ')&&(ch<='~'))?ch:'.');
#else
			BIO_snprintf(tmp,sizeof tmp,"%c",
				((ch>=os_toascii[' '])&&(ch<=os_toascii['~']))
				? os_toebcdic[ch]
				: '.');
#endif
			BUF_strlcat(buf,tmp,sizeof buf);
			}
		BUF_strlcat(buf,"\n",sizeof buf);
		/* if this is the last call then update the ddt_dump thing so
		 * that we will move the selection point in the debug window
		 */
		ret+=cb((void *)buf,strlen(buf),u);
		}
#ifdef TRUNCATE
	if (trc > 0)
		{
		BIO_snprintf(buf,sizeof buf,"%s%04x - <SPACES/NULS>\n",str,
			len+trc);
		ret+=cb((void *)buf,strlen(buf),u);
		}
#endif
	return(ret);
	}
开发者ID:millken,项目名称:zhuxianB30,代码行数:82,代码来源:b_dump.c


示例11: srp_main


//.........这里部分代码省略.........
        && argc < 1) {
        BIO_printf(bio_err,
                   "Need at least one user for options -add, -delete, -modify. \n");
        goto opthelp;
    }
    if ((passin || passout) && argc != 1) {
        BIO_printf(bio_err,
                   "-passin, -passout arguments only valid with one user.\n");
        goto opthelp;
    }

    if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
        BIO_printf(bio_err, "Error getting passwords\n");
        goto end;
    }

    if (!dbfile) {

        /*****************************************************************/
        tofree = NULL;
        if (configfile == NULL)
            configfile = getenv("OPENSSL_CONF");
        if (configfile == NULL)
            configfile = getenv("SSLEAY_CONF");
        if (configfile == NULL) {
            const char *s = X509_get_default_cert_area();
            size_t len = strlen(s) + 1 + sizeof(CONFIG_FILE);

            tofree = app_malloc(len, "config filename space");
# ifdef OPENSSL_SYS_VMS
            strcpy(tofree, s);
# else
            BUF_strlcpy(tofree, s, len);
            BUF_strlcat(tofree, "/", len);
# endif
            BUF_strlcat(tofree, CONFIG_FILE, len);
            configfile = tofree;
        }

        if (verbose)
            BIO_printf(bio_err, "Using configuration from %s\n", configfile);
        conf = NCONF_new(NULL);
        if (NCONF_load(conf, configfile, &errorline) <= 0) {
            if (errorline <= 0)
                BIO_printf(bio_err, "error loading the config file '%s'\n",
                           configfile);
            else
                BIO_printf(bio_err, "error on line %ld of config file '%s'\n",
                           errorline, configfile);
            goto end;
        }
        OPENSSL_free(tofree);
        tofree = NULL;

        /* Lets get the config section we are using */
        if (section == NULL) {
            if (verbose)
                BIO_printf(bio_err,
                           "trying to read " ENV_DEFAULT_SRP
                           " in \" BASE_SECTION \"\n");

            section = NCONF_get_string(conf, BASE_SECTION, ENV_DEFAULT_SRP);
            if (section == NULL) {
                lookup_fail(BASE_SECTION, ENV_DEFAULT_SRP);
                goto end;
            }
开发者ID:Chatlanen,项目名称:openssl,代码行数:67,代码来源:srp.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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