summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/configuration.cc27
-rw-r--r--apt-pkg/contrib/configuration.h4
-rw-r--r--apt-pkg/contrib/strutl.cc114
-rw-r--r--apt-pkg/contrib/strutl.h19
4 files changed, 148 insertions, 16 deletions
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index fa07ed35a..27299ec6a 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: configuration.cc,v 1.8 1998/10/22 04:56:45 jgg Exp $
+// $Id: configuration.cc,v 1.9 1998/10/30 07:53:42 jgg Exp $
/* ######################################################################
Configuration Class
@@ -212,6 +212,31 @@ bool Configuration::Exists(const char *Name)
return true;
}
/*}}}*/
+// Configuration::Dump - Dump the config /*{{{*/
+// ---------------------------------------------------------------------
+/* Dump the entire configuration space */
+void Configuration::Dump()
+{
+ /* Write out all of the configuration directives by walking the
+ configuration tree */
+ const Configuration::Item *Top = _config->Tree(0);
+ for (; Top != 0;)
+ {
+ clog << Top->FullTag() << " \"" << Top->Value << "\";" << endl;
+
+ if (Top->Child != 0)
+ {
+ Top = Top->Child;
+ continue;
+ }
+
+ while (Top != 0 && Top->Next == 0)
+ Top = Top->Parent;
+ if (Top != 0)
+ Top = Top->Next;
+ }
+}
+ /*}}}*/
// Configuration::Item::FullTag - Return the fully scoped tag /*{{{*/
// ---------------------------------------------------------------------
diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h
index 14c80e4ad..cf5a90f57 100644
--- a/apt-pkg/contrib/configuration.h
+++ b/apt-pkg/contrib/configuration.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: configuration.h,v 1.6 1998/10/22 04:56:46 jgg Exp $
+// $Id: configuration.h,v 1.7 1998/10/30 07:53:44 jgg Exp $
/* ######################################################################
Configuration Class
@@ -65,6 +65,8 @@ class Configuration
bool Exists(const char *Name);
inline const Item *Tree(const char *Name) {return Lookup(Name,false);};
+
+ void Dump();
Configuration();
};
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 68421a241..d6a7143e4 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: strutl.cc,v 1.8 1998/10/24 04:58:07 jgg Exp $
+// $Id: strutl.cc,v 1.9 1998/10/30 07:53:45 jgg Exp $
/* ######################################################################
String Util - Some usefull string functions.
@@ -308,17 +308,6 @@ string URItoFileName(string URI)
return URI;
}
/*}}}*/
-// URIAccess - Return the access method for the URI /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string URIAccess(string URI)
-{
- string::size_type Pos = URI.find(':');
- if (Pos == string::npos)
- return URI;
- return string(URI,0,Pos);
-}
- /*}}}*/
// Base64Encode - Base64 Encoding routine for short strings /*{{{*/
// ---------------------------------------------------------------------
/* This routine performs a base64 transformation on a string. It was ripped
@@ -619,3 +608,104 @@ bool StrToTime(string Val,time_t &Result)
return true;
}
/*}}}*/
+
+// URI::URI - Constructor /*{{{*/
+// ---------------------------------------------------------------------
+/* This parses the URI into all of its components */
+URI::URI(string U)
+{
+ string::const_iterator I = U.begin();
+
+ // Locate the first colon, this seperates the scheme
+ for (; I < U.end() && *I != ':' ; I++);
+ string::const_iterator FirstColon = I;
+
+ // Determine if this is a host type URI with a leading double //
+ string::const_iterator SingleSlash = I;
+ if (I + 3 < U.end() && I[1] == '/' && I[2] == '/')
+ {
+ // Locate the single / that starts the path
+ for (; I < U.end(); I++)
+ {
+ if (*I == '/' && I[1] == '/')
+ I += 2;
+ else
+ if (*I == '/')
+ break;
+ }
+ if (I > U.end())
+ I = U.end();
+ SingleSlash = I;
+ }
+
+ // We can now write the access and path specifiers
+ Access = string(U,0,FirstColon - U.begin());
+ if (SingleSlash != U.end())
+ Path = string(U,SingleSlash - U.begin() + 1);
+
+ // Now we attempt to locate a user:pass@host fragment
+ FirstColon += 3;
+ if (FirstColon >= U.end())
+ return;
+
+ if (FirstColon > SingleSlash)
+ FirstColon = SingleSlash;
+
+ // Search for the @
+ I = FirstColon;
+ for (; I < SingleSlash && *I != '@'; I++);
+ string::const_iterator At = I;
+
+ // Colon in the @ section
+ I = FirstColon + 1;
+ for (; I < At && *I != ':'; I++);
+ string::const_iterator SecondColon = I;
+
+ // Now write the host and user/pass
+ if (At == SingleSlash)
+ {
+ if (FirstColon < SingleSlash)
+ Host = string(U,FirstColon - U.begin(),SingleSlash - FirstColon);
+ }
+ else
+ {
+ Host = string(U,At - U.begin() + 1,SingleSlash - At - 1);
+ User = string(U,FirstColon - U.begin(),SecondColon - FirstColon);
+ if (SecondColon < At)
+ Password = string(U,SecondColon - U.begin() + 1,At - SecondColon - 1);
+ }
+
+ // Now we parse off a pot number from the hostname
+ Port = 0;
+ string::size_type Pos = Host.rfind(':');
+ if (Pos == string::npos)
+ return;
+
+ Port = atoi(string(Host,Pos+1).c_str());
+ Host = string(Host,0,Pos);
+}
+ /*}}}*/
+// URI::operator string - Convert the URI to a string /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+URI::operator string()
+{
+ string Res = Access + ':';
+ if (Host.empty() == false)
+ {
+ if (User.empty() == false)
+ {
+ Res += "//" + User;
+ if (Password.empty() == false)
+ Res += ":" + Password;
+ Res += "@";
+ }
+ Res += Host;
+ }
+
+ if (Path.empty() == false)
+ Res += "/" + Path;
+
+ return Res;
+}
+ /*}}}*/
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index 1de2437b9..7e3e47344 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: strutl.h,v 1.7 1998/10/23 00:50:00 jgg Exp $
+// $Id: strutl.h,v 1.8 1998/10/30 07:53:46 jgg Exp $
/* ######################################################################
String Util - These are some usefull string functions
@@ -32,7 +32,6 @@ string TimeToStr(unsigned long Sec);
string SubstVar(string Str,string Subst,string Contents);
string Base64Encode(string Str);
string URItoFileName(string URI);
-string URIAccess(string URI);
string TimeRFC1123(time_t Date);
bool StrToTime(string Val,time_t &Result);
string LookupTag(string Message,const char *Tag,const char *Default = 0);
@@ -44,4 +43,20 @@ inline int stringcmp(const char *A,const char *AEnd,const char *B) {return strin
int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
inline int stringcasecmp(const char *A,const char *AEnd,const char *B) {return stringcasecmp(A,AEnd,B,B+strlen(B));};
+class URI
+{
+ public:
+
+ string Access;
+ string User;
+ string Password;
+ string Host;
+ string Path;
+ unsigned int Port;
+
+ operator string();
+
+ URI(string Path);
+};
+
#endif