Re: 回复:Re: Any MHD_ContentReaderCallback Example Code
Hi lingweicai,
As you cannot 'update' cls, just use malloc a
struct MyContext {
struct MyList *head_ptr;
// possibly more stuff here
} *ctx;
and pass 'ctx' as 'cls' instead of passing 'head_ptr' directly.
That way, you can easily update 'head_ptr'.
Happy hacking!
Christian
On 02/21/2018 12:48 PM, lingweicai wrote:
>
> 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,
> "
%s ",
> 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
>
> *发送时间:*2018-02-05 21:58:17
>
> *收件
> 人:*lingweicai ;libmicrohttpd
>
> *主 题:*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
>
>
>
>
>
>
>
>