Re: problem with ap_md5 in custom module

2012-08-16 Thread nik600
Great! this fix the problem

thanks for your help.

On Wed, Aug 15, 2012 at 10:47 PM, Ben Noordhuis  wrote:
> On Wed, Aug 15, 2012 at 5:13 PM, nik600  wrote:
>> Dear all
>>
>> i'm having a problem with ap_md5, i just want to write a custom module
>> that compute che md5 checksum of the requested url and give it back to
>> the user.
>>
>> This is my code:
>> *
>> *
>> static int kcache_handler(request_rec* r)
>> {
>> if (!r->handler || strcmp(r->handler, "kcache"))
>> return DECLINED;
>>
>> if (r->method_number != M_GET)
>> return HTTP_METHOD_NOT_ALLOWED;
>>
>> char* kcache_md5;
>> kcache_md5 = (char *)ap_md5(r->pool,r->unparsed_uri);
>>
>> ap_set_content_type(r, "text/html;charset=ascii");
>> ap_rputs("", r);
>> ap_rputs("K-Hello World!", r);
>> ap_rprintf(r,"K-Hello
>> World!%s=%s", r->unparsed_uri,kcache_md5);
>> return OK;
>> }
>> *
>> *
>>
>> i've got a warning during compilation:
>>
>> src/mod_kcache.c:18:15: warning: cast to pointer from integer of
>> different size [-Wint-to-pointer-cast]
>>
>> Is quite strange to me that ap_md5 returns an int, as in the
>> documentation it is reported to return a char *
>>
>> http://ci.apache.org/projects/httpd/trunk/doxygen/group__APACHE__CORE__MD5.html
>>
>> By the way, if i try to run it i get a segfault, if i comment the line
>> that prints kcache_md5 with   ap_rprintf the module doesn't segfault.
>>
>> So, where i'm wrong?
>
> It seems you don't include util_md5.h so the compiler defaults the
> function prototype to `int ap_md5()`. Compile with -Wall -Wextra and
> you'll get warnings about things like that.



-- 
/*/
nik600
http://www.kumbe.it


Re: problem with ap_md5 in custom module

2012-08-15 Thread Ben Noordhuis
On Wed, Aug 15, 2012 at 5:13 PM, nik600  wrote:
> Dear all
>
> i'm having a problem with ap_md5, i just want to write a custom module
> that compute che md5 checksum of the requested url and give it back to
> the user.
>
> This is my code:
> *
> *
> static int kcache_handler(request_rec* r)
> {
> if (!r->handler || strcmp(r->handler, "kcache"))
> return DECLINED;
>
> if (r->method_number != M_GET)
> return HTTP_METHOD_NOT_ALLOWED;
>
> char* kcache_md5;
> kcache_md5 = (char *)ap_md5(r->pool,r->unparsed_uri);
>
> ap_set_content_type(r, "text/html;charset=ascii");
> ap_rputs("", r);
> ap_rputs("K-Hello World!", r);
> ap_rprintf(r,"K-Hello
> World!%s=%s", r->unparsed_uri,kcache_md5);
> return OK;
> }
> *
> *
>
> i've got a warning during compilation:
>
> src/mod_kcache.c:18:15: warning: cast to pointer from integer of
> different size [-Wint-to-pointer-cast]
>
> Is quite strange to me that ap_md5 returns an int, as in the
> documentation it is reported to return a char *
>
> http://ci.apache.org/projects/httpd/trunk/doxygen/group__APACHE__CORE__MD5.html
>
> By the way, if i try to run it i get a segfault, if i comment the line
> that prints kcache_md5 with   ap_rprintf the module doesn't segfault.
>
> So, where i'm wrong?

It seems you don't include util_md5.h so the compiler defaults the
function prototype to `int ap_md5()`. Compile with -Wall -Wextra and
you'll get warnings about things like that.


problem with ap_md5 in custom module

2012-08-15 Thread nik600
Dear all

i'm having a problem with ap_md5, i just want to write a custom module
that compute che md5 checksum of the requested url and give it back to
the user.

This is my code:
*
*
static int kcache_handler(request_rec* r)
{
if (!r->handler || strcmp(r->handler, "kcache"))
return DECLINED;

if (r->method_number != M_GET)
return HTTP_METHOD_NOT_ALLOWED;

char* kcache_md5;
kcache_md5 = (char *)ap_md5(r->pool,r->unparsed_uri);

ap_set_content_type(r, "text/html;charset=ascii");
ap_rputs("", r);
ap_rputs("K-Hello World!", r);
ap_rprintf(r,"K-Hello
World!%s=%s", r->unparsed_uri,kcache_md5);
return OK;
}
*
*

i've got a warning during compilation:

src/mod_kcache.c:18:15: warning: cast to pointer from integer of
different size [-Wint-to-pointer-cast]

Is quite strange to me that ap_md5 returns an int, as in the
documentation it is reported to return a char *

http://ci.apache.org/projects/httpd/trunk/doxygen/group__APACHE__CORE__MD5.html

By the way, if i try to run it i get a segfault, if i comment the line
that prints kcache_md5 with   ap_rprintf the module doesn't segfault.

So, where i'm wrong?

Thanks to all in advance

-- 
/*/
nik600