Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 #include "URL.h"
00025 #include <iostream.h>
00026 #include <fstream.h>
00027 
00028 URL *
00029 create_url(const char *url_string)
00030 {
00031   char buf[4096];
00032   int len = 0;
00033   URL *url_p = new URL(url_string);
00034   URL & url = *url_p;
00035 
00036   cout << "scheme        : " << url.getScheme() << endl;
00037   len = url.getUserName(buf, sizeof(buf));
00038   buf[len] = '\0';
00039   cout << "user name     : " << buf << endl;
00040   cout << "UserNameExists: " << url.userNameExists() << endl;
00041   cout << "UserNameEmpty : " << url.userNameEmpty() << endl;
00042 
00043 
00044   len = url.getPassword(buf, sizeof(buf));
00045   buf[len] = '\0';
00046   cout << "password      : " << buf << endl;
00047   cout << "PasswordExists: " << url.passwordExists() << endl;
00048   cout << "PasswordEmpty : " << url.passwordEmpty() << endl;
00049 
00050 
00051   len = url.getHost(buf, sizeof(buf));
00052   buf[len] = '\0';
00053   cout << "host          : " << buf << endl;
00054   cout << "HostEmpty     : " << url.hostEmpty() << endl;
00055 
00056   cout << "port          : " << url.getPort() << endl;
00057   cout << "PortEmpty     : " << url.portEmpty() << endl;
00058   cout << "DefaultPort   : " << url.defaultPort() << endl;
00059 
00060   
00061   switch (url.getScheme()) {
00062   case URL_SCHEME_NONE:
00063   case URL_SCHEME_HTTP:
00064   case URL_SCHEME_HTTPS:
00065     len = url.getHttpPath(buf, sizeof(buf));
00066     buf[len] = '\0';
00067     cout << "http path     : " << buf << endl;
00068     len = url.getParams(buf, sizeof(buf));
00069     buf[len] = '\0';
00070     cout << "http params   : " << buf << endl;
00071     len = url.getQuery(buf, sizeof(buf));
00072     buf[len] = '\0';
00073     cout << "http query    : " << buf << endl;
00074     len = url.getFragment(buf, sizeof(buf));
00075     buf[len] = '\0';
00076     cout << "http fragment : " << buf << endl;
00077     break;
00078 
00079   default:
00080     break;
00081 
00082   }
00083   cout << "real length   : " << strlen(url_string) << endl;
00084   cout << "u-bound length: " << url.getUrlLengthUpperBound() << endl;
00085   cout << endl;
00086 
00087   int bl = url.dump(buf, sizeof(buf) - 1);
00088   cout << buf << endl << endl;
00089   cout << "bytes = " << bl << endl;
00090 
00091   return (url_p);
00092 }
00093 
00094 void
00095 test_marshal(URL * url)
00096 {
00097   char buf[8196];
00098 
00099   int bl = url->marshal(buf, sizeof(buf) - 1);
00100   cout << buf << endl << endl;
00101   cout << "bytes = " << bl << endl;
00102 
00103   
00104   URL new_url;
00105   new_url.unmarshal(buf, bl);
00106 
00107   int bl2 = new_url.marshal(buf, sizeof(buf) - 1);
00108   cout << buf << endl << endl;
00109   cout << "bytes = " << bl << endl;
00110 
00111   return;
00112 }
00113 
00114 
00115 main()
00116 {
00117   create_url("www.microsoft.com/isapi/redir.dll?TARGET=%2Foffice%2Fmigration%2F&nonie3home&homepage&&&&headline1&1006");
00118 }