~ubuntu-branches/ubuntu/natty/curl/natty-proposed

« back to all changes in this revision

Viewing changes to lib/ftplistparser.c

  • Committer: Bazaar Package Importer
  • Author(s): Ramakrishnan Muthukrishnan
  • Date: 2010-08-12 08:20:48 UTC
  • mto: (3.4.8 sid)
  • mto: This revision was merged to the branch mainline in revision 43.
  • Revision ID: james.westby@ubuntu.com-20100812082048-7g7fewx1ai2ozgsf
Tags: upstream-7.21.1
ImportĀ upstreamĀ versionĀ 7.21.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
#define FTP_BUFFER_ALLOCSIZE 160
62
62
 
63
63
typedef enum {
64
 
  PL_UNIX_FILETYPE = 0,
 
64
  PL_UNIX_TOTALSIZE = 0,
 
65
  PL_UNIX_FILETYPE,
65
66
  PL_UNIX_PERMISSION,
66
67
  PL_UNIX_HLINKS,
67
68
  PL_UNIX_USER,
74
75
 
75
76
typedef union {
76
77
  enum {
 
78
    PL_UNIX_TOTALSIZE_INIT = 0,
 
79
    PL_UNIX_TOTALSIZE_READING
 
80
  } total_dirsize;
 
81
 
 
82
  enum {
77
83
    PL_UNIX_HLINKS_PRESPACE = 0,
78
84
    PL_UNIX_HLINKS_NUMBER
79
85
  } hlinks;
396
402
    }
397
403
 
398
404
    finfo = parser->file_data;
399
 
    finfo->b_data[finfo->b_used++] = buffer[i];
 
405
    finfo->b_data[finfo->b_used++] = c;
400
406
 
401
407
    if(finfo->b_used >= finfo->b_size - 1) {
402
408
      /* if it is important, extend buffer space for file data */
418
424
    switch (parser->os_type) {
419
425
    case OS_TYPE_UNIX:
420
426
      switch (parser->state.UNIX.main) {
 
427
      case PL_UNIX_TOTALSIZE:
 
428
        switch(parser->state.UNIX.sub.total_dirsize) {
 
429
        case PL_UNIX_TOTALSIZE_INIT:
 
430
          if(c == 't') {
 
431
            parser->state.UNIX.sub.total_dirsize = PL_UNIX_TOTALSIZE_READING;
 
432
            parser->item_length++;
 
433
          }
 
434
          else {
 
435
            parser->state.UNIX.main = PL_UNIX_FILETYPE;
 
436
            /* start FSM again not considering size of directory */
 
437
            finfo->b_used = 0;
 
438
            i--;
 
439
          }
 
440
          break;
 
441
        case PL_UNIX_TOTALSIZE_READING:
 
442
          parser->item_length++;
 
443
          if(c == '\r') {
 
444
            parser->item_length--;
 
445
            finfo->b_used--;
 
446
          }
 
447
          else if(c == '\n') {
 
448
            finfo->b_data[parser->item_length - 1] = 0;
 
449
            if(strncmp("total ", finfo->b_data, 6) == 0) {
 
450
              char *endptr = NULL;
 
451
              /* here we can deal with directory size */
 
452
              curlx_strtoofft(finfo->b_data+6, &endptr, 10);
 
453
              if(*endptr != 0) {
 
454
                PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
 
455
                return bufflen;
 
456
              }
 
457
              else {
 
458
                parser->state.UNIX.main = PL_UNIX_FILETYPE;
 
459
                finfo->b_used = 0;
 
460
              }
 
461
            }
 
462
            else {
 
463
              PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
 
464
              return bufflen;
 
465
            }
 
466
          }
 
467
          break;
 
468
        }
 
469
        break;
421
470
      case PL_UNIX_FILETYPE:
422
471
        switch (c) {
423
472
        case '-':