1
/***************************************************************************
3
* Project ___| | | | _ \| |
5
* | (__| |_| | _ <| |___
6
* \___|\___/|_| \_\_____|
8
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
10
* This software is licensed as described in the file COPYING, which
11
* you should have received as part of this distribution. The terms
12
* are also available at http://curl.haxx.se/docs/copyright.html.
14
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
15
* copies of the Software, and permit persons to whom the Software is
16
* furnished to do so, under the terms of the COPYING file.
18
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
* KIND, either express or implied.
21
* $Id: dict.c,v 1.7 2004/10/13 14:45:30 andy Exp $
22
***************************************************************************/
26
/* -- WIN32 approved -- */
32
#include <sys/types.h>
37
#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
41
#ifdef HAVE_SYS_SOCKET_H
42
#include <sys/socket.h>
44
#include <netinet/in.h>
50
#ifdef HAVE_ARPA_INET_H
51
#include <arpa/inet.h>
56
#include <sys/ioctl.h>
59
#ifdef HAVE_SYS_PARAM_H
60
#include <sys/param.h>
63
#ifdef HAVE_SYS_SELECT_H
64
#include <sys/select.h>
71
#include <curl/curl.h>
79
#define _MPRINTF_REPLACE /* use our functions only */
80
#include <curl/mprintf.h>
82
CURLcode Curl_dict(struct connectdata *conn)
86
char *database = NULL;
87
char *strategy = NULL;
88
char *nthdef = NULL; /* This is not part of the protocol, but required
91
struct SessionHandle *data=conn->data;
92
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
94
char *path = conn->path;
95
curl_off_t *bytecount = &conn->bytecount;
97
if(conn->bits.user_passwd) {
101
if (strnequal(path, DICT_MATCH, sizeof(DICT_MATCH)-1) ||
102
strnequal(path, DICT_MATCH2, sizeof(DICT_MATCH2)-1) ||
103
strnequal(path, DICT_MATCH3, sizeof(DICT_MATCH3)-1)) {
105
word = strchr(path, ':');
108
database = strchr(word, ':');
110
*database++ = (char)0;
111
strategy = strchr(database, ':');
113
*strategy++ = (char)0;
114
nthdef = strchr(strategy, ':');
122
if ((word == NULL) || (*word == (char)0)) {
123
failf(data, "lookup word is missing");
125
if ((database == NULL) || (*database == (char)0)) {
126
database = (char *)"!";
128
if ((strategy == NULL) || (*strategy == (char)0)) {
129
strategy = (char *)".";
132
result = Curl_sendf(sockfd, conn,
133
"CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\n"
145
failf(data, "Failed sending DICT request");
147
result = Curl_Transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount,
148
-1, NULL); /* no upload */
152
else if (strnequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) ||
153
strnequal(path, DICT_DEFINE2, sizeof(DICT_DEFINE2)-1) ||
154
strnequal(path, DICT_DEFINE3, sizeof(DICT_DEFINE3)-1)) {
156
word = strchr(path, ':');
159
database = strchr(word, ':');
161
*database++ = (char)0;
162
nthdef = strchr(database, ':');
169
if ((word == NULL) || (*word == (char)0)) {
170
failf(data, "lookup word is missing");
172
if ((database == NULL) || (*database == (char)0)) {
173
database = (char *)"!";
176
result = Curl_sendf(sockfd, conn,
177
"CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\n"
185
failf(data, "Failed sending DICT request");
187
result = Curl_Transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount,
188
-1, NULL); /* no upload */
196
ppath = strchr(path, '/');
201
for (i = 0; ppath[i]; i++) {
205
result = Curl_sendf(sockfd, conn,
206
"CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\n"
210
failf(data, "Failed sending DICT request");
212
result = Curl_Transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount,