466{
467 char itempath[512];
472 int parsed;
473 int linkedTo;
474 int endChars;
475 int rlisted;
476 int opt;
478 int sortBy;
479 int sortOrder;
480 int unknownOpts;
481 char optstr[32];
482 char unoptstr[32];
483 int doNotUseCache;
484 int wasInCache;
485 int mlsd;
486 int ci;
487
490
491 sortBy = 'n';
492 sortOrder = 'a';
493 linkedTo = 0;
494 endChars = (listmode == 'C') ? 1 : 0;
495 unknownOpts = 0;
496 memset(unoptstr, 0,
sizeof(unoptstr));
497 unoptstr[0] = '-';
498 doNotUseCache = 0;
499 rlisted = 0;
500
503 switch (opt) {
504 case 't':
505 sortBy = 't';
506 break;
507 case 'S':
508 sortBy = 's';
509 break;
510 case 'r':
511 sortOrder = 'd';
512 break;
513 case 'L':
514 linkedTo = 1;
515 break;
516 case 'f':
517 doNotUseCache = 1;
518 break;
519 case 'F':
520 case 'p':
521 endChars = 1;
522 break;
523 case '1':
524 case 'C':
525 case 'l':
526 listmode = opt;
527 break;
528 case '-':
529 break;
530 default:
531 if (unknownOpts < ((int) sizeof(unoptstr) - 2))
532 unoptstr[unknownOpts + 1] = opt;
533 unknownOpts++;
534 break;
535 }
536 }
537
538
541
542 if (unknownOpts > 0) {
543
544
545
546
547 Trace(0,
"ls caching not used because of ls flags: %s\n", unoptstr);
548 optstr[0] = '-';
549 optstr[1] = listmode;
550 optstr[2] = '\0';
555 return;
556 }
557
558 rlisted = 1;
559 parsed = -1;
560 wasInCache = 0;
562 }
else if ((doNotUseCache != 0) || ((ci =
LsCacheLookup(itempath)) < 0)) {
563
564 wasInCache = 0;
565
566 mlsd = 1;
570 return;
571 }
572
573 rlisted = 1;
574 filp = &fil;
575 if (mlsd != 0) {
576 parsed =
UnMlsD(filp, &dirContents);
577 if (parsed < 0) {
578 Trace(0,
"UnMlsD: %d\n", parsed);
579 }
580 } else {
582 if (parsed < 0) {
583 Trace(0,
"UnLslR: %d\n", parsed);
584 }
585 }
586 if (parsed >= 0) {
591 return;
592 }
593 }
594 } else {
596 wasInCache = 1;
597 parsed = 1;
598 Trace(0,
"ls cache hit: %s\n", itempath);
599 }
600
601 if (rlisted != 0) {
602 Trace(0,
"Remote listing contents {\n");
603 for (linePtr = dirContents.first;
605 linePtr = nextLinePtr)
606 {
607 nextLinePtr = linePtr->
next;
609 }
611 }
612
613 if (parsed >= 0) {
616 if (listmode == 'l')
618 else if (listmode == '1')
620 else
622 }
623 if (wasInCache == 0) {
625 }
627 for (linePtr = dirContents.first;
629 linePtr = nextLinePtr)
630 {
631 nextLinePtr = linePtr->
next;
634 }
635 }
636
638}
int WINAPIV fprintf(FILE *file, const char *format,...)
int UnMlsD(FileInfoListPtr filp, LineListPtr llp)
int UnLslR(FileInfoListPtr filp, LineListPtr llp, int serverType)
void InitLineList(LineListPtr list)
void InitFileInfoList(FileInfoListPtr list)
void VectorizeFileInfoList(FileInfoListPtr list)
void DisposeLineListContents(LineListPtr list)
void SortFileInfoList(FileInfoListPtr list, int sortKey, int sortOrder)
void LsL(FileInfoListPtr dirp, int endChars, int linkedTo, FILE *stream)
void Ls1(FileInfoListPtr dirp, int endChars, FILE *stream)
static void LsC(FileInfoListPtr dirp, int endChars, FILE *stream)
int LsCacheLookup(const char *const itempath)
static void LsCacheAdd(const char *const itempath, FileInfoListPtr files)
int FTPListToMemory2(const FTPCIPtr cip, const char *const pattern, const LineListPtr llines, const char *const lsflags, const int blankLines, int *const tryMLSD)
void PathCat(char *const dst, const size_t dsize, const char *const cwd, const char *const src)