Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
6a1f401a
Commit
6a1f401a
authored
Nov 15, 2016
by
Eric Cano
Browse files
Moved Regex into common/Utils
parent
a3c1a047
Changes
17
Hide whitespace changes
Inline
Side-by-side
common/CMakeLists.txt
View file @
6a1f401a
...
...
@@ -117,6 +117,7 @@ set (COMMON_LIB_SRC_FILES
threading/Semaphores.cpp
threading/SubProcess.cpp
utils/GetOptThreadSafe.cpp
utils/Regex.cpp
utils/utils.cpp
utils/strerror_r_wrapper.cpp
CreationLog.cpp
...
...
@@ -135,7 +136,6 @@ target_link_libraries (ctacommon
pthread
uuid
z
Utils
cap
)
set
(
COMMON_UNIT_TESTS_LIB_SRC_FILES
...
...
@@ -160,6 +160,7 @@ set (COMMON_UNIT_TESTS_LIB_SRC_FILES
threading/ThreadingTests.cpp
threading/AtomicCounterTest.cpp
utils/GetOptThreadSafeTest.cpp
utils/RegexTest.cpp
utils/UtilsTest.cpp
UserIdentityTest.cpp
optionalTest.cpp
)
...
...
common/checksum/Checksum.cpp
View file @
6a1f401a
...
...
@@ -17,7 +17,7 @@
*/
#include
"common/checksum/Checksum.hpp"
#include
"
tapeserver/castor/tape/tapeserver
/utils/Regex.hpp"
#include
"
common
/utils/Regex.hpp"
#include
<sstream>
//------------------------------------------------------------------------------
...
...
@@ -42,7 +42,7 @@ cta::Checksum::Checksum(const std::string& url): m_type(CHECKSUMTYPE_NONE) {
if
(
url
.
empty
()
||
url
==
"-"
)
{
return
;
}
castor
::
tape
::
utils
::
Regex
re
(
"^adler32:0[Xx]([[:xdigit:]]+)$"
);
utils
::
Regex
re
(
"^adler32:0[Xx]([[:xdigit:]]+)$"
);
auto
result
=
re
.
exec
(
url
);
if
(
result
.
size
())
{
m_type
=
CHECKSUMTYPE_ADLER32
;
...
...
tapeserver/castor/tape/tapeserver
/utils/Regex.cpp
→
common
/utils/Regex.cpp
View file @
6a1f401a
...
...
@@ -25,9 +25,9 @@
#include
"common/exception/Exception.hpp"
#include
<regex.h>
using
namespace
c
astor
::
tape
;
namespace
c
ta
{
namespace
utils
{
utils
::
Regex
::
Regex
(
const
char
*
re_str
)
:
m_set
(
false
)
{
Regex
::
Regex
(
const
char
*
re_str
)
:
m_set
(
false
)
{
if
(
int
rc
=
::
regcomp
(
&
m_re
,
re_str
,
REG_EXTENDED
))
{
std
::
string
error
(
"Could not compile regular expression:
\"
"
);
error
+=
re_str
;
...
...
@@ -42,12 +42,12 @@ utils::Regex::Regex(const char * re_str) : m_set(false) {
m_set
=
true
;
}
utils
::
Regex
::~
Regex
()
{
Regex
::~
Regex
()
{
if
(
m_set
)
::
regfree
(
&
m_re
);
}
std
::
vector
<
std
::
string
>
utils
::
Regex
::
exec
(
const
std
::
string
&
s
)
{
std
::
vector
<
std
::
string
>
Regex
::
exec
(
const
std
::
string
&
s
)
{
regmatch_t
matches
[
100
];
if
(
REG_NOMATCH
!=
::
regexec
(
&
m_re
,
s
.
c_str
(),
100
,
matches
,
0
))
{
std
::
vector
<
std
::
string
>
ret
;
...
...
@@ -61,3 +61,5 @@ std::vector<std::string> utils::Regex::exec(const std::string &s) {
}
return
std
::
vector
<
std
::
string
>
();
}
}}
// namespace cta::utils
tapeserver/castor/tape/tapeserver
/utils/Regex.hpp
→
common
/utils/Regex.hpp
View file @
6a1f401a
...
...
@@ -31,9 +31,7 @@
* useful for its destructor which will allow
* RAII.
*/
namespace
castor
{
namespace
tape
{
namespace
utils
{
namespace
cta
{
namespace
utils
{
class
Regex
{
public:
...
...
@@ -44,6 +42,4 @@ namespace utils {
regex_t
m_re
;
bool
m_set
;
};
/* class regex */
}
// namespace Utils
}
// namespace tape
}
// namespace castor
}}
// namespace cta::utils
tapeserver/castor/tape/tapeserver
/utils/RegexTest.cpp
→
common
/utils/RegexTest.cpp
View file @
6a1f401a
...
...
@@ -32,8 +32,8 @@ using ::testing::_;
namespace
unitTests
{
TEST
(
castor_tape_utils_
Regex
,
BasicFunctionality
)
{
ca
stor
::
tape
::
utils
::
Regex
re
(
"a(b)"
);
TEST
(
Regex
,
BasicFunctionality
)
{
c
t
a
::
utils
::
Regex
re
(
"a(b)"
);
std
::
vector
<
std
::
string
>
ret1
,
ret2
;
ret1
=
re
.
exec
(
"1abc"
);
ret2
=
re
.
exec
(
"xyz"
);
...
...
@@ -44,8 +44,8 @@ TEST(castor_tape_utils_Regex, BasicFunctionality) {
ASSERT_EQ
(
ret2
.
size
(),
0U
);
}
TEST
(
castor_tape_utils_
Regex
,
OperationalTest
)
{
ca
stor
::
tape
::
utils
::
Regex
re
(
"^scsi_tape:(st[[:digit:]]+)$"
);
TEST
(
Regex
,
OperationalTest
)
{
c
t
a
::
utils
::
Regex
re
(
"^scsi_tape:(st[[:digit:]]+)$"
);
std
::
vector
<
std
::
string
>
ret1
,
ret2
,
ret3
;
ret1
=
re
.
exec
(
"scsi_tape:st1"
);
ret2
=
re
.
exec
(
"scsi_tape:st124"
);
...
...
@@ -61,8 +61,8 @@ TEST(castor_tape_utils_Regex, OperationalTest) {
}
TEST
(
castor_tape_utils_
Regex
,
SubstringMatch
)
{
ca
stor
::
tape
::
utils
::
Regex
re
(
"^radosstriper:///([^:]+@[^:]+):(.*)$"
);
TEST
(
Regex
,
SubstringMatch
)
{
c
t
a
::
utils
::
Regex
re
(
"^radosstriper:///([^:]+@[^:]+):(.*)$"
);
std
::
vector
<
std
::
string
>
ret1
;
ret1
=
re
.
exec
(
"radosstriper:///user@pool:12345@castorns.7890"
);
...
...
objectstore/BackendFactory.cpp
View file @
6a1f401a
...
...
@@ -20,11 +20,11 @@
#include
"BackendRados.hpp"
#include
"BackendVFS.hpp"
#include
"common/utils/utils.hpp"
#include
"
tapeserver/castor/tape/tapeserver
/utils/Regex.hpp"
#include
"
common
/utils/Regex.hpp"
auto
cta
::
objectstore
::
BackendFactory
::
createBackend
(
const
std
::
string
&
URL
)
->
std
::
unique_ptr
<
Backend
>
{
castor
::
tape
::
utils
::
Regex
fileRe
(
"^file://(.*)$"
),
utils
::
Regex
fileRe
(
"^file://(.*)$"
),
radosRe
(
"^rados://([^@]+)@(.*)$"
);
std
::
vector
<
std
::
string
>
regexResult
;
// Is it a file:// URL?
...
...
objectstore/BackendVFS.cpp
View file @
6a1f401a
...
...
@@ -19,7 +19,7 @@
#include
"BackendVFS.hpp"
#include
"common/exception/Errnum.hpp"
#include
"common/utils/utils.hpp"
#include
"
tapeserver/castor/tape/tapeserver
/utils/Regex.hpp"
#include
"
common
/utils/Regex.hpp"
#include
<fstream>
#include
<stdlib.h>
...
...
@@ -186,7 +186,7 @@ bool BackendVFS::exists(std::string name) {
std
::
list
<
std
::
string
>
BackendVFS
::
list
()
{
std
::
list
<
std
::
string
>
ret
;
// We should not list ., .. and the .<object>.lock files
castor
::
tape
::
utils
::
Regex
re
(
"^(
\\
..+
\\
.lock|
\\
.{1,2})$"
);
utils
::
Regex
re
(
"^(
\\
..+
\\
.lock|
\\
.{1,2})$"
);
::
DIR
*
dir
=
::
opendir
(
m_root
.
c_str
());
cta
::
exception
::
Errnum
::
throwOnNull
(
dir
);
while
(
struct
::
dirent
*
ent
=::
readdir
(
dir
))
{
...
...
objectstore/CMakeLists.txt
View file @
6a1f401a
...
...
@@ -68,7 +68,7 @@ add_library (ctaobjectstore SHARED
GarbageCollector.cpp
SchedulerGlobalLock.cpp
ValueCountMap.cpp
)
target_link_libraries
(
ctaobjectstore
Utils
rados json-c ctautils
)
target_link_libraries
(
ctaobjectstore rados json-c ctautils
)
set_source_files_properties
(
BackendRados.cpp PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations
)
install
(
TARGETS ctaobjectstore DESTINATION usr/
${
CMAKE_INSTALL_LIBDIR
}
)
...
...
scheduler/CMakeLists.txt
View file @
6a1f401a
...
...
@@ -28,7 +28,7 @@ add_library (ctascheduler SHARED
${
CTA_SCHEDULER_SRC_FILES
}
)
install
(
TARGETS ctascheduler DESTINATION usr/
${
CMAKE_INSTALL_LIBDIR
}
)
target_link_libraries
(
ctascheduler ctacommon ctaobjectstore protobuf
Utils
ctautils
)
target_link_libraries
(
ctascheduler ctacommon ctaobjectstore protobuf ctautils
)
#add_library (ctaschedulerutils SHARED
# _old_prototype_DummyScheduler.cpp)
...
...
tapeserver/castor/tape/tapeserver/CMakeLists.txt
View file @
6a1f401a
...
...
@@ -39,7 +39,6 @@ set(CTEST_OUTPUT_ON_FAILURE 1)
add_subdirectory
(
SCSI
)
add_subdirectory
(
drive
)
add_subdirectory
(
system
)
add_subdirectory
(
utils
)
add_subdirectory
(
file
)
add_subdirectory
(
daemon
)
...
...
tapeserver/castor/tape/tapeserver/SCSI/Device.cpp
View file @
6a1f401a
...
...
@@ -37,7 +37,7 @@ using namespace castor::tape;
*/
SCSI
::
DeviceVector
::
DeviceVector
(
System
::
virtualWrapper
&
sysWrapper
)
:
m_sysWrapper
(
sysWrapper
)
{
std
::
string
sysDevsPath
=
"/sys/bus/scsi/devices"
;
utils
::
Regex
ifFirstCharIsDigit
(
"^[[:digit:]]"
);
cta
::
utils
::
Regex
ifFirstCharIsDigit
(
"^[[:digit:]]"
);
std
::
vector
<
std
::
string
>
checkResult
;
DIR
*
dirp
;
cta
::
exception
::
Errnum
::
throwOnNull
(
...
...
@@ -142,8 +142,8 @@ void SCSI::DeviceVector::getTapeInfo(DeviceInfo & devinfo) {
tapeDir
=
""
;
}
utils
::
Regex
st_re
((
scsiPrefix
+
"(st[[:digit:]]+)$"
).
c_str
());
utils
::
Regex
nst_re
((
scsiPrefix
+
"(nst[[:digit:]]+)$"
).
c_str
());
cta
::
utils
::
Regex
st_re
((
scsiPrefix
+
"(st[[:digit:]]+)$"
).
c_str
());
cta
::
utils
::
Regex
nst_re
((
scsiPrefix
+
"(nst[[:digit:]]+)$"
).
c_str
());
while
(
struct
dirent
*
dent
=
m_sysWrapper
.
readdir
(
dirp
))
{
std
::
vector
<
std
::
string
>
res
;
...
...
tapeserver/castor/tape/tapeserver/SCSI/Device.hpp
View file @
6a1f401a
...
...
@@ -30,7 +30,7 @@
#include
<dirent.h>
#include
"../system/Wrapper.hpp"
#include
"common/exception/Exception.hpp"
#include
"
..
/utils/Regex.hpp"
#include
"
common
/utils/Regex.hpp"
#include
"Constants.hpp"
#include
<string>
...
...
tapeserver/castor/tape/tapeserver/daemon/EncryptionControl.cpp
View file @
6a1f401a
...
...
@@ -25,7 +25,7 @@
#include
"EncryptionControl.hpp"
#include
"common/threading/SubProcess.hpp"
#include
"c
astor/tape/tapeserver
/utils/Regex.hpp"
#include
"c
ommon
/utils/Regex.hpp"
#include
"common/exception/Exception.hpp"
namespace
castor
{
...
...
tapeserver/castor/tape/tapeserver/drive/CMakeLists.txt
View file @
6a1f401a
...
...
@@ -51,7 +51,6 @@ target_link_libraries(TapeDriveReadWriteTest
ctamediachanger
SCSI
System
Utils
ctacommon
#ctaclient
ctaTapeServerDaemon
...
...
tapeserver/castor/tape/tapeserver/file/DiskFile.hpp
View file @
6a1f401a
...
...
@@ -23,7 +23,7 @@
#pragma once
#include
"c
astor/tape/tapeserver
/utils/Regex.hpp"
#include
"c
ommon
/utils/Regex.hpp"
#include
"common/threading/Mutex.hpp"
#include
<cryptopp/rsa.h>
#include
<memory>
...
...
@@ -54,7 +54,7 @@ namespace castor {
* Currently, the parameter allows switching between RFIO and XROOT
*/
class
DiskFileFactory
{
typedef
ca
stor
::
tape
::
utils
::
Regex
Regex
;
typedef
c
t
a
::
utils
::
Regex
Regex
;
public:
DiskFileFactory
(
const
std
::
string
&
remoteFileProtocol
,
const
std
::
string
&
xrootPrivateKey
,
uint16_t
xrootTimeout
,
...
...
tapeserver/castor/tape/tapeserver/utils/CMakeLists.txt
deleted
100644 → 0
View file @
a3c1a047
# This file is part of the Castor project.
# See http://castor.web.cern.ch/castor
#
# Copyright (C) 2003 CERN
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# @author Castor Dev team, castor-dev@cern.ch
#
cmake_minimum_required
(
VERSION 2.6
)
include_directories
(
${
CMAKE_SOURCE_DIR
}
/tapeserver
)
add_library
(
Utils Regex.cpp
)
add_library
(
ctatapeserverutilsunittests SHARED
RegexTest.cpp
)
target_link_libraries
(
ctatapeserverutilsunittests
Utils
)
install
(
TARGETS ctatapeserverutilsunittests DESTINATION usr/
${
CMAKE_INSTALL_LIBDIR
}
)
tests/CMakeLists.txt
View file @
6a1f401a
...
...
@@ -32,7 +32,6 @@ target_link_libraries(cta-unitTests
ctatapeserverdriveunittests
ctatapeserverfileunittests
ctatapeserverscsiunittests
ctatapeserverutilsunittests
ctautilsunittests
ctacommon
ctacommonunittests
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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