server.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef WOE_SERVER_H
  2. #define WOE_SERVER_H
  3. #ifndef WOE_SERVER_MAX_TIMERS
  4. #define WOE_SERVER_MAX_TIMERS 128
  5. #endif
  6. #include <stdarg.h>
  7. #include <mruby.h>
  8. struct woe_server;
  9. struct woe_server * woe_server_new(int port);
  10. struct woe_server * woe_server_free(struct woe_server * srv);
  11. int woe_server_listen(struct woe_server * srv);
  12. int woe_server_update(struct woe_server * srv, int timeout);
  13. int woe_server_busy(struct woe_server * srv);
  14. void woe_server_request_shutdown(struct woe_server * srv);
  15. enum woe_timer_type {
  16. WOE_TIMER_TYPE_REPEAT,
  17. WOE_TIMER_TYPE_ONCE
  18. };
  19. int woe_server_start_timer(struct woe_server * srv,
  20. int sec, int ns, enum woe_timer_type type);
  21. int woe_server_send_to_client(struct woe_server * srv, int client, char * data, size_t size);
  22. struct woe_server * woe_server_set_mrb(struct woe_server * srv, mrb_state * mrb);
  23. mrb_state * woe_server_get_mrb(struct woe_server * srv);
  24. int woe_server_disconnect_id(struct woe_server * srv, int id);
  25. int woe_server_iac(struct woe_server * srv, int client, int command);
  26. int woe_server_negotiate(struct woe_server * srv, int client, int how, int option);
  27. int woe_server_begin_sb(struct woe_server * srv, int client, int telopt);
  28. int woe_server_finish_sb(struct woe_server * srv, int client);
  29. int woe_server_subnegotiation(struct woe_server * srv, int client, int telopt, char * buffer, int size);
  30. int woe_server_begin_compress2(struct woe_server * srv, int client);
  31. int woe_server_vprintf(struct woe_server * srv, int client, const char *fmt, va_list va);
  32. int woe_server_printf(struct woe_server * srv, int client, const char *fmt, ...);
  33. int woe_server_raw_vprintf(struct woe_server * srv, int client, const char *fmt, va_list va);
  34. int woe_server_raw_printf(struct woe_server * srv, int client, const char *fmt, ...);
  35. int woe_server_begin_newenviron(struct woe_server * srv, int client, int type);
  36. int woe_server_newenviron_value(struct woe_server * srv, int client, int type, char * value);
  37. int woe_server_finish_newenviron(struct woe_server * srv, int client);
  38. int woe_server_ttype_send(struct woe_server * srv, int client);
  39. int woe_server_ttype_is(struct woe_server * srv, int client, char * ttype);
  40. int woe_server_send_zmp(struct woe_server * srv, int client, int argc, const char ** argv);
  41. int woe_server_send_vzmpv(struct woe_server * srv, int client, va_list va);
  42. int woe_server_send_zmpv(struct woe_server * srv, int client, ...);
  43. int woe_server_begin_zmp(struct woe_server * srv, int client, const char * cmd);
  44. int woe_server_zmp_arg(struct woe_server * srv, int client, const char * arg);
  45. int woe_server_finish_zmp(struct woe_server * srv, int client, const char * cmd);
  46. #endif