[cl-net-snmp-cvs] r19 - trunk

ctian at common-lisp.net ctian at common-lisp.net
Fri May 25 07:50:57 UTC 2007


Author: ctian
Date: Fri May 25 03:50:55 2007
New Revision: 19

Added:
   trunk/load.lisp
Removed:
   trunk/scripts.lisp
Modified:
   trunk/asn1.lisp
   trunk/lw-dff.lisp
   trunk/net-snmp-dff.lisp
   trunk/net-snmp.asd
   trunk/net-snmp.h
Log:
clean up eval-whens

Modified: trunk/asn1.lisp
==============================================================================
--- trunk/asn1.lisp	(original)
+++ trunk/asn1.lisp	Fri May 25 03:50:55 2007
@@ -1,34 +1,33 @@
 (in-package :org.net-snmp)
 
-(eval-when (:compile-toplevel :load-toplevel)
-  (defclass oid ()
-    ((name :type string :reader oid-name :initarg :name)
-     (length :type integer :reader oid-length)
-     c-oids
-     c-oid-len))
+(defclass oid ()
+  ((name :type string :reader oid-name :initarg :name)
+   (length :type integer :reader oid-length)
+   c-oids
+   c-oid-len))
 
-  #-lispworks
-  (defmethod shared-initialize :after ((instance oid) slot-names &rest initargs)
-    (declare (ignore slot-names initargs))
-    (with-slots (name length c-oids c-oid-len) instance
-      (progn
-	(setf c-oids (foreign-alloc 'c-oid :count +max-oid-len+)
-	      c-oid-len (foreign-alloc 'c-size-type :initial-element +max-oid-len+))
-	(if (and (> (length name) 0)
-		 (eq (elt name 0) #\.))
-	    (c-read-objid name c-oids c-oid-len)
-	    (c-get-node name c-oids c-oid-len))
-	(setf length (mem-ref c-oid-len 'c-size-type)))))
+#-lispworks
+(defmethod shared-initialize :after ((instance oid) slot-names &rest initargs)
+  (declare (ignore slot-names initargs))
+  (with-slots (name length c-oids c-oid-len) instance
+    (progn
+      (setf c-oids (foreign-alloc 'c-oid :count +max-oid-len+)
+            c-oid-len (foreign-alloc 'c-size-type :initial-element +max-oid-len+))
+      (if (and (> (length name) 0)
+               (eq (elt name 0) #\.))
+          (c-read-objid name c-oids c-oid-len)
+        (c-get-node name c-oids c-oid-len))
+      (setf length (mem-ref c-oid-len 'c-size-type)))))
 
-  #+lispworks
-  (defmethod shared-initialize :after ((instance oid) slot-names &rest initargs)
-    (declare (ignore slot-names initargs))
-    (with-slots (name length c-oids c-oid-len) instance
-      (progn
-	(setf c-oids (fli:allocate-foreign-object :type 'oid :nelems +max-oid-len+)
-	      c-oid-len (fli:allocate-foreign-object :type 'size-t))
-        (read-objid name c-oids c-oid-len)
-	(setf length (fli:dereference c-oid-len))))))
+#+lispworks
+(defmethod shared-initialize :after ((instance oid) slot-names &rest initargs)
+  (declare (ignore slot-names initargs))
+  (with-slots (name length c-oids c-oid-len) instance
+    (progn
+      (setf c-oids (fli:allocate-foreign-object :type 'oid :nelems +max-oid-len+)
+            c-oid-len (fli:allocate-foreign-object :type 'size-t))
+      (read-objid name c-oids c-oid-len)
+      (setf length (fli:dereference c-oid-len)))))
 
 #-lispworks
 (defun snmp-var->value (v)
@@ -55,7 +54,7 @@
     ;; ASN_OCTET_STR
     (#x04
      (fli:convert-from-foreign-string
-       (fli:foreign-slot-value (fli:foreign-slot-pointer v 'val)
-                               'string)
-       :length (fli:foreign-slot-value v 'val-len)))
+      (fli:foreign-slot-value (fli:foreign-slot-pointer v 'val)
+                              'string)
+      :length (fli:foreign-slot-value v 'val-len)))
     (otherwise (fli:foreign-slot-value v 'type))))

Added: trunk/load.lisp
==============================================================================
--- (empty file)
+++ trunk/load.lisp	Fri May 25 03:50:55 2007
@@ -0,0 +1,6 @@
+(in-package :org.net-snmp)
+
+(eval-when (:load-toplevel)
+  (init-snmp "snmpapp")
+  (format t "Net-SNMP Initialized.~%"))
+

Modified: trunk/lw-dff.lisp
==============================================================================
--- trunk/lw-dff.lisp	(original)
+++ trunk/lw-dff.lisp	Fri May 25 03:50:55 2007
@@ -1,33 +1,22 @@
 (in-package :org.net-snmp)
 
-(eval-when (:compile-toplevel :load-toplevel)
-  (fli:define-c-typedef (size-t (:foreign-name "size_t"))
-    (:unsigned :long))
-  (fli:define-c-typedef (u-long (:foreign-name "u_long"))
-    (:unsigned :long))
-  (fli:define-c-typedef (oid (:foreign-name "oid")) u-long)
-
-  (fli:define-foreign-function (init-snmp "init_snmp" :source)
-      ;; Page 32 of FLI Manual
-      ((arg-1 (:reference-pass :ef-mb-string)))
-    :result-type :void
-    :language :ansi-c)
-
-  (fli:define-foreign-function (read-objid "read_objid" :source)
-      ((arg-1 (:reference-pass :ef-mb-string))
-       (arg-2 (:pointer oid))
-       (arg-3 (:pointer size-t)))
-    :result-type :int
-    :language :ansi-c)
-
-  (fli:define-foreign-function (get-node "get_node" :source)
-      ((arg-1 (:reference-pass :ef-mb-string))
-       (arg-2 (:pointer oid))
-       (arg-3 (:pointer size-t)))
-    :result-type :int
-    :language :ansi-c))
-
-(eval-when (:load-toplevel)
-  (init-snmp "snmpapp")
-  (format t "Net-SNMP Initialized.~%"))
+(fli:define-foreign-function (init-snmp "init_snmp" :source)
+    ;; Page 32 of FLI Manual
+    ((arg-1 (:reference-pass :ef-mb-string)))
+  :result-type :void
+  :language :ansi-c)
+
+(fli:define-foreign-function (read-objid "read_objid" :source)
+    ((arg-1 (:reference-pass :ef-mb-string))
+     (arg-2 (:pointer oid))
+     (arg-3 (:pointer size-t)))
+  :result-type :int
+  :language :ansi-c)
+
+(fli:define-foreign-function (get-node "get_node" :source)
+    ((arg-1 (:reference-pass :ef-mb-string))
+     (arg-2 (:pointer oid))
+     (arg-3 (:pointer size-t)))
+  :result-type :int
+  :language :ansi-c)
 

Modified: trunk/net-snmp-dff.lisp
==============================================================================
--- trunk/net-snmp-dff.lisp	(original)
+++ trunk/net-snmp-dff.lisp	Fri May 25 03:50:55 2007
@@ -1,12 +1,17 @@
-#| DATE           : 24 May 2007 
+#| DATE           : 25 May 2007 
  | USER           : binghe 
  | PROCESSED FILE : net-snmp.h
  |#
 
-(in-package :org.net-snmp)
+(in-package "ORG.NET-SNMP")
 
 ;;; Derived from file : "/home/binghe/cl-net-snmp/net-snmp.h"
 
+(fli:define-c-typedef (u-long (:foreign-name "u_long"))
+                      (:unsigned :long))
+(fli:define-c-typedef (size-t (:foreign-name "size_t"))
+                      (:unsigned :long))
+(fli:define-c-typedef (oid (:foreign-name "oid")) u-long)
 (fli:define-c-typedef (u-char (:foreign-name "u_char"))
                       (:unsigned :char))
 (fli:define-c-typedef (u-short (:foreign-name "u_short"))

Modified: trunk/net-snmp.asd
==============================================================================
--- trunk/net-snmp.asd	(original)
+++ trunk/net-snmp.asd	Fri May 25 03:50:55 2007
@@ -16,10 +16,11 @@
   :components ((:file "package")
 	       (:file "constants" :depends-on ("package"))
 	       #-lispworks (:file "typedefs" :depends-on ("constants"))
-               #+lispworks (:file "lw-dff" :depends-on ("package"))
-               #+lispworks (:file "net-snmp-dff" :depends-on ("package"))
+               #+lispworks (:file "net-snmp-dff" :depends-on ("constants"))
+               #+lispworks (:file "lw-dff" :depends-on ("net-snmp-dff"))
+               #+lispworks (:file "load" :depends-on ("lw-dff"))
                #-lispworks (:file "snmp-api" :depends-on ("constants" "typedefs"))
-	       (:file "asn1" :depends-on (#-lispworks "typedefs" #+lispworks "net-snmp-dff"))
+	       (:file "asn1" :depends-on (#-lispworks "typedefs" #+lispworks "load"))
 	       (:file "classes" :depends-on ("asn1"))))
 
 (defsystem sabrina
@@ -29,3 +30,14 @@
   :depends-on (:net-snmp
                :net-telent-date)
   :components ((:file "sabrina")))
+
+(defun make-fli-dff ()
+  (foreign-parser:process-foreign-file "net-snmp.h"
+                                       :dff "net-snmp-dff.lisp"
+                                       :case-sensitive :split-name
+                                       :package :org.net-snmp))
+
+;; (fli:start-collecting-template-info)
+(defun make-fli-templates ()
+  (with-open-file (stream "fli-templates.lisp" :direction :output)
+    (fli:print-collected-template-info :output-stream stream)))

Modified: trunk/net-snmp.h
==============================================================================
--- trunk/net-snmp.h	(original)
+++ trunk/net-snmp.h	Fri May 25 03:50:55 2007
@@ -1,7 +1,6 @@
 typedef unsigned long u_long;
 typedef unsigned long size_t;
 typedef u_long oid;
-
 typedef unsigned char u_char;
 typedef unsigned short u_short;
 typedef unsigned int u_int;



More information about the Cl-net-snmp-cvs mailing list