seninha has quit [Remote host closed the connection]
aw- has left #picolisp [#picolisp]
aw- has joined #picolisp
<
aw->
tankf33der: good catch for the host bug
msavoritias has joined #picolisp
rob_w has joined #picolisp
rob_w has quit [Remote host closed the connection]
seninha has joined #picolisp
seninha has quit [Remote host closed the connection]
seninha has joined #picolisp
seninha has quit [Quit: Leaving]
seninha has joined #picolisp
<
tankf33der>
hi all
<
tankf33der>
abu[7]: i have a structure
<
tankf33der>
how to init first field by struct? Never did before. :/
<
abu[7]>
Hi tankf33der!
<
abu[7]>
const uint8_t *pass; So it must be a pointer to a string
<
tankf33der>
or to a list
<
tankf33der>
i meant from list side
<
tankf33der>
==============
<
tankf33der>
i would like pass a list to first arg
<
abu[7]>
It can't be done directly in 'native', needs a call to 'struct'
<
abu[7]>
or a 'malloc' call
<
abu[7]>
'struct' is better
<
tankf33der>
i have a struct already, malloced.
<
abu[7]>
or, even better if you have a string, is (%@ "strdup" ...
<
abu[7]>
yes, but you must store a pointer
<
abu[7]>
"strdup" returns such a pointer, but you must "free" it later. Nasty ...
<
tankf33der>
can i use a list as a source of data?
<
abu[7]>
List of characters, but this is an
*array*, not a *pointer* to an array as you need here
<
abu[7]>
"strdup" gives you a pointer
abu[7] has left #picolisp [#picolisp]
abu[7] has joined #picolisp
<
abu[7]>
Hit Ctrl-D
<
tankf33der>
i seen strdup example somewhere
<
abu[7]>
just found it too
<
abu[7]>
So you pass to native (cons 'P (%@ "strdup" ...
<
abu[7]>
but it needs to be in a separate variable to "free" it later
<
tankf33der>
i know this, i do not understand the middle
<
tankf33der>
i have a string "mike" or a list of bytes (mapcar char (chop "mike"))
<
abu[7]>
The first element in the structure you pass to 'native will be (P . ptr)
<
abu[7]>
(mapcar char is a no-op after 'chop'
<
abu[7]>
I'm wrong with 'P'
<
abu[7]>
it is a pair (sym . cnt)
<
abu[7]>
wrong copy/paste
<
abu[7]>
the line above it: pair (num . cnt)
<
abu[7]>
num is the pointer returned from strdup
<
tankf33der>
how to call strdup ?
<
abu[7]>
(%@ "strdup" 'P "abc def")
<
abu[7]>
gives the pointer
<
abu[7]>
: (struct @ 'S) -> "abc def"
<
tankf33der>
testing.
<
tankf33der>
got a pointer from a list of bytes.
<
abu[7]>
You could use 'byte' in a loop then
<
abu[7]>
no need to convert to char
<
abu[7]>
(buf Buf 100 (for (I . C) Lst (byte (+ Buf I -1) C)) .. Buf ...
<
abu[7]>
Then pass Buf to native as the first number in the struct
<
abu[7]>
No need to "free" then because 'buf' cleans up automatically
<
tankf33der>
but i need to init all 4 args in the struct
<
tankf33der>
will be messy anyway.
<
abu[7]>
(buf A 999 (buf B 999 (buf C 999 (buf D 999 ...
<
tankf33der>
too much.
<
abu[7]>
native cannot do it directly, because it does nit know when to free the things
<
tankf33der>
i understand this a little bit.
<
abu[7]>
So you need 4 pointers to buffers
<
tankf33der>
only two
<
tankf33der>
struct is two pointers and two ints
<
abu[7]>
ah, ok, then better
<
abu[7]>
The loop with 'byte' is overkill
<
abu[7]>
Yoc can use 'B' in a struct
<
tankf33der>
to store a pointer?
<
abu[7]>
no, struct returns the pointer
<
abu[7]>
but to initialize the struct
<
abu[7]>
Let me try
<
abu[7]>
: (buf Ptr 99 (struct Ptr NIL 65 66 67 0) (struct Ptr 'S)) -> "ABC"
<
abu[7]>
If you have a variable list, use 'apply':
<
abu[7]>
(buf Ptr 99 (apply struct (65 66 67 0) Ptr NIL) (struct Ptr 'S))
<
abu[7]>
(let Lst (65 66 67 0) (buf Ptr (length Lst) (apply struct Lst Ptr NIL) (struct Ptr 'S)))
<
tankf33der>
i will use a strdup variation.
<
tankf33der>
with free after all
<
abu[7]>
yes, probably the shortest
<
tankf33der>
abu[7]
<
tankf33der>
is this correct demo code?
<
abu[7]>
'(PtrPass . 8) needs to be evaluated
<
abu[7]>
(cons PtrPass 8)
<
tankf33der>
eh. ok
<
abu[7]>
and, as you said, the "free" calls later
<
tankf33der>
sure. thanks.
<
skyjuice>
Greetings Plispers
<
skyjuice>
@abu[7]:libera.chat what's the checksum for:
<
skyjuice>
(sha256)
<
abu[7]>
skyjuice, What do you mean?
<
abu[7]>
I find sha1
<
abu[7]>
(native "libcrypto.so" "SHA1" '(B . 20) Str (length Str) '(NIL (20)))
<
abu[7]>
sha256 should be analog
<
skyjuice>
I'm would like to verify the integrity of the downloaded file
<
skyjuice>
The output I get from running " sha256sum browser.zip" in the terminal is:
<
skyjuice>
ec14a09b0953b874d358286cbf3e9c82bed03198ad8457faafe710cf7986efc3
<
skyjuice>
Can you confirm that is the correct hash/checksum
<
skyjuice>
* confirm that this is the
<
abu[7]>
Ah, yes. Which file? pil21.tgz ?
<
abu[7]>
Current pil21.tgz is 929051a6704f8c9ec8239e2ac2ef5d57c9c35f29835dd218b54c069c
<
abu[7]>
yes, ec14a09b0953b874d358286cbf3e9c82bed03198ad8457faafe710cf7986efc3
<
tankf33der>
fighting with native, no success
<
tankf33der>
function mono prints garbage
<
abu[7]>
Does not print -1 ? (I have not tried, I'm on a Ukrainian grill party)
<
abu[7]>
(struct Config NIL -1 -1 -1 -1) initializes
*bytes*
<
tankf33der>
a negative number, whose absolute value is stored as an unsigned integer
<
abu[7]>
so it should be 1
<
tankf33der>
garbage
<
abu[7]>
(struct Config '(I I I I)))
<
abu[7]>
(struct Config 'P '(I I I I)))
<
tankf33der>
crashes
<
tankf33der>
all (1 . 8) garbage too
<
tankf33der>
meant (1 . 4)
<
abu[7]>
'(I I I I) should be OK too
<
abu[7]>
printf("%d -> algo\n", config->algorithm);
<
abu[7]>
I think 'config' is a pointer
<
tankf33der>
sure, this is a typo.
<
tankf33der>
it prints (1 1 1 1) when i am fetching values from struct
<
tankf33der>
but prints garbage from C.
<
tankf33der>
lets discuss tomorrow then.
<
abu[7]>
ok, better :)
<
skyjuice>
<abu[7]> "yes, ec14a09b0953b874d358286cbf3..." <- Perfect thx
<
rick42>
aw-: yes, i am old :) | 2023-07-10 <aw-> rick42: !!
<
rick42>
abu[7]: thanks for the pil security notice/update
<
rick42>
(I am catching up here. lol)
<
rick42>
tankf33der: nice catch on the host bug
msavoritias has quit [Remote host closed the connection]
<
abu[7]>
cool rick42! :)