libmicrohttpd
[Top][All Lists]
Advanced

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

[libmicrohttpd] 回复: Re: 回复:Re: Any MHD_ContentReaderCallback Example Cod


From: lingweicai
Subject: [libmicrohttpd] 回复: Re: 回复:Re: Any MHD_ContentReaderCallback Example Code
Date: Mon, 26 Feb 2018 16:09:41 +0800 (CST)

Hi Christian:

Your reply is VERY VERY helpful to me.

THANK you and have a good day:-)

Forrest Lingweicai

-------原始邮件-------

发件人:
Christian Grothoff<address@hidden>
时 间: 2018/02/25 02:35:14
收件人:
lingweicai<address@hidden>
libmicrohttpd<address@hidden>
抄 送:
undefined
主 题:
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
>
>
>
>
>
>
>
>

发自搜狐邮箱客户端








reply via email to

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