pcp
[Top] [All Lists]

Re: [pcp] pmwebapi reintroduction

To: "Frank Ch. Eigler" <fche@xxxxxxxxxx>
Subject: Re: [pcp] pmwebapi reintroduction
From: Nathan Scott <nathans@xxxxxxxxxx>
Date: Thu, 22 Mar 2012 20:28:32 +1100 (EST)
Cc: pcp developers <pcp@xxxxxxxxxxx>
In-reply-to: <20120321153525.GD25969@xxxxxxxxxx>
Hi Frank,


Hi -

As far back as a year ago [1], we talked about building a
web-accessible PMAPI.  I started prototyping something along the lines
we talked about, and am now getting back to it more seriously.

Awesome.

The code is being developed in the pcpfans.git repo I mentioned the
other day, in the fche/pmwebapi branch.  To build it, you first need
to install libmicrohttpd [2], a LGPL2'd library for web service.  (I
could not find a better alternative, in the sense of license
compatibility, availability on major distros, portability.)  Then:
It sounds like a good option.

I had a crack at building it today - looks like a more recent version
of libmicrohttpd than is in Debian unstable (0.4.6) is needed, else
this class of issue ensues:

In file included from main.c:21:0:
pmwebapi.h:24:24: fatal error: microhttpd.h: No such file or directory
compilation terminated.
make: *** [main.o] Error 1

[ Setting up libmicrohttpd5 (0.4.6-1) ... ]
[ Setting up libmicrohttpd-dev (0.4.6-1) ... ]

In file included from pmwebapi.h:24:0,
                 from main.c:21:
/usr/include/microhttpd.h:497:3: error: unknown type name ‘intptr_t’
/usr/include/microhttpd.h:717:32: error: unknown type name ‘socklen_t’
/usr/include/microhttpd.h:761:33: error: unknown type name ‘size_t’
/usr/include/microhttpd.h:830:5: error: unknown type name ‘uint64_t’
/usr/include/microhttpd.h:868:46: error: unknown type name ‘uint64_t’
/usr/include/microhttpd.h:868:60: error: unknown type name ‘size_t’
/usr/include/microhttpd.h:890:41: error: unknown type name ‘MHD_AcceptPolicyCallback’
/usr/include/microhttpd.h:892:41: error: unknown type name ‘MHD_AccessHandlerCallback’
/usr/include/microhttpd.h:893:55: error: unknown type name ‘va_list’
/usr/include/microhttpd.h:912:38: error: unknown type name ‘MHD_AcceptPolicyCallback’
/usr/include/microhttpd.h:914:38: error: unknown type name ‘MHD_AccessHandlerCallback’
/usr/include/microhttpd.h:940:16: error: unknown type name ‘fd_set’
/usr/include/microhttpd.h:941:16: error: unknown type name ‘fd_set’
/usr/include/microhttpd.h:941:39: error: unknown type name ‘fd_set’
/usr/include/microhttpd.h:1085:57: error: unknown type name ‘uint64_t’
/usr/include/microhttpd.h:1086:57: error: unknown type name ‘size_t’
/usr/include/microhttpd.h:1087:57: error: unknown type name ‘MHD_ContentReaderCallback’
/usr/include/microhttpd.h:1104:53: error: unknown type name ‘size_t’
/usr/include/microhttpd.h:1196:54: error: unknown type name ‘size_t’
/usr/include/microhttpd.h:1197:54: error: unknown type name ‘MHD_PostDataIterator’
/usr/include/microhttpd.h:1216:42: error: unknown type name ‘size_t’
/usr/include/microhttpd.h:1271:3: error: unknown type name ‘size_t’
/usr/include/microhttpd.h:1276:3: error: unknown type name ‘size_t’
main.c: In function ‘main’:
main.c:196:3: warning: implicit declaration of function ‘MHD_start_daemon’ [-Wimplicit-function-declaration]
main.c:196:5: warning: assignment makes pointer from integer without a cast [enabled by default]
main.c:231:5: warning: implicit declaration of function ‘MHD_get_fdset’ [-Wimplicit-function-declaration]
main.c:245:5: warning: implicit declaration of function ‘pmwebapi_gc’ [-Wimplicit-function-declaration]
make: *** [main.o] Error 1

Then I ran out of time - looks like a header-file-inclusion-ordering issue for
some libc / microhttpd.h combinations, and once thats cleared a bit we get
to a 0.4.x vs 0.9.x API extension... (I'm guessing, haven't built a 0.9 yet)

gcc  -fpic -fno-strict-aliasing -D_GNU_SOURCE  -Wall -g -DPCP_DEBUG -DPCP_VERSION=\"3.6.0\" -I../../src/include -I../../src/include/pcp   -c -o pmwebapi.o pmwebapi.c
pmwebapi.c: In function ‘pmwebapi_respond’:
pmwebapi.c:152:7: warning: implicit declaration of function ‘MHD_create_response_from_buffer’ [-Wimplicit-function-declaration]
pmwebapi.c:153:47: error: ‘MHD_RESPMEM_PERSISTENT’ undeclared (first use in this function)
pmwebapi.c:153:47: note: each undeclared identifier is reported only once for each function it appears in
make: *** [pmwebapi.o] Error 1

So, not much feedback for you yet I'm afraid, other than the beginnings of
a list of some macros to test for in configure checks later.  Oh - attached
patch gets those initial errors out of the way (pcp/impl.h pulls in a set of
common headers and deals with some platform quirks for us, so some is
just removing dup includes).

The prototype pmwebapi has another little feature I imagine would be
useful to serve tiny pcp webapps: an optional very basic fileserver
associated with the "-r resdir" option.  The idea is to make it
possible to serve pmapi webapps, without having to set up a full web
server.

Good stuff.  I'll get some more time over the weekend to take a closer look,
and will see if I can setup a local server to gather more feedback from the
web/UI guys here.

cheers.

--
Nathan

Attachment: microhttpd.patchlet
Description: Text Data

<Prev in Thread] Current Thread [Next in Thread>