Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - Dmi

#81
try to run following code:
(set 'host "127.0.0.1" 'port 64001)
(do-until socket
  (set 'socket (net-connect host port)))
(if (and socket (net-receive socket 'str 512))
  (begin
    (print "connected> " str)
    (do-while (net-send socket (append (read-line) "n"))
      (sleep 1)
      (while (!= (net-peek socket) 0)
        (begin
          (net-receive socket 'str 512)
          (print "got: " str)))
      (print "eval: "))))
(exit)

and, while it is running, try to start newlisp-tk on the same host.

If program above exits silently, try again several times.

If program gives "eval:" prompt, then you gain "newlisp -p" instance started by newlisp-tk:

Try to write lisp expressions...

And check newlisp-tk window - it sucks now.



I can gain shell about 1 of 3-5 tryes...



Problem analysis:

When newlisp-tk starting, it run newlisp -p 64001, then trying to connect to it.

There is some time between newlisp start listen and newlisp-tk send connect to it.

Quite fast malicous program can (statistically) gain race with newlisp-tk.



I think this isn't good... And... it is remotely exploitable too!

I think this functionality must have a strict user authorization (but not by plain passwords ;-) Possible, using randomly generated cookie, known by newlisp and it's client (like X11 magic-cookie) will be sufficient.



But... I think domain sockets will be more useful ;-)
#82
Anything else we might add? / better awk
August 19, 2005, 04:16:43 PM
I wrote a small context to imitate awk operation

here is example:
(awk (read-file "/etc/passwd")
  (set 'FS ":")
  (rawk S
    ("^ro" (println (F 0) " " (F 2)))
    ("^daem" (println (F 2) " " (F 0)))))

is analog for:
$ awk -F: '
/^ro/{print $1,$3}
/^daem/{print $3,$1}
' /etc/passwd

here is the origin:

http://en.feautec.pp.ru/SiteNews/awklsp">//http://en.feautec.pp.ru/SiteNews/awklsp
#83
newLISP and the O.S. / debian package for newLisp
August 05, 2005, 01:47:39 PM
You can find "debian" directory for packaging newLisp to .deb at

http://en.feautec.pp.ru/SiteNews/NewLispDebian">//http://en.feautec.pp.ru/SiteNews/NewLispDebian

Instructions about packaging are in the package's README.Debian file
#84
Anything else we might add? / memory allocation
August 03, 2005, 04:26:07 PM
I got a list about 6000 complex elements into memory
(set 'd (read-db "filename"))
and got 15M of memory allocated by newlisp.

then I transform "d" as follows:
(set 'd (convert-db d))
Finally I got about 2000 transformed (and reduced) items in d,

but newlisp allocates 30M now!

All code and executing was done in separate context. I save this context to be sure, that no lost symbols are there.

As I can see, following subsequent caslls to mentioned (convert-db) does not cause newlisp size growing - so allocated space is reused properly.



But can newlisp dynamically reduce the size it allocated? And when?
#85
Anything else we might add? / newLisp for Symbian?
August 03, 2005, 08:50:29 AM
Is there a such thing?

Or does someone has researched possibility of port?
#86
Anything else we might add? / iteration filter
July 31, 2005, 06:03:46 PM
Is there a way to simplify construction like such:
(push
  (let (s nil)
    (until (set 's (some-func)))
    s)
  db)

(push ... db) - is only envelope for example: say, I want to repeatedly got values and push only non-nil ones.



Is there a standard way to do that? Something like
(push (until (some-func)) db)
Or is there a way to write macro for such thing?

Or is it a wrong lispish style? ;-)
#87
Anything else we might add? / unix domain sockets
July 20, 2005, 03:41:46 PM
Lutz!

What about net-listen for af_unix - file-based sockets?

Is there a way to use AF_UNIX domain in net-* functions?

I need to play with syslog-like technics...



Probably I could reproduce a copy of nl-sock.c but for AF_UNIX domain.

But perhaps there is something already?
#88
Anything else we might add? / JSON parser
July 20, 2005, 08:04:06 AM
I wrote a parser for JSON data language http://www.crockford.com/JSON">//http://www.crockford.com/JSON.

Of course, on newLisp :-)



I'am a novice in newLisp, so I can't guess about a quality of code.

Source is downloadable here: http://en.feautec.pp.ru/SiteNews/JSONParser">//http://en.feautec.pp.ru/SiteNews/JSONParser



BTW, the size is comparable to perl one! :-)
#89
Does "length" - function for a list pre-knows it's size, or it iterates through all list elements?

In another words - is length function quite fast?
#90
Possible it would be nice to have in native library post-increment versions of (inc) and (dec), which will return value as was before incrementing?

Something like:
(define (inc-p symb num)
  (let (old (eval symb))
    (if num (inc symb num) (inc symb))
    old))

> (setq i 2)
2
> (inc-p 'i)
2
> i
3
#91
newLisp avoids a garbage collection by nice way - use copying of values in assignments and function calls.

But copying of values is not sufficient to serve real programming needs - and so, we have "contexts" techinics in newLisp, that allows passing by reference.



But, if contexts are subject of dynamic creation and referencing, then they are also the subject of garbage collection!



I'll explain: Suppose, I want to build tree of objects. So, each object will be in separate context, and some of it's variables will contains contexts, holding other objects.

So, I load such tree from somewhere, then found subtree, that I'm interesting for, got the reference to it's root object and then want to destroy whole tree and save interesting subtree for later usage.



With garbage collection I simply will not be worry about that.

But in newLisp I must explicitly copy my subtree to new objects, because the fact of referencing will not protect my objects from destroing.



Possible, here is a point to improvement?
#92
Anything else we might add? / make new context
July 08, 2005, 02:15:11 PM
Is (make-new) function in chapter "contexts as prototypes" is reserved word?

That follows from text explanations. But what "side effect" present? - It looks like regular function in followed code.[/url][/u]
#93
I trying to replace one symbol in a list-tree with another symbol or list.

Code in the subject not really works because "ref" returns list, but "nth-set" wants plain sequence of numbers.

Will pop & push be an equivalent?

What is the best way to replace _all_ occurencies of "token1" in list-tree?



Thanks.
#94
> (set 'q '(a b))
(a b)
> (q 1)
b
> (q 2)
b

but from last call I expect "nil" or something similar.

Does I wrong?

I want a list where last few elements will be optional (all together).

Can I know (through one operator) is such element presents in list and (if present) got its value?



Thanks.
#95
Hello!

I'm new to lisp and newLisp - sorry if that's quite stupid ;)

Can I return a list from a function as element-by-element, without collecting it to the temporary variable? And is it have a sense?



To enumerate network interfaces I wrote such thing:
# analog to: /sbin/ifconfig|awk '/^[[:alpha:]]/{print $1}'
(define (if-list)
  (set 'iflist (list))
  (dolist (str (exec "/sbin/ifconfig"))
    (if (find "^[[:alpha:]][[:alnum:]]+" str 0)
      (set 'iflist (append iflist (list $0)))))
  iflist)

Can I somehow remove "iflist" from code?

Possible there is a better way for such tasks?