[prelude-cvslog] r10051 - in libprelude/branches/libprelude-easy-bindings/bindings: . swig tests
noreply at prelude-ids.org
noreply at prelude-ids.org
Sat Nov 17 16:59:05 CET 2007
Author: pollux
Date: 2007-11-17 16:58:58 +0100 (Sat, 17 Nov 2007)
New Revision: 10051
Modified:
libprelude/branches/libprelude-easy-bindings/bindings/easy-idmef.cxx
libprelude/branches/libprelude-easy-bindings/bindings/easy-idmef.h
libprelude/branches/libprelude-easy-bindings/bindings/swig/libprelude-easy.i
libprelude/branches/libprelude-easy-bindings/bindings/tests/pooling.py
Log:
Add function Get to IDMEF object.
Modified: libprelude/branches/libprelude-easy-bindings/bindings/easy-idmef.cxx
===================================================================
--- libprelude/branches/libprelude-easy-bindings/bindings/easy-idmef.cxx 2007-11-17 15:25:24 UTC (rev 10050)
+++ libprelude/branches/libprelude-easy-bindings/bindings/easy-idmef.cxx 2007-11-17 15:58:58 UTC (rev 10051)
@@ -1,3 +1,5 @@
+#include <string.h>
+
#include <prelude.h>
#include <idmef-path.h>
#include <idmef-message-print.h>
@@ -17,8 +19,6 @@
IDMEF::IDMEF(idmef_message_t * message)
{
_message = message;
-
- init();
}
int IDMEF::init()
@@ -95,6 +95,42 @@
idmef_path_destroy(path);
}
+char * IDMEF::Get(const char *object)
+{
+ int ret;
+ idmef_path_t *path;
+ idmef_value_t *val = NULL;
+ prelude_string_t * str;
+ char * real_str = NULL;
+
+#ifdef DEBUG
+ fprintf(stderr,"Entering %s\n",__func__);
+#endif
+
+ printf("Getting value: [%s]\n",object);
+
+ ret = idmef_path_new(&path, object);
+ if (ret < 0)
+ return NULL;
+
+ ret = idmef_path_get(path, _message, &val);
+ if (ret < 0) {
+ idmef_path_destroy(path);
+ return NULL;
+ }
+
+ str = idmef_value_get_string(val);
+
+ if (str) {
+ real_str = strdup(prelude_string_get_string(str));
+ }
+
+ idmef_value_destroy(val);
+ idmef_path_destroy(path);
+
+ return real_str;
+}
+
void IDMEF::PrintToStdout(void)
{
int ret;
Modified: libprelude/branches/libprelude-easy-bindings/bindings/easy-idmef.h
===================================================================
--- libprelude/branches/libprelude-easy-bindings/bindings/easy-idmef.h 2007-11-17 15:25:24 UTC (rev 10050)
+++ libprelude/branches/libprelude-easy-bindings/bindings/easy-idmef.h 2007-11-17 15:58:58 UTC (rev 10051)
@@ -27,6 +27,7 @@
idmef_message_t *GetMessage();
int Set(const char *object, const char *value);
+ char * Get(const char *object);
void PrintToStdout(void);
Modified: libprelude/branches/libprelude-easy-bindings/bindings/swig/libprelude-easy.i
===================================================================
--- libprelude/branches/libprelude-easy-bindings/bindings/swig/libprelude-easy.i 2007-11-17 15:25:24 UTC (rev 10050)
+++ libprelude/branches/libprelude-easy-bindings/bindings/swig/libprelude-easy.i 2007-11-17 15:58:58 UTC (rev 10051)
@@ -33,6 +33,7 @@
%newobject ClientProfile::GetTlsClientTrustedCertFilename;
%newobject ClientProfile::GetBackupDirname;
%newobject ClientProfile::GetProfileDirname;
+%newobject Client::Get;
%include easy-prelude-connection-pool.h
%include easy-prelude-client-profile.h
Modified: libprelude/branches/libprelude-easy-bindings/bindings/tests/pooling.py
===================================================================
--- libprelude/branches/libprelude-easy-bindings/bindings/tests/pooling.py 2007-11-17 15:25:24 UTC (rev 10050)
+++ libprelude/branches/libprelude-easy-bindings/bindings/tests/pooling.py 2007-11-17 15:58:58 UTC (rev 10051)
@@ -23,12 +23,22 @@
+
+def handle_alert(idmef):
+ print idmef
+ idmef.PrintToStdout()
+ print idmef.Get("alert.create_time")
+ print idmef.Get("gruik")
+ print idmef.Get("alert.classification.text")
+ idmef.Set("alert.classification.text","blah")
+ print idmef.Get("alert.classification.text")
+
+
import time
while 1:
print "."
idmef = client.ReadIDMEF(1)
if idmef:
- print idmef
- idmef.PrintToStdout()
+ handle_alert(idmef)
time.sleep(2)
More information about the Prelude-cvslog
mailing list