MCPcopy Create free account
hub / github.com/dillo-browser/dillo / get_command

Function get_command

dpid/main.c:153–189  ·  view source on GitHub ↗

! * Get value of cmd field in dpi_tag * \Return * command code on success, -1 on failure */

Source from the content-addressed store, hash-verified

151 * command code on success, -1 on failure
152 */
153static int get_command(Dsh *sh, char *dpi_tag)
154{
155 char *cmd, *d_cmd;
156 int COMMAND;
157
158 if (dpi_tag == NULL) {
159 _ERRMSG("get_command", "dpid tag is NULL", 0);
160 return (-1);
161 }
162
163 cmd = a_Dpip_get_attr(dpi_tag, "cmd");
164
165 if (cmd == NULL) {
166 ERRMSG("get_command", "a_Dpip_get_attr", 0);
167 MSG_ERR(": dpid failed to parse cmd in %s\n", dpi_tag);
168 d_cmd = a_Dpip_build_cmd("cmd=%s msg=%s",
169 "DpiError", "Failed to parse request");
170 a_Dpip_dsh_write_str(sh, 1, d_cmd);
171 dFree(d_cmd);
172 COMMAND = -1;
173 } else if (strcmp("auth", cmd) == 0) {
174 COMMAND = AUTH_CMD;
175 } else if (strcmp("DpiBye", cmd) == 0) {
176 COMMAND = BYE_CMD;
177 } else if (strcmp("check_server", cmd) == 0) {
178 COMMAND = CHECK_SERVER_CMD;
179 } else if (strcmp("register_all", cmd) == 0) {
180 COMMAND = REGISTER_ALL_CMD;
181 } else if (strcmp("register_service", cmd) == 0) {
182 COMMAND = REGISTER_SERVICE_CMD;
183 } else { /* Error unknown command */
184 COMMAND = UNKNOWN_CMD;
185 }
186
187 dFree(cmd);
188 return (COMMAND);
189}
190
191/**
192 * Check whether a dpi server is running

Callers 1

mainFunction · 0.85

Calls 4

a_Dpip_get_attrFunction · 0.85
a_Dpip_build_cmdFunction · 0.85
a_Dpip_dsh_write_strFunction · 0.85
dFreeFunction · 0.85

Tested by

no test coverage detected