1 /* -*- mode: C; indent-tabs-mode: t; tab-width: 8; c-basic-offset: 2; -*- */
4 * This file is part of Seed, the GObject Introspection<->Javascript bindings.
6 * Seed is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 * Seed is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with Seed. If not, see <http://www.gnu.org/licenses/>.
17 * Copyright (C) Robert Carr 2009 <carrr@rpi.edu>
22 #include "../../config.h"
31 #include <sys/utsname.h>
33 #include <sys/types.h>
43 SeedObject os_namespace;
45 #define EXPECTED_EXCEPTION(name, argnum) \
46 seed_make_exception (ctx, exception, "ArgumentError", name " expected " argnum " got %Zd", argument_count); \
47 return seed_make_undefined (ctx);
50 seed_os_realpath (SeedContext ctx,
52 SeedObject this_object,
53 size_t argument_count,
54 const SeedValue arguments[],
55 SeedException * exception)
60 if (argument_count != 1)
62 EXPECTED_EXCEPTION("os.realpath", "1 argument");
64 arg = seed_value_to_string (ctx, arguments[0], exception);
65 ret = realpath(arg, NULL);
68 return seed_value_from_string (ctx, ret, exception);
72 seed_os_chdir (SeedContext ctx,
74 SeedObject this_object,
75 size_t argument_count,
76 const SeedValue arguments[],
77 SeedException * exception)
82 if (argument_count != 1)
84 EXPECTED_EXCEPTION("os.chdir", "1 argument");
86 arg = seed_value_to_string (ctx, arguments[0], exception);
90 return seed_value_from_int (ctx, ret, exception);
94 seed_os_fchdir (SeedContext ctx,
96 SeedObject this_object,
97 size_t argument_count,
98 const SeedValue arguments[],
99 SeedException * exception)
103 if (argument_count != 1)
105 EXPECTED_EXCEPTION("os.fchdir", "1 argument");
107 arg = seed_value_to_int (ctx, arguments[0], exception);
110 return seed_value_from_int (ctx, ret, exception);
114 seed_os_getcwd (SeedContext ctx,
116 SeedObject this_object,
117 size_t argument_count,
118 const SeedValue arguments[],
119 SeedException * exception)
124 if (argument_count != 0)
126 EXPECTED_EXCEPTION("os.getcwd", "no arguments");
128 ret = getcwd (NULL, 0);
129 seed_ret = seed_value_from_string (ctx, ret, exception);
136 seed_os_ctermid (SeedContext ctx,
138 SeedObject this_object,
139 size_t argument_count,
140 const SeedValue arguments[],
141 SeedException * exception)
146 if (argument_count != 0)
148 EXPECTED_EXCEPTION("os.getcwd", "no arguments");
150 // ctermid returns a static buffer
151 ret = ctermid (NULL);
152 seed_ret = seed_value_from_string (ctx, ret, exception);
158 seed_os_getegid (SeedContext ctx,
160 SeedObject this_object,
161 size_t argument_count,
162 const SeedValue arguments[],
163 SeedException * exception)
167 if (argument_count != 0)
169 EXPECTED_EXCEPTION("os.getegid", "no arguments");
173 return seed_value_from_long (ctx, (glong) ret, exception);
177 seed_os_geteuid (SeedContext ctx,
179 SeedObject this_object,
180 size_t argument_count,
181 const SeedValue arguments[],
182 SeedException * exception)
186 if (argument_count != 0)
188 EXPECTED_EXCEPTION("os.geteuid", "no arguments");
192 return seed_value_from_long (ctx, (glong) ret, exception);
196 seed_os_getgid (SeedContext ctx,
198 SeedObject this_object,
199 size_t argument_count,
200 const SeedValue arguments[],
201 SeedException * exception)
205 if (argument_count != 0)
207 EXPECTED_EXCEPTION("os.getgid", "no arguments");
211 return seed_value_from_long (ctx, (glong) ret, exception);
215 seed_os_getuid (SeedContext ctx,
217 SeedObject this_object,
218 size_t argument_count,
219 const SeedValue arguments[],
220 SeedException * exception)
224 if (argument_count != 0)
226 EXPECTED_EXCEPTION("os.getuid", "no arguments");
230 return seed_value_from_long (ctx, (glong) ret, exception);
234 seed_os_getgroups (SeedContext ctx,
236 SeedObject this_object,
237 size_t argument_count,
238 const SeedValue arguments[],
239 SeedException * exception)
246 if (argument_count != 0)
248 EXPECTED_EXCEPTION("os.getgroups", "no arguments");
250 num_groups = getgroups(0, NULL);
251 group_list = g_alloca (num_groups * sizeof(gid_t));
252 groups = g_alloca (num_groups * sizeof(SeedValue));
253 if (getgroups (num_groups, group_list) < 0)
255 // TODO: Decide on how to handle exceptions for things like this...
256 // Investigate python
257 return seed_make_null (ctx);
260 for (i = 0; i < num_groups; i++)
262 groups[i] = seed_value_from_long (ctx, (glong) group_list[i], exception);
264 ret = seed_make_array (ctx, groups, num_groups, exception);
270 seed_os_getlogin (SeedContext ctx,
272 SeedObject this_object,
273 size_t argument_count,
274 const SeedValue arguments[],
275 SeedException * exception)
277 if (argument_count != 0)
279 EXPECTED_EXCEPTION("os.getlogin", "no arguments");
282 return seed_value_from_string (ctx, getlogin(), exception);
286 seed_os_getpgid (SeedContext ctx,
288 SeedObject this_object,
289 size_t argument_count,
290 const SeedValue arguments[],
291 SeedException * exception)
294 if (argument_count != 1)
296 EXPECTED_EXCEPTION("os.getpgid", "1 argument");
298 pid = (pid_t) seed_value_to_long (ctx, arguments[0], exception);
300 return seed_value_from_long (ctx, (glong) getpgid(pid), exception);
304 seed_os_getpgrp (SeedContext ctx,
306 SeedObject this_object,
307 size_t argument_count,
308 const SeedValue arguments[],
309 SeedException * exception)
311 if (argument_count != 0)
313 EXPECTED_EXCEPTION("os.getpgrp", "no arguments");
316 return seed_value_from_long (ctx, (glong) getpgrp(), exception);
320 seed_os_getpid (SeedContext ctx,
322 SeedObject this_object,
323 size_t argument_count,
324 const SeedValue arguments[],
325 SeedException * exception)
327 if (argument_count != 0)
329 EXPECTED_EXCEPTION("os.getpid", "no arguments");
332 return seed_value_from_long (ctx, (glong) getpid(), exception);
336 seed_os_getppid (SeedContext ctx,
338 SeedObject this_object,
339 size_t argument_count,
340 const SeedValue arguments[],
341 SeedException * exception)
343 if (argument_count != 0)
345 EXPECTED_EXCEPTION("os.getppid", "no arguments");
348 return seed_value_from_long (ctx, (glong) getppid(), exception);
352 seed_os_getenv (SeedContext ctx,
354 SeedObject this_object,
355 size_t argument_count,
356 const SeedValue arguments[],
357 SeedException * exception)
361 if (argument_count != 1)
363 EXPECTED_EXCEPTION("os.getenv", "1 arguments");
365 name = seed_value_to_string (ctx, arguments[0], exception);
366 value = getenv (name);
367 ret = seed_value_from_string (ctx, value, exception);
374 seed_os_putenv (SeedContext ctx,
376 SeedObject this_object,
377 size_t argument_count,
378 const SeedValue arguments[],
379 SeedException * exception)
382 gchar *name, *value, *arg;
384 if (argument_count != 2)
386 EXPECTED_EXCEPTION("os.putenv", "2 arguments");
388 name = seed_value_to_string (ctx, arguments[0], exception);
389 value = seed_value_to_string (ctx, arguments[1], exception);
390 arg = g_strconcat (name, "=", value, NULL);
397 return seed_value_from_int (ctx, ret, exception);
402 seed_os_setegid (SeedContext ctx,
404 SeedObject this_object,
405 size_t argument_count,
406 const SeedValue arguments[],
407 SeedException * exception)
411 if (argument_count != 1)
413 EXPECTED_EXCEPTION("os.setegid", "1 argument");
415 arg = seed_value_to_long (ctx, arguments[0], exception);
417 return seed_value_from_int (ctx, setegid(arg), exception);
421 seed_os_setgid (SeedContext ctx,
423 SeedObject this_object,
424 size_t argument_count,
425 const SeedValue arguments[],
426 SeedException * exception)
430 if (argument_count != 1)
432 EXPECTED_EXCEPTION("os.setgid", "1 argument");
434 arg = seed_value_to_long (ctx, arguments[0], exception);
436 return seed_value_from_int (ctx, setgid(arg), exception);
440 seed_os_seteuid (SeedContext ctx,
442 SeedObject this_object,
443 size_t argument_count,
444 const SeedValue arguments[],
445 SeedException * exception)
449 if (argument_count != 1)
451 EXPECTED_EXCEPTION("os.seteuid", "1 argument");
453 arg = seed_value_to_long (ctx, arguments[0], exception);
455 return seed_value_from_int (ctx, seteuid(arg), exception);
459 seed_os_setuid (SeedContext ctx,
461 SeedObject this_object,
462 size_t argument_count,
463 const SeedValue arguments[],
464 SeedException * exception)
468 if (argument_count != 1)
470 EXPECTED_EXCEPTION("os.setuid", "1 argument");
472 arg = seed_value_to_long (ctx, arguments[0], exception);
474 return seed_value_from_int (ctx, setuid(arg), exception);
478 seed_os_strerror (SeedContext ctx,
480 SeedObject this_object,
481 size_t argument_count,
482 const SeedValue arguments[],
483 SeedException * exception)
487 if (argument_count != 1)
489 EXPECTED_EXCEPTION("os.strerror", "1 argument");
491 arg = seed_value_to_int (ctx, arguments[0], exception);
493 return seed_value_from_string (ctx, strerror(arg), exception);
497 seed_os_umask (SeedContext ctx,
499 SeedObject this_object,
500 size_t argument_count,
501 const SeedValue arguments[],
502 SeedException * exception)
506 if (argument_count != 1)
508 EXPECTED_EXCEPTION("os.umask", "1 argument");
510 arg = seed_value_to_long (ctx, arguments[0], exception);
512 return seed_value_from_long (ctx, umask(arg), exception);
516 seed_os_uname (SeedContext ctx,
518 SeedObject this_object,
519 size_t argument_count,
520 const SeedValue arguments[],
521 SeedException * exception)
523 SeedValue elements[5], ret;
527 if (argument_count != 0)
529 EXPECTED_EXCEPTION("os.uname", "no arguments");
532 // TODO: Do something with c
533 elements[0] = seed_value_from_string (ctx, name.sysname, exception);
534 elements[1] = seed_value_from_string (ctx, name.nodename, exception);
535 elements[2] = seed_value_from_string (ctx, name.release, exception);
536 elements[3] = seed_value_from_string (ctx, name.version, exception);
537 elements[4] = seed_value_from_string (ctx, name.machine, exception);
538 ret = seed_make_array (ctx, elements, 5, exception);
546 seed_os_unsetenv (SeedContext ctx,
548 SeedObject this_object,
549 size_t argument_count,
550 const SeedValue arguments[],
551 SeedException * exception)
556 if (argument_count != 1)
558 EXPECTED_EXCEPTION("os.unsetenv", "1 argument");
561 arg = seed_value_to_string (ctx, arguments[0], exception);
562 ret = unsetenv (arg);
565 return seed_value_from_int (ctx, ret, exception);
569 seed_os_open (SeedContext ctx,
571 SeedObject this_object,
572 size_t argument_count,
573 const SeedValue arguments[],
574 SeedException * exception)
579 if (argument_count != 2)
581 EXPECTED_EXCEPTION("os.open", "2 arguments");
584 path = seed_value_to_string (ctx, arguments[0], exception);
585 flags = seed_value_to_int (ctx, arguments[1], exception);
587 ret = open (path, flags);
590 return seed_value_from_int (ctx, ret, exception);
594 seed_os_close (SeedContext ctx,
596 SeedObject this_object,
597 size_t argument_count,
598 const SeedValue arguments[],
599 SeedException * exception)
603 if (argument_count != 1)
605 EXPECTED_EXCEPTION("os.close", "2 arguments");
608 arg = seed_value_to_int (ctx, arguments[0], exception);
610 return seed_value_from_int (ctx, close (arg), exception);
614 seed_os_dup (SeedContext ctx,
616 SeedObject this_object,
617 size_t argument_count,
618 const SeedValue arguments[],
619 SeedException * exception)
623 if (argument_count != 1)
625 EXPECTED_EXCEPTION("os.dup", "1 argument");
628 arg = seed_value_to_int (ctx, arguments[0], exception);
630 return seed_value_from_int (ctx, dup (arg), exception);
633 seed_os_dup2 (SeedContext ctx,
635 SeedObject this_object,
636 size_t argument_count,
637 const SeedValue arguments[],
638 SeedException * exception)
642 if (argument_count != 2)
644 EXPECTED_EXCEPTION("os.dup2", "2 arguments");
647 arg = seed_value_to_int (ctx, arguments[0], exception);
648 arg2 = seed_value_to_int (ctx, arguments[0], exception);
650 return seed_value_from_int (ctx, dup2 (arg, arg2), exception);
654 seed_os_fchmod (SeedContext ctx,
656 SeedObject this_object,
657 size_t argument_count,
658 const SeedValue arguments[],
659 SeedException * exception)
664 if (argument_count != 2)
666 EXPECTED_EXCEPTION ("os.fchmod", "2 arguments");
668 fd = seed_value_to_int (ctx, arguments[0], exception);
669 mode = seed_value_to_long (ctx, arguments[1], exception);
671 return seed_value_from_int (ctx, fchmod (fd, mode), exception);
675 seed_os_fchown (SeedContext ctx,
677 SeedObject this_object,
678 size_t argument_count,
679 const SeedValue arguments[],
680 SeedException * exception)
686 if (argument_count != 3)
688 EXPECTED_EXCEPTION ("os.fchown", "3 arguments");
690 fd = seed_value_to_int (ctx, arguments[0], exception);
691 uid = seed_value_to_long (ctx, arguments[1], exception);
692 gid = seed_value_to_long (ctx, arguments[2], exception);
694 return seed_value_from_int (ctx, fchown (fd, uid, gid), exception);
698 seed_os_fdatasync (SeedContext ctx,
700 SeedObject this_object,
701 size_t argument_count,
702 const SeedValue arguments[],
703 SeedException * exception)
707 if (argument_count != 1)
709 EXPECTED_EXCEPTION ("os.fdatasync", "1 argument");
711 fd = seed_value_to_int (ctx, arguments[0], exception);
713 return seed_value_from_int (ctx, fdatasync (fd), exception);
717 seed_os_fpathconf (SeedContext ctx,
719 SeedObject this_object,
720 size_t argument_count,
721 const SeedValue arguments[],
722 SeedException * exception)
726 if (argument_count != 2)
728 EXPECTED_EXCEPTION ("os.fpathconf", "2 arguments");
730 fd = seed_value_to_int (ctx, arguments[0], exception);
731 name = seed_value_to_int (ctx, arguments[1], exception);
733 return seed_value_from_long (ctx, fpathconf (fd, name), exception);
737 seed_os_fsync (SeedContext ctx,
739 SeedObject this_object,
740 size_t argument_count,
741 const SeedValue arguments[],
742 SeedException * exception)
746 if (argument_count != 1)
748 EXPECTED_EXCEPTION ("os.fsync", "1 argument");
750 fd = seed_value_to_int (ctx, arguments[0], exception);
752 return seed_value_from_long (ctx, fsync (fd), exception);
756 seed_os_ftruncate (SeedContext ctx,
758 SeedObject this_object,
759 size_t argument_count,
760 const SeedValue arguments[],
761 SeedException * exception)
766 if (argument_count != 2)
768 EXPECTED_EXCEPTION ("os.ftruncate", "2 arguments");
770 fd = seed_value_to_int (ctx, arguments[0], exception);
771 length = seed_value_to_int (ctx, arguments[1], exception);
773 return seed_value_from_long (ctx, ftruncate (fd, length), exception);
777 seed_os_isatty (SeedContext ctx,
779 SeedObject this_object,
780 size_t argument_count,
781 const SeedValue arguments[],
782 SeedException * exception)
786 if (argument_count != 1)
788 EXPECTED_EXCEPTION ("os.isatty", "1 argument");
790 fd = seed_value_to_int (ctx, arguments[0], exception);
792 return seed_value_from_boolean (ctx, isatty (fd), exception);
796 seed_os_lseek (SeedContext ctx,
798 SeedObject this_object,
799 size_t argument_count,
800 const SeedValue arguments[],
801 SeedException * exception)
806 if (argument_count != 3)
808 EXPECTED_EXCEPTION ("os.lseek", "3 arguments");
810 fd = seed_value_to_int (ctx, arguments[0], exception);
811 offset = seed_value_to_long (ctx, arguments[1], exception);
812 whence = seed_value_to_int (ctx, arguments[2], exception);
814 return seed_value_from_long (ctx, lseek (fd, offset, whence), exception);
818 seed_os_openpty (SeedContext ctx,
820 SeedObject this_object,
821 size_t argument_count,
822 const SeedValue arguments[],
823 SeedException * exception)
825 SeedValue fds[2], ret;
828 if (argument_count != 0)
830 EXPECTED_EXCEPTION ("os.openpty", "no arguments");
832 openpty (&master, &slave, NULL, NULL, NULL);
834 fds[0] = seed_value_from_int (ctx, master, exception);
835 fds[1] = seed_value_from_int (ctx, slave, exception);
837 ret = seed_make_array (ctx, fds, 2, exception);
843 seed_os_pipe (SeedContext ctx,
845 SeedObject this_object,
846 size_t argument_count,
847 const SeedValue arguments[],
848 SeedException * exception)
850 SeedValue fds[2], ret;
853 if (argument_count != 0)
855 EXPECTED_EXCEPTION ("os.pipe", "no arguments");
857 if (pipe (fildes) < 0)
862 fds[0] = seed_value_from_int (ctx, fildes[0], exception);
863 fds[1] = seed_value_from_int (ctx, fildes[1], exception);
865 ret = seed_make_array (ctx, fds, 2, exception);
871 seed_os_read (SeedContext ctx,
873 SeedObject this_object,
874 size_t argument_count,
875 const SeedValue arguments[],
876 SeedException * exception)
882 if (argument_count != 2)
884 EXPECTED_EXCEPTION ("os.read", "2 arguments");
886 fd = seed_value_to_int (ctx, arguments[0], exception);
887 n = seed_value_to_int (ctx, arguments[1], exception);
889 buf = g_alloca (n * sizeof (gchar));
890 nr = read (fd, buf, n);
894 ret = seed_value_from_string (ctx, buf, exception);
896 ret = seed_make_null (ctx);
902 seed_os_write (SeedContext ctx,
904 SeedObject this_object,
905 size_t argument_count,
906 const SeedValue arguments[],
907 SeedException * exception)
912 if (argument_count != 2)
914 EXPECTED_EXCEPTION ("os.write", "2 arguments");
916 fd = seed_value_to_int (ctx, arguments[0], exception);
917 buf = seed_value_to_string (ctx, arguments[1], exception);
919 nw = write (fd, buf, strlen (buf));
921 return seed_value_from_int (ctx, nw, exception);
925 seed_os_ttyname (SeedContext ctx,
927 SeedObject this_object,
928 size_t argument_count,
929 const SeedValue arguments[],
930 SeedException * exception)
934 if (argument_count != 1)
936 EXPECTED_EXCEPTION ("os.ttyname", "1 argument");
938 fd = seed_value_to_int (ctx, arguments[0], exception);
940 return seed_value_from_string (ctx, ttyname (fd), exception);
944 seed_os_tcgetpgrp (SeedContext ctx,
946 SeedObject this_object,
947 size_t argument_count,
948 const SeedValue arguments[],
949 SeedException * exception)
953 if (argument_count != 1)
955 EXPECTED_EXCEPTION ("os.tcgetpgrp", "1 argument");
957 fd = seed_value_to_int (ctx, arguments[0], exception);
959 return seed_value_from_long (ctx, tcgetpgrp (fd), exception);
963 seed_os_tcsetpgrp (SeedContext ctx,
965 SeedObject this_object,
966 size_t argument_count,
967 const SeedValue arguments[],
968 SeedException * exception)
973 if (argument_count != 2)
975 EXPECTED_EXCEPTION ("os.tcsetpgrp", "2 arguments");
977 fd = seed_value_to_int (ctx, arguments[0], exception);
978 pgrp = seed_value_to_int (ctx, arguments[1], exception);
980 return seed_value_from_int (ctx, tcsetpgrp (fd, pgrp), exception);
984 seed_os_access (SeedContext ctx,
986 SeedObject this_object,
987 size_t argument_count,
988 const SeedValue arguments[],
989 SeedException * exception)
995 if (argument_count != 2)
997 EXPECTED_EXCEPTION ("os.access", "2 arguments");
999 path = seed_value_to_string (ctx, arguments[0], exception);
1000 amd = seed_value_to_int (ctx, arguments[1], exception);
1002 ret = access (path, amd);
1005 return seed_value_from_boolean (ctx, TRUE, exception);
1007 return seed_value_from_boolean (ctx, FALSE, exception);
1011 seed_os_fork (SeedContext ctx,
1012 SeedObject function,
1013 SeedObject this_object,
1014 gsize argument_count,
1015 const SeedValue arguments[],
1016 SeedException *exception)
1020 return seed_value_from_long (ctx, t, exception);
1023 seed_static_function os_funcs[] = {
1024 {"fork", seed_os_fork, 0},
1025 {"realpath", seed_os_realpath, 0},
1026 {"chdir", seed_os_chdir, 0},
1027 {"fchdir", seed_os_fchdir, 0},
1028 {"getcwd", seed_os_getcwd, 0},
1029 {"ctermid", seed_os_ctermid, 0},
1030 {"getegid", seed_os_getegid, 0},
1031 {"geteuid", seed_os_geteuid, 0},
1032 {"getgid", seed_os_getgid, 0},
1033 {"getuid", seed_os_getuid, 0},
1034 {"getlogin", seed_os_getlogin, 0},
1035 {"getpgid", seed_os_getpgid, 0},
1036 {"getpgrp", seed_os_getpgrp, 0},
1037 {"getpid", seed_os_getpid, 0},
1038 {"getppid", seed_os_getuid, 0},
1039 {"getenv", seed_os_getenv, 0},
1040 {"putenv", seed_os_putenv, 0},
1041 {"setegid", seed_os_setegid, 0},
1042 {"setgid", seed_os_setegid, 0},
1043 {"seteuid", seed_os_setegid, 0},
1044 {"setuid", seed_os_setuid, 0},
1045 {"strerror", seed_os_strerror, 0},
1046 {"umask", seed_os_umask, 0},
1047 {"uname", seed_os_uname, 0},
1048 {"unsetenv", seed_os_unsetenv, 0},
1049 {"open", seed_os_open, 0},
1050 {"close", seed_os_close, 0},
1051 {"dup", seed_os_dup, 0},
1052 {"dup2", seed_os_dup2, 0},
1053 {"fchmod", seed_os_fchmod, 0},
1054 {"fchown", seed_os_fchown, 0},
1055 {"fdatasync", seed_os_fdatasync, 0},
1056 {"fpathconf", seed_os_fpathconf, 0},
1057 {"fsync", seed_os_fsync, 0},
1058 {"ftruncate", seed_os_ftruncate, 0},
1059 {"isatty", seed_os_isatty, 0},
1060 {"lseek", seed_os_lseek, 0},
1061 {"openpty", seed_os_openpty, 0},
1062 {"pipe", seed_os_pipe, 0},
1063 {"read", seed_os_read, 0},
1064 {"write", seed_os_write, 0},
1065 {"ttyname", seed_os_ttyname, 0},
1066 {"tcgetpgrp", seed_os_tcgetpgrp, 0},
1067 {"tcsetpgrp", seed_os_tcsetpgrp, 0},
1068 {"access", seed_os_access, 0}
1071 #define OS_DEFINE_ENUM(name, value) \
1072 seed_object_set_property (eng->context, os_namespace, name, \
1073 seed_value_from_long (eng->context, value, NULL))
1074 #define OS_DEFINE_QUICK_ENUM(value) \
1075 seed_object_set_property (eng->context, os_namespace, #value, \
1076 seed_value_from_long (eng->context, value, NULL)) \
1079 seed_module_init(SeedEngine * eng)
1081 SeedClass os_namespace_class;
1082 seed_class_definition os_namespace_class_definition = seed_empty_class;
1084 os_namespace_class_definition.static_functions = os_funcs;
1085 os_namespace_class = seed_create_class (&os_namespace_class_definition);
1087 os_namespace = seed_make_object (eng->context, os_namespace_class, NULL);
1089 OS_DEFINE_QUICK_ENUM (O_RDONLY);
1090 OS_DEFINE_QUICK_ENUM (O_WRONLY);
1091 OS_DEFINE_QUICK_ENUM (O_RDWR);
1092 OS_DEFINE_QUICK_ENUM (O_APPEND);
1093 OS_DEFINE_QUICK_ENUM (O_CREAT);
1094 OS_DEFINE_QUICK_ENUM (O_EXCL);
1095 OS_DEFINE_QUICK_ENUM (O_TRUNC);
1097 #if defined (O_DSYNC)
1098 OS_DEFINE_QUICK_ENUM (O_DSYNC);
1100 #if defined (O_RSYNC)
1101 OS_DEFINE_QUICK_ENUM (O_RSYNC);
1104 OS_DEFINE_QUICK_ENUM (O_SYNC);
1105 OS_DEFINE_QUICK_ENUM (O_NDELAY);
1106 OS_DEFINE_QUICK_ENUM (O_NONBLOCK);
1107 OS_DEFINE_QUICK_ENUM (O_NOCTTY);
1108 // OS_DEFINE_QUICK_ENUM (O_SHLOCK);
1109 // OS_DEFINE_QUICK_ENUM (O_EXLOCK);
1111 OS_DEFINE_QUICK_ENUM (O_ASYNC);
1112 #if defined (O_DIRECT)
1113 OS_DEFINE_QUICK_ENUM (O_DIRECT);
1115 OS_DEFINE_QUICK_ENUM (O_DIRECTORY);
1116 OS_DEFINE_QUICK_ENUM (O_NOFOLLOW);
1117 #if defined (O_NOATIME)
1118 OS_DEFINE_QUICK_ENUM (O_NOATIME);
1121 OS_DEFINE_QUICK_ENUM (SEEK_SET);
1122 OS_DEFINE_QUICK_ENUM (SEEK_CUR);
1123 OS_DEFINE_QUICK_ENUM (SEEK_END);
1125 OS_DEFINE_QUICK_ENUM (F_OK);
1126 OS_DEFINE_QUICK_ENUM (R_OK);
1127 OS_DEFINE_QUICK_ENUM (W_OK);
1128 OS_DEFINE_QUICK_ENUM (X_OK);
1130 return os_namespace;