12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <assert.h>
-
- #include "../inc/lc6_config.h"
- #include "../inc/lc6_user.h"
- #include "../inc/lc6_crypto.h"
- #include "../inc/lc6_event.h"
-
- LIBCHAT* libchat_init(char *path, unsigned char *password) {
- LC6_CTX *conf;
-
- lc6crypto_init();
-
- conf = lc6config_load(path, password);
-
- if ( !conf )
- return NULL;
-
- if ( !conf->user )
- conf->user = lc6user_create();
-
- return (LIBCHAT*)conf;
- }
-
- int libchat_event_reg(LIBCHAT *ctx, LIBCHAT_CB *cb) {
- LC6_CTX *conf = (LC6_CTX*)ctx;
-
- assert(conf);
- assert(cb);
-
- conf->callback = cb;
-
- return 0;
- }
-
- int libchat_start(LIBCHAT *ctx) {
- LC6_CTX *conf = (LC6_CTX*)ctx;
- return lc6event_start(conf);
- }
-
- int libchat_stop(LIBCHAT *ctx) {
- LC6_CTX *conf = (LC6_CTX*)ctx;
- return lc6event_stop(conf);
- }
-
- void libchat_free(LIBCHAT *ctx, unsigned char *password) {
- LC6_CTX *conf = (LC6_CTX*)ctx;
- lc6config_save(conf, password);
- lc6config_free(conf);
- }
|