liolib.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. /*
  2. ** $Id: liolib.c,v 1.64 2000/05/24 13:54:49 roberto Exp roberto $
  3. ** Standard I/O (and system) library
  4. ** See Copyright Notice in lua.h
  5. */
  6. #include <ctype.h>
  7. #include <errno.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <time.h>
  12. #define LUA_REENTRANT
  13. #include "lauxlib.h"
  14. #include "lua.h"
  15. #include "luadebug.h"
  16. #include "lualib.h"
  17. #ifndef OLD_ANSI
  18. #include <locale.h>
  19. #else
  20. /* no support for locale and for strerror: fake them */
  21. #define setlocale(a,b) ((void)a, strcmp((b),"C")==0?"C":NULL)
  22. #define LC_ALL 0
  23. #define LC_COLLATE 0
  24. #define LC_CTYPE 0
  25. #define LC_MONETARY 0
  26. #define LC_NUMERIC 0
  27. #define LC_TIME 0
  28. #define strerror(e) "(no error message provided by operating system)"
  29. #endif
  30. #ifdef POPEN
  31. /* FILE *popen();
  32. int pclose(); */
  33. #define CLOSEFILE(L, f) ((pclose(f) == -1) ? fclose(f) : 0)
  34. #else
  35. /* no support for popen */
  36. #define popen(x,y) NULL /* that is, popen always fails */
  37. #define CLOSEFILE(L, f) (fclose(f))
  38. #endif
  39. #define INFILE 0
  40. #define OUTFILE 1
  41. typedef struct IOCtrl {
  42. FILE *file[2]; /* values of _INPUT and _OUTPUT */
  43. int iotag; /* tag for file handles */
  44. int closedtag; /* tag for closed handles */
  45. } IOCtrl;
  46. static const char *const filenames[] = {"_INPUT", "_OUTPUT", NULL};
  47. static void atribTM (lua_State *L) {
  48. IOCtrl *ctrl = (IOCtrl *)lua_getuserdata(L, lua_getparam(L, 1));
  49. const char *varname = luaL_check_string(L, 2);
  50. lua_Object newvalue = lua_getparam(L, 4);
  51. int inout;
  52. if ((inout = luaL_findstring(varname, filenames)) != -1) {
  53. if (lua_tag(L, newvalue) != ctrl->iotag)
  54. luaL_verror(L, "%.20s value must be a valid file handle",
  55. filenames[inout]);
  56. ctrl->file[inout] = (FILE *)lua_getuserdata(L, newvalue);
  57. }
  58. /* set the actual variable */
  59. lua_pushglobaltable(L);
  60. lua_pushstring(L, varname);
  61. lua_pushobject(L, newvalue);
  62. lua_rawset(L);
  63. }
  64. static void ctrl_collect (lua_State *L) {
  65. IOCtrl *ctrl = (IOCtrl *)lua_getuserdata(L, lua_getparam(L, 1));
  66. free(ctrl);
  67. }
  68. static void pushresult (lua_State *L, int i) {
  69. if (i)
  70. lua_pushuserdata(L, NULL);
  71. else {
  72. lua_pushnil(L);
  73. lua_pushstring(L, strerror(errno));
  74. lua_pushnumber(L, errno);
  75. }
  76. }
  77. /*
  78. ** {======================================================
  79. ** FILE Operations
  80. ** =======================================================
  81. */
  82. static FILE *gethandle (lua_State *L, IOCtrl *ctrl, lua_Object f) {
  83. if (lua_isuserdata(L, f)) {
  84. int ftag = lua_tag(L, f);
  85. if (ftag == ctrl->iotag)
  86. return (FILE *)lua_getuserdata(L, f);
  87. else if (ftag == ctrl->closedtag)
  88. lua_error(L, "cannot access a closed file");
  89. /* else go through */
  90. }
  91. return NULL;
  92. }
  93. static FILE *getnonullfile (lua_State *L, IOCtrl *ctrl, int arg) {
  94. FILE *f = gethandle(L, ctrl, lua_getparam(L, arg));
  95. luaL_arg_check(L, f, arg, "invalid file handle");
  96. return f;
  97. }
  98. static FILE *getfileparam (lua_State *L, IOCtrl *ctrl, int *arg, int inout) {
  99. FILE *f = gethandle(L, ctrl, lua_getparam(L, *arg));
  100. if (f) {
  101. (*arg)++;
  102. return f;
  103. }
  104. else
  105. return ctrl->file[inout];
  106. }
  107. static void setfilebyname (lua_State *L, IOCtrl *ctrl, FILE *f,
  108. const char *name) {
  109. lua_pushusertag(L, f, ctrl->iotag);
  110. lua_setglobal(L, name);
  111. }
  112. static void setfile (lua_State *L, IOCtrl *ctrl, FILE *f, int inout) {
  113. ctrl->file[inout] = f;
  114. lua_pushusertag(L, f, ctrl->iotag);
  115. lua_setglobal(L, filenames[inout]);
  116. }
  117. static void setreturn (lua_State *L, IOCtrl *ctrl, FILE *f, int inout) {
  118. if (f == NULL)
  119. pushresult(L, 0);
  120. else {
  121. setfile(L, ctrl, f, inout);
  122. lua_pushusertag(L, f, ctrl->iotag);
  123. }
  124. }
  125. static int closefile (lua_State *L, IOCtrl *ctrl, FILE *f) {
  126. if (f == stdin || f == stdout)
  127. return 1;
  128. else {
  129. if (f == ctrl->file[INFILE])
  130. setfile(L, ctrl, stdin, INFILE);
  131. else if (f == ctrl->file[OUTFILE])
  132. setfile(L, ctrl, stdout, OUTFILE);
  133. lua_pushusertag(L, f, ctrl->iotag);
  134. lua_settag(L, ctrl->closedtag);
  135. return (CLOSEFILE(L, f) == 0);
  136. }
  137. }
  138. static void io_close (lua_State *L) {
  139. IOCtrl *ctrl = (IOCtrl *)lua_getuserdata(L, lua_getparam(L, 1));
  140. pushresult(L, closefile(L, ctrl, getnonullfile(L, ctrl, 2)));
  141. }
  142. static void io_open (lua_State *L) {
  143. IOCtrl *ctrl = (IOCtrl *)lua_getuserdata(L, lua_getparam(L, 1));
  144. FILE *f = fopen(luaL_check_string(L, 2), luaL_check_string(L, 3));
  145. if (f) lua_pushusertag(L, f, ctrl->iotag);
  146. else pushresult(L, 0);
  147. }
  148. static void io_fromto (lua_State *L, int inout, const char *mode) {
  149. IOCtrl *ctrl = (IOCtrl *)lua_getuserdata(L, lua_getparam(L, 1));
  150. lua_Object f = lua_getparam(L, 2);
  151. FILE *current;
  152. if (f == LUA_NOOBJECT) {
  153. pushresult(L, closefile(L, ctrl, ctrl->file[inout]));
  154. return;
  155. }
  156. else if (lua_tag(L, f) == ctrl->iotag) /* deprecated option */
  157. current = (FILE *)lua_getuserdata(L, f);
  158. else {
  159. const char *s = luaL_check_string(L, 2);
  160. current = (*s == '|') ? popen(s+1, mode) : fopen(s, mode);
  161. }
  162. setreturn(L, ctrl, current, inout);
  163. }
  164. static void io_readfrom (lua_State *L) {
  165. io_fromto(L, INFILE, "r");
  166. }
  167. static void io_writeto (lua_State *L) {
  168. io_fromto(L, OUTFILE, "w");
  169. }
  170. static void io_appendto (lua_State *L) {
  171. IOCtrl *ctrl = (IOCtrl *)lua_getuserdata(L, lua_getparam(L, 1));
  172. FILE *current = fopen(luaL_check_string(L, 2), "a");
  173. setreturn(L, ctrl, current, OUTFILE);
  174. }
  175. /*
  176. ** {======================================================
  177. ** READ
  178. ** =======================================================
  179. */
  180. #ifdef LUA_COMPAT_READPATTERN
  181. /*
  182. ** We cannot lookahead without need, because this can lock stdin.
  183. ** This flag signals when we need to read a next char.
  184. */
  185. #define NEED_OTHER (EOF-1) /* just some flag different from EOF */
  186. static int read_pattern (lua_State *L, FILE *f, const char *p) {
  187. int inskip = 0; /* {skip} level */
  188. int c = NEED_OTHER;
  189. while (*p != '\0') {
  190. switch (*p) {
  191. case '{':
  192. inskip++;
  193. p++;
  194. continue;
  195. case '}':
  196. if (!inskip) lua_error(L, "unbalanced braces in read pattern");
  197. inskip--;
  198. p++;
  199. continue;
  200. default: {
  201. const char *ep = luaI_classend(L, p); /* get what is next */
  202. int m; /* match result */
  203. if (c == NEED_OTHER) c = getc(f);
  204. m = (c==EOF) ? 0 : luaI_singlematch(c, p, ep);
  205. if (m) {
  206. if (!inskip) luaL_addchar(L, c);
  207. c = NEED_OTHER;
  208. }
  209. switch (*ep) {
  210. case '+': /* repetition (1 or more) */
  211. if (!m) goto break_while; /* pattern fails? */
  212. /* else go through */
  213. case '*': /* repetition (0 or more) */
  214. while (m) { /* reads the same item until it fails */
  215. c = getc(f);
  216. m = (c==EOF) ? 0 : luaI_singlematch(c, p, ep);
  217. if (m && !inskip) luaL_addchar(L, c);
  218. }
  219. /* go through to continue reading the pattern */
  220. case '?': /* optional */
  221. p = ep+1; /* continues reading the pattern */
  222. continue;
  223. default:
  224. if (!m) goto break_while; /* pattern fails? */
  225. p = ep; /* else continues reading the pattern */
  226. }
  227. }
  228. }
  229. } break_while:
  230. if (c != NEED_OTHER) ungetc(c, f);
  231. return (*p == '\0');
  232. }
  233. #else
  234. #define read_pattern(L, f, p) (lua_error(L, "read patterns are deprecated"), 0)
  235. #endif
  236. static int read_number (lua_State *L, FILE *f) {
  237. double d;
  238. if (fscanf(f, "%lf", &d) == 1) {
  239. lua_pushnumber(L, d);
  240. return 1;
  241. }
  242. else return 0; /* read fails */
  243. }
  244. static void read_word (lua_State *L, FILE *f) {
  245. int c;
  246. do { c = fgetc(f); } while (isspace(c)); /* skip spaces */
  247. while (c != EOF && !isspace(c)) {
  248. luaL_addchar(L, c);
  249. c = fgetc(f);
  250. }
  251. ungetc(c, f);
  252. }
  253. #define HUNK_LINE 256
  254. #define HUNK_FILE BUFSIZ
  255. static int read_line (lua_State *L, FILE *f) {
  256. int n;
  257. char *b;
  258. for (;;) {
  259. b = luaL_openspace(L, HUNK_LINE);
  260. if (!fgets(b, HUNK_LINE, f)) return 0; /* read fails */
  261. n = strlen(b);
  262. if (b[n-1] != '\n')
  263. luaL_addsize(L, n);
  264. else {
  265. luaL_addsize(L, n-1); /* do not add the `\n' */
  266. break;
  267. }
  268. }
  269. return 1;
  270. }
  271. static void read_file (lua_State *L, FILE *f) {
  272. size_t n;
  273. do {
  274. char *b = luaL_openspace(L, HUNK_FILE);
  275. n = fread(b, sizeof(char), HUNK_FILE, f);
  276. luaL_addsize(L, n);
  277. } while (n==HUNK_FILE);
  278. }
  279. static int read_chars (lua_State *L, FILE *f, size_t n) {
  280. char *b = luaL_openspace(L, n);
  281. size_t n1 = fread(b, sizeof(char), n, f);
  282. luaL_addsize(L, n1);
  283. return (n == n1);
  284. }
  285. static void io_read (lua_State *L) {
  286. IOCtrl *ctrl = (IOCtrl *)lua_getuserdata(L, lua_getparam(L, 1));
  287. int arg = 2;
  288. FILE *f = getfileparam(L, ctrl, &arg, INFILE);
  289. lua_Object op = lua_getparam(L, arg);
  290. do { /* repeat for each part */
  291. size_t l;
  292. int success;
  293. luaL_resetbuffer(L);
  294. if (lua_isnumber(L, op))
  295. success = read_chars(L, f, (size_t)lua_getnumber(L, op));
  296. else {
  297. const char *p = luaL_opt_string(L, arg, "*l");
  298. if (p[0] != '*')
  299. success = read_pattern(L, f, p); /* deprecated! */
  300. else {
  301. switch (p[1]) {
  302. case 'n': /* number */
  303. if (!read_number(L, f)) return; /* read fails */
  304. continue; /* number is already pushed; avoid the "pushstring" */
  305. case 'l': /* line */
  306. success = read_line(L, f);
  307. break;
  308. case 'a': /* file */
  309. read_file(L, f);
  310. success = 1; /* always success */
  311. break;
  312. case 'w': /* word */
  313. read_word(L, f);
  314. success = 0; /* must read something to succeed */
  315. break;
  316. default:
  317. luaL_argerror(L, arg, "invalid format");
  318. success = 0; /* to avoid warnings */
  319. }
  320. }
  321. }
  322. l = luaL_getsize(L);
  323. if (!success && l==0) return; /* read fails */
  324. lua_pushlstring(L, luaL_buffer(L), l);
  325. } while ((op = lua_getparam(L, ++arg)) != LUA_NOOBJECT);
  326. }
  327. /* }====================================================== */
  328. static void io_write (lua_State *L) {
  329. IOCtrl *ctrl = (IOCtrl *)lua_getuserdata(L, lua_getparam(L, 1));
  330. int arg = 2;
  331. FILE *f = getfileparam(L, ctrl, &arg, OUTFILE);
  332. int status = 1;
  333. lua_Object o;
  334. while ((o = lua_getparam(L, arg)) != LUA_NOOBJECT) {
  335. if (lua_type(L, o)[2] == 'm') { /* nuMber? */ /* LUA_NUMBER */
  336. /* optimization: could be done exactly as for strings */
  337. status = status && fprintf(f, "%.16g", lua_getnumber(L, o)) > 0;
  338. }
  339. else {
  340. size_t l;
  341. const char *s = luaL_check_lstr(L, arg, &l);
  342. status = status && (fwrite(s, sizeof(char), l, f) == l);
  343. }
  344. arg++;
  345. }
  346. pushresult(L, status);
  347. }
  348. static void io_seek (lua_State *L) {
  349. static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
  350. static const char *const modenames[] = {"set", "cur", "end", NULL};
  351. IOCtrl *ctrl = (IOCtrl *)lua_getuserdata(L, lua_getparam(L, 1));
  352. FILE *f = getnonullfile(L, ctrl, 2);
  353. int op = luaL_findstring(luaL_opt_string(L, 3, "cur"), modenames);
  354. long offset = luaL_opt_long(L, 4, 0);
  355. luaL_arg_check(L, op != -1, 3, "invalid mode");
  356. op = fseek(f, offset, mode[op]);
  357. if (op)
  358. pushresult(L, 0); /* error */
  359. else
  360. lua_pushnumber(L, ftell(f));
  361. }
  362. static void io_flush (lua_State *L) {
  363. IOCtrl *ctrl = (IOCtrl *)lua_getuserdata(L, lua_getparam(L, 1));
  364. lua_Object of = lua_getparam(L, 2);
  365. FILE *f = gethandle(L, ctrl, of);
  366. luaL_arg_check(L, f || of == LUA_NOOBJECT, 2, "invalid file handle");
  367. pushresult(L, fflush(f) == 0);
  368. }
  369. /* }====================================================== */
  370. /*
  371. ** {======================================================
  372. ** Other O.S. Operations
  373. ** =======================================================
  374. */
  375. static void io_execute (lua_State *L) {
  376. lua_pushnumber(L, system(luaL_check_string(L, 1)));
  377. }
  378. static void io_remove (lua_State *L) {
  379. pushresult(L, remove(luaL_check_string(L, 1)) == 0);
  380. }
  381. static void io_rename (lua_State *L) {
  382. pushresult(L, rename(luaL_check_string(L, 1),
  383. luaL_check_string(L, 2)) == 0);
  384. }
  385. static void io_tmpname (lua_State *L) {
  386. lua_pushstring(L, tmpnam(NULL));
  387. }
  388. static void io_getenv (lua_State *L) {
  389. lua_pushstring(L, getenv(luaL_check_string(L, 1))); /* if NULL push nil */
  390. }
  391. static void io_clock (lua_State *L) {
  392. lua_pushnumber(L, ((double)clock())/CLOCKS_PER_SEC);
  393. }
  394. static void io_date (lua_State *L) {
  395. char b[256];
  396. const char *s = luaL_opt_string(L, 1, "%c");
  397. struct tm *stm;
  398. time_t t;
  399. time(&t); stm = localtime(&t);
  400. if (strftime(b, sizeof(b), s, stm))
  401. lua_pushstring(L, b);
  402. else
  403. lua_error(L, "invalid `date' format");
  404. }
  405. static void setloc (lua_State *L) {
  406. static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY,
  407. LC_NUMERIC, LC_TIME};
  408. static const char *const catnames[] = {"all", "collate", "ctype", "monetary",
  409. "numeric", "time", NULL};
  410. int op = luaL_findstring(luaL_opt_string(L, 2, "all"), catnames);
  411. luaL_arg_check(L, op != -1, 2, "invalid option");
  412. lua_pushstring(L, setlocale(cat[op], luaL_check_string(L, 1)));
  413. }
  414. static void io_exit (lua_State *L) {
  415. exit(luaL_opt_int(L, 1, EXIT_SUCCESS));
  416. }
  417. /* }====================================================== */
  418. static void io_debug (lua_State *L) {
  419. for (;;) {
  420. char buffer[250];
  421. fprintf(stderr, "lua_debug> ");
  422. if (fgets(buffer, sizeof(buffer), stdin) == 0 ||
  423. strcmp(buffer, "cont\n") == 0)
  424. return;
  425. lua_dostring(L, buffer);
  426. }
  427. }
  428. #define MESSAGESIZE 150
  429. #define MAXMESSAGE (MESSAGESIZE*10)
  430. static void errorfb (lua_State *L) {
  431. char buff[MAXMESSAGE];
  432. int level = 1; /* skip level 0 (it's this function) */
  433. lua_Debug ar;
  434. lua_Object alertfunc;
  435. sprintf(buff, "error: %.200s\n", lua_getstring(L, lua_getparam(L, 1)));
  436. while (lua_getstack(L, level++, &ar)) {
  437. char buffchunk[60];
  438. lua_getinfo(L, "Snl", &ar);
  439. luaL_chunkid(buffchunk, ar.source, sizeof(buffchunk));
  440. if (level == 2) strcat(buff, "stack traceback:\n");
  441. strcat(buff, " ");
  442. if (strlen(buff) > MAXMESSAGE-MESSAGESIZE) {
  443. strcat(buff, "...\n");
  444. break; /* buffer is full */
  445. }
  446. switch (*ar.namewhat) {
  447. case 'g': case 'l': /* global, local */
  448. sprintf(buff+strlen(buff), "function `%.50s'", ar.name);
  449. break;
  450. case 'f': /* field */
  451. sprintf(buff+strlen(buff), "method `%.50s'", ar.name);
  452. break;
  453. case 't': /* tag method */
  454. sprintf(buff+strlen(buff), "`%.50s' tag method", ar.name);
  455. break;
  456. default: {
  457. if (*ar.what == 'm') /* main? */
  458. sprintf(buff+strlen(buff), "main of %.70s", buffchunk);
  459. else if (*ar.what == 'C') /* C function? */
  460. sprintf(buff+strlen(buff), "%.70s", buffchunk);
  461. else
  462. sprintf(buff+strlen(buff), "function <%d:%.70s>",
  463. ar.linedefined, buffchunk);
  464. ar.source = NULL;
  465. }
  466. }
  467. if (ar.currentline > 0)
  468. sprintf(buff+strlen(buff), " at line %d", ar.currentline);
  469. if (ar.source)
  470. sprintf(buff+strlen(buff), " [%.70s]", buffchunk);
  471. strcat(buff, "\n");
  472. }
  473. lua_pushglobaltable(L);
  474. lua_pushstring(L, LUA_ALERT);
  475. alertfunc = lua_rawget(L);
  476. if (lua_isfunction(L, alertfunc)) { /* avoid loop if _ALERT is not defined */
  477. lua_pushstring(L, buff);
  478. lua_callfunction(L, alertfunc);
  479. }
  480. }
  481. static const struct luaL_reg iolib[] = {
  482. {LUA_ERRORMESSAGE, errorfb},
  483. {"clock", io_clock},
  484. {"date", io_date},
  485. {"debug", io_debug},
  486. {"execute", io_execute},
  487. {"exit", io_exit},
  488. {"getenv", io_getenv},
  489. {"remove", io_remove},
  490. {"rename", io_rename},
  491. {"setlocale", setloc},
  492. {"tmpname", io_tmpname}
  493. };
  494. static const struct luaL_reg iolibtag[] = {
  495. {"appendto", io_appendto},
  496. {"closefile", io_close},
  497. {"flush", io_flush},
  498. {"openfile", io_open},
  499. {"read", io_read},
  500. {"readfrom", io_readfrom},
  501. {"seek", io_seek},
  502. {"write", io_write},
  503. {"writeto", io_writeto}
  504. };
  505. static void openwithcontrol (lua_State *L) {
  506. IOCtrl *ctrl = (IOCtrl *)malloc(sizeof(IOCtrl));
  507. unsigned int i;
  508. int ctrltag = lua_newtag(L);
  509. ctrl->iotag = lua_newtag(L);
  510. ctrl->closedtag = lua_newtag(L);
  511. for (i=0; i<sizeof(iolibtag)/sizeof(iolibtag[0]); i++) {
  512. /* put `ctrl' as upvalue for these functions */
  513. lua_pushusertag(L, ctrl, ctrltag);
  514. lua_pushcclosure(L, iolibtag[i].func, 1);
  515. lua_setglobal(L, iolibtag[i].name);
  516. }
  517. /* predefined file handles */
  518. ctrl->file[INFILE] = stdin;
  519. setfile(L, ctrl, stdin, INFILE);
  520. ctrl->file[OUTFILE] = stdout;
  521. setfile(L, ctrl, stdout, OUTFILE);
  522. setfilebyname(L, ctrl, stdin, "_STDIN");
  523. setfilebyname(L, ctrl, stdout, "_STDOUT");
  524. setfilebyname(L, ctrl, stderr, "_STDERR");
  525. /* change file when assigned */
  526. lua_pushusertag(L, ctrl, ctrltag);
  527. lua_pushcclosure(L, atribTM, 1);
  528. lua_settagmethod(L, ctrl->iotag, "setglobal");
  529. /* delete `ctrl' when collected */
  530. lua_pushusertag(L, ctrl, ctrltag);
  531. lua_pushcclosure(L, ctrl_collect, 1);
  532. lua_settagmethod(L, ctrltag, "gc");
  533. }
  534. void lua_iolibopen (lua_State *L) {
  535. luaL_openl(L, iolib);
  536. openwithcontrol(L);
  537. }