Jump to content

How to call C function (DLL) with va_list argument?


Recommended Posts

Hi guys!

I'm actually trying to make a wrapper for https://www.gnu.org/software/libmicrohttpd/

Any idea how to call this function with DllCall???

_MHD_EXTERN struct MHD_Daemon *
MHD_start_daemon_va (unsigned int flags,
             uint16_t port,
             MHD_AcceptPolicyCallback apc, void *apc_cls,
             MHD_AccessHandlerCallback dh, void *dh_cls,
             va_list ap);

// or this one
_MHD_EXTERN struct MHD_Daemon *
MHD_start_daemon (unsigned int flags,
          uint16_t port,
          MHD_AcceptPolicyCallback apc, void *apc_cls,
          MHD_AccessHandlerCallback dh, void *dh_cls,
          ...);

Thanks :)

Link to comment
Share on other sites

Hi!

Yes... but No! I already saw all HTTP server topics and I need a... REAL server (notably: handling multipart/form-data to handle file uploads).

This is why I need to wrap this GNU library (that seems rather complete).

I'm in parallel trying to create an AutoIt based web server UDF (and not an executable), but I feel like re-creating the wheel. But, if I can't port GNU microhttpd, I will complete my AutoIt based HTTP server and share it!

Link to comment
Share on other sites

Hello. It seems to be an array of values. I wrote this example to illustrate it better.

Local $tvarlist = DllStructCreate("ptr[3]")
Local $sString="Croacia"
Local $tstring = DllStructCreate("wchar string[" & StringLen($sString) +2 & "]")
$tstring.String =$sString
DllStructSetData($tvarlist, 1, 10, 1)
DllStructSetData($tvarlist, 1, 1856, 2)
DllStructSetData($tvarlist, 1, DllStructGetPtr($tstring), 3)
Local $tOutput = DllStructCreate("wchar Value[1024]")
Local $sString = "Nikola Tesla nació el %ld de julio de %ld en Smiljan, %s."
Local $aCall = DllCall("User32.dll", "int", "wvsprintfW", "ptr", DllStructGetPtr($tOutput), "wstr", $sString, "ptr", DllStructGetPtr($tvarlist))
ConsoleWrite($tOutput.Value & @CRLF)

Saludos

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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