Lines Matching refs:ftpc

232 static void freedirs(struct ftp_conn *ftpc)
234 if(ftpc->dirs) {
236 for(i = 0; i < ftpc->dirdepth; i++) {
237 free(ftpc->dirs[i]);
238 ftpc->dirs[i] = NULL;
240 free(ftpc->dirs);
241 ftpc->dirs = NULL;
242 ftpc->dirdepth = 0;
244 Curl_safefree(ftpc->file);
247 Curl_safefree(ftpc->newhost);
364 struct ftp_conn *ftpc = &conn->proto.ftpc;
365 struct pingpong *pp = &ftpc->pp;
452 if(conn->proto.ftpc.state_saved == FTP_STOR) {
465 conn->proto.ftpc.retr_size_saved, FALSE, -1);
468 conn->proto.ftpc.pp.pending_resp = TRUE; /* expect server response */
562 char * const buf = Curl_dyn_ptr(&data->conn->proto.ftpc.pp.recvbuf);
626 struct ftp_conn *ftpc = &conn->proto.ftpc;
627 struct pingpong *pp = &ftpc->pp;
764 struct ftp_conn *ftpc = &conn->proto.ftpc;
771 if(ftpc->state != newstate)
773 (void *)ftpc, lineno, ftp_state_names[ftpc->state],
778 ftpc->state = newstate;
785 &conn->proto.ftpc.pp, "USER %s",
788 struct ftp_conn *ftpc = &conn->proto.ftpc;
789 ftpc->ftp_trying_alternative = FALSE;
798 CURLcode result = Curl_pp_sendf(data, &conn->proto.ftpc.pp, "%s", "PWD");
810 return Curl_pp_getsock(data, &conn->proto.ftpc.pp, socks);
817 struct ftp_conn *ftpc = &conn->proto.ftpc;
830 if(FTP_STOP == ftpc->state) {
843 return Curl_pp_getsock(data, &conn->proto.ftpc.pp, socks);
856 struct ftp_conn *ftpc = &conn->proto.ftpc;
858 if(ftpc->cwddone)
862 /* FTPFILE_NOCWD with full path: expect ftpc->cwddone! */
864 !(ftpc->dirdepth && ftpc->dirs[0][0] == '/'));
866 ftpc->count2 = 0; /* count2 counts failed CWDs */
868 if(conn->bits.reuse && ftpc->entrypath &&
870 !(ftpc->dirdepth && ftpc->dirs[0][0] == '/')) {
874 ftpc->cwdcount = 0; /* we count this as the first path, then we add one
876 result = Curl_pp_sendf(data, &ftpc->pp, "CWD %s", ftpc->entrypath);
881 if(ftpc->dirdepth) {
882 ftpc->cwdcount = 1;
885 result = Curl_pp_sendf(data, &ftpc->pp, "CWD %s",
886 ftpc->dirs[ftpc->cwdcount -1]);
910 struct ftp_conn *ftpc = &conn->proto.ftpc;
1214 result = Curl_pp_sendf(data, &ftpc->pp, "%s |%d|%s|%hu|", mode[fcmd],
1242 result = Curl_pp_sendf(data, &ftpc->pp, "%s %s", mode[fcmd], target);
1253 ftpc->count1 = fcmd;
1274 struct ftp_conn *ftpc = &conn->proto.ftpc;
1302 result = Curl_pp_sendf(data, &ftpc->pp, "%s", mode[modeoff]);
1304 ftpc->count1 = modeoff;
1340 struct ftp_conn *ftpc = &conn->proto.ftpc;
1341 if(!conn->proto.ftpc.file)
1342 result = Curl_pp_sendf(data, &ftpc->pp, "PRET %s",
1347 result = Curl_pp_sendf(data, &ftpc->pp, "PRET STOR %s",
1348 conn->proto.ftpc.file);
1350 result = Curl_pp_sendf(data, &ftpc->pp, "PRET RETR %s",
1351 conn->proto.ftpc.file);
1366 struct ftp_conn *ftpc = &conn->proto.ftpc;
1368 if((ftp->transfer != PPTRANSFER_BODY) && ftpc->file) {
1373 result = Curl_pp_sendf(data, &ftpc->pp, "REST %d", 0);
1388 struct ftp_conn *ftpc = &conn->proto.ftpc;
1390 if((ftp->transfer == PPTRANSFER_INFO) && ftpc->file) {
1393 /* we know ftpc->file is a valid pointer to a file name */
1394 result = Curl_pp_sendf(data, &ftpc->pp, "SIZE %s", ftpc->file);
1460 result = Curl_pp_sendf(data, &conn->proto.ftpc.pp, "%s", cmd);
1486 struct ftp_conn *ftpc = &conn->proto.ftpc;
1491 if(data->req.no_body && ftpc->file &&
1518 struct ftp_conn *ftpc = &conn->proto.ftpc;
1521 if((data->set.get_filetime || data->set.timecondition) && ftpc->file) {
1525 result = Curl_pp_sendf(data, &ftpc->pp, "MDTM %s", ftpc->file);
1544 struct ftp_conn *ftpc = &conn->proto.ftpc;
1565 result = Curl_pp_sendf(data, &ftpc->pp, "SIZE %s", ftpc->file);
1630 result = Curl_pp_sendf(data, &ftpc->pp, append?"APPE %s":"STOR %s",
1631 ftpc->file);
1645 struct ftp_conn *ftpc = &conn->proto.ftpc;
1670 ftpc->count1 = 0;
1672 ftpc->count1++;
1678 while((i< ftpc->count1) && item) {
1686 ftpc->count2 = 1; /* the sent command is allowed to fail */
1689 ftpc->count2 = 0; /* failure means cancel operation */
1691 result = Curl_pp_sendf(data, &ftpc->pp, "%s", cmd);
1710 if(ftpc->known_filesize != -1) {
1711 Curl_pgrsSetDownloadSize(data, ftpc->known_filesize);
1712 result = ftp_state_retr(data, ftpc->known_filesize);
1728 result = Curl_pp_sendf(data, &ftpc->pp, "RETR %s", ftpc->file);
1733 result = Curl_pp_sendf(data, &ftpc->pp, "SIZE %s", ftpc->file);
1775 result = Curl_pp_sendf(data, &conn->proto.ftpc.pp, "%s", "PASV");
1777 conn->proto.ftpc.count1++;
1825 struct ftp_conn *ftpc = &conn->proto.ftpc;
1830 struct pingpong *pp = &ftpc->pp;
1835 Curl_safefree(ftpc->newhost);
1837 if((ftpc->count1 == 0) &&
1858 ftpc->newport = (unsigned short)(num & 0xffff);
1859 ftpc->newhost = strdup(control_address(conn));
1860 if(!ftpc->newhost)
1872 else if((ftpc->count1 == 1) &&
1904 ftpc->newhost = strdup(control_address(conn));
1907 ftpc->newhost = aprintf("%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
1909 if(!ftpc->newhost)
1912 ftpc->newport = (unsigned short)(((ip[4]<<8) + ip[5]) & 0xffff);
1914 else if(ftpc->count1 == 0) {
1950 DEBUGASSERT(ftpc->newhost);
1953 if(conn->bits.tcp_fastopen && !conn->bits.reuse && !ftpc->newhost[0]) {
1955 Curl_safefree(ftpc->newhost);
1956 ftpc->newhost = strdup(control_address(conn));
1957 if(!ftpc->newhost)
1961 rc = Curl_resolv(data, ftpc->newhost, ftpc->newport, FALSE, &addr);
1966 connectport = ftpc->newport; /* we connect to the remote port */
1969 failf(data, "Can't resolve new host %s:%hu", ftpc->newhost, connectport);
1980 if(ftpc->count1 == 0 && ftpcode == 229)
1995 ftp_pasv_verbose(data, addr->addr, ftpc->newhost, connectport);
2000 conn->secondary_port = ftpc->newport;
2001 conn->secondaryhostname = strdup(ftpc->newhost);
2015 struct ftp_conn *ftpc = &conn->proto.ftpc;
2016 ftpport fcmd = (ftpport)ftpc->count1;
2102 struct ftp_conn *ftpc = &conn->proto.ftpc;
2110 struct pingpong *pp = &ftpc->pp;
2127 ftpc->file &&
2239 struct ftp_conn *ftpc = &conn->proto.ftpc;
2302 result = Curl_pp_sendf(data, &ftpc->pp, "REST %" CURL_FORMAT_CURL_OFF_T,
2309 result = Curl_pp_sendf(data, &ftpc->pp, "RETR %s", ftpc->file);
2323 char *buf = Curl_dyn_ptr(&data->conn->proto.ftpc.pp.recvbuf);
2324 size_t len = data->conn->proto.ftpc.pp.nfinal;
2387 struct ftp_conn *ftpc = &conn->proto.ftpc;
2409 result = Curl_pp_sendf(data, &ftpc->pp, "RETR %s", ftpc->file);
2432 conn->proto.ftpc.state_saved = instate;
2445 struct ftp_conn *ftpc = &conn->proto.ftpc;
2447 ftpc->wait_data_conn = TRUE;
2507 char *buf = Curl_dyn_ptr(&conn->proto.ftpc.pp.recvbuf);
2548 conn->proto.ftpc.state_saved = instate;
2549 conn->proto.ftpc.retr_size_saved = size;
2559 struct ftp_conn *ftpc = &conn->proto.ftpc;
2562 ftpc->wait_data_conn = TRUE;
2606 result = Curl_pp_sendf(data, &conn->proto.ftpc.pp, "PBSZ %d", 0);
2622 struct ftp_conn *ftpc = &conn->proto.ftpc;
2625 if((ftpcode == 331) && (ftpc->state == FTP_USER)) {
2628 result = Curl_pp_sendf(data, &ftpc->pp, "PASS %s",
2640 result = Curl_pp_sendf(data, &ftpc->pp, "ACCT %s",
2657 !ftpc->ftp_trying_alternative) {
2660 Curl_pp_sendf(data, &ftpc->pp, "%s",
2663 ftpc->ftp_trying_alternative = TRUE;
2697 struct ftp_conn *ftpc = &conn->proto.ftpc;
2698 struct pingpong *pp = &ftpc->pp;
2711 switch(ftpc->state) {
2748 ftpc->count3 = 0;
2752 ftpc->count2 = 1; /* add one to get next */
2753 ftpc->count1 = 0;
2756 ftpc->count2 = -1; /* subtract one to get next */
2757 ftpc->count1 = 1;
2764 result = Curl_pp_sendf(data, &ftpc->pp, "AUTH %s",
2765 ftpauth[ftpc->count1]);
2803 else if(ftpc->count3 < 1) {
2804 ftpc->count3++;
2805 ftpc->count1 += ftpc->count2; /* get next attempt */
2806 result = Curl_pp_sendf(data, &ftpc->pp, "AUTH %s",
2807 ftpauth[ftpc->count1]);
2831 Curl_pp_sendf(data, &ftpc->pp, "PROT %c",
2851 result = Curl_pp_sendf(data, &ftpc->pp, "%s", "CCC");
2929 if(!ftpc->server_os && dir[0] != '/') {
2930 result = Curl_pp_sendf(data, &ftpc->pp, "%s", "SYST");
2935 Curl_safefree(ftpc->entrypath);
2936 ftpc->entrypath = dir; /* remember this */
2937 infof(data, "Entry path is '%s'", ftpc->entrypath);
2939 data->state.most_recent_ftp_entrypath = ftpc->entrypath;
2944 Curl_safefree(ftpc->entrypath);
2945 ftpc->entrypath = dir; /* remember this */
2946 infof(data, "Entry path is '%s'", ftpc->entrypath);
2948 data->state.most_recent_ftp_entrypath = ftpc->entrypath;
2981 result = Curl_pp_sendf(data, &ftpc->pp, "%s", "SITE NAMEFMT 1");
2987 Curl_safefree(ftpc->server_os);
2988 ftpc->server_os = os;
2994 Curl_safefree(ftpc->server_os);
2995 ftpc->server_os = os;
3020 if((ftpcode >= 400) && !ftpc->count2) {
3026 result = ftp_state_quote(data, FALSE, ftpc->state);
3033 ftpc->cwdcount && !ftpc->count2) {
3035 ftpc->count2++; /* counter to prevent CWD-MKD loops */
3040 ftpc->count3 = (data->set.ftp_create_missing_dirs == 2) ? 1 : 0;
3042 result = Curl_pp_sendf(data, &ftpc->pp, "MKD %s",
3043 ftpc->dirs[ftpc->cwdcount - 1]);
3050 ftpc->cwdfail = TRUE; /* don't remember this path as we failed
3057 ftpc->count2 = 0;
3058 if(++ftpc->cwdcount <= ftpc->dirdepth)
3060 result = Curl_pp_sendf(data, &ftpc->pp, "CWD %s",
3061 ftpc->dirs[ftpc->cwdcount - 1]);
3068 if((ftpcode/100 != 2) && !ftpc->count3--) {
3076 result = Curl_pp_sendf(data, &ftpc->pp, "CWD %s",
3077 ftpc->dirs[ftpc->cwdcount - 1]);
3089 result = ftp_state_type_resp(data, ftpcode, ftpc->state);
3095 result = ftp_state_size_resp(data, ftpcode, ftpc->state);
3100 result = ftp_state_rest_resp(data, conn, ftpcode, ftpc->state);
3122 result = ftp_state_get_resp(data, ftpcode, ftpc->state);
3126 result = ftp_state_stor_resp(data, ftpcode, ftpc->state);
3146 struct ftp_conn *ftpc = &conn->proto.ftpc;
3147 CURLcode result = Curl_pp_statemach(data, &ftpc->pp, FALSE, FALSE);
3152 *done = (ftpc->state == FTP_STOP) ? TRUE : FALSE;
3160 struct ftp_conn *ftpc = &conn->proto.ftpc;
3161 struct pingpong *pp = &ftpc->pp;
3164 while(ftpc->state != FTP_STOP) {
3186 struct ftp_conn *ftpc = &conn->proto.ftpc;
3187 struct pingpong *pp = &ftpc->pp;
3229 struct ftp_conn *ftpc = &conn->proto.ftpc;
3230 struct pingpong *pp = &ftpc->pp;
3264 ftpc->ctl_valid = FALSE;
3265 ftpc->cwdfail = TRUE; /* set this TRUE to prevent us to remember the
3273 if(data->set.chunk_end && ftpc->file) {
3278 ftpc->known_filesize = -1;
3288 ftpc->ctl_valid = FALSE; /* mark control connection as bad */
3290 free(ftpc->prevpath);
3291 ftpc->prevpath = NULL; /* no path remembering */
3295 free(rawPath); /* full path => no CWDs happened => keep ftpc->prevpath */
3297 free(ftpc->prevpath);
3299 if(!ftpc->cwdfail) {
3303 pathLen -= ftpc->file?strlen(ftpc->file):0; /* file is url-decoded */
3306 ftpc->prevpath = rawPath;
3310 ftpc->prevpath = NULL; /* no path */
3314 if(ftpc->prevpath)
3315 infof(data, "Remembering we are in dir \"%s\"", ftpc->prevpath);
3319 freedirs(ftpc);
3328 if(!result && ftpc->dont_check && data->req.maxdownload > 0) {
3334 ftpc->ctl_valid = FALSE; /* mark control connection as bad */
3342 if(!result && (ftp->transfer == PPTRANSFER_BODY) && ftpc->ctl_valid &&
3361 ftpc->ctl_valid = FALSE; /* mark control connection as bad */
3370 if(ftpc->dont_check && data->req.maxdownload > 0) {
3378 if(!ftpc->dont_check) {
3427 else if(!ftpc->dont_check &&
3437 ftpc->dont_check = FALSE;
3461 struct ftp_conn *ftpc = &conn->proto.ftpc;
3462 struct pingpong *pp = &ftpc->pp;
3483 result = Curl_pp_sendf(data, &ftpc->pp, "%s", cmd);
3512 return conn->proto.ftpc.transfertype != (ascii_wanted?'A':'I');
3527 struct ftp_conn *ftpc = &conn->proto.ftpc;
3531 if(ftpc->transfertype == want) {
3536 result = Curl_pp_sendf(data, &ftpc->pp, "TYPE %c", want);
3541 ftpc->transfertype = want;
3582 struct ftp_conn *ftpc = &conn->proto.ftpc;
3601 if(result && (ftpc->count1 == 0)) {
3613 if(ftpc->state) {
3622 if(result || !ftpc->wait_data_conn)
3626 TRUE but so is ftpc->wait_data_conn, which says we need to wait for the
3635 if(ftpc->wait_data_conn) {
3645 ftpc->wait_data_conn = FALSE;
3673 ftpc->dont_check = TRUE;
3678 else if(data->state.list_only || !ftpc->file) {
3707 if(!ftpc->wait_data_conn) {
3906 struct ftp_conn *ftpc = &conn->proto.ftpc;
3942 ftpc->known_filesize = finfo->size;
4008 struct ftp_conn *ftpc = &conn->proto.ftpc;
4011 ftpc->wait_data_conn = FALSE; /* default to no such wait */
4048 if(conn->proto.ftpc.ctl_valid) {
4049 result = Curl_pp_sendf(data, &conn->proto.ftpc.pp, "%s", "QUIT");
4053 conn->proto.ftpc.ctl_valid = FALSE; /* mark control connection as bad */
4078 struct ftp_conn *ftpc = &conn->proto.ftpc;
4079 struct pingpong *pp = &ftpc->pp;
4089 ftpc->ctl_valid = FALSE;
4094 if(ftpc->entrypath) {
4095 if(data->state.most_recent_ftp_entrypath == ftpc->entrypath) {
4098 Curl_safefree(ftpc->entrypath);
4101 freedirs(ftpc);
4102 Curl_safefree(ftpc->account);
4103 Curl_safefree(ftpc->alternative_to_user);
4104 Curl_safefree(ftpc->prevpath);
4105 Curl_safefree(ftpc->server_os);
4129 struct ftp_conn *ftpc = &conn->proto.ftpc;
4136 ftpc->ctl_valid = FALSE;
4137 ftpc->cwdfail = FALSE;
4152 else: ftpc->file is not used anywhere other than for operations on
4167 ftpc->dirs = calloc(1, sizeof(ftpc->dirs[0]));
4168 if(!ftpc->dirs) {
4173 ftpc->dirs[0] = Curl_memdup0(rawPath, dirlen);
4174 if(!ftpc->dirs[0]) {
4179 ftpc->dirdepth = 1; /* we consider it to be a single dir */
4199 ftpc->dirs = calloc(dirAlloc, sizeof(ftpc->dirs[0]));
4200 if(!ftpc->dirs) {
4210 if((compLen == 0) && (ftpc->dirdepth == 0))
4222 ftpc->dirs[ftpc->dirdepth++] = comp;
4227 DEBUGASSERT((size_t)ftpc->dirdepth <= dirAlloc);
4234 ftpc->file = strdup(fileName);
4236 ftpc->file = NULL; /* instead of point to a zero byte,
4239 if(data->state.upload && !ftpc->file && (ftp->transfer == PPTRANSFER_BODY)) {
4246 ftpc->cwddone = FALSE; /* default to not done */
4249 ftpc->cwddone = TRUE; /* skip CWD for absolute paths */
4251 const char *oldPath = conn->bits.reuse ? ftpc->prevpath : "";
4257 n -= ftpc->file?strlen(ftpc->file):0;
4261 ftpc->cwddone = TRUE;
4275 struct ftp_conn *ftpc = &conn->proto.ftpc;
4294 ftpc->ctl_valid = TRUE; /* seems good */
4334 struct ftp_conn *ftpc = &conn->proto.ftpc;
4342 ftpc->ctl_valid = TRUE; /* starts good */
4360 freedirs(ftpc);
4371 struct ftp_conn *ftpc = &conn->proto.ftpc;
4379 ftpc->account = strdup(data->set.str[STRING_FTP_ACCOUNT]);
4380 if(!ftpc->account) {
4386 ftpc->alternative_to_user =
4388 if(!ftpc->alternative_to_user) {
4389 Curl_safefree(ftpc->account);
4430 ftpc->known_filesize = -1; /* unknown size for now */
4431 ftpc->use_ssl = data->set.use_ssl;
4432 ftpc->ccc = data->set.ftp_ccc;