1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

David McCreedy added CURLINFO_FTP_ENTRY_PATH to export the FTP entry path

This commit is contained in:
Daniel Stenberg 2006-03-21 22:30:03 +00:00
parent 83367f67de
commit 598ffeea89
9 changed files with 70 additions and 11 deletions

View File

@ -7,6 +7,8 @@
Changelog
Daniel (21 March 2006)
- David McCreedy added CURLINFO_FTP_ENTRY_PATH.
- Xavier Bouchoux made the SSL connection non-blocking for the multi interface
(when using OpenSSL).

View File

@ -11,6 +11,7 @@ Curl and libcurl 7.15.4
This release includes the following changes:
o added CURLINFO_FTP_ENTRY_PATH
o less blocking for the multi interface during SSL connect negotiation
This release includes the following bugfixes:

View File

@ -21,7 +21,7 @@
.\" * $Id$
.\" **************************************************************************
.\"
.TH curl 1 "21 Feb 2006" "Curl 7.15.2" "Curl Manual"
.TH curl 1 "21 Mar 2006" "Curl 7.15.4" "Curl Manual"
.SH NAME
curl \- transfer a URL
.SH SYNOPSIS
@ -1131,6 +1131,10 @@ Number of new connects made in the recent transfer. (Added in 7.12.3)
.TP
.B num_redirects
Number of redirects that were followed in the request. (Added in 7.12.3)
.TP
.B ftp_entry_path
The initial path libcurl ended up in when logging on to the remote FTP
server. (Added in 7.15.4)
.RE
If this option is used several times, the last one will be used.

View File

@ -1,8 +1,27 @@
.\" You can view this file with:
.\" nroff -man [file]
.\" $Id$
.\" **************************************************************************
.\" * _ _ ____ _
.\" * Project ___| | | | _ \| |
.\" * / __| | | | |_) | |
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
.\" * are also available at http://curl.haxx.se/docs/copyright.html.
.\" *
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
.\" * copies of the Software, and permit persons to whom the Software is
.\" * furnished to do so, under the terms of the COPYING file.
.\" *
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
.\" * KIND, either express or implied.
.\" *
.\" * $Id$
.\" **************************************************************************
.\"
.TH curl_easy_getinfo 3 "6 Oct 2005" "libcurl 7.12.3" "libcurl Manual"
.TH curl_easy_getinfo 3 "21 Mar 2006" "libcurl 7.15.4" "libcurl Manual"
.SH NAME
curl_easy_getinfo - extract information from a curl handle
.SH SYNOPSIS
@ -148,6 +167,11 @@ working with the socket, you must call curl_easy_cleanup() as usual and let
libcurl close the socket and cleanup other resources associated with the
handle. This is typically used in combination with \fICURLOPT_CONNECT_ONLY\fP.
(Added in 7.15.2)
.IP CURLINFO_FTP_ENTRY_PATH
Pass a pointer to a 'char *' to receive a pointer to a string holding the path
of the entry path. That is the initial path libcurl ended up in when logging
on to the remote FTP server. This stores a NULL as pointer if something is
wrong. (Added in 7.15.4)
.SH TIMES
.NF
An overview of the six time values available from curl_easy_getinfo()

View File

@ -1292,9 +1292,10 @@ typedef enum {
CURLINFO_SSL_ENGINES = CURLINFO_SLIST + 27,
CURLINFO_COOKIELIST = CURLINFO_SLIST + 28,
CURLINFO_LASTSOCKET = CURLINFO_LONG + 29,
CURLINFO_FTP_ENTRY_PATH = CURLINFO_STRING + 30,
/* Fill in new entries below here! */
CURLINFO_LASTONE = 29
CURLINFO_LASTONE = 30
} CURLINFO;
/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as

View File

@ -2530,6 +2530,8 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
}
ftp->entrypath =dir; /* remember this */
infof(data, "Entry path is '%s'\n", ftp->entrypath);
/* also save it where getinfo can access it: */
data->state.most_recent_ftp_entrypath = ftp->entrypath;
}
else {
/* couldn't get the path */
@ -3423,8 +3425,12 @@ CURLcode Curl_ftp_disconnect(struct connectdata *conn)
if(ftp) {
(void)ftp_quit(conn); /* ignore errors on the QUIT */
if(ftp->entrypath)
if(ftp->entrypath) {
struct SessionHandle *data = conn->data;
data->state.most_recent_ftp_entrypath = NULL;
free(ftp->entrypath);
ftp->entrypath = NULL;
}
if(ftp->cache) {
free(ftp->cache);
ftp->cache = NULL;

View File

@ -187,6 +187,14 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
case CURLINFO_COOKIELIST:
*param_slistp = Curl_cookie_list(data);
break;
case CURLINFO_FTP_ENTRY_PATH:
/* Return the entrypath string from the most recent connection.
This pointer was copied from the connectdata structure by FTP.
The actual string may be free()ed by subsequent libcurl calls so
it must be copied to a safer area before the next libcurl call.
Callers must never free it themselves. */
*param_charp = data->state.most_recent_ftp_entrypath;
break;
case CURLINFO_LASTSOCKET:
if((data->state.lastconnect != -1) &&
(data->state.connects[data->state.lastconnect] != NULL))

View File

@ -833,7 +833,7 @@ typedef enum {
/*
* Values that are generated, temporary or calculated internally for a
* "session handle" must be defined within the 'struct urlstate'. This struct
* "session handle" must be defined within the 'struct UrlState'. This struct
* will be used within the SessionHandle struct. When the 'SessionHandle'
* struct is cloned, this data MUST NOT be copied.
*
@ -921,6 +921,10 @@ struct UrlState {
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
ENGINE *engine;
#endif /* USE_SSLEAY */
/* a place to store the most recenlty set FTP entrypath */
char *most_recent_ftp_entrypath;
};
@ -950,7 +954,7 @@ struct DynamicStatic {
* This 'UserDefined' struct must only contain data that is set once to go
* for many (perhaps) independent connections. Values that are generated or
* calculated internally for the "session handle" MUST be defined within the
* 'struct urlstate' instead. The only exceptions MUST note the changes in
* 'struct UrlState' instead. The only exceptions MUST note the changes in
* the 'DynamicStatic' struct.
*/
@ -964,7 +968,7 @@ struct UserDefined {
this. */
void *out; /* the fetched file goes here */
void *in; /* the uploaded file is read from here */
void *writeheader; /* write the header to this is non-NULL */
void *writeheader; /* write the header to this if non-NULL */
char *set_url; /* what original URL to work on */
char *set_proxy; /* proxy to use */
long use_port; /* which port to use (when not using default) */
@ -1111,7 +1115,7 @@ struct UserDefined {
* From now on, the 'SessionHandle' must only contain data that is set once to
* go for many (perhaps) independent connections. Values that are generated or
* calculated internally for the "session handle" must be defined within the
* 'struct urlstate' instead. */
* 'struct UrlState' instead. */
struct SessionHandle {
struct curl_hash *hostcache;

View File

@ -60,6 +60,7 @@ typedef enum {
VAR_NUM_CONNECTS,
VAR_REDIRECT_TIME,
VAR_REDIRECT_COUNT,
VAR_FTP_ENTRY_PATH,
VAR_NUM_OF_VARS /* must be the last */
} replaceid;
@ -88,6 +89,7 @@ static const struct variable replacements[]={
{"num_connects", VAR_NUM_CONNECTS},
{"time_redirect", VAR_REDIRECT_TIME},
{"num_redirects", VAR_REDIRECT_COUNT},
{"ftp_entry_path", VAR_FTP_ENTRY_PATH},
{NULL, VAR_NONE}
};
@ -213,6 +215,13 @@ void ourWriteOut(CURL *curl, char *writeinfo)
curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &stringp))
&& stringp)
fputs(stringp, stream);
break;
case VAR_FTP_ENTRY_PATH:
if((CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_FTP_ENTRY_PATH, &stringp))
&& stringp)
fputs(stringp, stream);
break;
default:
break;
}