/* ** Copyright (c) 2007 D. Richard Hipp ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public ** License version 2 as published by the Free Software Foundation. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ** General Public License for more details. ** ** You should have received a copy of the GNU General Public ** License along with this library; if not, write to the ** Free Software Foundation, Inc., 59 Temple Place - Suite 330, ** Boston, MA 02111-1307, USA. ** ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ******************************************************************************* ** ** This file contains code for parsing URLs that appear on the command-line */ #include "config.h" #include "url.h" /* ** Parse the given URL. Populate variables in the global "g" structure. ** ** g.urlIsFile True if this is a file URL ** g.urlName Hostname for HTTP:. Filename for FILE: ** g.urlPort Port name for HTTP. ** g.urlPath Path name for HTTP. ** g.urlUser Userid. ** g.urlPasswd Password. ** g.urlCanonical The URL in canonical form ** ** HTTP url format is: ** ** http://userid:password@host:port/path?query#fragment ** */ void url_parse(const char *zUrl){ int i, j, c; char *zFile = 0; if( strncmp(zUrl, "http:", 5)==0 ){ g.urlIsFile = 0; for(i=7; (c=zUrl[i])!=0 && c!='/' && c!='@'; i++){} if( c=='@' ){ for(j=7; j