本文整理汇总了C++中cdk_free函数的典型用法代码示例。如果您正苦于以下问题:C++ cdk_free函数的具体用法?C++ cdk_free怎么用?C++ cdk_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cdk_free函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: cdk_stream_close
/**
* cdk_stream_close: Close a stream and flush all buffers.
* @s: The STREAM object.
*
* This function work different for read or write streams. When the
* stream is for reading, the filtering is already done and we can
* simply close the file and all buffers.
* But for the case it's a write stream, we need to apply all registered
* filters now. The file is closed in the filter function and not here.
**/
cdk_error_t
cdk_stream_close( cdk_stream_t s )
{
struct stream_filter_s * f, * f2;
int rc = 0;
if( !s )
return CDK_Inv_Value;
_cdk_log_debug( "close stream `%s'\n", s->fname? s->fname : "[temp]" );
if( !s->flags.filtrated && !s->error )
rc = cdk_stream_flush( s );
if( s->fname || s->flags.temp ) {
rc = fclose( s->fp );
s->fp = NULL;
if( rc )
rc = CDK_File_Error;
}
f = s->filters;
while( f ) {
f2 = f->next;
if( f->fnct )
f->fnct( f->opaque, STREAMCTL_FREE, NULL, NULL );
cdk_free( f );
f = f2;
}
if( s->fname ) {
cdk_free( s->fname );
s->fname = NULL;
}
cdk_free( s );
return rc;
}
开发者ID:uvbs,项目名称:SupportCenter,代码行数:44,代码来源:stream.c
示例2: cdk_stream_new
/**
* cdk_stream_new: Create a new stream into into the given file.
* @file: The name of the new file
* @ret_s: The new STREAM object
**/
cdk_error_t
cdk_stream_new( const char * file, cdk_stream_t * ret_s )
{
cdk_stream_t s;
if( !ret_s )
return CDK_Inv_Value;
_cdk_log_debug( "new stream `%s'\n", file? file : "[temp]" );
*ret_s = NULL;
s = cdk_calloc( 1, sizeof *s );
if( !s )
return CDK_Out_Of_Core;
s->flags.write = 1;
if( !file )
s->flags.temp = 1;
else {
s->fname = cdk_strdup( file );
if( !s->fname ) {
cdk_free( s );
return CDK_Out_Of_Core;
}
}
s->fp = tmpfile( );
if( !s->fp ) {
cdk_free( s->fname );
cdk_free( s );
return CDK_File_Error;
}
*ret_s = s;
return 0;
}
开发者ID:uvbs,项目名称:SupportCenter,代码行数:37,代码来源:stream.c
示例3: keydb_idx_search
static int
keydb_idx_search( cdk_stream_t inp, u32 * keyid,
const byte * fpr, u32 * r_off )
{
key_idx_t idx;
if( !inp || !r_off )
return CDK_Inv_Value;
if( (keyid && fpr) || (!keyid && !fpr) )
return CDK_Inv_Mode;
*r_off = 0xFFFFFFFF;
cdk_stream_seek( inp, 0 );
while( keydb_idx_parse( inp, &idx ) != CDK_EOF ) {
if( keyid && KEYID_CMP( keyid, idx->keyid ) ) {
*r_off = idx->offset;
break;
}
else if( fpr && !memcmp( idx->fpr, fpr, 20 ) ) {
*r_off = idx->offset;
break;
}
cdk_free( idx );
idx = NULL;
}
cdk_free( idx );
return *r_off != 0xFFFFFFFF ? 0 : CDK_EOF;
}
开发者ID:uvbs,项目名称:SupportCenter,代码行数:28,代码来源:keydb.c
示例4: cdk_stream_open
/**
* cdk_stream_open: create a new stream based on an existing file.
* @file: The file to open
* @ret_s: The new STREAM object
**/
cdk_error_t
cdk_stream_open( const char * file, cdk_stream_t * ret_s )
{
cdk_stream_t s;
if( !file || !ret_s )
return CDK_Inv_Value;
_cdk_log_debug( "open stream `%s'\n", file );
*ret_s = NULL;
s = cdk_calloc( 1, sizeof *s );
if( !s )
return CDK_Out_Of_Core;
s->fname = cdk_strdup( file );
if( !s->fname ) {
cdk_free( s );
return CDK_Out_Of_Core;
}
s->fp = fopen( file, "rb" );
if( !s->fp ) {
cdk_free( s->fname );
cdk_free( s );
return CDK_File_Error;
}
s->flags.write = 0;
*ret_s = s;
return 0;
}
开发者ID:uvbs,项目名称:SupportCenter,代码行数:33,代码来源:stream.c
示例5: _cdk_result_verify_free
void
_cdk_result_verify_free (cdk_verify_result_t res)
{
if (!res)
return;
cdk_free (res->policy_url);
cdk_free (res->sig_data);
cdk_free (res);
}
开发者ID:Chronic-Dev,项目名称:gnutls,代码行数:9,代码来源:verify.c
示例6: keydb_search_free
void
keydb_search_free( cdk_dbsearch_t dbs )
{
if( !dbs )
return;
if( dbs->type == CDK_DBSEARCH_EXACT || dbs->type == CDK_DBSEARCH_SUBSTR )
cdk_free( dbs->u.pattern );
dbs->type = 0;
cdk_free( dbs );
}
开发者ID:uvbs,项目名称:SupportCenter,代码行数:10,代码来源:keydb.c
示例7: keydb_idx_build
/* This functions builds an index of the keyring into a separate file
with the name keyring.ext.idx. It contains the offset of all public-
and public subkeys. The format of the file is:
--------
4 octets offset of the packet
8 octets keyid
20 octets fingerprint
--------
We store the keyid and the fingerprint due to the fact we can't get
the keyid from a v3 fingerprint directly.
*/
static int
keydb_idx_build( const char * file )
{
cdk_packet_t pkt;
cdk_stream_t inp, out = NULL;
byte buf[8], fpr[20];
char * fname;
u32 keyid[2];
int rc, pos;
if( !file )
return CDK_Inv_Value;
pkt = cdk_calloc( 1, sizeof * pkt );
if( !pkt )
return CDK_Out_Of_Core;
fname = keydb_idx_mkname( file );
if( !fname ) {
rc = CDK_Out_Of_Core;
goto leave;
}
rc = cdk_stream_open( file, &inp );
if( !rc )
rc = cdk_stream_create( fname, &out );
if( rc )
goto leave;
while( !cdk_stream_eof( inp ) ) {
pos = cdk_stream_tell( inp );
rc = cdk_pkt_read( inp, pkt );
if( rc )
break;
if( pkt->pkttype == CDK_PKT_PUBLIC_KEY
|| pkt->pkttype == CDK_PKT_PUBLIC_SUBKEY ) {
_cdk_u32tobuf( pos, buf );
cdk_stream_write( out, buf, 4 );
cdk_pk_get_keyid( pkt->pkt.public_key, keyid );
_cdk_u32tobuf( keyid[0], buf );
_cdk_u32tobuf( keyid[1], buf + 4 );
cdk_stream_write( out, buf, 8 );
cdk_pk_get_fingerprint( pkt->pkt.public_key, fpr );
cdk_stream_write( out, fpr, 20 );
}
cdk_pkt_free( pkt );
cdk_pkt_init( pkt );
}
cdk_stream_close( out );
leave:
cdk_stream_close( inp );
cdk_free( fname );
cdk_free( pkt );
return rc;
}
开发者ID:uvbs,项目名称:SupportCenter,代码行数:66,代码来源:keydb.c
示例8: cdk_listkey_close
/**
* cdk_listkey_close:
* @ctx: the list key context
*
* Free the list key context.
**/
void
cdk_listkey_close( cdk_listkey_t ctx )
{
if( ctx ) {
if( ctx->type )
cdk_free( ctx->u.patt );
else
cdk_strlist_free( ctx->u.fpatt );
cdk_free( ctx );
}
}
开发者ID:uvbs,项目名称:SupportCenter,代码行数:17,代码来源:keydb.c
示例9: _cdk_free_userid
void _cdk_free_userid(cdk_pkt_userid_t uid)
{
if (!uid)
return;
cdk_free(uid->prefs);
uid->prefs = NULL;
cdk_free(uid->attrib_img);
uid->attrib_img = NULL;
cdk_free(uid);
}
开发者ID:Distrotech,项目名称:gnutls,代码行数:11,代码来源:new-packet.c
示例10: cdk_pklist_encrypt
/**
* cdk_pklist_encrypt:
* @pkl: the keylist
* @dek: the data encryption key
* @outp: the stream to write in the data
*
* Encrypt the session key with each key of the list and wrap it
* into a PUBKEY_ENC packet and write it to @outp.
*/
cdk_error_t
cdk_pklist_encrypt( cdk_keylist_t pk_list, cdk_dek_t dek, cdk_stream_t outp )
{
cdk_pkt_pubkey_t pk = NULL;
cdk_pkt_pubkey_enc_t enc = NULL;
cdk_packet_t pkt;
cdk_sesskey_t frame = NULL;
int nbits = 0;
int rc = 0;
if( !pk_list || !dek || !outp )
return CDK_Inv_Value;
if( pk_list->type != CDK_PKT_PUBLIC_KEY )
return CDK_Inv_Mode;
pkt = cdk_calloc( 1, sizeof * pkt );
if( !pkt )
return CDK_Out_Of_Core;
for( ; pk_list; pk_list = pk_list->next ) {
pk = pk_list->key.pk;
cdk_free( enc );
enc = cdk_calloc( 1, sizeof *enc );
if( !enc )
return CDK_Out_Of_Core;
enc->version = 3;
enc->pubkey_algo = pk->pubkey_algo;
cdk_pk_get_keyid( pk, enc->keyid );
nbits = cdk_pk_get_nbits( pk );
rc = cdk_dek_encode_pkcs1( dek, nbits, &frame );
if( rc )
break;
rc = cdk_pk_encrypt( pk, enc, frame );
cdk_sesskey_free( frame );
if( rc )
break;
else {
cdk_pkt_init( pkt );
pkt->old_ctb = dek->rfc1991? 1 : 0;
pkt->pkttype = CDK_PKT_PUBKEY_ENC;
pkt->pkt.pubkey_enc = enc;
rc = cdk_pkt_write( outp, pkt );
cdk_pkt_free( pkt );
if( rc )
break;
}
}
cdk_free( pkt );
cdk_free( enc );
return rc;
}
开发者ID:uvbs,项目名称:SupportCenter,代码行数:60,代码来源:keylist.c
示例11: cdk_pk_release
void cdk_pk_release(cdk_pubkey_t pk)
{
size_t npkey;
if (!pk)
return;
npkey = cdk_pk_get_npkey(pk->pubkey_algo);
_cdk_free_userid(pk->uid);
pk->uid = NULL;
cdk_free(pk->prefs);
pk->prefs = NULL;
_cdk_free_mpibuf(npkey, pk->mpi);
cdk_free(pk);
}
开发者ID:Distrotech,项目名称:gnutls,代码行数:15,代码来源:new-packet.c
示例12: _cdk_pkt_write2
cdk_error_t
_cdk_pkt_write2 (cdk_stream_t out, int pkttype, void *pktctx)
{
cdk_packet_t pkt;
cdk_error_t rc;
rc = cdk_pkt_new (&pkt);
if (rc)
return rc;
switch (pkttype)
{
case CDK_PKT_PUBLIC_KEY:
case CDK_PKT_PUBLIC_SUBKEY:
pkt->pkt.public_key = pktctx;
break;
case CDK_PKT_SIGNATURE:
pkt->pkt.signature = pktctx;
break;
case CDK_PKT_SECRET_KEY:
case CDK_PKT_SECRET_SUBKEY:
pkt->pkt.secret_key = pktctx;
break;
case CDK_PKT_USER_ID:
pkt->pkt.user_id = pktctx;
break;
}
pkt->pkttype = pkttype;
rc = cdk_pkt_write (out, pkt);
cdk_free (pkt);
return rc;
}
开发者ID:ystk,项目名称:debian-gnutls26,代码行数:33,代码来源:write-packet.c
示例13: cdk_pkt_release
/**
* cdk_pkt_release:
* @pkt: the packet
*
* Free the contents of the given package and
* release the memory of the structure.
**/
void cdk_pkt_release(cdk_packet_t pkt)
{
if (!pkt)
return;
cdk_pkt_free(pkt);
cdk_free(pkt);
}
开发者ID:Distrotech,项目名称:gnutls,代码行数:14,代码来源:new-packet.c
示例14: cdk_keygen_set_name
/**
* cdk_keygen_set_name: set the userid name for the key
* @hd: the keygen object
* @name: name
*
* The name will be encoded in UTF8 to avoid problems.
**/
void
cdk_keygen_set_name( cdk_keygen_ctx_t hd, const char * name )
{
if( hd ) {
cdk_free( hd->user_id );
hd->user_id = cdk_utf8_encode( name );
}
}
开发者ID:uvbs,项目名称:SupportCenter,代码行数:15,代码来源:keygen.c
示例15: cdk_sk_release
void cdk_sk_release(cdk_seckey_t sk)
{
size_t nskey;
if (!sk)
return;
nskey = cdk_pk_get_nskey(sk->pubkey_algo);
_cdk_free_mpibuf(nskey, sk->mpi);
cdk_free(sk->encdata);
sk->encdata = NULL;
cdk_pk_release(sk->pk);
sk->pk = NULL;
cdk_s2k_free(sk->protect.s2k);
sk->protect.s2k = NULL;
cdk_free(sk);
}
开发者ID:Distrotech,项目名称:gnutls,代码行数:17,代码来源:new-packet.c
示例16: free_literal
static void free_literal(cdk_pkt_literal_t pt)
{
if (!pt)
return;
/* The buffer which is referenced in this packet is closed
elsewhere. To close it here would cause a double close. */
cdk_free(pt);
}
开发者ID:Distrotech,项目名称:gnutls,代码行数:8,代码来源:new-packet.c
示例17: cdk_stream_write
/**
* cdk_stream_write:
* @s: The STREAM object
* @buf: The buffer with the values to write.
* @count: The size of the buffer.
*
* Tries to write count bytes into the stream.
* In this function we simply write the bytes to the stream. We can't
* use the filters here because it would mean they have to support
* partial flushing.
**/
int
cdk_stream_write (cdk_stream_t s, const void *buf, size_t count)
{
int nwritten;
if (!s)
{
s->error = CDK_Inv_Value;
gnutls_assert();
return EOF;
}
if (s->cbs_hd)
{
if (s->cbs.write)
return s->cbs.write (s->cbs_hd, buf, count);
return 0;
}
if (!s->flags.write)
{
s->error = CDK_Inv_Mode; /* this is a read stream */
gnutls_assert();
return EOF;
}
if (!buf && !count)
return stream_flush (s);
if (s->cache.on)
{
/* We need to resize the buffer if the additional data wouldn't
fit into it. We allocate more memory to avoid to resize it the
next time the function is used. */
if (s->cache.size + count > s->cache.alloced)
{
byte *old = s->cache.buf;
s->cache.buf =
cdk_calloc (1, s->cache.alloced + count + STREAM_BUFSIZE);
s->cache.alloced += (count + STREAM_BUFSIZE);
memcpy (s->cache.buf, old, s->cache.size);
cdk_free (old);
_cdk_log_debug ("stream: enlarge cache to %d octets\n",
s->cache.alloced);
}
memcpy (s->cache.buf + s->cache.size, buf, count);
s->cache.size += count;
return count;
}
nwritten = fwrite (buf, 1, count, s->fp);
if (!nwritten)
nwritten = EOF;
return nwritten;
}
开发者ID:bf4,项目名称:pidgin-mac,代码行数:67,代码来源:stream.c
示例18: if
byte *_cdk_subpkt_get_array(cdk_subpkt_t s, int count, size_t * r_nbytes)
{
cdk_subpkt_t list;
byte *buf;
size_t n, nbytes;
if (!s) {
if (r_nbytes)
*r_nbytes = 0;
return NULL;
}
for (n = 0, list = s; list; list = list->next) {
n++; /* type */
n += list->size;
if (list->size < 192)
n++;
else if (list->size < 8384)
n += 2;
else
n += 5;
}
buf = cdk_calloc(1, n + 1);
if (!buf)
return NULL;
n = 0;
for (list = s; list; list = list->next) {
nbytes = 1 + list->size; /* type */
if (nbytes < 192)
buf[n++] = nbytes;
else if (nbytes < 8384) {
nbytes -= 192;
buf[n++] = nbytes / 256 + 192;
buf[n++] = nbytes & 0xff;
} else {
buf[n++] = 0xFF;
buf[n++] = nbytes >> 24;
buf[n++] = nbytes >> 16;
buf[n++] = nbytes >> 8;
buf[n++] = nbytes;
}
buf[n++] = list->type;
memcpy(buf + n, list->d, list->size);
n += list->size;
}
if (count) {
cdk_free(buf);
buf = NULL;
}
if (r_nbytes)
*r_nbytes = n;
return buf;
}
开发者ID:Distrotech,项目名称:gnutls,代码行数:56,代码来源:new-packet.c
示例19: cdk_strlist_free
void
cdk_strlist_free (cdk_strlist_t sl)
{
cdk_strlist_t sl2;
for(; sl; sl = sl2 ) {
sl2 = sl->next;
cdk_free (sl);
}
}
开发者ID:uvbs,项目名称:SupportCenter,代码行数:10,代码来源:misc.c
示例20: cdk_subpkt_free
/**
* cdk_subpkt_free:
* @ctx: the sub packet node to free
*
* Release the context.
**/
void cdk_subpkt_free(cdk_subpkt_t ctx)
{
cdk_subpkt_t s;
while (ctx) {
s = ctx->next;
cdk_free(ctx);
ctx = s;
}
}
开发者ID:Distrotech,项目名称:gnutls,代码行数:16,代码来源:new-packet.c
注:本文中的cdk_free函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论