libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] Can I get the entire MHD log without depends on C functi


From: silvioprog
Subject: [libmicrohttpd] Can I get the entire MHD log without depends on C function like sprintf()?
Date: Sat, 27 Feb 2016 17:14:59 -0300

Hello,

I'm using MHD in a small application written in Delphi (Pascal), and it is working like a charm. Today I needed to get all generated log from MHD, however it seems that it depends on functions like *sprintf(), but the Pascal Format() function is a little bit different from C, because the Pascal ones use other format style. And the other problem is that Delphi and Free Pascal don't have this function on their RTL, so I did something like:

function vsnprintf_s(buffer: Pcchar; sizeOfBuffer: size_t; count: size_t;
  format: Pcchar; argptr: va_list): cint; cdecl;
  external LIB_NAME name {$IFDEF MSWINDOWS}'_vsnprintf_s'{$ELSE}'vsnprintf_s'{$ENDIF};

procedure ErrorLog(ACls: Pointer; AFmt: Pcchar; AArgs: va_list); cdecl;
var
  S: RawByteString;
  VBuffer: array[0..1024] of AnsiChar;
begin
  SetString(S, VBuffer, vsnprintf_s(VBuffer, SizeOf(VBuffer), Length(VBuffer),
    AFmt, AArgs));
  SetCodePage(S, CP_UTF8, False);
  MyLogger.Append(S);
end;

It works, but it seems a very weird solution, so can I get the entire generated MHD log in a *char? In pure C code, something like:

void error_log(void *cls, char *log) {
  printf("%s", log);
}

Instead of:

void error_log(void *cls, char *fmt, va_list args) {
  vprintf(fmt, args);
}

It would be very useful to the ones that need to get the entire log without depends on C format functions.

Thank you!

--
Silvio Clécio


reply via email to

[Prev in Thread] Current Thread [Next in Thread]