RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Ralf S. Engelschall Root: /v/rpm/cvs Email: r...@rpm5.org Module: rpm Date: 29-Mar-2009 00:13:47 Branch: HEAD Handle: 2009032823134700 Modified files: rpm CHANGES rpm/rpmio rpmlua.c Log: Add RPM Lua function rpm.hostname() Summary: Revision Changes Path 1.2884 +1 -0 rpm/CHANGES 2.66 +19 -0 rpm/rpmio/rpmlua.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.2883 -r1.2884 CHANGES --- rpm/CHANGES 28 Mar 2009 13:45:19 -0000 1.2883 +++ rpm/CHANGES 28 Mar 2009 23:13:47 -0000 1.2884 @@ -1,5 +1,6 @@ 5.2a3 -> 5.2a4: + - rse: add RPM Lua function rpm.hostname() - jbj: fix: handle ./../foo paths correctly (#491388). - jbj: rpmlib: rescusitate splint annotations. - jbj: rpmdb: rescusitate splint annotations. @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmlua.c ============================================================================ $ cvs diff -u -r2.65 -r2.66 rpmlua.c --- rpm/rpmio/rpmlua.c 2 Mar 2009 00:45:55 -0000 2.65 +++ rpm/rpmio/rpmlua.c 28 Mar 2009 23:13:47 -0000 2.66 @@ -1094,6 +1094,24 @@ return 1; } +static int rpm_hostname(lua_State *L) + /*...@globals internalState @*/ + /*...@modifies L, internalState @*/ +{ + char hostname[1024]; + struct hostent *hbn; + char *h; + + (void)gethostname(hostname, sizeof(hostname)); + if ((hbn = gethostbyname(hostname)) != NULL) + h = hbn->h_name; + else + h = "localhost"; + lua_pushstring(L, (const char *)h); + return 1; +} + + /*...@-readonlytrans -nullassign @*/ /*...@observer@*/ /*...@unchecked@*/ static const luaL_reg rpmlib[] = { @@ -1112,6 +1130,7 @@ {"slurp", rpm_slurp}, {"sleep", rpm_sleep}, {"realpath", rpm_realpath}, + {"hostname", rpm_hostname}, {NULL, NULL} }; /*...@=readonlytrans =nullassign @*/ @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org