libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] Propose api change


From: flavio.ceolin
Subject: Re: [libmicrohttpd] Propose api change
Date: Sun, 25 Oct 2015 20:52:27 -0200

Hi Christian,

It's awesome, thank you for the fast work.

> Hi!
>
> I typically keep the data type 'enum' even if it is a bitmask, as really
> in C we have enum = int, and the type declaration as enum helps the
> reader understand what kind of 'int' we are talking about.  I'd not want
> to loose that.
>
> But, the semantic change, give the pos->kind back instead of 'kind'
> makes a lot of sense, as only then one can really use the bitmask and
> know what kind of header is returned.  So I've changed that bit in SVN
> 36571.  I didn't "&" with 'kind' as pos->kind should really only always
> have one bit set.
>
> Happy hacking!
>
> Christian
>
> On 10/25/2015 10:07 PM, address@hidden wrote:
>> Hi folks,
>> 
>> I've playing around with microhttpd and i think the function
>> MHD_get_connection_values() can be easily improved. This function
>> receives an enum of MHD_ValueKind, so you have to call this function
>> with a kind per time if you need to get different kind of values.
>> 
>> I do not know how we deal with api changes in this project, but i think
>> it would be better if instead of receive an enum it receives an unsigne
>> int, so we could do something like this, MHD_GET_ARGUMENT_KIND |
>> MHD_HEADER_KIND | ...
>> 
>> Follow the patch (any suggestion is valid :))
>> 
>> 
>> Index: src/include/microhttpd.h
>> ===================================================================
>> --- src/include/microhttpd.h (revision 36562)
>> +++ src/include/microhttpd.h (working copy)
>> @@ -1786,7 +1786,7 @@
>>   */
>>  _MHD_EXTERN int
>>  MHD_get_connection_values (struct MHD_Connection *connection,
>> -                           enum MHD_ValueKind kind,
>> +                           unsigned int kind,
>>                             MHD_KeyValueIterator iterator, void 
>> *iterator_cls);
>>  
>>  
>> Index: src/microhttpd/connection.c
>> ===================================================================
>> --- src/microhttpd/connection.c      (revision 36562)
>> +++ src/microhttpd/connection.c      (working copy)
>> @@ -125,7 +125,7 @@
>>   */
>>  int
>>  MHD_get_connection_values (struct MHD_Connection *connection,
>> -                           enum MHD_ValueKind kind,
>> +                           unsigned int kind,
>>                             MHD_KeyValueIterator iterator, void 
>> *iterator_cls)
>>  {
>>    int ret;
>> @@ -140,7 +140,7 @@
>>      ret++;
>>      if ((NULL != iterator) &&
>>          (MHD_YES != iterator (iterator_cls,
>> -                              kind, pos->header, pos->value)))
>> +                              (pos->kind & kind), pos->header, pos->value)))
>>        return ret;
>>        }
>>    return ret;
>> 




reply via email to

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