summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/strutl.cc26
-rw-r--r--apt-pkg/contrib/strutl.h3
2 files changed, 27 insertions, 2 deletions
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index c1a1cb4db..7175402a7 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.35 2001/02/20 07:03:17 jgg Exp $
+// $Id: strutl.cc,v 1.36 2001/02/23 05:45:27 jgg Exp $
/* ######################################################################
String Util - Some useful string functions.
@@ -880,6 +880,30 @@ void ioprintf(ostream &out,const char *format,...)
}
/*}}}*/
+// CheckDomainList - See if Host is in a , seperate list /*{{{*/
+// ---------------------------------------------------------------------
+/* The domain list is a comma seperate list of domains that are suffix
+ matched against the argument */
+bool CheckDomainList(string Host,string List)
+{
+ const char *Start = List.begin();
+ for (const char *Cur = List.begin(); Cur <= List.end() ; Cur++)
+ {
+ if (Cur < List.end() && *Cur != ',')
+ continue;
+
+ // Match the end of the string..
+ if ((Host.size() >= (Cur - List.begin())) &&
+ Cur - Start != 0 &&
+ stringcasecmp(Host.end() - (Cur - Start),Host.end(),Start,Cur) == 0)
+ return true;
+
+ Start = Cur + 1;
+ }
+ return false;
+}
+ /*}}}*/
+
// URI::CopyFrom - Copy from an object /*{{{*/
// ---------------------------------------------------------------------
/* This parses the URI into all of its components */
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index 5549673a1..88f9a5013 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.16 2001/02/20 07:03:17 jgg Exp $
+// $Id: strutl.h,v 1.17 2001/02/23 05:45:27 jgg Exp $
/* ######################################################################
String Util - These are some useful string functions
@@ -53,6 +53,7 @@ bool Hex2Num(const char *Start,const char *End,unsigned char *Num,
bool TokSplitString(char Tok,char *Input,char **List,
unsigned long ListMax);
void ioprintf(ostream &out,const char *format,...) APT_FORMAT2;
+bool CheckDomainList(string Host,string List);
int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
inline int stringcmp(const char *A,const char *AEnd,const char *B) {return stringcmp(A,AEnd,B,B+strlen(B));};