Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
svn
ddnssync
Commits
87fd162f
Commit
87fd162f
authored
Oct 02, 2007
by
mr-ti
Browse files
No commit message
No commit message
parent
73665a19
Changes
4
Hide whitespace changes
Inline
Side-by-side
ddnssbase/cregex.cpp
View file @
87fd162f
...
...
@@ -21,7 +21,7 @@ CRegex::CRegex(const string &expr, int flags)
}
else
{
state
=
ERROR
;
}
nmatch
=
regex
.
re_nsub
;
nmatch
=
1
/*
regex.re_nsub
*/
;
pmatch
=
(
regmatch_t
*
)
malloc
(
sizeof
(
regmatch_t
)
*
nmatch
);
}
...
...
@@ -63,20 +63,28 @@ bool CRegex::exec(int flags){
}
}
string
CRegex
::
getFirstMatch
(
unsigned
int
level
){
unsigned
int
CRegex
::
begin
(){
return
(
state
==
MATCH
?
pmatch
[
0
].
rm_so
:
0
);
}
unsigned
int
CRegex
::
end
(){
return
(
state
==
MATCH
?
pmatch
[
0
].
rm_eo
:
0
);
}
string
CRegex
::
getFirstMatch
(){
string
match
;
if
(
exec
()
&&
pmatch
[
level
].
rm_so
!=-
1
&&
level
<=
regex
.
re_nsub
){
match
=
buffer
->
substr
(
pmatch
[
level
].
rm_so
,
pmatch
[
level
].
rm_eo
-
pmatch
[
level
].
rm_so
);
if
(
exec
()
&&
pmatch
[
0
].
rm_so
!=-
1
){
match
=
buffer
->
substr
(
pmatch
[
0
].
rm_so
,
pmatch
[
0
].
rm_eo
-
pmatch
[
0
].
rm_so
);
}
return
match
;
}
list
<
string
>
CRegex
::
getMatchs
(
unsigned
int
level
){
list
<
string
>
CRegex
::
getMatchs
(){
list
<
string
>
lst
;
if
(
state
!=
ERROR
&&
level
<=
regex
.
re_nsub
){
if
(
state
!=
ERROR
){
while
(
exec
()){
if
(
pmatch
[
level
].
rm_so
!=-
1
)
lst
.
push_back
(
buffer
->
substr
(
pmatch
[
level
].
rm_so
+
offset
,
pmatch
[
level
].
rm_eo
-
pmatch
[
level
].
rm_so
));
if
(
pmatch
[
0
].
rm_so
!=-
1
)
lst
.
push_back
(
buffer
->
substr
(
pmatch
[
0
].
rm_so
+
offset
,
pmatch
[
0
].
rm_eo
-
pmatch
[
0
].
rm_so
));
offset
+=
pmatch
[
0
].
rm_eo
+
1
;
}
offset
=
0
;
...
...
@@ -84,7 +92,7 @@ list<string> CRegex::getMatchs(unsigned int level){
return
lst
;
}
void
CRegex
::
setBuffer
(
string
*
buffer
){
void
CRegex
::
setBuffer
(
const
string
*
buffer
){
offset
=
0
;
this
->
buffer
=
buffer
;
}
...
...
ddnssbase/cregex.h
View file @
87fd162f
...
...
@@ -26,11 +26,13 @@ public:
};
CRegex
(
const
string
&
expr
,
int
flags
=
REG_EXTENDED
);
~
CRegex
();
void
setBuffer
(
string
*
buffer
);
void
setBuffer
(
const
string
*
buffer
);
bool
exec
(
int
flags
=
0
);
unsigned
int
begin
();
unsigned
int
end
();
State
getState
();
list
<
string
>
getMatchs
(
unsigned
int
level
=
0
);
string
getFirstMatch
(
unsigned
int
level
=
0
);
list
<
string
>
getMatchs
();
string
getFirstMatch
();
int
getErrorNb
();
string
getErrorMsg
();
virtual
string
className
();
...
...
@@ -40,8 +42,8 @@ private:
size_t
nmatch
;
regmatch_t
*
pmatch
;
int
errNo
;
string
*
buffer
;
unsigned
long
offset
;
const
string
*
buffer
;
string
::
size_type
offset
;
};
#endif
ddnssync/ddnsspluginlist.cpp
View file @
87fd162f
...
...
@@ -10,16 +10,16 @@
//
//
#include "ddnsspluginlist.h"
#include "../ddnssbase/cregex.h"
#include <dlfcn.h>
/**
* @brief DDnsSPluginList constructor.
*/
DDnsSPl
uginList
List
::
DDnsSPl
uginList
List
(
CUniConf
&
config
)
:
CUniObj
()
{
DDnsSPlList
::
DDnsSPlList
(
CUniConf
&
config
)
:
CUniObj
()
{
string
dirPath
=
config
.
getValue
(
"plugin_dir_path"
);
if
(
!
dirPath
.
empty
()){
CUniStringList
list
=
config
.
getListValue
(
"plugin_list"
);
Plugin
*
plugin
;
string
plugPath
;
void
*
handle
;
...
...
@@ -51,7 +51,7 @@ DDnsSPluginListList::DDnsSPluginListList(CUniConf &config):CUniObj() {
/**
* @brief DDnsSPluginList destructor.
*/
DDnsSPl
uginList
List
::~
DDnsSPl
uginList
List
()
{
DDnsSPlList
::~
DDnsSPlList
()
{
for
(
map
<
string
,
Plugin
*>::
iterator
it
=
plugList
.
begin
();
it
!=
plugList
.
end
();
it
++
){
dlclose
(
it
->
second
->
handle
);
delete
it
->
second
;
...
...
@@ -59,10 +59,25 @@ DDnsSPluginListList::~DDnsSPluginListList() {
}
}
void
DDnsSPlList
::
exec
(
const
string
&
request
){
CRegex
regex
(
"([[:alnum:]]+)"
);
regex
.
setBuffer
(
&
request
);
map
<
string
,
Plugin
*>::
iterator
it
=
plugList
.
find
(
regex
.
getFirstMatch
());
if
(
it
==
plugList
.
end
()){
throw
string
(
"Unknow command
\"
"
+
it
->
first
+
"
\"
"
);
}
else
{
string
::
size_type
newBeg
=
request
.
find_first_not_of
(
"
\t
"
,
regex
.
end
()
+
1
);
if
(
newBeg
==
string
::
npos
)
it
->
second
->
exec
(
""
);
else
it
->
second
->
exec
(
request
.
substr
(
newBeg
));
}
}
/**
* @brief The name of the class.
* @return "DDnsSPl
uginList
List"
* @return "DDnsSPlList"
*/
string
DDnsSPl
uginList
List
::
className
()
{
return
"DDnsSPl
uginList
List"
;
string
DDnsSPlList
::
className
()
{
return
"DDnsSPlList"
;
}
ddnssync/ddnsspluginlist.h
View file @
87fd162f
...
...
@@ -17,8 +17,8 @@
* @date 29/07/2007
*/
#ifndef DDNSSPL
UGIN
LIST_H
#define DDNSSPL
UGIN
LIST_H
#ifndef DDNSSPLLIST_H
#define DDNSSPLLIST_H
#include <unicomctrl/cuniconf.h>
#include <unicomctrl/unilib.h>
...
...
@@ -28,11 +28,11 @@
* This class can manage a plugin list.
* @brief Plugin list.
*/
class
DDnsSPl
uginList
List
:
public
CUniObj
{
class
DDnsSPlList
:
public
CUniObj
{
public:
DDnsSPl
uginList
List
(
CUniConf
&
config
);
~
DDnsSPl
uginList
List
();
void
exec
(
const
string
&
name
);
DDnsSPlList
(
CUniConf
&
config
);
~
DDnsSPlList
();
void
exec
(
const
string
&
request
);
virtual
string
className
();
private:
typedef
void
(
*
ExecFct
)(
const
string
&
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment