summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cd-tool.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/cd-tool.cpp b/cd-tool.cpp
index fbebf8e..fb17871 100644
--- a/cd-tool.cpp
+++ b/cd-tool.cpp
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: cd-tool.cpp,v 1.46 2005-11-13 13:43:21 pixel Exp $ */
+/* $Id: cd-tool.cpp,v 1.47 2005-12-01 13:26:11 pixel Exp $ */
#define WIP
@@ -362,6 +362,28 @@ struct option long_options[] = {
{0, 0, NULL, 0 }
};
+static Uint32 elf_hash(const unsigned char * name) {
+ Uint32 h = 0, g;
+
+ while (*name) {
+ h = (h << 4) + *name++;
+ if ((g = h & 0xf0000000))
+ h ^= g >> 24;
+ h &= ~g;
+ }
+
+ return h;
+}
+
+static int lua_elf_hash(lua_State * __L) {
+ Lua * L = Lua::find(__L);
+ String t = L->tostring();
+
+ L->push((lua_Number) elf_hash((unsigned char *) t.to_charp()));
+
+ return 1;
+}
+
CODE_BEGINS
/* That's the basic lua starter for non interactive mode */
@@ -389,6 +411,10 @@ Lua * start_basic_lua(void) {
L->push(myprint);
L->setvar();
+ L->push("hash");
+ L->push(lua_elf_hash);
+ L->setvar();
+
Luabasecdtool::pushstatics(L);
return L;