1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * The contents of this file are subject to the Mozilla Public License
9 * Version 1.0 (the "License"); you may not use this file except in
10 * compliance with the License. You may obtain a copy of the License at
11 * http://www.mozilla.org/MPL/
13 * Software distributed under the License is distributed on an "AS IS"
14 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
15 * License for the specific language governing rights and limitations
18 * The Original Code is Curl.
20 * The Initial Developer of the Original Code is Daniel Stenberg.
22 * Portions created by the Initial Developer are Copyright (C) 1998.
23 * All Rights Reserved.
25 * ------------------------------------------------------------
27 * - Daniel Stenberg <Daniel.Stenberg@haxx.nu>
38 * ------------------------------------------------------------
39 ****************************************************************************/
41 /* -- WIN32 approved -- */
47 #include <sys/types.h>
54 #if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
59 #ifdef HAVE_SYS_SOCKET_H
60 #include <sys/socket.h>
62 #include <netinet/in.h>
64 #include <sys/resource.h>
69 #ifdef HAVE_ARPA_INET_H
70 #include <arpa/inet.h>
75 #include <sys/ioctl.h>
78 #ifdef HAVE_SYS_PARAM_H
79 #include <sys/param.h>
82 #ifdef HAVE_SYS_SELECT_H
83 #include <sys/select.h>
90 #include <curl/curl.h>
96 #define _MPRINTF_REPLACE /* use our functions only */
97 #include <curl/mprintf.h>
100 UrgError dict(struct UrlData *data, char *path, long *bytecount)
105 char *database = NULL;
106 char *strategy = NULL;
107 char *nthdef = NULL; /* This is not part of the protocol, but required
109 UrgError result=URG_OK;
111 if(data->conf & CONF_USERPWD) {
112 /* AUTH is missing */
115 if (strnequal(path, DICT_MATCH, sizeof(DICT_MATCH)-1) ||
116 strnequal(path, DICT_MATCH2, sizeof(DICT_MATCH2)-1) ||
117 strnequal(path, DICT_MATCH3, sizeof(DICT_MATCH3)-1)) {
119 word = strchr(path, ':');
122 database = strchr(word, ':');
124 *database++ = (char)0;
125 strategy = strchr(database, ':');
127 *strategy++ = (char)0;
128 nthdef = strchr(strategy, ':');
136 if ((word == NULL) || (*word == (char)0)) {
137 failf(data, "lookup word is missing\n");
139 if ((database == NULL) || (*database == (char)0)) {
142 if ((strategy == NULL) || (*strategy == (char)0)) {
145 if ((nthdef == NULL) || (*nthdef == (char)0)) {
152 sendf(data->firstsocket, data,
153 "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\n"
165 result = Transfer(data, data->firstsocket, -1, FALSE, bytecount,
166 -1, NULL); /* no upload */
172 else if (strnequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) ||
173 strnequal(path, DICT_DEFINE2, sizeof(DICT_DEFINE2)-1) ||
174 strnequal(path, DICT_DEFINE3, sizeof(DICT_DEFINE3)-1)) {
176 word = strchr(path, ':');
179 database = strchr(word, ':');
181 *database++ = (char)0;
182 nthdef = strchr(database, ':');
189 if ((word == NULL) || (*word == (char)0)) {
190 failf(data, "lookup word is missing\n");
192 if ((database == NULL) || (*database == (char)0)) {
195 if ((nthdef == NULL) || (*nthdef == (char)0)) {
202 sendf(data->firstsocket, data,
203 "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\n"
213 result = Transfer(data, data->firstsocket, -1, FALSE, bytecount,
214 -1, NULL); /* no upload */
222 ppath = strchr(path, '/');
227 for (i = 0; (i < URL_MAX_LENGTH) && (ppath[i]); i++) {
231 sendf(data->firstsocket, data,
232 "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\n"
237 result = Transfer(data, data->firstsocket, -1, FALSE, bytecount,