diff options
Diffstat (limited to 'mfd/bi_system.m4')
-rw-r--r-- | mfd/bi_system.m4 | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/mfd/bi_system.m4 b/mfd/bi_system.m4 index e7eb8449..55bc9a36 100644 --- a/mfd/bi_system.m4 +++ b/mfd/bi_system.m4 @@ -1,3 +1,3 @@ /* This file is part of Mailfromd. -*- c -*- - Copyright (C) 2006, 2007, 2008 Sergey Poznyakoff + Copyright (C) 2006, 2007, 2008, 2009 Sergey Poznyakoff @@ -16,2 +16,3 @@ +#include <sys/utsname.h> #include "strftime.h" @@ -56,2 +57,58 @@ END +/* Interface to the system uname call. + + Format sequences are: + %s sysname + %n nodename + %r release + %v version + %m machine +*/ +MF_DEFUN(uname, STRING, STRING fmt) +{ + struct utsname ubuf; + + uname(&ubuf); + MF_OBSTACK_BEGIN(); + while (*fmt) { + if (*fmt == '%') { + switch (*++fmt) { + case 's': + MF_OBSTACK_GROW(ubuf.sysname, + strlen(ubuf.sysname)); + break; + case 'n': + MF_OBSTACK_GROW(ubuf.nodename, + strlen(ubuf.nodename)); + break; + case 'r': + MF_OBSTACK_GROW(ubuf.release, + strlen(ubuf.release)); + break; + case 'v': + MF_OBSTACK_GROW(ubuf.version, + strlen(ubuf.version)); + break; + case 'm': + MF_OBSTACK_GROW(ubuf.machine, + strlen(ubuf.machine)); + break; + case '%': + MF_OBSTACK_1GROW('%'); + break; + default: + MF_OBSTACK_1GROW('%'); + MF_OBSTACK_1GROW(*fmt); + } + fmt++; + } else { + MF_OBSTACK_1GROW(*fmt); + fmt++; + } + } + MF_OBSTACK_1GROW(0); + MF_RETURN_OBSTACK(); +} +END + MF_INIT |