ipmsg.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef _IPMSG_H_
  2. #define _IPMSG_H_
  3. #include <stdint.h>
  4. typedef struct
  5. {
  6. int skudp;
  7. short port;
  8. char *msgbuf;
  9. char *mrbuf;
  10. char user[24+1];
  11. char host[16+1];
  12. char group[16+1];
  13. long usrdata;
  14. } ipmsg_t;
  15. typedef struct ipmsg_fileinfo
  16. {
  17. uint32_t id;
  18. char *name;
  19. uint32_t size;
  20. uint32_t attr;
  21. uint32_t pos;
  22. struct ipmsg_fileinfo *next;
  23. }ipmsg_fileinfo_t;
  24. typedef enum
  25. {
  26. IPMSG_FE_ENTER,
  27. IPMSG_FE_EXIT,
  28. IPMSG_FE_OPEN,
  29. IPMSG_FE_CLOSE,
  30. IPMSG_FE_COMPLETE,
  31. }ipmsg_fileevent_t;
  32. typedef struct ipmsg_filehandler
  33. {
  34. ipmsg_t *im;
  35. ipmsg_fileinfo_t *fi;
  36. uint32_t ip;
  37. uint32_t packetid;
  38. /* used by user */
  39. long usrdata;
  40. uint32_t param;
  41. /* init by user */
  42. int (*notify)(struct ipmsg_filehandler *h, ipmsg_fileevent_t e, void *arg);
  43. int (*data)(struct ipmsg_filehandler *h, void *buf, int size);
  44. }ipmsg_filehandler_t;
  45. typedef struct
  46. {
  47. void (*msg)(ipmsg_t *im, uint32_t ip, const char *str);
  48. int (*fileattach)(ipmsg_t *im, ipmsg_filehandler_t *fh);
  49. }ipmsg_msghandler_t;
  50. int ipmsg_msgserver_init(ipmsg_t *im, short port); /* default port = 2425 */
  51. void ipmsg_msgserver_deinit(ipmsg_t *im);
  52. int ipmsg_login(ipmsg_t *im);
  53. int ipmsg_logout(ipmsg_t *im);
  54. int ipmsg_msg_recv(ipmsg_t *im, int ms, const ipmsg_msghandler_t *h);
  55. int ipmsg_msg_send(ipmsg_t *im, uint32_t ip, const char *str);
  56. int ipmsg_user_set(ipmsg_t *im, const char *name);
  57. void ipmsg_filehandler_free(ipmsg_filehandler_t *h);
  58. char *ipmsg_msg_make(ipmsg_t *im, uint32_t cmd, char *ext, char *group, char *dst, int *len_io);
  59. int ipmsg_sock_wait(int socket, long ms);
  60. int ipmsg_filerecv_start(ipmsg_filehandler_t *h);
  61. #endif