Re: Tcpdump and getopts

2011-03-06 Thread Alexander Burger
On Sat, Mar 05, 2011 at 05:10:12PM +0100, meingbg wrote:
 symlinks to picolisp and lib.l. Also, since I know of no way of finding out
 the path of the file currently being executed from within picolisp, I made

Does 'file' help in this case? Is suspect rather not. It returns the
path name of the current input file, but this depends of course on how
it was 'load'ed.

 the helper script to find out the path of getopts.l. If there is a standard
 directory structure, it will not be needed. For now, I have included getopts

Yes. As Jose suggested, it could be accessible along the line of
@opt/.../getopts.l.


 hex2 redefined. Perhaps the fact that (pad) also accepts symbols could be
 clarified in the documentation?

Indeed. The reference is wrong here, as it specifies just a 'num'.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Tcpdump and getopts

2011-03-06 Thread meingbg

 Does 'file' help in this case? Is suspect rather not. It returns the

'file' is exactly what I was looking for, but with a set directory structure
the operation itself is not needed.

//meingbg


Re: Tcpdump and getopts

2011-03-05 Thread meingbg

 Hi Meinbg, I'm the current maintainer of the picolisp-addons repo at
 google code, if you want to put your tool in that repo drop me a line,
 I'll have to make some little modifications to accommodate for the
 directory structure and documentation :) (that may still change because
 we haven't set everything in stone)

Sure, go on. If you want to, you could move getopts to it's own file and
(load ) it from tcphex.l, thereby making it possible to use getopts as a
library.

//meingbg


Re: Tcpdump and getopts

2011-03-04 Thread Alexander Burger
Hi meinbg,

 Let's see if this mail gets through:

Yes, perfectly.


 Tcphex is a tcp proxy that gives a realtime hexdump of data sent both ways.
 ...
 All comments appreciated.

Thanks for your contribution! It looks like you did a really good job!
Perhaps you might also want to publish it in the PicoLisp google code
repository?


I must confess that I didn't analyze everything in detail, still allow
me to write some impressions and hints.

tcphex
   I don't understand why that such a helper script is necessary. Don't
   the mechanisms described e.g. in the Scripting chapter of the
   tutorial work? If the PicoLisp script starts with

  #!/usr/bin/picolisp /usr/lib/picolisp/lib.l

   then no additional shell script would be required.

getopts.l
   In a similar way, it seems to me that (getopts) is a little overkill.
   But there are surely situations where it might be extremely useful.

   Using recur/recurse instead of a loop is interesting. I suspect,
   however, that using 'loop' or 'for' would also work.

tcphex.l
   Line 91: (out 2 (prinl (pack (rest
  'prinl' doesn't need 'pack'. It will also directly output nested
  data: (prinl (rest)) would give the same output.

  Also, calling (rest) is not needed. In general, instead of

 (foo (rest))

  it is more efficient to call

 (pass foo)

  because (rest) builds a list which is not needed thereafter. In
  total the above expression would reduce to

 (out 2 (pass prinl))

   Line 155: (let H (tail 2 (cons 0 (chop (hex Num
  The (cons 0 ..) seems to be to guarantee a minimum of two digits
  in the list. Instead, you could use (pad 2 (hex Num)).

   Line 166: (unless (= Success (catch '(NIL) (main) Success))
  I would recommend '==' here instead of '='. This guarantees that
  there is no conflict with some error string Success returned by
  'catch' by some bad chance.

  Even better might be

 (when (catch '(NIL) (nil (main)))

  It is a little shorter, and you would have access to the error
  message returned by 'catch' in the '@' variable.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Tcpdump and getopts

2011-03-04 Thread José Romero
On Fri, 4 Mar 2011 08:59:09 +0100
Alexander Burger a...@software-lab.de wrote:

 Hi meinbg,
=20
  Let's see if this mail gets through:
=20
 Yes, perfectly.
=20
=20
  Tcphex is a tcp proxy that gives a realtime hexdump of data sent
  both ways. ...
  All comments appreciated.
=20
 Thanks for your contribution! It looks like you did a really good job!
 Perhaps you might also want to publish it in the PicoLisp google code
 repository?
=20
=20
Hi Meinbg, I'm the current maintainer of the picolisp-addons repo at
google code, if you want to put your tool in that repo drop me a line,
I'll have to make some little modifications to accommodate for the
directory structure and documentation :) (that may still change because
we haven't set everything in stone)

 [snip]

Cheers,
Jos=C3=A9
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Tcpdump and getopts

2011-03-03 Thread meingbg
On Thu, Mar 3, 2011 at 2:46 PM, dexen deVries dexen.devr...@gmail.com
wrote:
 Your message got cut at that point :-(

 In any case, there is already a rather popular tool named `tcpdump', so
re-
 using this name may lead to poor discoverability via web search.

Thanks. I've changed the name to tcphex.
Let's see if this mail gets through:

Tcphex is a tcp proxy that gives a realtime hexdump of data sent both ways.
The packet also includes a getopts function for processing GNU-style cmdline
arguments.
It's in public domain and written in picolisp.
All comments appreciated.

You can download it in one of the following ways:
wget --no-check-certificate
https://github.com/meingbg/tcphex/tarball/master-O - | tar -xz
git clone g...@github.com:meingbg/tcphex.git
Browse to https://github.com/meingbg/tcphex and click on Downloads

//meingbg