Home - pkoper/gtm-posix GitHub Wiki
This GT.M POSIX Extension tries to deliver possibly the best M interface for a frequently used subset of POSIX functions for date & time, process environment, syslog, file & directory operations, passwd database and system info.
Features
- stringified option names
- octal file mode arguments
- wrapped return value of POSIX functions (M exception)
- POSIX errno as a local variable
Example
GTM>w $$time^posix()
1342948780
GTM>d localtime^posix(.n) zwr n
n("hour")=11
n("isdst")=1
n("mday")=22
n("min")=19
n("mon")=6
n("sec")=40
n("wday")=0
n("yday")=203
n("year")=112
GTM>w $$strftime^posix("%T %F",.n)
11:19:40 2012-07-22
GTM>d clktime^posix("MONOTONIC",.s,.ns) zwr s,ns
s=117932
ns=84340852
GTM>
Local Variables
[errno](/pkoper/gtm-posix/wiki/errno)
Functions
Date & Time
$$time^posix()
, $$mktime^posix(.n)
, localtime^posix(.n,.t)
, gmtime^posix(.n,.t)
, clktime^posix(.clkid,.sec,.nsec)
, clkres^posix(.clkid,.sec,.nsec)
, $$strftime^posix(.fmt,.n)
File & Directory
chmod^posix(.path,.mode)
, chown^posix(.path,.uid,.gid)
, lchown^posix(.path,.uid,.gid)
, unlink^posix(.path)
, link^posix(.oldpath,.newpath)
, symlink^posix(.oldpath,.newpath)
, $$readlink^posix(.path)
, mkdir^posix(.dir,.mode)
, rmdir^posix(.dir)
Directory Contents
$$opendir^posix(.path)
, $$readdir^posix(.dir)
, closedir^posix(.dir)
Recursive
mkpath^posix(.path)
, rmpath^posix(.path)
File Mode
stat^posix(.path,.n)
, lstat^posix(.path,.n)
Tests
$$isreg^posix(.mode)
, $$isdir^posix(.mode)
, $$ischr^posix(.mode)
, $$isblk^posix(.mode)
, $$isfifo^posix(.mode)
, $$islnk^posix(.mode)
, $$issock^posix(.mode)
Utils
$$umask^posix(.mask)
, $$octal^posix(.mode)
Passwd & Groups
getpwnam^posix(.user,.n)
, getpwuid^posix(.id,.n)
, getgrnam^posix(.group,.n)
, getgrgid^posix(.id,.n)
, $$getgrouplist^posix(.user)
Environment
setenv^posix(.name,.value,.overwrite)
, unsetenv^posix(.name)
Syslog
openlog^posix(.ident,.option,.facility)
, syslog^posix(.message,.priority)
System Info
times^posix(.n)
, uname^posix(.n)
, sysinfo^posix(.n)
Error
strerror^posix(e)
Installation
See Makefile for example procedure on compiling and installing. Check GT.M Programmer's Guide: Integrating External Routines for details on external calls.
Bundled libposix.so was compiled for i686 GNU/Linux (Debian 6.0.4) with GCC 4.6.3 and works well with GT.M V5.5-000 Linux x86.
License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
http://www.gnu.org/licenses/agpl.html
See also
For FIS extension on POSIX see http://sourceforge.net/projects/fis-gtm/files/Plugins/posix/. The namespaces of FIS and this extension do not collide, the licensing terms are the same, both of them can be used on one GT.M instance in the same time.