21#include "../dpip/dpip.h"
28#define MSG(...) printf("[hello dpi]: " __VA_ARGS__)
40 char *dpip_tag, *cmd = NULL, *url = NULL, *child_cmd = NULL;
41 char *esc_tag, *d_cmd;
45 char *choice[] = {
"Window was closed",
"Yes",
"No",
46 "Could be",
"It's OK",
"Cancel"};
66 MSG(
"can't authenticate request: %s\n",
dStrerror(errno));
77 MSG(
"tag = [%s]\n", dpip_tag);
89 char *dpip_tag2, *dialog_msg;
94 "cmd=%s title=%s msg=%s alt1=%s alt2=%s alt3=%s alt4=%s alt5=%s",
95 "dialog",
"Dillo: Hello",
"Do you want to see the hello page?",
96 choice[1], choice[2], choice[3], choice[4], choice[5]);
102 MSG(
"tag = [%s]\n", dpip_tag2);
108 choice_num = *dialog_msg -
'0';
123 "Content-type: text/html\n\n"
124 "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n"
126 "<head><title>Simple dpi test page (hello.dpi)</title></head>\n"
127 "<body><hr><h1>Hello world!</h1><hr>\n<br><br>\n");
132 "<table width='100%%' border='1' bgcolor='burlywood'><tr><td>\n"
133 "<big><em>Dialog question:</em> Do you want to see the hello page?<br>\n"
134 "<em>Answer received:</em> <b>%s</b></big> </table>\n"
136 choice_num < 0 ?
"There was NO dialog!" : choice[choice_num]);
141 "<h3>dpip tag received:</h3>\n"
143 "<br><small>(<b>dpip:</b> dpi protocol)</small><br><br><br>\n",
153 child_cmd =
dStrdup(
"date -R");
154 MSG(
"[%s]\n", child_cmd);
157 if ((in_stream = popen(child_cmd,
"r")) == NULL) {
166 while ((n = fread (buf, 1, 4096, in_stream)) > 0) {
172 if ((ret = pclose(in_stream)) != 0)
173 MSG(
"popen: [%d]\n", ret);
char * dStrdup(const char *s)
void a_Dpip_dsh_free(Dsh *dsh)
Free the SockHandler structure.
char * a_Dpip_build_cmd(const char *format,...)
Printf like function for building dpip commands.
int a_Dpip_dsh_write_str(Dsh *dsh, int flush, const char *str)
Convenience function.
char * a_Dpip_get_attr(const char *tag, const char *attrname)
Task: given a tag and an attribute name, return its value.
char * a_Dpip_dsh_read_token(Dsh *dsh, int blocking)
Return a newlly allocated string with the next dpip token in the socket.
void a_Dpip_dsh_close(Dsh *dsh)
Close this socket for reading and writing.
int a_Dpip_check_auth(const char *auth_tag)
Check whether the given 'auth' string equals what dpid saved.
int a_Dpip_dsh_write(Dsh *dsh, int flush, const char *Data, int DataSize)
Streamed write to socket.
Dsh * a_Dpip_dsh_new(int fd_in, int fd_out, int flush_sz)
Create and initialize a dpip socket handler.
#define a_Dpip_dsh_printf(sh, flush,...)
char * Escape_html_str(const char *str)
Dpip socket handler type.