summaryrefslogtreecommitdiff
path: root/luxio.c
diff options
context:
space:
mode:
Diffstat (limited to 'luxio.c')
-rw-r--r--luxio.c304
1 files changed, 193 insertions, 111 deletions
diff --git a/luxio.c b/luxio.c
index 42a922a..033e9a8 100644
--- a/luxio.c
+++ b/luxio.c
@@ -909,12 +909,16 @@ luxio_rewinddir(lua_State *L) /* 5.1.2 */
return 0;
}
-/**# Working directory *******************************************************/
+/*** Working directory.
+@section workdir
+*/
-/**% chdir
- * retval = chdir(path);
- * retval, errno = chdir(path)
- */
+/*** Change working directory.
+@tparam string path
+@treturn number return value
+@treturn errno errno
+@function chdir
+*/
static int
luxio_chdir(lua_State *L) /* 5.2.1 */
{
@@ -926,11 +930,11 @@ luxio_chdir(lua_State *L) /* 5.2.1 */
return 2;
}
-/**% getcwd
- * retval = getcwd(buf, buflen);
- * path, errno = getcwd()
- * nil, errno = getcwd()
- */
+/*** Get the current working directory.
+@treturn string|nil path or nil on error
+@treturn errno
+@function getcwd
+*/
static int
luxio_getcwd(lua_State *L) /* 5.2.2 */
{
@@ -947,12 +951,16 @@ luxio_getcwd(lua_State *L) /* 5.2.2 */
return 2;
}
-/**# General file creation ***************************************************/
+/*** General file creation.
+@section genfile
+*/
-/**% open
- * fd = open(path, flags[, mode]);
- * fd, errno = open(path, flags[, mode])
- */
+/*** Open and possibly create a file or device.
+@tparam string path
+@tparam number flags
+@tparam[opt] number mode, must be specified if creating.
+@function open
+*/
static int
luxio_open(lua_State *L) /* 5.3.1 */
{
@@ -979,10 +987,10 @@ luxio_open(lua_State *L) /* 5.3.1 */
/* TODO: creat() 5.3.2 */
-/**% umask
- * retval = umask(mask);
- * retval = umask(mask)
- */
+/*** Set file mode creation mask.
+@tparam number mask
+@function umask
+*/
static int
luxio_umask(lua_State *L) /* 5.3.3 */
{
@@ -993,10 +1001,13 @@ luxio_umask(lua_State *L) /* 5.3.3 */
return 1;
}
-/**% link
- * retval = link(existing, new);
- * retval, errno = link(existing, new)
- */
+/*** Make a new name for a file.
+@tparam string existing existing file name
+@tparam string new new file name
+@treturn number return value
+@treturn errno
+@function link
+*/
static int
luxio_link(lua_State *L) /* 5.3.4 */
{
@@ -1009,10 +1020,13 @@ luxio_link(lua_State *L) /* 5.3.4 */
return 2;
}
-/**% symlink
- * retval = symlink(oldpath, newpath);
- * retval, errno = symlink(oldpath, newpath)
- */
+/*** Make a new (symbolic) name for a file.
+@tparam string existing existing file name
+@tparam string new new file name
+@treturn number return value
+@treturn errno
+@function symlink
+*/
static int
luxio_symlink(lua_State *L) /* POSIX.1-2001, Unknown location */
{
@@ -1025,10 +1039,12 @@ luxio_symlink(lua_State *L) /* POSIX.1-2001, Unknown location */
return 2;
}
-/**% readlink
- * retval, target = readlink(path)
- * retval, errno = readlink(path)
- */
+/*** Read value of symlink.
+@tparam string path
+@treturn number return value
+@treturn string|errno value, or errno on error
+@function readlink
+*/
static int
luxio_readlink(lua_State *L) /* POSIX.1-2001, Unknown location */
{
@@ -1046,12 +1062,17 @@ luxio_readlink(lua_State *L) /* POSIX.1-2001, Unknown location */
return 2;
}
-/**# Special file creation ***************************************************/
+/*** Special file creation
+@section specfile
+*/
-/**% mkdir
- * retval = mkdir(pathname, mode);
- * retval, errno = mkdir(pathname, mode)
- */
+/*** Create a directory.
+@tparam string path
+@tparam number mode
+@treturn number return value
+@treturn errno
+@function mkdir
+*/
static int
luxio_mkdir(lua_State *L) /* 5.4.1 */
{
@@ -1064,10 +1085,13 @@ luxio_mkdir(lua_State *L) /* 5.4.1 */
return 2;
}
-/**% mkfifo
- * retval = mkfifo(pathname, mode);
- * retval, errno = mkfifo(pathname, mode)
- */
+/*** Make a FIFO special file (a named pipe)
+@tparam string path
+@tparam number mode
+@treturn number return value
+@treturn errno
+@function mkfifo
+*/
static int
luxio_mkfifo(lua_State *L) /* 5.4.2 */
{
@@ -1080,12 +1104,16 @@ luxio_mkfifo(lua_State *L) /* 5.4.2 */
return 2;
}
-/**# File removal ************************************************************/
+/*** File removal
+@section filerem
+*/
-/**% unlink
- * retval = unlink(pathname);
- * retval, errno = unlink(pathname)
- */
+/*** Delete a name and possibly the file it points to.
+@tparam string path
+@treturn number return value
+@treturn errno
+@function unlink
+*/
static int
luxio_unlink(lua_State *L) /* 5.5.1 */
{
@@ -1097,10 +1125,12 @@ luxio_unlink(lua_State *L) /* 5.5.1 */
return 2;
}
-/**% rmdir
- * retval = rmdir(pathname);
- * retval, errno = rmdir(pathname)
- */
+/*** Delete a directory.
+@tparam string path
+@treturn number return value
+@treturn errno
+@function rmdir
+*/
static int
luxio_rmdir(lua_State *L) /* 5.5.2 */
{
@@ -1112,10 +1142,13 @@ luxio_rmdir(lua_State *L) /* 5.5.2 */
return 2;
}
-/**% rename
- * retval = rename(old, new);
- * retval, errno = rename(old, new)
- */
+/*** Change the name or location of a file.
+@tparam string oldpath
+@tparam string newpath
+@treturn number return value
+@treturn errno
+@function rename
+*/
static int
luxio_rename(lua_State *L) /* 5.5.3 */
{
@@ -1128,7 +1161,27 @@ luxio_rename(lua_State *L) /* 5.5.3 */
return 2;
}
-/**# File characteristics ****************************************************/
+/*** File characteristics
+@section filechar
+*/
+
+/*** stat() information table
+Returned by @{stat} and family.
+@field dev id of device containing file
+@field ino inode of file
+@field mode protection mode
+@field nlink number of links
+@field uid user id of owner
+@field gid group id of owner
+@field rdev device id (if special file)
+@field size total size, in bytes
+@field blksize blocksize for file system I/O
+@field blocks number of blocks allocated
+@atime time of last access
+@mtime time of last modification
+@ctime time of last status change
+@table stat-table
+*/
static void
luxio_push_stat_table(lua_State *L, struct stat *s)
@@ -1156,10 +1209,12 @@ luxio_push_stat_table(lua_State *L, struct stat *s)
#undef PUSH_ENTRY
}
-/**% stat
- * retval = stat(pathname, statbuf);
- * retval, errno = stat(pathname) -- 'errno' can be table containing dev, ino, uid, gid, etc
- */
+/*** Get file status by path.
+@tparam string path
+@treturn number return value
+@treturn errno|stat-table
+@function stat
+*/
static int
luxio_stat(lua_State *L) /* 5.6.2 */
{
@@ -1178,10 +1233,12 @@ luxio_stat(lua_State *L) /* 5.6.2 */
return 2;
}
-/**% fstat
- * retval = fstat(fd, statbuf);
- * retval, errno = fstat(fd) -- 'errno' can be a table containing dev, ino, uid, gid, etc
- */
+/*** Get file status by fd.
+@tparam number fd
+@treturn number return value
+@treturn errno|stat-table
+@function fstat
+*/
static int
luxio_fstat(lua_State *L) /* 5.6.2 */
{
@@ -1200,10 +1257,12 @@ luxio_fstat(lua_State *L) /* 5.6.2 */
return 2;
}
-/**% lstat
- * retval = lstat(pathname, statbuf);
- * retval, errno = lstat(pathname) -- 'errno' can be a table containing dev, ino, uid, gid, etc
- */
+/*** Get symlink status by path.
+@tparam string path to symlink
+@treturn number return value
+@treturn errno|stat-table
+@function lstat
+*/
static int
luxio_lstat(lua_State *L) /* POSIX.1-2001 */
{
@@ -1228,49 +1287,59 @@ luxio_lstat(lua_State *L) /* POSIX.1-2001 */
return 1; \
}
-/**% S_ISREG
- * retval = S_ISREG(m);
- * retval = S_ISREG(m)
- */
+/*** Check status macro S_ISREG for stat mode field.
+@function S_ISREG
+@tparam number mode field from a stat call
+@treturn number
+*/
STAT_IS(REG)
-/**% S_ISDIR
- * retval = S_ISDIR(m);
- * retval = S_ISDIR(m)
- */
-STAT_IS(DIR)
+/*** Check status macro S_ISDIR for stat mode field.
+@function S_ISDIR
+@tparam number mode field from a stat call
+@treturn number
+*/
+ STAT_IS(DIR)
-/**% S_ISCHR
- * retval = S_ISCHR(m);
- * retval = S_ISCHR(m)
- */
+/*** Check status macro S_ISCHR for stat mode field.
+@function S_ISCHR
+@tparam number mode field from a stat call
+@treturn number
+*/
STAT_IS(CHR)
-/**% S_ISBLK
- * retval = S_ISBLK(m);
- * retval = S_ISBLK(m)
- */
+/*** Check status macro S_ISBLK for stat mode field.
+@function S_ISBLK
+@tparam number mode field from a stat call
+@treturn number
+*/
STAT_IS(BLK)
-/**% S_ISFIFO
- * retval = S_ISFIFO(m);
- * retval = S_ISFIFO(m)
- */
+/*** Check status macro S_ISFIFO for stat mode field.
+@function S_ISFIFO
+@tparam number mode field from a stat call
+@treturn number
+*/
STAT_IS(FIFO)
#ifdef S_ISLNK
-/**% S_ISLNK
- * retval = S_ISLNK(m);
- * retval = S_ISLNK(m)
- */
+/*** Check status macro S_ISLNK for stat mode field.
+Not always available.
+@function S_ISLNK
+@tparam number mode field from a stat call
+@treturn number
+*/
STAT_IS(LNK)
#endif
#ifdef S_ISSOCK
-/**% S_ISSOCK
- * retval = S_ISSOCK(m);
- * retval = S_ISSOCK(m)
- */
+/*** Check status macro S_ISSOCK for stat mode field.
+Not always available.
+@function S_ISSOCK
+@tparam number mode field from a stat call
+@treturn number
+*/
+
STAT_IS(SOCK)
#endif
@@ -1278,10 +1347,13 @@ STAT_IS(SOCK)
/* TODO: access() 5.6.3 */
-/**% chmod
- * retval = chmod(path, mode);
- * retval, errno = chmod(path, mode)
- */
+/*** Change permissions of a file.
+@tparam string path
+@tparam number mode
+@treturn number return value
+@treturn errno
+@function chmod
+*/
static int
luxio_chmod(lua_State *L) /* 5.6.4 */
{
@@ -1294,10 +1366,13 @@ luxio_chmod(lua_State *L) /* 5.6.4 */
return 2;
}
-/**% fchmod
- * retval = fchmod(fd, mode);
- * retval, errno = fchmod(fd, mode)
- */
+/*** Change permissions of a file by fd.
+@tparam number fd
+@tparam number mode
+@treturn number return value
+@treturn errno
+@function chmod
+*/
static int
luxio_fchmod(lua_State *L) /* 5.6.4 */
{
@@ -1310,10 +1385,14 @@ luxio_fchmod(lua_State *L) /* 5.6.4 */
return 2;
}
-/**% chown
- * retval = chown(path, owner, group);
- * retval, errno = chown(path, owner, group)
- */
+/*** Change ownership of a file.
+@tparam string path
+@tparam number owner
+@tprarm number group
+@treturn number return value
+@treturn errno
+@function chmod
+*/
static int
luxio_chown(lua_State *L) /* 5.6.5 */
{
@@ -1329,10 +1408,13 @@ luxio_chown(lua_State *L) /* 5.6.5 */
/* TODO: utime() 5.6.6 */
-/**% ftruncate
- * retval = ftruncate(fd, length);
- * retval, errno = ftruncate(fd, length)
- */
+/*** Truncate a file to a specified length.
+@tparam number fd
+@tparamnumber lenght
+@treturn number return value
+@treturn errno
+@function ftruncate
+*/
static int
luxio_ftruncate(lua_State *L) /* 5.6.7 */
{