|
From: | lingweicai |
Subject: | [libmicrohttpd] 回复:Re: Any MHD_ContentReaderCallback Example Code |
Date: | Wed, 21 Feb 2018 19:48:02 +0800 (CST) |
Thanks Christian.
Can I create a MHD_response, by the crc callback to print a circleq ( a circle queue,generated with Macro functions /sys/queue.h ), my crc callback is like this :
ssize_t
crc (void *cls, uint64_t pos, char *buf, size_t max)
{
struct circleq_user * cq_user_ptr = cls;
// if last entry, end the crc
if ( cq_user_ptr->entries.cqe_next == (void *) &head )
return MHD_CONTENT_READER_END_OF_STREAM;
// pointer of next entry to assigned to cls
cls = cq_user_ptr->entries.cqe_next ;
// generate buff content
return snprintf (buf, 256,
"<a href=""> cq_user_ptr->user_mem_list_ptr->u_base.u_name ,
cq_user_ptr->user_mem_list_ptr->u_base.u_name
);
}
when my circle-head pointer as the parameter of cls for crc, the above code always print the first entry of my circle queue. Can I assign the next pointer of
"cls = cq_user_ptr->entries.cqe_next ; "
to re-callback the crc ? it looks this does not work. how can I transfer the "next pointer" of my list as the parameter to the next call crc ?
Thanks,
Forrest Ling wei cai.
----- 原始邮件 -----
发件人:Christian Grothoff<address@hidden>
发送时间:2018-02-05 21:58:17
收件人:lingweicai<address@hidden>;libmicrohttpd<address@hidden>
主 题:Re: Any MHD_ContentReaderCallback Example Code
On 02/04/2018 03:19 AM, lingweicai wrote:
> Dear all:
>
> I want to create responses with strings variables, for example , html
> start tag, html title, css, js, head1, content, html end tag , etc.
>
> Can I use this callback function instead of
> MHD_create_response_from_buffer?
In principle you can use MHD_create_response_from_callback() always
instead of _from_buffer, as _from_callback is more general. Whether it
makes sense in your case I cannot judge.
> I have not found any example codes on the callback.
Look here: src/examples/fileserver_example_dirs.c
[Prev in Thread] | Current Thread | [Next in Thread] |