I hate parsing in C.

Discussion in 'OT Technology' started by purebad, Sep 22, 2006.

  1. purebad

    purebad I don't need your approval, right?

    Joined:
    Aug 25, 2006
    Messages:
    4,376
    Likes Received:
    0
    Location:
    Smyrna, GA
    Alright, I'm having to dust off the C skills, and get a program going, but as always with C my hangup is parsing.

    I need to parse something of the form:

    http://host_name:port_no/file_name.ext


    and pull out the hostname, the port number, and the filename w/ ext

    there may or maynot be a port number as well :/

    Im not asking for code, but suggestions of methods
     
  2. GOGZILLA

    GOGZILLA Double-Uranium Member

    Joined:
    Jan 16, 2003
    Messages:
    10,760
    Likes Received:
    3
    Location:
    Plantation, FL
    look for characters, the hostname is between a "//" and a ":"
    port is in between ":" and "/"
    file name is between "/" and "."
    ext is between "." and a null character presumably
     
  3. purebad

    purebad I don't need your approval, right?

    Joined:
    Aug 25, 2006
    Messages:
    4,376
    Likes Received:
    0
    Location:
    Smyrna, GA
    I wasent thinking so smartly, I always know it should start with http:// so I can just divide the string from position 7 through stringlen at the :
    so I would get the hostname and then the port w/ file name, so I can split the port w/ file at the / ....piece of cake :)
     

Share This Page