annotate dpi/hello.c @ 2048:5060d415a85a

clickable menu items (even those introducing submenus) MUST have callbacks I clicked on the "Panel size" item itself instead of any of the options in its submenu, and: Segfault!
author corvid <corvid@lavabit.com>
date Thu, 26 May 2011 02:51:18 +0000
parents c2fc4d2510d0
children
rev   line source
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
2 * Dpi for "Hello World".
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
3 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
4 * This server is an example. Play with it and modify to your taste.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
5 *
35
d9e7b35430de Updated copyright lines
jcid
parents: 0
diff changeset
6 * Copyright 2003-2007 Jorge Arellano Cid <jcid@dillo.org>
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
7 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
10 * the Free Software Foundation; either version 3 of the License, or
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
11 * (at your option) any later version.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
12 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
13 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
14
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
15 #include <unistd.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
16 #include <sys/types.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
17 #include <stdio.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
18 #include <stdlib.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
19 #include <string.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
20 #include <errno.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
21 #include "../dpip/dpip.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
22 #include "dpiutil.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
23
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
24 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
25 * Debugging macros
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
26 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
27 #define _MSG(...)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28 #define MSG(...) printf("[hello dpi]: " __VA_ARGS__)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
29
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
30 /*---------------------------------------------------------------------------*/
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
31
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
32
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
33 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
34 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
35 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
36 int main(void)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
37 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
38 FILE *in_stream;
1397
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
39 Dsh *sh;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
40 char *dpip_tag, *cmd = NULL, *url = NULL, *child_cmd = NULL;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
41 char *esc_tag, *d_cmd;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
42 size_t n;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
43 int ret;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
44 char buf[4096];
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
45 char *choice[] = {"Window was closed", "Yes", "No",
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
46 "Could be", "It's OK", "Cancel"};
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
47 /* "Could>be", ">It's OK", "Can'>cel"}; --for testing */
1414
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
48 int choice_num = -1;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
49
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
50 MSG("starting...\n");
1414
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
51 /* sleep(20) */
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
52
1414
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
53 /* Initialize the SockHandler.
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
54 * This means we'll use stdin for input and stdout for output.
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
55 * In case of a server dpi, we'd use a socket and pass its file descriptor
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
56 * twice (e.g. a_Dpip_dsh_new(sock_fd, sock_fd, 1024).
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
57 * (Note: by now the last parameter is not used) */
1397
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
58 sh = a_Dpip_dsh_new(STDIN_FILENO, STDOUT_FILENO, 2*1024);
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
59
1414
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
60 /* Authenticate our client...
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
61 * As we're using Internet domain sockets, DPIP checks whether the client
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
62 * runs with the user's ID, by means of a shared secret. The DPIP API does
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
63 * the work for us. */
1397
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
64 if (!(dpip_tag = a_Dpip_dsh_read_token(sh, 1)) ||
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
65 a_Dpip_check_auth(dpip_tag) < 0) {
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
66 MSG("can't authenticate request: %s\n", dStrerror(errno));
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
67 a_Dpip_dsh_close(sh);
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
68 return 1;
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
69 }
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
70 dFree(dpip_tag);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
71
1414
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
72 /* Read the dpi command from STDIN
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
73 * Now we're past the authentication phase, let's see what's dillo
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
74 * asking from us. a_Dpip_dsh_read_token() will block and return
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
75 * a full dpip token or null on error (it's commented in dpip.c) */
1397
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
76 dpip_tag = a_Dpip_dsh_read_token(sh, 1);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
77 MSG("tag = [%s]\n", dpip_tag);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
78
1414
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
79 /* Now that we have the dpip_tag, let's isolate the command and url */
1236
b912173aecd1 Added a_Dpip_get_attr_l() to DPIP's API
Jorge Arellano Cid <jcid@dillo.org>
parents: 35
diff changeset
80 cmd = a_Dpip_get_attr(dpip_tag, "cmd");
b912173aecd1 Added a_Dpip_get_attr_l() to DPIP's API
Jorge Arellano Cid <jcid@dillo.org>
parents: 35
diff changeset
81 url = a_Dpip_get_attr(dpip_tag, "url");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
82
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
83 /*-- Dialog part */
1414
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
84 /* This is the dialog window. This is an example of interaction with
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
85 * the user. If you're starting to understand dpis, comment this out
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
86 * by switching to "#if 0" and the dialog will be disabled. */
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
87 #if 1
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
88 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
89 char *dpip_tag2, *dialog_msg;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
90
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
91 /* Let's confirm the request */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
92 /* NOTE: you can send less alternatives (e.g. only alt1 and alt2) */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
93 d_cmd = a_Dpip_build_cmd(
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
94 "cmd=%s msg=%s alt1=%s alt2=%s alt3=%s alt4=%s alt5=%s",
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
95 "dialog", "Do you want to see the hello page?",
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
96 choice[1], choice[2], choice[3], choice[4], choice[5]);
1397
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
97 a_Dpip_dsh_write_str(sh, 1, d_cmd);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
98 dFree(d_cmd);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
99
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
100 /* Get the answer */
1397
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
101 dpip_tag2 = a_Dpip_dsh_read_token(sh, 1);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
102 MSG("tag = [%s]\n", dpip_tag2);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
103
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
104 /* Get "msg" value */
1236
b912173aecd1 Added a_Dpip_get_attr_l() to DPIP's API
Jorge Arellano Cid <jcid@dillo.org>
parents: 35
diff changeset
105 dialog_msg = a_Dpip_get_attr(dpip_tag2, "msg");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
106 choice_num = 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
107 if (dialog_msg)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
108 choice_num = *dialog_msg - '0';
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
109
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
110 dFree(dialog_msg);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
111 dFree(dpip_tag2);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
112 }
1414
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
113 #endif
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
114 /*-- EOD part */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
115
1414
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
116 /* Start sending our answer.
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
117 * (You can read the comments for DPIP API functions in dpip/dpip.c) */
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
118 d_cmd = a_Dpip_build_cmd("cmd=%s url=%s", "start_send_page", url);
1397
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
119 a_Dpip_dsh_write_str(sh, 0, d_cmd);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
120 dFree(d_cmd);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
121
1397
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
122 a_Dpip_dsh_printf(sh, 0,
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
123 "Content-type: text/html\n\n"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
124 "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
125 "<html>\n"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
126 "<head><title>Simple dpi test page (hello.dpi)</title></head>\n"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
127 "<body><hr><h1>Hello world!</h1><hr>\n<br><br>\n");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
128
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
129 /* Show the choice received with the dialog */
1397
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
130 a_Dpip_dsh_printf(sh, 0,
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
131 "<hr>\n"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
132 "<table width='100%%' border='1' bgcolor='burlywood'><tr><td>\n"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
133 "<big><em>Dialog question:</em> Do you want to see the hello page?<br>\n"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
134 "<em>Answer received:</em> <b>%s</b></big> </table>\n"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
135 "<hr>\n",
1414
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
136 choice_num < 0 ? "There was NO dialog!" : choice[choice_num]);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
137
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
138 /* Show the dpip tag we received */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
139 esc_tag = Escape_html_str(dpip_tag);
1397
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
140 a_Dpip_dsh_printf(sh, 0,
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
141 "<h3>dpip tag received:</h3>\n"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
142 "<pre>\n%s</pre>\n"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
143 "<br><small>(<b>dpip:</b> dpi protocol)</small><br><br><br>\n",
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
144 esc_tag);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
145 dFree(esc_tag);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
146
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
147
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
148 /* Now something more interesting,
1414
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
149 * fork a command and show its feedback.
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
150 * (An example of generating dynamic content with an external
c2fc4d2510d0 Updated Dpid.txt to the new DPIP API. Added more comments in hello.c
Jorge Arellano Cid <jcid@dillo.org>
parents: 1397
diff changeset
151 * program). */
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
152 if (cmd && url) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
153 child_cmd = dStrdup("date -R");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
154 MSG("[%s]\n", child_cmd);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
155
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
156 /* Fork, exec command, get its output and answer */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
157 if ((in_stream = popen(child_cmd, "r")) == NULL) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
158 perror("popen");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
159 return EXIT_FAILURE;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
160 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
161
1397
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
162 a_Dpip_dsh_write_str(sh, 0, "<h3>date:</h3>\n");
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
163 a_Dpip_dsh_write_str(sh, 0, "<pre>\n");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
164
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
165 /* Read/Write */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
166 while ((n = fread (buf, 1, 4096, in_stream)) > 0) {
1397
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
167 a_Dpip_dsh_write(sh, 0, buf, n);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
168 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
169
1397
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
170 a_Dpip_dsh_write_str(sh, 0, "</pre>\n");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
171
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
172 if ((ret = pclose(in_stream)) != 0)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
173 MSG("popen: [%d]\n", ret);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
174
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
175 dFree(child_cmd);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
176 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
177
1397
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
178 a_Dpip_dsh_write_str(sh, 1, "</body></html>\n");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
179
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
180 dFree(cmd);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
181 dFree(url);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
182 dFree(dpip_tag);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
183
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
184 /* Finish the SockHandler */
1397
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
185 a_Dpip_dsh_close(sh);
a9662d8ada3f hello dpi: convert to dsh API (with auth)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1236
diff changeset
186 a_Dpip_dsh_free(sh);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
187
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
188 return 0;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
189 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
190