FTP protocol

This is a discussion on FTP protocol within the Tech Board forums, part of the Community Boards category; So I've been implementing the ftp protocol for fun, and I'm basically done, but one annoying thing...the LIST command gives ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Location
    Hermosa Beach, CA
    Posts
    446

    FTP protocol

    So I've been implementing the ftp protocol for fun, and I'm basically done, but one annoying thing...the LIST command gives back a directory listing that seems to be in different format depending on what platform the FTP server happens to be running on. That's fine if I'm just writing a command-line ftp clone, but if I'm writing a GUI, I want my FTP library to be able to do a LIST via some function, and return a list data structure, where each list entry is something like:

    typedef struct {
    string name;
    int size;
    int prot;
    bool is_dir;
    } FtpFileEntry;

    So then the question comes up, how am I supposed to parse the results if I don't even know what format will come back? I know that there's a command to fetch an OS string...but I'm not sure that all unixes will even give the same format, or that all windows platforms will return the same format, etc.

    Any ideas?
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    There is no standard format, but there a few common formats. You may want to have a look at FTP_ParseNextFile from the WINE source code as a starting point.

  3. #3
    Registered User
    Join Date
    Aug 2002
    Location
    Hermosa Beach, CA
    Posts
    446
    Awesome. Nothing better than sample code. Thanks.
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,438
    Well, the standard does recommend the UNIX format in "ls -l" form, if I remember correctly. And most servers are implemented this way (they can or not be programmed to be configurable for other formats). It's the client that should worry about understanding the data it receives. The safest route is to choose UNIX format and let the client do the conversion if it needs to.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  5. #5
    Registered User
    Join Date
    Aug 2002
    Location
    Hermosa Beach, CA
    Posts
    446
    I'm only doing the client portion. I've got two test FTP servers, and one returns NT style, the other ls style.
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,438
    If you are doing the client you will definitely need to implement both.
    In fact you may even need to consider that the result of the LIST command can be sent to the client in ASCII or EBDCIC (? can't remember the exact name).

    Coding the NTLS command will help some. It's a simple list of filenames (again in either ASCII or EBDCIC). It will help parsing the result of LIST and it's also an excellent command for commands affecting multiple files.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to program in unix
    By Cpro in forum Linux Programming
    Replies: 21
    Last Post: 02-12-2008, 09:54 AM
  2. FTP Client
    By waldoayo in forum Networking/Device Communication
    Replies: 5
    Last Post: 04-29-2006, 11:49 AM
  3. FTP and Ident Server :: Winsock
    By kuphryn in forum Networking/Device Communication
    Replies: 2
    Last Post: 03-13-2004, 07:16 PM
  4. [C++] FTP client problem (winsock)
    By Niekie in forum Networking/Device Communication
    Replies: 2
    Last Post: 10-19-2003, 09:23 AM
  5. FTP Server :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 10-03-2002, 07:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21