include/DtChat/DtChat.h and Ipc.h define the UI-facing core API and the adapter contract. lib/libDtChat builds libDtChatIpc (strict JSON parser/writer, 1 MiB line framing) and the libDtChat core stub; test_json and test_frame cover escapes, UTF-8, depth 32, duplicate keys, overlong lines, CRLF, NUL and the write path. Wired into configure.ac, lib/Makefile.am and the installed headers. Standalone tests pass, ASan/UBSan clean.
114 lines
1.7 KiB
C
114 lines
1.7 KiB
C
/*
|
|
* core.c -- dtchat's core lifecycle (T1.1 stub)
|
|
*
|
|
* License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
|
*
|
|
* T1.1 only needs the public API to exist and link. The event loop (T1.2),
|
|
* storage (T1.3), conversations (T1.4) and adapters (T1.5) replace the
|
|
* stubs below; the signatures are already the ones the UI compiles against.
|
|
*/
|
|
#include "DtChat/DtChat.h"
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
struct DtChat {
|
|
char *dir;
|
|
};
|
|
|
|
DtChat *
|
|
dtchat_open(const char *config_dir)
|
|
{
|
|
DtChat *chat = calloc(1, sizeof(*chat));
|
|
|
|
if (chat == NULL)
|
|
return NULL;
|
|
chat->dir = strdup(config_dir ? config_dir : "");
|
|
if (chat->dir == NULL) {
|
|
free(chat);
|
|
return NULL;
|
|
}
|
|
return chat;
|
|
}
|
|
|
|
void
|
|
dtchat_close(DtChat *chat)
|
|
{
|
|
if (chat == NULL)
|
|
return;
|
|
free(chat->dir);
|
|
free(chat);
|
|
}
|
|
|
|
int
|
|
dtchat_fd(const DtChat *chat)
|
|
{
|
|
(void)chat;
|
|
return -1;
|
|
}
|
|
|
|
int
|
|
dtchat_poll(DtChat *chat, int timeout_ms)
|
|
{
|
|
(void)chat;
|
|
(void)timeout_ms;
|
|
return 0;
|
|
}
|
|
|
|
DtChatEvent *
|
|
dtchat_event_next(DtChat *chat)
|
|
{
|
|
(void)chat;
|
|
return NULL;
|
|
}
|
|
|
|
void
|
|
dtchat_event_free(DtChatEvent *event)
|
|
{
|
|
if (event == NULL)
|
|
return;
|
|
free(event->account);
|
|
free(event->conv);
|
|
free(event->from);
|
|
free(event->text);
|
|
free(event);
|
|
}
|
|
|
|
int
|
|
dtchat_send(DtChat *chat, const char *conv, const char *text)
|
|
{
|
|
(void)chat;
|
|
(void)conv;
|
|
(void)text;
|
|
return -1;
|
|
}
|
|
|
|
int
|
|
dtchat_join(DtChat *chat, const char *account, const char *conv)
|
|
{
|
|
(void)chat;
|
|
(void)account;
|
|
(void)conv;
|
|
return -1;
|
|
}
|
|
|
|
int
|
|
dtchat_answer(DtChat *chat, const char *account, int request_id,
|
|
const char *value)
|
|
{
|
|
(void)chat;
|
|
(void)account;
|
|
(void)request_id;
|
|
(void)value;
|
|
return -1;
|
|
}
|
|
|
|
int
|
|
dtchat_call(DtChat *chat, const char *peer, int media)
|
|
{
|
|
(void)chat;
|
|
(void)peer;
|
|
(void)media;
|
|
return -1;
|
|
}
|