server.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef WOE_SERVER_H
  2. #define WOE_SERVER_H
  3. #ifndef WOE_TIMERS_MAX
  4. #define WOE_TIMERS_MAX 32
  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_send_to_client(struct woe_server * srv, int client, char * data, size_t size);
  20. struct woe_server * woe_server_set_mrb(struct woe_server * srv, mrb_state * mrb);
  21. mrb_state * woe_server_get_mrb(struct woe_server * srv);
  22. int woe_server_disconnect_id(struct woe_server * srv, int id);
  23. int woe_server_iac(struct woe_server * srv, int client, int command);
  24. int woe_server_negotiate(struct woe_server * srv, int client, int how, int option);
  25. int woe_server_begin_sb(struct woe_server * srv, int client, int telopt);
  26. int woe_server_finish_sb(struct woe_server * srv, int client);
  27. int woe_server_subnegotiation(struct woe_server * srv, int client, int telopt, char * buffer, int size);
  28. int woe_server_begin_compress2(struct woe_server * srv, int client);
  29. int woe_server_vprintf(struct woe_server * srv, int client, const char *fmt, va_list va);
  30. int woe_server_printf(struct woe_server * srv, int client, const char *fmt, ...);
  31. int woe_server_raw_vprintf(struct woe_server * srv, int client, const char *fmt, va_list va);
  32. int woe_server_raw_printf(struct woe_server * srv, int client, const char *fmt, ...);
  33. int woe_server_begin_newenviron(struct woe_server * srv, int client, int type);
  34. int woe_server_newenviron_value(struct woe_server * srv, int client, int type, char * value);
  35. int woe_server_finish_newenviron(struct woe_server * srv, int client);
  36. int woe_server_ttype_send(struct woe_server * srv, int client);
  37. int woe_server_ttype_is(struct woe_server * srv, int client, char * ttype);
  38. int woe_server_send_zmp(struct woe_server * srv, int client, int argc, const char ** argv);
  39. int woe_server_send_vzmpv(struct woe_server * srv, int client, va_list va);
  40. int woe_server_send_zmpv(struct woe_server * srv, int client, ...);
  41. int woe_server_begin_zmp(struct woe_server * srv, int client, const char * cmd);
  42. int woe_server_zmp_arg(struct woe_server * srv, int client, const char * arg);
  43. int woe_server_finish_zmp(struct woe_server * srv, int client, const char * cmd);
  44. int woe_server_make_new_timer_id(struct woe_server * srv);
  45. struct woe_client * woe_server_remove_client(struct woe_server * srv, int index);
  46. struct woe_timer * woe_server_remove_timer(struct woe_server * srv, int index);
  47. int woe_server_set_timer_value(struct woe_server * srv, int index, double value, double interval);
  48. int woe_server_get_timer_value(struct woe_server * srv, int index, double * value, double * interval);
  49. #endif