Jump to content

Callback - no external library (dll) required


piccaso
 Share

Recommended Posts

happy to see an libcurl exemple !! tinks a lot Picasso !!

just one question about libcurl.au3

; This Callback function recieves the data downloaded
; it hast to behave exactly like crt's 'fwrite' 

Func _WriteFunc($pFile,$nSize,$nMemb,$pStream)
  ; Do nothing - discard data
   Return $nSize*$nMemb
EndFunc

how we can get data with _WriteFunc ?

I tried with DllStructGetData($pStream,1) but with no success

thinks again

Link to comment
Share on other sites

  • Replies 80
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

that way:

Func _WriteFunc($pFile,$nSize,$nMemb,$pStream)
   $vData = DllStructCreate("byte[" & $nSize*$nMemb & "]",$pStream)
   $data = DllStructGetData($vData,1)
   Return $nSize*$nMemb
EndFunc
:)
just tested now but a get a raw data (hexadecimal format i suppose) with this url http://www.autoitscript.com

some think like this

0000000000000000000000000000000000000000000000000000000000000000020000010000004C48BE773C48BE7718FFC2

77000000000C4ABE77084ABE77044ABE77004ABE77FC49BE77F849BE77F449BE77EC49BE77E449BE77DC49BE77D049BE77C4

49BE77BC49BE77B049BE77AC49BE77A849BE77A449BE77A049BE779C49BE779849BE779449BE779049BE778C49BE778849BE

778449BE778049BE777849BE776C49BE776449BE775C49BE779C49BE775449BE774C49BE774449BE773849BE773049BE7724

49BE771849BE771449BE771049BE770449BE77F048BE77E448BE770904000001000000010000008070000001000000F0F1FF

FF00000000505354000000000000000000000000000000000000000000000000000000000000000000000000000000000000

0000000000000000000000000000000000000050445400000000000000000000000000000000000000000000000000000000

000000000000000000000000000000000000000000000000000000000000000000E0FFC2772000C377FFFFFFFFFFFFFFFFFF

FFFFFF0000000000000000FFFFFFFF00

should i add a conversion function ?

Edited by mary
Link to comment
Share on other sites

Well yes, thats what i would expect from a byte array but there are to many 00's.

I'm having the same odd behaviour here...

When saved to a file (by libcurl internal) everything works fine but i never looked at the content when saving to memory.

i remember a c example of doing that coming with libcurl, i'll have a look at this later...

for now i just saw that i made a terrible mistake in the 'subclassing' stub, i mixed up 2 registers (esp & ebp).

I didn't use ebp in the stub so i guess i'm using ebp from SendMessage API :)

in other words, subclassing probably wont work on any other os build than mine.

I'll fix that first ;)

Edited by piccaso
CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

Ok i did my homework this time and actually read the documentation and wrote the 'subclassing' stub in proposed standard...

I hope that was the last fix :)

Also added a freebasic example of the dll and changed the libcurl to save the file to disk.

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

Ok i did my homework this time and actually read the documentation and wrote the 'subclassing' stub in proposed standard...

I hope that was the last fix :)

Also added a freebasic example of the dll and changed the libcurl to save the file to disk.

Great UDF and examples!!

I will try it for sure.

Thanks

Link to comment
Share on other sites

File size of libcurl_dummy = 0

Output is following:

RETR response: 550

It is according to curl_doc (libcurl/curl_easy_setopt.html):

CALLBACK OPTIONS
...
CURLOPT_WRITEDATA
...
If you're using libcurl as a win32 DLL, you MUST use the CURLOPT_WRITEFUNCTION if you set this option or you will experience crashes.
...

This is fact that Experience crashes...

You are compelled to write file by AutoIt's funcs

The point of world view

Link to comment
Share on other sites

550 means that the server doesn't want you to have it...

I read this but i think (but i don't know) docs are outdated because this worked fine for me with the nt and the win32 dll.

try another url..

The one i used is a speed test file from my isp, its on a public ftp server but maybe they configured it somehow clever :)

the dummy file is fopen'd and fclose'd anyway so thats why there is a 0 byte file...

I'm still trying to make 'download to memory' work - did i hear someone scream? mary? - but this will happen on another day...

did it really 'crash' ?

like rc != 0 ?

if so im wrong ;)

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

filesize after download and size reported by libcurl ($dltotal) are the same as if i download it with firefox and binary identical.

the server reports a size rounded to kb's which does not exactly fit...

is it that what you mean?

is so you can ignore it, thats pretty common... :)

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

No. File size of source and dest have different values.

Source file is received by other ftp client and dest file is received by libcurl.au3 script.

But it works fine - very fast.

I know too that help is created as a result of previous mistakes.

You can see that BOLD word MUST and it does matter, I think.

The point of world view

Link to comment
Share on other sites

No. File size of source and dest have different values.

Source file is received by other ftp client and dest file is received by libcurl.au3 script.

But it works fine - very fast.

well if the size differs it doesn't work fine for me...

I know too that help is created as a result of previous mistakes.

You can see that BOLD word MUST and it does matter, I think.

not sure what you mean, are you referring to CURLOPT_WRITEDATA doc's ?

libcurl is a mystery on its own, i'll probably spend more time on it than i thought...

but for now i'm going to sleep :)

oh, allmost forgot:

can you post which url u used? and os, libcurl version... anything interesting ;)

thanks.

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

oh its a text file, that explains everything :)

CURLOPT_TRANSFERTEXT

A non-zero parameter tells the library to use ASCII mode for ftp transfers, instead of the default binary transfer. For win32 systems it does not set the stdout to binary mode. This option can be usable when transferring text data between systems with different views on certain characters, such as newlines or similar.

libcurl does not do a complete ASCII conversion when doing ASCII transfers over FTP. This is a known limitation/flaw that nobody has rectified. libcurl simply sets the mode to ascii and performs a standard transfer.

i'm definitely to tired to understand that note about the flaw today ;)
CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...