[Tip for the day] Check the content

Q&A's, tips, howto's
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

[Tip for the day] Check the content

Post by newdep »

This script check on specific IO content inside a script.
If you want a quick overview on the scripts used newlisp functions.
I mainly use it to quickly check what the script contains on
IO functions or systems functions befor executing it with a
load read-file or.....Its though a visual check.. If its a small
script you may not even need this checkup..

Usage:

$check.lsp "http://www.nodep.nl/downloads/newlisp/update.lsp"
$check ./strange.lsp

Code: Select all

#!/usr/bin/newlisp -n
# start newlisp with no init.lsp

# quick check a script!
# newlisp v10+
# This script checks the level of 'use of IO functions'
# 

(setq net '( "delete-url" "get-url" "net-accept" "net-close" "net-connect" "net-error" "net-eval"
"net-interface" "net-listen" "net-local" "net-lookup" "net-peek" "net-peer" "net-ping"
"net-receive" "net-receive-from" "net-receive-udp" "net-select" "net-send" "net-send-to"
"net-send-udp" "net-service" "net-sessions" "post-url" "put-url"))

(setq dev '( "!" "append-file" "change-dir" "close" "command-event" "copy-file" "delete-file" "device"
"directory" "encrypt" "exec" "file-info" "load" "make-dir" "open" "peek" "prompt-event" "read-buffer"
"read-char" "read-file" "read-key" "read-line" "real-path" "remove-dir" "rename-file" "save"
"search" "seek" "source" "write-buffer" "write-char" "write-file" "write-line"))

(setq mem '( "cpymem" "address" "get-char" "get-float" "get-int" "get-long" "get-string" "import"
"abort" "destroy" "exec" "fork" "pipe" "process" "semaphore" "share" "spawn" "sync" "wait-pid"))

(setq FILE (parse (read-file (last (main-args)))))

(define (tab x y)
 (println x (dup " " (- 20 (length x))) y ))

(map (fn(x) (if (> x 0) (tab (net $idx) x))) (count net (intersect FILE net true)))
(map (fn(x) (if (> x 0) (tab (dev $idx) x))) (count dev (intersect FILE dev true)))
(map (fn(x) (if (> x 0) (tab (mem $idx) x))) (count mem (intersect FILE mem true)))

(exit)

-- (define? (Cornflakes))

Locked