More local string management.
This commit is contained in:
@ -10,6 +10,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "../dlib/dlib.h"
|
||||
#include "msg.hh"
|
||||
@ -17,8 +18,8 @@
|
||||
#include "domain.hh"
|
||||
|
||||
struct Rule {
|
||||
char *origin;
|
||||
char *destination;
|
||||
std::string origin;
|
||||
std::string destination;
|
||||
};
|
||||
|
||||
std::vector< Rule > exceptions;
|
||||
@ -64,10 +65,8 @@ void a_Domain_parse(FILE *fp)
|
||||
MSG("Domain: Default action \"%s\" not recognised.\n", tok2);
|
||||
}
|
||||
} else {
|
||||
exceptions.emplace_back();
|
||||
exceptions.back().origin = dStrdup(tok1);
|
||||
exceptions.back().destination = dStrdup(tok2);
|
||||
_MSG("Domain: Exception from %s to %s.\n", tok1, tok2);
|
||||
exceptions.emplace_back( tok1, tok2 );
|
||||
_MSG("Domain: Exception from %s to %s.\n", tok1.c_str(), tok2.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -77,12 +76,6 @@ void a_Domain_parse(FILE *fp)
|
||||
|
||||
void a_Domain_freeall(void)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < exceptions.size(); i++) {
|
||||
dFree(exceptions[i].origin);
|
||||
dFree(exceptions[i].destination);
|
||||
}
|
||||
exceptions.clear();
|
||||
}
|
||||
|
||||
@ -138,11 +131,11 @@ bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest)
|
||||
ret = default_deny ? FALSE : TRUE;
|
||||
|
||||
for (i = 0; i < exceptions.size(); i++) {
|
||||
if (Domain_match(source_host, exceptions[i].origin) &&
|
||||
Domain_match(dest_host, exceptions[i].destination)) {
|
||||
if (Domain_match(source_host, exceptions[i].origin.c_str()) &&
|
||||
Domain_match(dest_host, exceptions[i].destination.c_str())) {
|
||||
ret = default_deny;
|
||||
_MSG("Domain: Matched rule from %s to %s.\n", exceptions[i].origin,
|
||||
exceptions[i].destination);
|
||||
_MSG("Domain: Matched rule from %s to %s.\n", exceptions[i].origin.c_str(),
|
||||
exceptions[i].destination.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user