return naNewGhost(c, &naIOGhostType, ghost);
}
+#if SG_NASAL_UNRESTRICTED_OPEN
+// Allows unrestricted file access, which would be a security hole
+// Replaced by the one in flightgear src/Scripting/NasalSys.cxx
static naRef f_open(naContext c, naRef me, int argc, naRef* args)
{
FILE* f;
if(!f) naRuntimeError(c, strerror(errno));
return naIOGhost(c, f);
}
+#endif
// frees buffer before tossing an error
static int getcguard(naContext ctx, FILE* f, void* buf)
return result;
}
+#ifdef _WIN32
+#define S_ISLNK(m) 0
+#define S_ISSOCK(m) 0
+#endif
#ifdef _MSC_VER
#define S_ISREG(m) (((m)&_S_IFMT)==_S_IFREG)
#define S_ISDIR(m) (((m)&_S_IFMT)==_S_IFDIR)
#define S_ISCHR(m) (((m)&_S_IFMT)==_S_IFCHR)
#define S_ISFIFO(m) (((m)&_S_IFMT)==_S_IFIFO)
#define S_ISBLK(m) 0
-#define S_ISLNK(m) 0
-#define S_ISSOCK(m) 0
typedef unsigned short mode_t;
#endif
static naRef ftype(naContext ctx, mode_t m)
naRuntimeError(ctx, strerror(errno));
}
result = naNewVector(ctx);
- naVec_setsize(result, 12);
+ naVec_setsize(ctx, result, 12);
#define FLD(x) naVec_set(result, n++, naNum(s.st_##x));
FLD(dev); FLD(ino); FLD(mode); FLD(nlink); FLD(uid); FLD(gid);
FLD(rdev); FLD(size); FLD(atime); FLD(mtime); FLD(ctime);
{ "seek", f_seek },
{ "tell", f_tell },
{ "flush", f_flush },
+#if SG_NASAL_UNRESTRICTED_OPEN
{ "open", f_open },
+#endif
{ "readln", f_readln },
{ "stat", f_stat },
{ 0 }