9 * Example for how to communicate with a DFUI backend from within a CGI.
10 * Not currently working (missing the bit where we send back a response,)
11 * but it shows the outline.
13 * Only seems to work with thttpd (where user= the user that the DFUI
14 * backend is running as;) had no luck with Apache.
19 static struct dfui_response *
20 create_response_from_posted_data(void)
22 struct dfui_response *r;
24 r = dfui_response_new("the_form", "the_button_was_clicked");
25 /* add the contents of all fields to r's dataset(s) */
31 display_HTML_form_based_on(struct dfui_form *f __unused)
33 printf("<p>foo.</p>");
37 request_method_is(const char *method)
40 if (!strcasecmp(method, "plugh"))
47 main(int argc __unused, char **argv __unused)
49 struct dfui_connection *c;
51 struct dfui_response *r;
55 printf("Content-type: text/html\r\n\r\n");
58 c = dfui_connection_new(DFUI_TRANSPORT_CAPS, "test");
61 printf("<html><h1>Hi!</h1>");
64 if (request_method_is("POST")) {
65 r = create_response_from_posted_data();
67 dfui_response_free(r);
70 dfui_fe_receive(c, &msgtype, &payload);
72 case DFUI_BE_MSG_PRESENT:
73 f = (struct dfui_form *)payload;
74 display_HTML_form_based_on(f);
78 dfui_fe_disconnect(c);