Linking newLISP source/executable and command line options?

Started by fred, March 25, 2009, 06:03:28 AM

Previous topic - Next topic

fred

Is it possible to use command line options like -n when you link a source to an executable using link.lsp?

newdep

#1
You mean for the linked file or while linking the file?
-- (define? (Cornflakes))

fred

#2
For the new file/executable, i don't need startup files and perhaps options for memory sizes.

But i don't think it exists otherwise it would have been documented and i could not find it.

newdep

#3
I cant think of a way to do this...would be a nice option though to do that...
-- (define? (Cornflakes))

Lutz

#4
Just like in any other newLISP script you can use the function 'main-args' to get command-line option into a linked script. E.g. if you link the following as myprog (or myprog.exe):


(println (main-args))
(exit)


and execute myprog, you can do:


myprog a b c

and the program prints (Mac OS X):


("./myprog" "a" "b" "c")

this way your linked program can process its command line options.

newdep

#5
yes thats true Lutz, but you cant supress the use of the init.lsp with it..

or make newlisp http directly..I think that is what fred ment..
-- (define? (Cornflakes))

Lutz

#6
Quotebut you cant supress the use of the init.lsp with it..


programs made with link.lsp do not load init.lsp or .init.lsp



ps: I will add this to the documentation of link.lsp

fred

#7
Thanks all :)

So making a stand-alone executable made with link.lsp has a kind of "-n" option build in.

This is enough for me but what about the other options like -s and -m?

Perhaps if the first line of the included executed code looks like ":-s 4000" it could be processed as command line, adding the first line as a parameter for link, just a thought.

I continue my small steps with newLISP :)

Kazimir Majorinc

#8
He, I just did my first standalone exe with Newlisp. I had no clue it was that easy.



Few questions:



Is it possible to make executables for other OS-es except one I use?



What is the license for distribution?
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

newdep

#9
If you have the binary's it should be possible..



I can give it a try.. ill let you know..
-- (define? (Cornflakes))

newdep

#10
Linking a newlisp.exe under unix creates nicly a executable ;-)



oke here some proof ;-) I first copied the newlisp.exe from windows

to my linux machine..and started the linux newlisp..



newLISP v.10.0.3 on Linux IPv4, execute 'newlisp -h' for more info.



(MAIN)-> (load "link.lsp")

(lambda (orgExe newExeName lispSourceName) (set 'size (first (file-info orgExe)))

 (copy-file orgExe newExeName)

 (set 'buff (pack "ld" size))

 (set 'handle (open newExeName "u"))

 (search handle "@@@@@@@@")

 (write-buffer handle buff 4)

 (set 'buff (read-file lispSourceName))

 (set 'keylen (pack "ld" (length buff)))

 (write-buffer handle keylen 4)

 (seek handle size)

 (set 'buff (encrypt buff (string (length buff))))

 (write-buffer handle buff (length buff))

 (close handle))

(MAIN)-> (link "newlisp.exe" "update.exe" "update.lsp")

true



(set 'X:zeep '("~/prog/nl/progs")) $ ls -al update.exe

-rw-r--r-- 1 X users 225456 2009-03-25 20:34 update.exe

(set 'X:zeep '("~/prog/nl/progs")) $ wine update.exe

** never mind the command-prompt above, that a nerd thing **



+ v1.13 newlisp Updater (Win32)

+ Running version => 10002

+ Found version   => 10003

+ Retrieving file => newlisp-10003-win-gs-128.exe (1005024 Bytes)

+ Download speed  => 200403 Bps

+ Writing file    => C:windowstemp/newlisp-10003-win-gs-128.exe

+ Done...







PS: License issues for distribution, As long as you provide the GNU license

and the source code...(but im not sure if taht should be readable instantly or decoded first ;-)
-- (define? (Cornflakes))

newdep

#11
and here is de delink.lsp for the current 10+ version

(always need to keep track on the coding of Lutz when decoding ;-)





(define (delink orgExe LispSourceName )

 

    ;; open linked newlisp file

    (set 'infile (open orgExe "r"))



    ;; start seeking for the light..

    (seek infile (+ (search infile "for more info.") 15))

    (read-buffer infile buff 4)

    (set 'bin (unpack "ld" buff))

    (read-buffer infile buff 4)

    (set 'code (unpack "ld" buff))

    (seek infile (first bin))

    (read-buffer infile buff (first code))

    (set 'buff (encrypt buff (string (first code))))



    ;; create a new and write-to LispSourcefile

    (set 'outfile (open LispSourceName "w"))

    (write-buffer outfile buff (length buff))

    (close infile)

    (close outfile))







(MAIN)-> (load "delink.lsp")

(lambda (orgExe LispSourceName) (set 'infile (open orgExe "r")) (seek infile (+ (

    search infile "for more info.") 15))

 (read-buffer infile buff 4)

 (set 'bin (unpack "ld" buff))

 (read-buffer infile buff 4)

 (set 'code (unpack "ld" buff))

 (seek infile (first bin))

 (read-buffer infile buff (first code))

 (set 'buff (encrypt buff (string (first code))))

 (set 'outfile (open LispSourceName "w"))

 (write-buffer outfile buff (length buff))

 (close infile)

 (close outfile))

(MAIN)-> (delink "update.exe" "t.t")

true





(MAIN)-> !cat t.t



#!/usr/bin/newlisp

;;-----------------------------------------------------------------

;; A newlisp update script.

;; Checks both official and development release availebility

;; Stores the highest version found. Enjoy, nodep (c) 2004

;;

;; No standard in filenaming for newlisp releases yet so no

;; support for utf8 or other predefined OS types.

;;-----------------------------------------------------------------

..

..

..

..

..
-- (define? (Cornflakes))

Kazimir Majorinc

#12
Works well on Vista 64. And what is delink?
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

newdep

#13
a reverse link.lsp



If you get a linked package you dont see the source code

or if you lost the source code (as i did) you want it back from

the linked package ;-)
-- (define? (Cornflakes))