Revision: 66544
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 21, 2014 05:09 by lalzy
Initial Code
;;;; Functions that is soley for settings, craeting reading or writhin (defun get_interface_list () "Returns a 2D list of mtu value and interface. First element is the MTU-Value(Integer), rest of the list is the Interface(String)" (let ((output (ext:run-shell-command "netsh interface ipv4 show subinterfaces" :output :stream)) (split nil) (lines '())) (loop for line = (read-line output nil 'eof) until (eq line 'eof) do (setf line (cl-utilities:SPLIT-SEQUENCE #\Space line :remove-empty-subseqs t)) (when line (cond (split (let* ((mtu-value (parse-integer (car line))) (interface (cdr (cdr (cdr (cdr line)))))) (if (listp interface) (setf line (cons mtu-value interface)) (setf line (list mtu-value interface)))) (setf lines (cons line lines))) ((equal (char (car line) 0) #\-) (setf split t)))) ) (reverse lines))) (defun load_settings () "Read the settings file if it exists" (with-open-file (stream "settings.ini" :if-does-not-exist nil) (if stream (loop for line = (read-line stream nil 'eof) until (eq line 'eof) do (setf line (cl-utilities:SPLIT-SEQUENCE #\Space line :remove-empty-subseqs t)) (when line (cond ((equal (car line) "mtu") (setf *mtu* (parse-integer (car (cdr (cdr line)))))) ((equal (car line) "mtub") (setf *mtub* (parse-integer (car (cdr (cdr line)))))) ((equal (car line) "interface") (let ((temp (format nil "~{~a ~}" (cdr (cdr line))))) (setf *interface* (subseq temp 0 (- (length line) 1)))))))) 'None))) (defun create_settings (interface) "Create settings" (setf *mtu* (car interface)) (setf *mtub* (car interface)) (let ((temp (format nil "~{~a ~}" (cdr interface)))) (setf *interface* (subseq temp 0 (- (length temp) 1)))) 'created ;; Write to settings.ini )
Initial URL
Initial Description
Everything that has to do with the settings.ini file.
Initial Title
MTU-Changing program - Settings.lisp
Initial Tags
Initial Language
Lisp