From 598ffeea891c4cdd644b48477d54ae714cce0291 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 21 Mar 2006 22:30:03 +0000 Subject: David McCreedy added CURLINFO_FTP_ENTRY_PATH to export the FTP entry path --- lib/ftp.c | 8 +++++++- lib/getinfo.c | 8 ++++++++ lib/urldata.h | 12 ++++++++---- 3 files changed, 23 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/ftp.c b/lib/ftp.c index 86d37eafc..2c6fc7981 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -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; diff --git a/lib/getinfo.c b/lib/getinfo.c index 2a4c3aac4..c7b4cfa4a 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -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)) diff --git a/lib/urldata.h b/lib/urldata.h index 1418f3e92..fb7382ad8 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -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; -- cgit v1.2.3