group PJ_BASIC



This macro creates Unicode or ANSI literal string depending whether native platform string is Unicode or ANSI.


Utility macro to compute the number of elements in static array.


Length of object names.


We need to tell the compiler that the function takes printf style arguments, so the compiler can check the code more carefully and generate the appropriate warnings, if necessary.

PJ_CHECK_OVERFLOW_UINT32_TO_LONG(uint32_var, exec_on_overflow)

Utility macro to check if uint32 var will overflow if converted to signed long.


typedef int pj_int32_t

Signed 32bit integer.

typedef unsigned int pj_uint32_t

Unsigned 32bit integer.

typedef short pj_int16_t

Signed 16bit integer.

typedef unsigned short pj_uint16_t

Unsigned 16bit integer.

typedef signed char pj_int8_t

Signed 8bit integer.

typedef unsigned char pj_uint8_t

Unsigned 8bit integer.

typedef size_t pj_size_t

Large unsigned integer.

typedef long pj_ssize_t

Large signed integer.

typedef int pj_status_t

Status code.

typedef int pj_bool_t


typedef char pj_char_t

Native char type, which will be equal to wchar_t for Unicode and char for ANSI.

typedef pj_ssize_t pj_off_t

File offset type.

typedef pj_uint32_t pj_uint_t

Generic unsigned integer types.

This is a 64 bit unsigned integer if the system support it, otherwise this is a 32 bit unsigned integer.

typedef void pj_list_type

The opaque data type for linked list, which is used as arguments throughout the linked list operations.

typedef struct pj_hash_table_t pj_hash_table_t

Opaque data type for hash tables.

typedef struct pj_hash_entry pj_hash_entry

Opaque data type for hash entry (only used internally by hash table).

typedef struct pj_ioqueue_t pj_ioqueue_t

Opaque data type for I/O Queue structure.

typedef struct pj_ioqueue_key_t pj_ioqueue_key_t

Opaque data type for key that identifies a handle registered to the I/O queue framework.

typedef struct pj_timer_heap_t pj_timer_heap_t

Opaque data to identify timer heap.

typedef struct pj_atomic_t pj_atomic_t

Opaque data type for atomic operations.

typedef PJ_ATOMIC_VALUE_TYPE pj_atomic_value_t

Value type of an atomic variable.

typedef struct pj_thread_t pj_thread_t

Thread handle.

typedef struct pj_lock_t pj_lock_t

Lock object.

typedef struct pj_grp_lock_t pj_grp_lock_t

Group lock

typedef struct pj_mutex_t pj_mutex_t

Mutex handle.

typedef struct pj_sem_t pj_sem_t

Semaphore handle.

typedef struct pj_event_t pj_event_t

Event object.

typedef struct pj_pipe_t pj_pipe_t

Unidirectional stream pipe object.

typedef void *pj_oshandle_t

Operating system handle.

typedef long pj_sock_t

Socket handle.

typedef void pj_sockaddr_t

Generic socket address.

typedef unsigned int pj_color_t

Color type.

typedef int pj_exception_id_t

Exception id.

typedef void (*pj_exit_callback)(void)

Type of callback to register to pj_atexit().


enum pj_constants_

Some constants


enumerator PJ_SUCCESS

Status is OK.

enumerator PJ_TRUE

True value.

enumerator PJ_FALSE

False value.


pj_status_t pj_init(void)

Initialize the PJ Library. This function must be called before using the library. The purpose of this function is to initialize static library data, such as character table used in random string generation, and to initialize operating system dependent functionality (such as WSAStartup() in Windows).

Apart from calling pj_init(), application typically should also initialize the random seed by calling pj_srand().


PJ_SUCCESS on success.

void pj_shutdown(void)

Shutdown PJLIB.

pj_status_t pj_atexit(pj_exit_callback func)

Register cleanup function to be called by PJLIB when pj_shutdown() is called.


func – The function to be registered.


PJ_SUCCESS on success.

pj_int16_t pj_swap16(pj_int16_t val16)

Swap the byte order of an 16bit data.


val16 – The 16bit data.


An 16bit data with swapped byte order.

pj_int32_t pj_swap32(pj_int32_t val32)

Swap the byte order of an 32bit data.


val32 – The 32bit data.


An 32bit data with swapped byte order.

struct pj_str_t
#include <types.h>

This type is used as replacement to legacy C string, and used throughout the library. By convention, the string is NOT null terminated.

This type is used as replacement to legacy C string, and used throughout the library.

Public Members

char *ptr

Buffer pointer, which is by convention NOT null terminated.

pj_ssize_t slen

The length of the string.

union pj_timestamp
#include <types.h>

This structure represents high resolution (64bit) time value. The time values represent time in cycles, which is retrieved by calling pj_get_timestamp().

Public Members

pj_uint32_t hi

high 32-bit value of the 64-bit value.

pj_uint32_t lo

Low 32-bit value of the 64-bit value.

struct pj_timestamp::[anonymous] u32

The 64-bit value as two 32-bit values.

struct pj_hash_iterator_t
#include <types.h>

Data type for hash search iterator. This structure should be opaque, however applications need to declare concrete variable of this type, that’s why the declaration is visible here.

Public Members

pj_uint32_t index

Internal index.

pj_hash_entry *entry

Internal entry.