Type Definitions

The types.h header file contains definitions for primitive types, structs, macros, functions dedicated to ASN.1 types.

boolean

Definition:

typedef unsigned char boolean
Constants:
#define	false	0
#define	true	1

Bits

Definition:

typedef struct {
    unsigned int length; /* number of bits */
    char*  bytes;
} Bits;
Functions:
Bits* wrapBits(char* bytes, unsigned int length) - Wrap a bytes array into Bits.
boolean isBitSet(Bits* bits, unsigned int bit) - Answer if the specific bit is set.
void setBit(Bits* bits, unsigned int bit) - To set the specific bit.
void clearBit(Bits* bits, unsigned int bit) - To clear the specific bit.

Octets

Definition:

typedef struct {
    unsigned int length; /* number of bytes */
    char*  bytes;
} Octets;
Functions:
Octets* wrapOctets(char* bytes, unsigned int length) - Wrap a bytes array into Octets.

Oid

Definition:

typedef struct {
    unsigned int length;
    unsigned int* ids;
} Oid;
Functions:
None

Character Strings

Definition:

typedef unsigned short wchar;
typedef unsigned int uchar;
Functions:
unsigned int cstrlen(char* s) - Calculate the length of the 0 terminate string.
unsigned int wstrlen(wchar* s) - Calculate the length of the 0 terminate string.
unsigned int ustrlen(uchar* s) - Calculate the length of the 0 terminate string.

Time

Definition:

typedef struct {
    signed int year; /* 0~9999 */
    signed char month; /* Jun = 1, ..., Dec = 12 */
    signed char day; /* 1~31 */
    signed char hour; /* 0~23 */
    signed char minute; /* 0~59 */
    signed char second; /* 0~59 */
    signed char hour_offset; /* hour offset from UTC. For example, hour_offset=8 means eight hours ahead of GMT */
    signed char minute_offset;/* minute offset from UTC. For example, minute_offset=15 means 15 minutes ahead of GMT */
    signed int millisec; /* 0~999 */
} Time;
Functions:
None

List

Definition:

#define List(E)             \
struct {                    \
    unsigned int capacity;  \
    unsigned int size;      \
    E* elements;            \
}
Members:
capacity - The capacity of the array, i.e. the maximum number of elements this array can  hold.
size - The actual size of the list.
elements - The elements array.