teddydd has joined #picolisp
rob_w has joined #picolisp
aw- has quit [Quit: Leaving.]
aw- has joined #picolisp
aw- has quit [Ping timeout: 272 seconds]
aw- has joined #picolisp
rob_w has quit [Quit: Leaving]
teddydd has quit [Read error: Connection reset by peer]
<
tankf33der>
Regenaxer: stuck with native
<
tankf33der>
cant get correct hostname
teddydd has joined #picolisp
<
Regenaxer>
How about (host ...)?
<
Regenaxer>
hmm, nonsense
<
Regenaxer>
So gethostname() is a problem?
<
Regenaxer>
Probably with malloc() and (struct)
teddy__ has joined #picolisp
<
Regenaxer>
Or pass a buffer directly and return list of chars
teddydd has quit [Ping timeout: 265 seconds]
<
tankf33der>
what would be first argument?
teddydd has joined #picolisp
<
Regenaxer>
'(C . 1024)
<
tankf33der>
returns "l" "a" "m" "b" "d" "a")
<
tankf33der>
returns a list ("l" "a" "m" "b" "d" "a")
teddy__ has quit [Ping timeout: 255 seconds]
<
Regenaxer>
How about '(H (32 . C)) ?
<
Regenaxer>
Hmm, your version seems ok
<
Regenaxer>
'(H (32 C . 32))
<
tankf33der>
there was a trick to get string from it
<
tankf33der>
because zero ended sequence
<
tankf33der>
already packed.
<
Regenaxer>
yeah, but I don't remember
<
Regenaxer>
We discussed with aw- iirc
<
aw->
im just looking at my code now
<
Regenaxer>
Hi aw-!
<
Regenaxer>
tankf33der, so "lambda" is basically correct?
<
aw->
so what i was doing was using malloc
<
aw->
save the value in there
<
aw->
and then strdup
<
aw->
to get a string
<
Regenaxer>
ah, yes, strdup()
<
Regenaxer>
hmm, what is the best then?
<
Regenaxer>
(make (while (byte H) (link @) (inc 'H] ?
<
Regenaxer>
There must be a more direct way
<
Regenaxer>
wont work
<
Regenaxer>
H is a list, not a pointer
<
Regenaxer>
but a zero byte is not representable
<
aw->
i can paste some of my code
<
Regenaxer>
There must have been such a case
<
Regenaxer>
Isn't an example in src/net.l ?
<
aw->
(let *P (native "@" "malloc" 'N (length Key))
<
aw->
(native "@" "strdup" 'S *P) )
<
aw->
something like that
<
Regenaxer>
lib/net.l
<
Regenaxer>
(host) function
<
Regenaxer>
(struct Host 'S)
<
Regenaxer>
(host) basically does what we need
<
Regenaxer>
(buf Host NI_MAXHOST ...
<
Regenaxer>
gets the pointer
<
aw->
can also use "read" too
<
aw->
(setq Mem (native "@" "malloc" 'N 256)) # 255 (bytes) + 1 (null-byte)
<
aw->
(byte (+ Mem Len) 0) # add a null-byte
<
aw->
(native "@" "read" 'N Fd Mem Len)
<
Regenaxer>
malloc() is not needed if (buf ) is used
<
aw->
something like that
<
aw->
oh yueah im just grabbing stuff from my code all over the place haha
teddy__ has joined #picolisp
<
Regenaxer>
Hmm, how does read work here? Where is Fd from?
teddydd has quit [Read error: Connection reset by peer]
<
tankf33der>
i am using this, now with return check.
<
Regenaxer>
hmm, but the zero byte handling?
<
Regenaxer>
Why not just (in '(hostname) (line T)) ?
<
aw->
Regenaxer: sorry it's only a bit of code
<
Regenaxer>
too slow?
<
Regenaxer>
no problem :)
<
Regenaxer>
I mean is (in '(hostname) too slow?
<
aw->
tankf33der: yes (in '(hostname) ... seems good if you're on *nix
<
Regenaxer>
Otherwise (buf ... (struct) best
<
tankf33der>
zero byte handled
<
tankf33der>
because this code:
<
Regenaxer>
Another try is:
<
Regenaxer>
(buf Host 1024
<
Regenaxer>
(%@ "gethostname" 'I Host 1024)
<
Regenaxer>
(struct Host 'S) ) )
<
tankf33der>
returns a list of bytes: (108 97 109 98 100 97 0)
<
Regenaxer>
(buf ...) is also most efficient
<
tankf33der>
Is buf more efficiant then native?
<
Regenaxer>
buf only alloctes stack space, by decrementing the stack pointer
<
Regenaxer>
So a lot more efficient than (%@ "malloc" .. plus (%@ "free
<
tankf33der>
Than i must switch to it.
<
Regenaxer>
'buf' is new in pil21
<
tankf33der>
now 'buf' in main index
<
tankf33der>
now 'buf' in main index of reference
<
Regenaxer>
missing?
teddy__ has quit [Remote host closed the connection]
teddy__ has joined #picolisp
<
Regenaxer>
oh, missing
<
tankf33der>
also add link to struct for buf too
<
tankf33der>
also add link to struct from buf too
<
Regenaxer>
Which section should 'buf' go to in ref?
<
tankf33der>
where struct and native are
<
Regenaxer>
it is in the area of 'use' and 'let' internally
<
Regenaxer>
buf has not really to do with struct
<
Regenaxer>
It is a local binding
<
tankf33der>
trying call monocypher and libgmp via buf.
<
Regenaxer>
I added docs
<
tankf33der>
I cant use buf if c function requires two or
<
tankf33der>
more arguments.
teddy__ has quit [Read error: Connection reset by peer]
<
Regenaxer>
You can
<
Regenaxer>
(buf P 100 (buf Q 200 ...
<
Regenaxer>
But buf is not needed in all cases, as native can do it too
teddydd has joined #picolisp
teddydd has quit [Ping timeout: 256 seconds]
teddydd has joined #picolisp
teddydd has quit [Ping timeout: 245 seconds]
teddydd has joined #picolisp
olaf_h has joined #picolisp
olaf_h has quit [Client Quit]
teddydd has quit [Ping timeout: 245 seconds]
aw- has quit [Quit: Leaving.]
aw- has joined #picolisp