RSA BSAFE Cert-C

Certificate Components for C

Crypto-C 6.2.1 Developer's Guide
Search

stdlibrf.h File Reference

This file contains the functions that facilitate memory management, strings and time management.

#include "bsfmacro.h"
#include "bsfplatf.h"
#include "aglobal.h"

Go to the source code of this file.

Functions

void T_memset (POINTER, int, unsigned int)
 Sets a block of memory to a given value. More...

void T_memcpy (POINTER, POINTER, unsigned int)
 Copies a block of memory. More...

void T_memmove (POINTER, POINTER, unsigned int)
 Copies a block of memory. More...

int T_memcmp (POINTER, POINTER, unsigned int)
 Compares the first len of firstBlock and secondBlock by scanning the blocks from the lowest address to the highest until a difference is found. More...

POINTER T_malloc (unsigned int)
 Allocates a block of memory of at least len Bytes. More...

POINTER T_realloc (POINTER, unsigned int)
 Changes the size of block to len. More...

void T_free (POINTER)
 Frees an allocated block of memory. More...

void T_strcpy (char *, char *)
 Copies all Bytes of input, up to and including the first NULL Byte, to output. More...

int T_strcmp (char *, char *)
 Compares firstString and secondString by scanning the strings, from the lowest address to the highest, until a difference is found. More...

unsigned int T_strlen (char *)
 Computes the length of a string (the number of Bytes up to, but not including, the first NULL Byte). More...

void T_time (UINT4 *)
 Obtains the current time in seconds since 12:00 A.M. More...


Function Documentation

void T_free POINTER    block ;
 

Frees an allocated block of memory. Call T_malloc() to allocate the value of block. Call T_realloc() to reallocate the memory, or set it to NULL_PTR. No operation is performed if p is set to NULL_PTR.

Parameters:
block [In] A block address.
Samples:
array.c, asn1.c, attrib.c, attributil.c, b64.c, cert.c, certsonly.c, certutil.c, cftest.c, cmpku.c, cmpreq.c, cms.c, critical.c, crl.c, crlutil.c, crmf.c, datamsg.c, dbutil.c, dcrl.c, demoutil.c, dhcert.c, dutil.c, exten.c, extnhlp.c, extnutil.c, extract.c, fulfill.c, kcscrs.c, kcsscep.c, keyutil.c, keywrap.c, memio.c, mscapicert.c, myprint.c, name.c, nameutil.c, ocsp.c, p10util.c, p11dbimp.c, p11dblist.c, p11util.c, p12memio.c, p12util.c, p7stream.c, pkcs10.c, pkcs11db.c, pkcs11msg.c, pkcs12.c, pkcs12exp.c, pkiutil.c, roleattrib.c, saltname.c, scepdb.c, scepreq.c, sslcpvt.c, urlenc.c, validate.c, and verisign.c.

POINTER T_malloc unsigned int    len ;
 

Allocates a block of memory of at least len Bytes. The value of len can be 0. In this case, this function returns a valid non-NULL_PTR value.

Parameters:
len [In] The length of the block.
Returns:
The address of the block indicates success.
NULL_PTR indicates there is insufficient memory.
Samples:
b64.c, cms.c, dbutil.c, demoutil.c, dhcert.c, extnutil.c, fulfill.c, kcscrs.c, kcsscep.c, keyutil.c, keywrap.c, memio.c, myprint.c, p11util.c, p12util.c, p7stream.c, roleattrib.c, scepdb.c, scepreq.c, userextn.c, and verisign.c.

int T_memcmp POINTER    firstBlock,
POINTER    secondBlock,
unsigned int    len
;
 

Compares the first len of firstBlock and secondBlock by scanning the blocks from the lowest address to the highest until a difference is found. The smaller-valued block is the one with the smaller-valued Byte at the point of difference. If no difference is found, the blocks are equal.If the value of len is 0, this function returns 0.

Parameters:
firstBlock [In] The first block of memory.
secondBlock [In] The second block of memory.
len [In] The length of the blocks.
Returns:
<0 indicates that the firstBlock is smaller-valued.
=0 indicates that the blocks are equal.
>0 indicates that the firstBlock is larger-valued.
Samples:
attributil.c, datamsg.c, dhcert.c, extnhlp.c, extnutil.c, inoutcl.c, myprint.c, nameutil.c, and pkcs10.c.

void T_memcpy POINTER    output,
POINTER    input,
unsigned int    len
;
 

Copies a block of memory. The first len Bytes of input are copied to output. The value of len can be 0, in which case output and input are ignored. The ability to handle overlapping blocks correctly depends on the implementation, and therefore should be avoided. Call T_memmove() to process overlapping blocks.

Parameters:
output [In, Out] The output block.
input [In] The input block.
len [In] The length of the blocks.
Samples:
array.c, dhcert.c, dutil.c, fulfill.c, kcscrs.c, kcsscep.c, keyutil.c, keywrap.c, memio.c, myprint.c, p11util.c, scepdb.c, userextn.c, and verisign.c.

void T_memmove POINTER    output,
POINTER    input,
unsigned int    len
;
 

Copies a block of memory. The first len Bytes of input are copied to output. The input and output blocks may overlap. The value of len can be 0, in which case output is undefined.

Parameters:
output [In, Out] The output block.
input [In] The input block.
len [In] The length of the blocks.

void T_memset POINTER    output,
int    value,
unsigned int    len
;
 

Sets a block of memory to a given value. The first len Bytes of output are set to value. If the value of len is 0, output is ignored.

Parameters:
output [In, Out] The output block.
value [In] The value to which output is set.
len [In] The length of the block.
Samples:
b64.c, certutil.c, cmp.c, datamsg.c, dcrl.c, demo.c, demoutil.c, dhcert.c, dummyrand.c, extnhlp.c, extnutil.c, fulfill.c, genreq.c, kcscrs.c, kcsscep.c, keyutil.c, keywrap.c, memio.c, mscapicert.c, myprint.c, ocsp.c, p11dbimp.c, p11dblist.c, p11util.c, p12memio.c, p12util.c, pkcs10.c, pkcs11db.c, pkcs11msg.c, pkcs12.c, pkcs12exp.c, pkiutil.c, roleattrib.c, scepreq.c, sslcpvt.c, timeutil.c, validate.c, and verisign.c.

POINTER T_realloc POINTER    block,
unsigned int    len
;
 

Changes the size of block to len. Allocates a memory block of length len Bytes. Copies as many Bytes as possible from the old memory block to the new one and frees the old block. The address of the new block can be different from the address of the old block. The value of len may be 0, in which case it returns a valid NULL_PTR value.

On error, call T_free() to free block. Call T_malloc() to allocate the value of block. Call T_realloc() to reallocate, or set to NULL_PTR. If block is NULL_PTR, this function performs as T_malloc().

Parameters:
block [In] The input block.
len [In] The length of the block.
Returns:
The address of the new block indicates success.
NULL_PTR indicates an error.
Samples:
array.c, dutil.c, extnhlp.c, memio.c, and ocsp.c.

int T_strcmp char *    firstString,
char *    secondString
;
 

Compares firstString and secondString by scanning the strings, from the lowest address to the highest, until a difference is found. The smaller-valued string is the one with the smaller-valued Byte at the point of difference. If no difference is found up to the length of the shortest string, the strings are equal if they have the same length. Otherwise, the longer string has the larger value. The strings are not considered equal if their lengths differ.

The data in firstString and secondString must be NULL-terminated.

Parameters:
firstString [In] The first string to compare.
secondString [In] The second string to compare.
Returns:
<0 indicates that the value of firstString is smaller than secondString.
=0 indicates that the value of firstString is equal to secondString.
>0 indicates that the value of firstString is greater than secondString.
Samples:
demoutil.c.

void T_strcpy char *    output,
char *    input
;
 

Copies all Bytes of input, up to and including the first NULL Byte, to output.

Parameters:
output [In, Out] The copied string.
input [In] The string to copy.
Samples:
ldap.c, and ldap2.c.

unsigned int T_strlen char *    string ;
 

Computes the length of a string (the number of Bytes up to, but not including, the first NULL Byte).

Parameters:
string [In] The input string.
Returns:
The length of string.
Samples:
array.c, attributil.c, cmp.c, cmpreq.c, demoutil.c, dutil.c, kcsscep.c, keyutil.c, keywrap.c, ldap.c, ldap2.c, nameutil.c, ocsp.c, p11dbimp.c, p11util.c, p12util.c, p7stream.c, pkcs12.c, pkcs12exp.c, pkiutil.c, roleattrib.c, rsadbm.c, scepdb.c, simpleio.c, timeutil.c, and urlenc.c.

void T_time UINT4   theTime ;
 

Obtains the current time in seconds since 12:00 A.M. GMT, January 1, 1970, and stores the result in theTime.

Parameters:
theTime [Out] The current time.
note.gif
Cert-C expects this function to be used to write the time into the provided UINT4 parameter. On some platforms, the standard theTime system function call may write more Bytes than are present in a UINT4. If the input time pointer is passed directly to the system theTime function, verify that the size is correct.
Samples:
cftest.c, dcrl.c, fulfill.c, ldap.c, ldap2.c, surrende.c, and timeutil.c.


Copyright (c) 1999-2005 RSA Security Inc. All rights reserved. 067-001001-2720-001-000 - 2.7.2