## Overview
Alphabetical reference of all DAP SDK functions, data types, constants, and macros. This serves as a quick lookup guide for developers working with the DAP SDK API. Each entry includes the function signature, brief description, module reference, and links to detailed documentation.
**Organization:**
- **Functions** - All public API functions alphabetically
- **Data Types** - Structures, enums, and typedefs
- **Constants** - Defined constants and macros
- **Error Codes** - Complete error code reference
**Note:** All module references link to the current module documentation structure where each module starts with an Overview section and contains comprehensive function documentation without separate Key Responsibilities sections.
---
## Functions
### A
#### `dap_addr_from_string()`
```c
int dap_addr_from_string(const char *addr_str, dap_addr_t *addr);
```
Parse string representation of address into dap_addr_t structure.
**Module:** [[Modules/Module DAP Net|Module DAP Net]]
#### `dap_addr_to_string()`
```c
int dap_addr_to_string(const dap_addr_t *addr, char *str, size_t str_size);
```
Convert dap_addr_t structure to string representation.
**Module:** [[Modules/Module DAP Net|Module DAP Net]]
### B
#### `dap_bin2hex()`
```c
char* dap_bin2hex(char *hex_str, const void *bin_data, size_t bin_size);
```
Convert binary data to hexadecimal string representation.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_buffer_new()`
```c
dap_buffer_t* dap_buffer_new(size_t initial_capacity);
```
Create new buffer with specified initial capacity.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_buffer_read()`
```c
size_t dap_buffer_read(dap_buffer_t *buffer, void *dest, size_t size);
```
Read data from buffer into destination.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_buffer_write()`
```c
size_t dap_buffer_write(dap_buffer_t *buffer, const void *src, size_t size);
```
Write data from source into buffer.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_buffer_free()`
```c
void dap_buffer_free(dap_buffer_t *buffer);
```
Free buffer and all associated memory.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
### C
#### `dap_client_connect()`
```c
dap_client_t* dap_client_connect(const char *addr, uint16_t port, int timeout_ms);
```
Establish connection to DAP server.
**Module:** [[Modules/Module DAP Net - Client|Module DAP Net - Client]]
#### `dap_client_disconnect()`
```c
void dap_client_disconnect(dap_client_t *client);
```
Disconnect from DAP server and cleanup resources.
**Module:** [[Modules/Module DAP Net - Client|Module DAP Net - Client]]
#### `dap_client_send_request()`
```c
int dap_client_send_request(dap_client_t *client, const void *request, size_t size);
```
Send request to connected DAP server.
**Module:** [[Modules/Module DAP Net - Client|Module DAP Net - Client]]
#### `dap_common_init()`
```c
int dap_common_init(const char *app_name, const char *config_file);
```
Initialize DAP SDK with application name and optional configuration file.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_common_deinit()`
```c
void dap_common_deinit(void);
```
Cleanup and shutdown DAP SDK, freeing all resources.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_config_get_bool()`
```c
bool dap_config_get_bool(const char *section, const char *key, bool default_value);
```
Get boolean configuration value with fallback default.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_config_get_int()`
```c
int dap_config_get_int(const char *section, const char *key, int default_value);
```
Get integer configuration value with fallback default.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_config_get_string()`
```c
const char* dap_config_get_string(const char *section, const char *key, const char *default_value);
```
Get string configuration value with fallback default.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_config_load()`
```c
int dap_config_load(const char *config_file);
```
Load configuration from specified file.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_crypto_init()`
```c
int dap_crypto_init(void);
```
Initialize cryptographic subsystem.
**Module:** [[Modules/Module DAP Crypto|Module DAP Crypto]]
### D
#### `dap_db_connect()`
```c
dap_db_t* dap_db_connect(const char *connection_string);
```
Connect to database using connection string.
**Module:** [[Modules/Module DAP Global DB|Module DAP Global DB]]
#### `dap_db_execute()`
```c
int dap_db_execute(dap_db_t *db, const char *query, dap_db_result_t **result);
```
Execute database query and return result set.
**Module:** [[Modules/Module DAP Global DB|Module DAP Global DB]]
#### `dap_db_disconnect()`
```c
void dap_db_disconnect(dap_db_t *db);
```
Disconnect from database and cleanup connection.
**Module:** [[Modules/Module DAP Global DB|Module DAP Global DB]]
### E
#### `dap_enc_key_new_generate()`
```c
dap_enc_key_t* dap_enc_key_new_generate(dap_enc_key_type_t type, const void *params, size_t params_size, const void *seed, size_t seed_size, size_t key_size);
```
Generate new encryption key of specified type.
**Module:** [[Modules/Module DAP Crypto|Module DAP Crypto]]
#### `dap_enc_key_encrypt()`
```c
dap_enc_data_t* dap_enc_key_encrypt(dap_enc_key_t *key, const void *data, size_t data_size);
```
Encrypt data using specified key.
**Module:** [[Modules/Module DAP Crypto|Module DAP Crypto]]
#### `dap_enc_key_decrypt()`
```c
int dap_enc_key_decrypt(dap_enc_key_t *key, dap_enc_data_t *encrypted_data, void **decrypted_data, size_t *decrypted_size);
```
Decrypt data using specified key.
**Module:** [[Modules/Module DAP Crypto|Module DAP Crypto]]
#### `dap_events_init()`
```c
int dap_events_init(void);
```
Initialize event processing system.
**Module:** [[Modules/Module DAP IO|Module DAP IO]]
#### `dap_events_start()`
```c
int dap_events_start(void);
```
Start event processing loop.
**Module:** [[Modules/Module DAP IO|Module DAP IO]]
#### `dap_events_stop()`
```c
void dap_events_stop(void);
```
Stop event processing and cleanup.
**Module:** [[Modules/Module DAP IO|Module DAP IO]]
### F
#### `dap_file_read_all()`
```c
int dap_file_read_all(const char *filename, void **data, size_t *size);
```
Read entire file content into memory buffer.
**Module:** [[Modules/Module DAP IO|Module DAP IO]]
#### `dap_file_write_all()`
```c
int dap_file_write_all(const char *filename, const void *data, size_t size);
```
Write data buffer to file, creating or overwriting as needed.
**Module:** [[Modules/Module DAP IO|Module DAP IO]]
### G
### H
#### `dap_hash_fast()`
```c
int dap_hash_fast(const void *data, size_t data_size, dap_hash_fast_t *hash_out);
```
Compute fast hash of input data.
**Module:** [[Modules/Module DAP Crypto|Module DAP Crypto]]
#### `dap_hash_slow()`
```c
int dap_hash_slow(const void *data, size_t data_size, dap_hash_slow_t *hash_out);
```
Compute cryptographically secure hash of input data.
**Module:** [[Modules/Module DAP Crypto|Module DAP Crypto]]
#### `dap_hex2bin()`
```c
int dap_hex2bin(void *bin_data, const char *hex_str, size_t bin_size);
```
Convert hexadecimal string to binary data.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
### I
#### `dap_io_init()`
```c
int dap_io_init(void);
```
Initialize I/O subsystem.
**Module:** [[Modules/Module DAP IO|Module DAP IO]]
### J
### K
### L
#### `dap_list_new()`
```c
dap_list_t* dap_list_new(void);
```
Create new empty doubly-linked list.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_list_append()`
```c
int dap_list_append(dap_list_t *list, void *data);
```
Append data to end of list.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_list_prepend()`
```c
int dap_list_prepend(dap_list_t *list, void *data);
```
Prepend data to beginning of list.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_list_remove()`
```c
int dap_list_remove(dap_list_t *list, dap_list_node_t *node);
```
Remove specific node from list.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_list_free()`
```c
void dap_list_free(dap_list_t *list, void (*free_func)(void *data));
```
Free list and optionally call free function on each data element.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_log_init()`
```c
int dap_log_init(const dap_log_config_t *config);
```
Initialize logging system with configuration.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `log_it()`
```c
void log_it(dap_log_level_t level, const char *fmt, ...);
```
Write log message at specified level.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
### M
#### `dap_memory_get_stats()`
```c
int dap_memory_get_stats(dap_memory_stats_t *stats);
```
Get current memory usage statistics.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_malloc()`
```c
void* dap_malloc(size_t size);
```
Allocate memory with DAP memory management.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_free()`
```c
void dap_free(void *ptr);
```
Free memory allocated with DAP memory management.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
### N
#### `dap_net_init()`
```c
int dap_net_init(void);
```
Initialize network subsystem.
**Module:** [[Modules/Module DAP Net|Module DAP Net]]
### O
### P
#### `dap_plugin_load()`
```c
dap_plugin_t* dap_plugin_load(const char *plugin_path);
```
Load plugin from specified file path.
**Module:** [[Modules/Module DAP Plugin|Module DAP Plugin]]
#### `dap_plugin_unload()`
```c
void dap_plugin_unload(dap_plugin_t *plugin);
```
Unload plugin and cleanup resources.
**Module:** [[Modules/Module DAP Plugin|Module DAP Plugin]]
#### `dap_plugin_get_symbol()`
```c
void* dap_plugin_get_symbol(dap_plugin_t *plugin, const char *symbol_name);
```
Get symbol address from loaded plugin.
**Module:** [[Modules/Module DAP Plugin|Module DAP Plugin]]
### Q
### R
#### `dap_random_bytes()`
```c
int dap_random_bytes(void *buffer, size_t size);
```
Generate cryptographically secure random bytes.
**Module:** [[Modules/Module DAP Crypto|Module DAP Crypto]]
#### `dap_random_uint32()`
```c
uint32_t dap_random_uint32(void);
```
Generate random 32-bit unsigned integer.
**Module:** [[Modules/Module DAP Crypto|Module DAP Crypto]]
### S
#### `dap_server_start()`
```c
dap_server_t* dap_server_start(const char *addr, uint16_t port);
```
Start DAP server listening on specified address and port.
**Module:** [[Modules/Module DAP Server|Module DAP Server]]
#### `dap_server_stop()`
```c
void dap_server_stop(dap_server_t *server);
```
Stop DAP server and cleanup resources.
**Module:** [[Modules/Module DAP Server|Module DAP Server]]
#### `dap_sign_create()`
```c
dap_sign_t* dap_sign_create(dap_enc_key_t *key, const void *data, size_t data_size);
```
Create digital signature for data using specified key.
**Module:** [[Modules/Module DAP Crypto|Module DAP Crypto]]
#### `dap_sign_verify()`
```c
int dap_sign_verify(dap_sign_t *sign, dap_enc_key_t *key, const void *data, size_t data_size);
```
Verify digital signature against data using specified key.
**Module:** [[Modules/Module DAP Crypto|Module DAP Crypto]]
#### `dap_socket_create()`
```c
dap_socket_t* dap_socket_create(int type);
```
Create new socket of specified type.
**Module:** [[Modules/Module DAP Net|Module DAP Net]]
#### `dap_socket_connect()`
```c
int dap_socket_connect(dap_socket_t *socket, const dap_addr_t *addr, int timeout_ms);
```
Connect socket to remote address with timeout.
**Module:** [[Modules/Module DAP Net|Module DAP Net]]
#### `dap_socket_close()`
```c
void dap_socket_close(dap_socket_t *socket);
```
Close socket and cleanup resources.
**Module:** [[Modules/Module DAP Net|Module DAP Net]]
#### `dap_stream_create()`
```c
dap_stream_t* dap_stream_create(dap_stream_type_t type);
```
Create new stream of specified type.
**Module:** [[Modules/Module DAP Stream|Module DAP Stream]]
#### `dap_stream_read()`
```c
int dap_stream_read(dap_stream_t *stream, void *buffer, size_t size, size_t *bytes_read);
```
Read data from stream into buffer.
**Module:** [[Modules/Module DAP Stream|Module DAP Stream]]
#### `dap_stream_write()`
```c
int dap_stream_write(dap_stream_t *stream, const void *data, size_t size);
```
Write data to stream.
**Module:** [[Modules/Module DAP Stream|Module DAP Stream]]
#### `dap_stream_close()`
```c
void dap_stream_close(dap_stream_t *stream);
```
Close stream and cleanup resources.
**Module:** [[Modules/Module DAP Stream|Module DAP Stream]]
#### `dap_strdup()`
```c
char* dap_strdup(const char *str);
```
Duplicate string using DAP memory management.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_string_new()`
```c
dap_string_t* dap_string_new(const char *initial_str);
```
Create new dynamic string with optional initial content.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_string_append()`
```c
int dap_string_append(dap_string_t *str, const char *append_str);
```
Append string to dynamic string.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_string_free()`
```c
void dap_string_free(dap_string_t *str);
```
Free dynamic string and associated memory.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
### T
#### `dap_test_run()`
```c
int dap_test_run(const char *test_name, dap_test_func_t test_func);
```
Run individual test function with specified name.
**Module:** [[Modules/Module DAP Test|Module DAP Test]]
#### `dap_test_suite_run()`
```c
int dap_test_suite_run(const char *suite_name, dap_test_suite_t *suite);
```
Run complete test suite with reporting.
**Module:** [[Modules/Module DAP Test|Module DAP Test]]
#### `dap_time_now()`
```c
void dap_time_now(dap_time_t *time);
```
Get current system time with nanosecond precision.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_time_diff()`
```c
void dap_time_diff(const dap_time_t *start, const dap_time_t *end, dap_interval_t *diff);
```
Calculate time difference between two timestamps.
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
### U
### V
### W
#### `dap_worker_get_auto()`
```c
dap_worker_t* dap_worker_get_auto(void);
```
Get automatically selected worker thread for load balancing.
**Module:** [[Modules/Module DAP IO|Module DAP IO]]
### X
### Y
### Z
---
## Data Types
### Basic Types
#### `dap_addr_t`
Network address structure supporting IPv4 and IPv6.
```c
typedef struct dap_addr {
uint8_t addr[16];
uint16_t port;
uint8_t family;
uint8_t reserved;
} dap_addr_t;
```
**Module:** [[Modules/Module DAP Net|Module DAP Net]]
#### `dap_buffer_t`
Dynamic buffer for data storage and manipulation.
```c
typedef struct dap_buffer {
uint8_t *data;
size_t size;
size_t capacity;
size_t position;
bool is_readonly;
bool auto_resize;
} dap_buffer_t;
```
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_hash_fast_t`
Fast hash structure for high-performance hashing.
```c
typedef union dap_hash_fast {
uint8_t raw[DAP_HASH_FAST_SIZE];
uint64_t uint64[DAP_HASH_FAST_SIZE / 8];
uint32_t uint32[DAP_HASH_FAST_SIZE / 4];
} dap_hash_fast_t;
```
**Module:** [[Modules/Module DAP Crypto|Module DAP Crypto]]
#### `dap_hash_slow_t`
Cryptographically secure hash structure.
```c
typedef union dap_hash_slow {
uint8_t raw[DAP_HASH_SLOW_SIZE];
uint64_t uint64[DAP_HASH_SLOW_SIZE / 8];
} dap_hash_slow_t;
```
**Module:** [[Modules/Module DAP Crypto|Module DAP Crypto]]
#### `dap_list_t`
Doubly-linked list structure.
```c
typedef struct dap_list {
dap_list_node_t *head;
dap_list_node_t *tail;
size_t count;
pthread_mutex_t mutex;
} dap_list_t;
```
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_string_t`
Dynamic string structure.
```c
typedef struct dap_string {
char *str;
size_t len;
size_t capacity;
bool is_const;
} dap_string_t;
```
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_time_t`
High-precision timestamp structure.
```c
typedef struct dap_time {
uint64_t sec;
uint32_t nsec;
} dap_time_t;
```
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
### Configuration Types
#### `dap_config_t`
Main configuration structure.
```c
typedef struct dap_config {
char *app_name;
char *config_file;
dap_config_section_t *sections;
uint32_t section_count;
bool is_loaded;
pthread_mutex_t mutex;
} dap_config_t;
```
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
#### `dap_log_config_t`
Logging configuration structure.
```c
typedef struct dap_log_config {
dap_log_level_t level;
char *log_file;
bool console_output;
bool file_output;
bool syslog_output;
size_t max_file_size;
int max_backup_files;
bool enable_colors;
bool include_timestamp;
bool include_thread_id;
bool include_function_name;
} dap_log_config_t;
```
**Module:** [[Modules/Module DAP Core|Module DAP Core]]
### Cryptographic Types
#### `dap_enc_key_t`
Encryption key structure (opaque).
```c
typedef struct dap_enc_key dap_enc_key_t;
```
**Module:** [[Modules/Module DAP Crypto|Module DAP Crypto]]
#### `dap_sign_t`
Digital signature structure (opaque).
```c
typedef struct dap_sign dap_sign_t;
```
**Module:** [[Modules/Module DAP Crypto|Module DAP Crypto]]
### Network Types
#### `dap_client_t`
Client connection structure (opaque).
```c
typedef struct dap_client dap_client_t;
```
**Module:** [[Modules/Module DAP Client|Module DAP Client]]
#### `dap_server_t`
Server instance structure (opaque).
```c
typedef struct dap_server dap_server_t;
```
**Module:** [[Modules/Module DAP Server|Module DAP Server]]
#### `dap_socket_t`
Socket structure.
```c
typedef struct dap_socket {
int fd;
dap_addr_t local_addr;
dap_addr_t remote_addr;
int socket_type;
int protocol;
uint32_t flags;
dap_socket_state_t state;
} dap_socket_t;
```
**Module:** [[Modules/Module DAP Net|Module DAP Net]]
### Stream Types
#### `dap_stream_t`
Stream structure (opaque).
```c
typedef struct dap_stream dap_stream_t;
```
**Module:** [[Modules/Module DAP Stream|Module DAP Stream]]
### Database Types
#### `dap_db_t`
Database connection structure (opaque).
```c
typedef struct dap_db dap_db_t;
```
**Module:** [[Modules/Module DAP Global DB|Module DAP Global DB]]
### Plugin Types
#### `dap_plugin_t`
Plugin handle structure (opaque).
```c
typedef struct dap_plugin dap_plugin_t;
```
**Module:** [[Modules/Module DAP Plugin|Module DAP Plugin]]
### Test Types
#### `dap_test_suite_t`
Test suite structure (opaque).
```c
typedef struct dap_test_suite dap_test_suite_t;
```
**Module:** [[Modules/Module DAP Test|Module DAP Test]]
---
## Enums and Constants
### Log Levels
#### `dap_log_level_t`
```c
typedef enum dap_log_level {
DAP_LOG_NONE = 0,
DAP_LOG_CRITICAL = 1,
DAP_LOG_ERROR = 2,
DAP_LOG_WARNING = 3,
DAP_LOG_NOTICE = 4,
DAP_LOG_INFO = 5,
DAP_LOG_DEBUG = 6
} dap_log_level_t;
```
### Error Codes
#### `dap_error_t`
```c
typedef enum dap_error {
DAP_ERROR_SUCCESS = 0,
// General errors (1-99)
DAP_ERROR_GENERAL = 1,
DAP_ERROR_INVALID_PARAMETER = 2,
DAP_ERROR_NULL_POINTER = 3,
DAP_ERROR_OUT_OF_MEMORY = 4,
DAP_ERROR_BUFFER_TOO_SMALL = 5,
DAP_ERROR_NOT_IMPLEMENTED = 6,
DAP_ERROR_NOT_SUPPORTED = 7,
DAP_ERROR_TIMEOUT = 8,
DAP_ERROR_INTERRUPTED = 9,
// File/IO errors (100-199)
DAP_ERROR_FILE_NOT_FOUND = 100,
DAP_ERROR_FILE_ACCESS_DENIED = 101,
DAP_ERROR_FILE_ALREADY_EXISTS = 102,
DAP_ERROR_FILE_IO_ERROR = 103,
DAP_ERROR_FILE_FORMAT_ERROR = 104,
// Network errors (200-299)
DAP_ERROR_NETWORK_UNREACHABLE = 200,
DAP_ERROR_CONNECTION_REFUSED = 201,
DAP_ERROR_CONNECTION_LOST = 202,
DAP_ERROR_DNS_RESOLUTION_FAILED = 203,
DAP_ERROR_SOCKET_ERROR = 204,
// Crypto errors (300-399)
DAP_ERROR_CRYPTO_GENERAL = 300,
DAP_ERROR_CRYPTO_INVALID_KEY = 301,
DAP_ERROR_CRYPTO_VERIFICATION_FAILED = 302,
DAP_ERROR_CRYPTO_UNSUPPORTED_ALGORITHM = 303,
// Configuration errors (400-499)
DAP_ERROR_CONFIG_NOT_FOUND = 400,
DAP_ERROR_CONFIG_PARSE_ERROR = 401,
DAP_ERROR_CONFIG_INVALID_VALUE = 402,
// Plugin errors (500-599)
DAP_ERROR_PLUGIN_NOT_FOUND = 500,
DAP_ERROR_PLUGIN_LOAD_FAILED = 501,
DAP_ERROR_PLUGIN_INIT_FAILED = 502,
DAP_ERROR_PLUGIN_VERSION_MISMATCH = 503,
// Database errors (600-699)
DAP_ERROR_DB_CONNECTION_FAILED = 600,
DAP_ERROR_DB_QUERY_FAILED = 601,
DAP_ERROR_DB_CONSTRAINT_VIOLATION = 602,
DAP_ERROR_DB_NOT_FOUND = 603
} dap_error_t;
```
### Hash Constants
```c
#define DAP_HASH_FAST_SIZE 32
#define DAP_HASH_SLOW_SIZE 64
```
### Memory Constants
```c
#define DAP_DEFAULT_MEMORY_POOL_SIZE (16 * 1024 * 1024) // 16MB
#define DAP_MAX_MEMORY_POOL_SIZE (1024 * 1024 * 1024) // 1GB
#define DAP_MEMORY_ALIGNMENT 16
```
### Network Constants
```c
#define DAP_NET_DEFAULT_PORT 8080
#define DAP_NET_MAX_CONNECTIONS 1000
#define DAP_NET_DEFAULT_TIMEOUT 30000 // 30 seconds
#define DAP_NET_BUFFER_SIZE (64 * 1024) // 64KB
```
### Logging Constants
```c
#define DAP_LOG_MAX_MESSAGE_SIZE 4096
#define DAP_LOG_MAX_FILE_SIZE (10 * 1024 * 1024) // 10MB
#define DAP_LOG_MAX_BACKUP_FILES 5
```
---
## Macros
### Memory Management Macros
```c
#define DAP_NEW(type) \
((type*)dap_malloc(sizeof(type)))
#define DAP_NEW_Z(type) \
((type*)dap_calloc(1, sizeof(type)))
#define DAP_NEW_SIZE(type, size) \
((type*)dap_malloc(size))
#define DAP_NEW_Z_SIZE(type, size) \
((type*)dap_calloc(1, size))
#define DAP_DELETE(ptr) \
do { dap_free(ptr); (ptr) = NULL; } while(0)
#define DAP_REALLOC(ptr, new_size) \
dap_realloc((ptr), (new_size))
```
### Utility Macros
```c
#define DAP_ARRAY_SIZE(arr) \
(sizeof(arr) / sizeof((arr)[0]))
#define DAP_MIN(a, b) \
((a) < (b) ? (a) : (b))
#define DAP_MAX(a, b) \
((a) > (b) ? (a) : (b))
#define DAP_ALIGN_UP(size, align) \
(((size) + (align) - 1) & ~((align) - 1))
#define DAP_IS_ALIGNED(ptr, align) \
(((uintptr_t)(ptr) & ((align) - 1)) == 0)
#define DAP_CONTAINER_OF(ptr, type, member) \
((type*)((char*)(ptr) - offsetof(type, member)))
```
### Logging Macros
```c
#define log_it_critical(fmt, ...) \
dap_log_write(DAP_LOG_CRITICAL, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
#define log_it_error(fmt, ...) \
dap_log_write(DAP_LOG_ERROR, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
#define log_it_warning(fmt, ...) \
dap_log_write(DAP_LOG_WARNING, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
#define log_it_info(fmt, ...) \
dap_log_write(DAP_LOG_INFO, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
#define log_it_debug(fmt, ...) \
dap_log_write(DAP_LOG_DEBUG, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
```
### Test Macros
```c
#define DAP_ASSERT(condition) \
do { \
if (!(condition)) { \
dap_test_fail(__FILE__, __LINE__, "Assertion failed: " #condition); \
return DAP_TEST_FAIL; \
} \
} while(0)
#define DAP_ASSERT_EQUAL(actual, expected) \
do { \
if ((actual) != (expected)) { \
dap_test_fail(__FILE__, __LINE__, "Expected %d, got %d", (expected), (actual)); \
return DAP_TEST_FAIL; \
} \
} while(0)
#define DAP_ASSERT_NOT_NULL(ptr) \
do { \
if ((ptr) == NULL) { \
dap_test_fail(__FILE__, __LINE__, "Pointer should not be NULL"); \
return DAP_TEST_FAIL; \
} \
} while(0)
#define DAP_ASSERT_STRING_EQUAL(actual, expected) \
do { \
if (strcmp((actual), (expected)) != 0) { \
dap_test_fail(__FILE__, __LINE__, "Expected \"%s\", got \"%s\"", (expected), (actual)); \
return DAP_TEST_FAIL; \
} \
} while(0)
```
---
## Quick Reference by Module
### Core Module Functions
- `dap_common_init()`, `dap_common_deinit()`
- `dap_malloc()`, `dap_free()`, `dap_strdup()`
- `dap_config_load()`, `dap_config_get_*()`
- `log_it()`, `dap_log_init()`
- `dap_time_now()`, `dap_time_diff()`
### Crypto Module Functions
- `dap_hash_fast()`, `dap_hash_slow()`
- `dap_enc_key_new_generate()`, `dap_enc_key_encrypt()`, `dap_enc_key_decrypt()`
- `dap_sign_create()`, `dap_sign_verify()`
- `dap_random_bytes()`, `dap_random_uint32()`
### I/O Module Functions
- `dap_events_init()`, `dap_events_start()`, `dap_events_stop()`
- `dap_file_read_all()`, `dap_file_write_all()`
- `dap_worker_get_auto()`
### Network Module Functions
- `dap_addr_from_string()`, `dap_addr_to_string()`
- `dap_socket_create()`, `dap_socket_connect()`, `dap_socket_close()`
### Stream Module Functions
- `dap_stream_create()`, `dap_stream_read()`, `dap_stream_write()`, `dap_stream_close()`
### Client Module Functions
- `dap_client_connect()`, `dap_client_disconnect()`, `dap_client_send_request()`
### Server Module Functions
- `dap_server_start()`, `dap_server_stop()`
### Database Module Functions
- `dap_db_connect()`, `dap_db_execute()`, `dap_db_disconnect()`
### Plugin Module Functions
- `dap_plugin_load()`, `dap_plugin_unload()`, `dap_plugin_get_symbol()`
### Test Module Functions
- `dap_test_run()`, `dap_test_suite_run()`
---
## Navigation
### Related Documentation
- **[[Modules/Module Overview|Module Overview]]** - Detailed module documentation
- **[[ETC/Architecture Overview|Architecture Overview]]** - System architecture
- **[[ETC/Development Guide|Development Guide]]** - Best practices and patterns
- **[[ETC/First Application|First Application]]** - Step-by-step tutorial
- **[[ETC/Troubleshooting|Troubleshooting]]** - Problem resolution
### Module-Specific References
- **[[Modules/Module DAP Core|Module DAP Core]]** - Core functionality
- **[[Modules/Module DAP Crypto|Module DAP Crypto]]** - Cryptographic operations
- **[[Modules/Module DAP IO|Module DAP IO]]** - I/O and event processing
- **[[Modules/Module DAP Net|Module DAP Net]]** - Network operations
- **[[Modules/Module DAP Stream|Module DAP Stream]]** - Stream management
- **[[Modules/Module DAP Client|Module DAP Client]]** - Client functionality
- **[[Modules/Module DAP Server|Module DAP Server]]** - Server functionality
- **[[Modules/Module DAP Global DB|Module DAP Global DB]]** - Database operations
- **[[Modules/Module DAP Plugin|Module DAP Plugin]]** - Plugin system
- **[[Modules/Module DAP Test|Module DAP Test]]** - Testing framework
---
*Last updated: December 2024 | Version: 1.0 | Complete API Reference for DAP SDK*