client.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef WOE_CLIENT_H
  2. #define WOE_CLIENT_H
  3. #if !defined(_POSIX_SOURCE)
  4. #define _POSIX_SOURCE
  5. #endif
  6. #if !defined(_BSD_SOURCE)
  7. #define _BSD_SOURCE
  8. #endif
  9. #include <sys/socket.h>
  10. #include <netinet/in.h>
  11. #include <arpa/inet.h>
  12. #include <netdb.h>
  13. #include <poll.h>
  14. #include <unistd.h>
  15. #include <errno.h>
  16. #include <stdio.h>
  17. #include <string.h>
  18. #include <stdlib.h>
  19. #include <ctype.h>
  20. #include "libtelnet.h"
  21. #ifndef WOE_CLIENTS_MAX
  22. /* Must beless than ulimit -nor */
  23. #define WOE_CLIENTS_MAX 1000
  24. #endif
  25. #ifndef WOE_CLIENT_BUFFER_SIZE
  26. #define WOE_CLIENT_BUFFER_SIZE 256
  27. #endif
  28. struct woe_server;
  29. struct woe_client {
  30. struct woe_server * server;
  31. int index;
  32. int sock;
  33. telnet_t * telnet;
  34. char linebuf[256];
  35. int linepos;
  36. int busy;
  37. struct sockaddr_in addr;
  38. socklen_t addrlen;
  39. };
  40. int woe_clients_max(void);
  41. int woe_client_input(struct woe_client * cli, const char * buffer, size_t size);
  42. int woe_client_zmp(struct woe_client * cli, int argc, char *argv[]);
  43. struct woe_client *
  44. woe_client_new(struct woe_server * srv, int index, int socket,
  45. struct sockaddr_in *addr, socklen_t addrlen);
  46. struct woe_client * woe_client_free(struct woe_client * cli);
  47. #endif