A library for a decentralised peer-to-peer chat over IPv6 only.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

libchat6.c 950B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <assert.h>
  5. #include "../inc/lc6_config.h"
  6. #include "../inc/lc6_user.h"
  7. #include "../inc/lc6_crypto.h"
  8. #include "../inc/lc6_event.h"
  9. LIBCHAT* libchat_init(char *path, unsigned char *password) {
  10. LC6_CTX *conf;
  11. lc6crypto_init();
  12. conf = lc6config_load(path, password);
  13. if ( !conf )
  14. return NULL;
  15. if ( !conf->user )
  16. conf->user = lc6user_create();
  17. return (LIBCHAT*)conf;
  18. }
  19. int libchat_event_reg(LIBCHAT *ctx, LIBCHAT_CB *cb) {
  20. LC6_CTX *conf = (LC6_CTX*)ctx;
  21. assert(conf);
  22. assert(cb);
  23. conf->callback = cb;
  24. return 0;
  25. }
  26. int libchat_start(LIBCHAT *ctx) {
  27. LC6_CTX *conf = (LC6_CTX*)ctx;
  28. return lc6event_start(conf);
  29. }
  30. int libchat_stop(LIBCHAT *ctx) {
  31. LC6_CTX *conf = (LC6_CTX*)ctx;
  32. return lc6event_stop(conf);
  33. }
  34. void libchat_free(LIBCHAT *ctx, unsigned char *password) {
  35. LC6_CTX *conf = (LC6_CTX*)ctx;
  36. lc6config_save(conf, password);
  37. lc6config_free(conf);
  38. }