toruby.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. /*
  2. * toruby.c helps expose functionality from C to Mruby for Eruta.
  3. * All functions are prefixed with tr_.
  4. * Look at the tr_*.c files.
  5. * */
  6. #define _XOPEN_SOURCE 700
  7. #include "toruby.h"
  8. #include "tr_macro.h"
  9. #include "monolog.h"
  10. #include "rh.h"
  11. #include "state.h"
  12. #include "server.h"
  13. #include "libtelnet.h"
  14. #include "tr_file.h"
  15. #include <unistd.h>
  16. #include <signal.h>
  17. #include <mruby/hash.h>
  18. #include <mruby/class.h>
  19. #include <mruby/data.h>
  20. #include <mruby/array.h>
  21. /*
  22. #include "tr_macro.h"
  23. #include "tr_audio.h"
  24. #include "tr_graph.h"
  25. #include "tr_store.h"
  26. #include "tr_sprite.h"
  27. */
  28. /* Documentation of mrb_get_args:
  29. retrieve arguments from mrb_state.
  30. mrb_get_args(mrb, format, ...)
  31. returns number of arguments parsed.
  32. format specifiers:
  33. o: Object [mrb_value]
  34. S: String [mrb_value]
  35. A: Array [mrb_value]
  36. H: Hash [mrb_value]
  37. s: String [char*,int]
  38. z: String [char*] nul terminated
  39. a: Array [mrb_value*,mrb_int]
  40. f: Float [mrb_float]
  41. i: Integer [mrb_int]
  42. b: Binary [int]
  43. n: Symbol [mrb_sym]
  44. &: Block [mrb_value]
  45. *: rest argument [mrb_value*,int]
  46. |: optional
  47. */
  48. /** Writes a NOTE message to the log. */
  49. static mrb_value tr_log(mrb_state * mrb, mrb_value self) {
  50. (void) self; (void) mrb;
  51. mrb_value text = mrb_nil_value();
  52. mrb_get_args(mrb, "S", &text);
  53. LOG_NOTE("%s\n", RSTRING_PTR(text));
  54. return self;
  55. }
  56. /** Writes a messageto a certain log level log. */
  57. static mrb_value tr_log_to(mrb_state * mrb, mrb_value self) {
  58. (void) self; (void) mrb;
  59. mrb_value level = mrb_nil_value();
  60. mrb_value text = mrb_nil_value();
  61. mrb_get_args(mrb, "SS", &level, &text);
  62. LOG_LEVEL(RSTRING_PTR(level), "%s\n", RSTRING_PTR(text));
  63. return self;
  64. }
  65. /** Cause a warning to be logged */
  66. static mrb_value tr_warn(mrb_state * mrb, mrb_value self) {
  67. (void) self; (void) mrb;
  68. mrb_value text = mrb_nil_value();
  69. mrb_get_args(mrb, "S", &text);
  70. LOG_WARNING("%s\n", RSTRING_PTR(text));
  71. return self;
  72. }
  73. /** Enables a certain log level */
  74. static mrb_value tr_log_enable(mrb_state * mrb, mrb_value self) {
  75. (void) self; (void) mrb;
  76. mrb_value text = mrb_nil_value();
  77. mrb_get_args(mrb, "S", &text);
  78. monolog_enable_level(RSTRING_PTR(text));
  79. return self;
  80. }
  81. /** Disables a certain log level */
  82. static mrb_value tr_log_disable(mrb_state * mrb, mrb_value self) {
  83. (void) self; (void) mrb;
  84. mrb_value text = mrb_nil_value();
  85. mrb_get_args(mrb, "S", &text);
  86. monolog_disable_level(RSTRING_PTR(text));
  87. return self;
  88. }
  89. /* Loads another script from the script directory. */
  90. static mrb_value tr_script(mrb_state * mrb, mrb_value self) {
  91. int res;
  92. char * command;
  93. (void) self;
  94. mrb_value text = mrb_nil_value();
  95. mrb_get_args(mrb, "S", &text);
  96. command = mrb_str_to_cstr(mrb, text);
  97. res = rh_run_script(mrb, command);
  98. return mrb_fixnum_value(res);
  99. }
  100. /* Sends data to a given client */
  101. static mrb_value tr_send_to_client(mrb_state * mrb, mrb_value self) {
  102. int res;
  103. mrb_int client = -1;
  104. char * data = NULL;
  105. int size = 0;
  106. struct woe_server * srv = MRB_WOE_SERVER(mrb);
  107. (void) self;
  108. mrb_get_args(mrb, "is", &client, &data, &size);
  109. res = woe_server_send_to_client(srv, client, data, size);
  110. return mrb_fixnum_value(res);
  111. }
  112. /* Shuts down a given client */
  113. static mrb_value tr_server_done(mrb_state * mrb, mrb_value self) {
  114. struct woe_server * srv = MRB_WOE_SERVER(mrb);
  115. (void) self;
  116. woe_server_request_shutdown(srv);
  117. return mrb_nil_value();
  118. }
  119. /* Disconnects a given client by id */
  120. static mrb_value tr_disconnect_client(mrb_state * mrb, mrb_value self) {
  121. int res;
  122. mrb_int client;
  123. struct woe_server * srv = MRB_WOE_SERVER(mrb);
  124. (void) self;
  125. mrb_get_args(mrb, "i", &client);
  126. res = woe_server_disconnect_id(srv, client);
  127. return mrb_fixnum_value(res);
  128. }
  129. /* Yeah, I know, but this reduces boilerplate. */
  130. #define WRAP_SERVER_BEGIN(NAME) \
  131. static mrb_value NAME(mrb_state * mrb, mrb_value self) { \
  132. int res; \
  133. mrb_int client = -1; \
  134. struct woe_server * srv = MRB_WOE_SERVER(mrb); \
  135. (void) self; \
  136. #define WRAP_SERVER_TIMER_BEGIN(NAME) \
  137. static mrb_value NAME(mrb_state * mrb, mrb_value self) { \
  138. int res; \
  139. mrb_int timer = -1; \
  140. struct woe_server * srv = MRB_WOE_SERVER(mrb); \
  141. (void) self; \
  142. #define WRAP_SERVER_END() \
  143. return mrb_fixnum_value(res); \
  144. }
  145. WRAP_SERVER_BEGIN(tr_server_iac) {
  146. mrb_int command = 0;
  147. mrb_get_args(mrb, "ii", &client, &command);
  148. res = woe_server_iac(srv, client, command);
  149. } WRAP_SERVER_END()
  150. WRAP_SERVER_BEGIN(tr_server_negotiate) {
  151. mrb_int how = 0, option = 0;
  152. mrb_get_args(mrb, "iii", &client, &how, &option);
  153. res = woe_server_negotiate(srv, client, how, option);
  154. } WRAP_SERVER_END()
  155. WRAP_SERVER_BEGIN(tr_server_begin_sb) {
  156. mrb_int telopt = 0;
  157. mrb_get_args(mrb, "ii", &client, &telopt);
  158. res = woe_server_begin_sb(srv, client, telopt);
  159. } WRAP_SERVER_END()
  160. WRAP_SERVER_BEGIN(tr_server_finish_sb) {
  161. mrb_get_args(mrb, "i", &client);
  162. res = woe_server_finish_sb(srv, client);
  163. } WRAP_SERVER_END()
  164. WRAP_SERVER_BEGIN(tr_server_subnegotiation) {
  165. mrb_int telopt = 0, size = 0;
  166. char * data = NULL;
  167. mrb_get_args(mrb, "iis", &client, &telopt, &data, &size);
  168. res = woe_server_subnegotiation(srv, client, telopt, data, size);
  169. } WRAP_SERVER_END()
  170. WRAP_SERVER_BEGIN(tr_server_begin_compress2) {
  171. mrb_get_args(mrb, "i", &client);
  172. res = woe_server_begin_compress2(srv, client);
  173. } WRAP_SERVER_END()
  174. WRAP_SERVER_BEGIN(tr_server_puts) {
  175. char * fmt = NULL;
  176. mrb_get_args(mrb, "iz", &client, &fmt);
  177. res = woe_server_printf(srv, client, fmt);
  178. } WRAP_SERVER_END()
  179. WRAP_SERVER_BEGIN(tr_server_raw_puts) {
  180. char * fmt = NULL;
  181. mrb_get_args(mrb, "iz", &client, &fmt);
  182. res = woe_server_raw_printf(srv, client, fmt);
  183. } WRAP_SERVER_END()
  184. WRAP_SERVER_BEGIN(tr_server_begin_newenviron) {
  185. mrb_int type;
  186. mrb_get_args(mrb, "ii", &client, &type);
  187. res = woe_server_begin_newenviron(srv, client, type);
  188. } WRAP_SERVER_END()
  189. WRAP_SERVER_BEGIN(tr_server_newenviron_value) {
  190. mrb_int type;
  191. char * value = NULL;
  192. mrb_get_args(mrb, "iiz", &client, &type, &value);
  193. res = woe_server_newenviron_value(srv, client, type, value);
  194. } WRAP_SERVER_END()
  195. WRAP_SERVER_BEGIN(tr_server_finish_newenviron) {
  196. mrb_get_args(mrb, "i", &client);
  197. res = woe_server_finish_newenviron(srv, client);
  198. } WRAP_SERVER_END()
  199. WRAP_SERVER_BEGIN(tr_server_ttype_send) {
  200. mrb_get_args(mrb, "i", &client);
  201. res = woe_server_ttype_send(srv, client);
  202. } WRAP_SERVER_END()
  203. WRAP_SERVER_BEGIN(tr_server_ttype_is) {
  204. mrb_int type;
  205. char * ttype = NULL;
  206. mrb_get_args(mrb, "iz", &client, &ttype);
  207. res = woe_server_ttype_is(srv, client, ttype);
  208. } WRAP_SERVER_END()
  209. /*
  210. int woe_server_send_zmp(struct woe_server * srv, int client, int argc, const char ** argv);
  211. int woe_server_send_vzmpv(struct woe_server * srv, int client, va_list va);
  212. int woe_server_send_zmpv(struct woe_server * srv, int client, ...);
  213. */
  214. WRAP_SERVER_BEGIN(tr_server_begin_zmp) {
  215. char * command = NULL;
  216. mrb_get_args(mrb, "iz", &client, &command);
  217. res = woe_server_begin_zmp(srv, client, command);
  218. } WRAP_SERVER_END()
  219. WRAP_SERVER_BEGIN(tr_server_zmp_arg) {
  220. char * arg = NULL;
  221. mrb_get_args(mrb, "iz", &client, &arg);
  222. res = woe_server_zmp_arg(srv, client, arg);
  223. } WRAP_SERVER_END()
  224. WRAP_SERVER_BEGIN(tr_server_finish_zmp) {
  225. char * command;
  226. mrb_get_args(mrb, "iz", &client, &command);
  227. res = woe_server_finish_zmp(srv, client, command);
  228. } WRAP_SERVER_END()
  229. WRAP_SERVER_TIMER_BEGIN(tr_server_new_timer) {
  230. (void) timer;
  231. res = woe_server_make_new_timer_id(srv);
  232. } WRAP_SERVER_END()
  233. WRAP_SERVER_TIMER_BEGIN(tr_server_set_timer) {
  234. mrb_float value = 0.0, interval = 0.0;
  235. mrb_get_args(mrb, "iff", &timer, &value, &interval);
  236. res = woe_server_set_timer_value(srv, timer, value, interval);
  237. } WRAP_SERVER_END()
  238. static mrb_value tr_server_get_timer(mrb_state * mrb, mrb_value self) {
  239. int res;
  240. mrb_int timer = -1;
  241. struct woe_server * srv = MRB_WOE_SERVER(mrb);
  242. (void) self;
  243. double value = 0.0, interval = 0.0;
  244. mrb_get_args(mrb, "i", &timer);
  245. res = woe_server_get_timer_value(srv, timer, &value, &interval);
  246. {
  247. mrb_value vals[3] = { mrb_fixnum_value(res), mrb_float_value(mrb, value), mrb_float_value(mrb, interval) };
  248. return mrb_ary_new_from_values(mrb, 3, vals);
  249. }
  250. }
  251. static mrb_value tr_crypt(mrb_state * mrb, mrb_value self) {
  252. mrb_value res;
  253. char * pass = NULL;
  254. char * salt = NULL;
  255. char * hash = NULL;
  256. mrb_get_args(mrb, "zz", &pass, &salt);
  257. hash = crypt(pass, salt);
  258. return mrb_str_new(mrb, hash, 13);
  259. }
  260. /* Initializes the functionality that Eruta exposes to Ruby. */
  261. int tr_init(mrb_state * mrb) {
  262. // luaL_dostring(lua, "print 'Hello!' ");
  263. struct RClass *woe;
  264. struct RClass *srv;
  265. struct RClass *krn;
  266. struct RClass *tel;
  267. struct RClass *sig;
  268. struct RClass *fil;
  269. tr_init_file(mrb);
  270. woe = mrb_define_module(mrb, "Woe");
  271. srv = mrb_define_module_under(mrb, woe, "Server");
  272. tel = mrb_define_module(mrb, "Telnet");
  273. sig = mrb_define_module(mrb, "Signal");
  274. krn = mrb_module_get(mrb, "Kernel");
  275. if(!krn) return -1;
  276. TR_CLASS_METHOD_ARGC(mrb , woe, "crypt" , tr_crypt, 2);
  277. TR_CLASS_METHOD_NOARG(mrb , woe, "quit" , tr_server_done);
  278. TR_CLASS_METHOD_NOARG(mrb , srv, "quit" , tr_server_done);
  279. TR_CLASS_METHOD_ARGC(mrb , srv, "send_to_client" , tr_send_to_client, 2);
  280. TR_CLASS_METHOD_NOARG(mrb , srv, "disconnect" , tr_disconnect_client);
  281. TR_CLASS_METHOD_ARGC(mrb, srv, "iac" , tr_server_iac, 2);
  282. TR_CLASS_METHOD_ARGC(mrb, srv, "negotiate" , tr_server_negotiate , 3);
  283. TR_CLASS_METHOD_ARGC(mrb, srv, "begin_sb" , tr_server_begin_sb , 2);
  284. TR_CLASS_METHOD_ARGC(mrb, srv, "finish_sb" , tr_server_finish_sb , 1);
  285. TR_CLASS_METHOD_ARGC(mrb, srv, "subnegotiation" , tr_server_subnegotiation, 3);
  286. TR_CLASS_METHOD_ARGC(mrb, srv, "begin_compress2", tr_server_begin_compress2, 2);
  287. TR_CLASS_METHOD_ARGC(mrb, srv, "puts" , tr_server_puts, 2);
  288. TR_CLASS_METHOD_ARGC(mrb, srv, "raw_puts" , tr_server_raw_puts, 2);
  289. TR_CLASS_METHOD_ARGC(mrb, srv, "begin_newenviron" , tr_server_begin_newenviron, 2);
  290. TR_CLASS_METHOD_ARGC(mrb, srv, "newenviron_value" , tr_server_newenviron_value, 3);
  291. TR_CLASS_METHOD_ARGC(mrb, srv, "finish_newenviron", tr_server_finish_newenviron, 1);
  292. TR_CLASS_METHOD_ARGC(mrb, srv, "ttype_send" , tr_server_ttype_send, 1);
  293. TR_CLASS_METHOD_ARGC(mrb, srv, "ttype_is" , tr_server_ttype_is, 2);
  294. TR_CLASS_METHOD_ARGC(mrb, srv, "begin_zmp" , tr_server_finish_zmp, 2);
  295. TR_CLASS_METHOD_ARGC(mrb, srv, "zmp_arg" , tr_server_finish_zmp, 2);
  296. TR_CLASS_METHOD_ARGC(mrb, srv, "finish_zmp" , tr_server_finish_zmp, 2);
  297. TR_CLASS_METHOD_NOARG(mrb, srv, "new_timer" , tr_server_new_timer);
  298. TR_CLASS_METHOD_ARGC(mrb, srv, "set_timer" , tr_server_set_timer, 3);
  299. TR_CLASS_METHOD_ARGC(mrb, srv, "get_timer" , tr_server_get_timer, 1);
  300. /* Telnet constants, commands, etc. */
  301. TR_CONST_INT_VALUE(mrb, tel, TELNET_IAC);
  302. TR_CONST_INT_VALUE(mrb, tel, TELNET_DONT);
  303. TR_CONST_INT_VALUE(mrb, tel, TELNET_DO);
  304. TR_CONST_INT_VALUE(mrb, tel, TELNET_WILL);
  305. TR_CONST_INT_VALUE(mrb, tel, TELNET_WONT);
  306. TR_CONST_INT_VALUE(mrb, tel, TELNET_SB);
  307. TR_CONST_INT_VALUE(mrb, tel, TELNET_GA);
  308. TR_CONST_INT_VALUE(mrb, tel, TELNET_EL);
  309. TR_CONST_INT_VALUE(mrb, tel, TELNET_EC);
  310. TR_CONST_INT_VALUE(mrb, tel, TELNET_AYT);
  311. TR_CONST_INT_VALUE(mrb, tel, TELNET_AO);
  312. TR_CONST_INT_VALUE(mrb, tel, TELNET_IP);
  313. TR_CONST_INT_VALUE(mrb, tel, TELNET_BREAK);
  314. TR_CONST_INT_VALUE(mrb, tel, TELNET_DM);
  315. TR_CONST_INT_VALUE(mrb, tel, TELNET_NOP);
  316. TR_CONST_INT_VALUE(mrb, tel, TELNET_SE);
  317. TR_CONST_INT_VALUE(mrb, tel, TELNET_EOR);
  318. TR_CONST_INT_VALUE(mrb, tel, TELNET_ABORT);
  319. TR_CONST_INT_VALUE(mrb, tel, TELNET_SUSP);
  320. TR_CONST_INT_VALUE(mrb, tel, TELNET_EOF);
  321. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_BINARY);
  322. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_ECHO);
  323. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_RCP);
  324. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_SGA);
  325. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_NAMS);
  326. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_STATUS);
  327. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_TM);
  328. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_RCTE);
  329. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_NAOL);
  330. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_NAOP);
  331. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_NAOCRD);
  332. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_NAOHTS);
  333. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_NAOHTD);
  334. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_NAOFFD);
  335. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_NAOVTS);
  336. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_NAOVTD);
  337. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_NAOLFD);
  338. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_XASCII);
  339. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_LOGOUT);
  340. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_BM);
  341. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_DET);
  342. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_SUPDUP);
  343. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_SUPDUPOUTPUT);
  344. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_SNDLOC);
  345. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_TTYPE);
  346. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_EOR);
  347. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_3270REGIME);
  348. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_X3PAD);
  349. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_NAWS);
  350. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_TSPEED);
  351. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_LFLOW);
  352. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_LINEMODE);
  353. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_XDISPLOC);
  354. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_ENVIRON);
  355. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_AUTHENTICATION);
  356. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_ENCRYPT);
  357. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_NEW_ENVIRON);
  358. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_MSSP);
  359. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_COMPRESS);
  360. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_COMPRESS2);
  361. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_ZMP);
  362. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_EXOPL);
  363. TR_CONST_INT_VALUE(mrb, tel, TELNET_TELOPT_MCCP2);
  364. TR_CONST_INT_VALUE(mrb, tel, TELNET_TTYPE_IS);
  365. TR_CONST_INT_VALUE(mrb, tel, TELNET_TTYPE_SEND);
  366. TR_CONST_INT_VALUE(mrb, tel, TELNET_ENVIRON_IS);
  367. TR_CONST_INT_VALUE(mrb, tel, TELNET_ENVIRON_SEND);
  368. TR_CONST_INT_VALUE(mrb, tel, TELNET_ENVIRON_INFO);
  369. TR_CONST_INT_VALUE(mrb, tel, TELNET_ENVIRON_VAR);
  370. TR_CONST_INT_VALUE(mrb, tel, TELNET_ENVIRON_VALUE);
  371. TR_CONST_INT_VALUE(mrb, tel, TELNET_ENVIRON_ESC);
  372. TR_CONST_INT_VALUE(mrb, tel, TELNET_ENVIRON_USERVAR);
  373. TR_CONST_INT_VALUE(mrb, tel, TELNET_MSSP_VAL);
  374. TR_CONST_INT_VALUE(mrb, tel, TELNET_MSSP_VAR);
  375. TR_CONST_INT_VALUE(mrb, tel, TELNET_EOK);
  376. TR_CONST_INT_VALUE(mrb, tel, TELNET_EBADVAL);
  377. TR_CONST_INT_VALUE(mrb, tel, TELNET_ENOMEM);
  378. TR_CONST_INT_VALUE(mrb, tel, TELNET_EOVERFLOW);
  379. TR_CONST_INT_VALUE(mrb, tel, TELNET_EPROTOCOL);
  380. TR_CONST_INT_VALUE(mrb, tel, TELNET_ECOMPRESS);
  381. TR_CONST_INT_VALUE(mrb, sig, SIGHUP);
  382. TR_CONST_INT_VALUE(mrb, sig, SIGINT);
  383. TR_CONST_INT_VALUE(mrb, sig, SIGQUIT);
  384. TR_CONST_INT_VALUE(mrb, sig, SIGILL);
  385. TR_CONST_INT_VALUE(mrb, sig, SIGABRT);
  386. TR_CONST_INT_VALUE(mrb, sig, SIGFPE);
  387. TR_CONST_INT_VALUE(mrb, sig, SIGKILL);
  388. TR_CONST_INT_VALUE(mrb, sig, SIGSEGV);
  389. TR_CONST_INT_VALUE(mrb, sig, SIGPIPE);
  390. TR_CONST_INT_VALUE(mrb, sig, SIGALRM);
  391. TR_CONST_INT_VALUE(mrb, sig, SIGTERM);
  392. TR_CONST_INT_VALUE(mrb, sig, SIGUSR1);
  393. TR_CONST_INT_VALUE(mrb, sig, SIGUSR2);
  394. TR_CONST_INT_VALUE(mrb, sig, SIGCHLD);
  395. TR_CONST_INT_VALUE(mrb, sig, SIGCONT);
  396. TR_CONST_INT_VALUE(mrb, sig, SIGSTOP);
  397. TR_CONST_INT_VALUE(mrb, sig, SIGTSTP);
  398. TR_CONST_INT_VALUE(mrb, sig, SIGTTIN);
  399. TR_CONST_INT_VALUE(mrb, sig, SIGTTOU);
  400. TR_CONST_INT_VALUE(mrb, sig, SIGBUS);
  401. TR_CONST_INT_VALUE(mrb, sig, SIGPOLL);
  402. TR_CONST_INT_VALUE(mrb, sig, SIGPROF);
  403. TR_CONST_INT_VALUE(mrb, sig, SIGSYS);
  404. TR_CONST_INT_VALUE(mrb, sig, SIGTRAP);
  405. TR_CONST_INT_VALUE(mrb, sig, SIGURG);
  406. TR_CONST_INT_VALUE(mrb, sig, SIGVTALRM);
  407. TR_CONST_INT_VALUE(mrb, sig, SIGXCPU);
  408. TR_CONST_INT_VALUE(mrb, sig, SIGXFSZ);
  409. TR_CONST_INT_VALUE(mrb, sig, SIGIOT);
  410. TR_CONST_INT_VALUE(mrb, sig, SIGSTKFLT);
  411. TR_CONST_INT_VALUE(mrb, sig, SIGIO);
  412. TR_CONST_INT_VALUE(mrb, sig, SIGCLD);
  413. TR_CONST_INT_VALUE(mrb, sig, SIGPWR);
  414. TR_CONST_INT_VALUE(mrb, sig, SIGWINCH);
  415. TR_CONST_INT_VALUE(mrb, sig, SIGUNUSED);
  416. TR_METHOD_ARGC(mrb, krn, "woe_warn" , tr_warn , 1);
  417. TR_METHOD_ARGC(mrb, krn, "woe_warning" , tr_warn , 1);
  418. TR_METHOD_ARGC(mrb, krn, "woe_log" , tr_log , 1);
  419. TR_METHOD_ARGC(mrb, krn, "woe_log_to" , tr_log_to , 2);
  420. TR_METHOD_ARGC(mrb, krn, "log_enable" , tr_log_disable , 1);
  421. TR_METHOD_ARGC(mrb, krn, "log_disable" , tr_log_enable , 1);
  422. TR_METHOD_ARGC(mrb, krn, "script" , tr_script , 1);
  423. // must restore gc area here ????
  424. mrb_gc_arena_restore(mrb, 0);
  425. return 0;
  426. }