Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
mhwd
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
30
Issues
30
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
2
Merge Requests
2
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Applications
mhwd
Commits
7a1852f9
Commit
7a1852f9
authored
Apr 29, 2012
by
Roland Singer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* added function to include extern files from config
* implemented function to determind right path of included files
parent
d1e1bd56
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
8 deletions
+52
-8
libmhwd/config.cpp
libmhwd/config.cpp
+44
-1
libmhwd/config.h
libmhwd/config.h
+1
-0
libmhwd/const.h
libmhwd/const.h
+1
-1
libmhwd/test/test.cpp
libmhwd/test/test.cpp
+6
-6
No files found.
libmhwd/config.cpp
View file @
7a1852f9
...
...
@@ -69,9 +69,41 @@ bool mhwd::Config::readConfig(const Vita::string path) {
key
=
parts
.
front
().
trim
().
toLower
();
value
=
parts
.
back
().
trim
(
"
\"
"
).
trim
();
// Read in extern file
if
(
value
.
size
()
>
1
&&
value
.
substr
(
0
,
1
)
==
">"
)
{
ifstream
file
(
getRightPath
(
value
.
substr
(
1
)).
c_str
(),
ios
::
in
);
if
(
!
file
.
is_open
())
return
false
;
Vita
::
string
line
;
value
.
clear
();
while
(
!
file
.
eof
())
{
getline
(
file
,
line
);
size_t
pos
=
line
.
find_first_of
(
'#'
);
if
(
pos
!=
string
::
npos
)
line
.
erase
(
pos
);
if
(
line
.
trim
().
empty
())
continue
;
value
+=
" "
+
line
.
trim
();
}
file
.
close
();
value
=
value
.
trim
();
// remove all multiple spaces
while
(
value
.
find
(
" "
)
!=
string
::
npos
)
{
value
=
value
.
replace
(
" "
,
" "
);
}
}
if
(
key
==
"include"
)
{
readConfig
(
value
);
readConfig
(
getRightPath
(
value
)
);
}
else
if
(
key
==
"name"
)
{
name
=
value
;
...
...
@@ -147,3 +179,14 @@ void mhwd::Config::addNewIDsGroup() {
IDsGroup
group
;
IDs
.
push_back
(
group
);
}
Vita
::
string
mhwd
::
Config
::
getRightPath
(
Vita
::
string
str
)
{
str
=
str
.
trim
();
if
(
str
.
size
()
<=
0
||
str
.
substr
(
0
,
1
)
==
"/"
)
return
str
;
return
path
.
substr
(
0
,
path
.
find_last_of
(
'/'
))
+
"/"
+
str
;
}
libmhwd/config.h
View file @
7a1852f9
...
...
@@ -56,6 +56,7 @@ namespace mhwd {
bool
readConfig
(
const
Vita
::
string
path
);
vector
<
string
>
getIDs
(
Vita
::
string
str
);
inline
void
addNewIDsGroup
();
Vita
::
string
getRightPath
(
Vita
::
string
str
);
};
}
...
...
libmhwd/const.h
View file @
7a1852f9
...
...
@@ -20,4 +20,4 @@
#define MHWD_CONFIG_END "mhwd"
#define MHWD_USB_CONFIG_DIR "/var/lib/mhwd/usb"
#define MHWD_PCI_CONFIG_DIR "/var/lib/mhwd/pci"
#define MHWD_PCI_CONFIG_DIR "
." //"
/var/lib/mhwd/pci"
libmhwd/test/test.cpp
View file @
7a1852f9
...
...
@@ -16,14 +16,13 @@ using namespace std;
int
main
(
int
argc
,
char
*
argv
[])
{
mhwd
::
hwd
::
printUSBDetails
();
/*vector<mhwd::Device*> devices = mhwd::hwd::getPCIDevices();
vector
<
mhwd
::
Device
*>
devices
=
mhwd
::
hwd
::
getPCIDevices
();
for
(
vector
<
mhwd
::
Device
*>::
const_iterator
iterator
=
devices
.
begin
();
iterator
!=
devices
.
end
();
iterator
++
)
{
vector
<
mhwd
::
Config
>
configs
=
(
*
iterator
)
->
getConfigs
();
cout << (*iterator)->getClassName() << ": ";
if
(
!
configs
.
empty
())
cout
<<
(
*
iterator
)
->
getClassName
()
<<
": "
;
for
(
vector
<
mhwd
::
Config
>::
const_iterator
iterator
=
configs
.
begin
();
iterator
!=
configs
.
end
();
iterator
++
)
{
mhwd
::
Config
config
=
(
*
iterator
);
...
...
@@ -31,8 +30,9 @@ int main (int argc, char *argv[])
cout
<<
config
.
getName
()
<<
" "
;
}
cout << endl;
}+/
if
(
!
configs
.
empty
())
cout
<<
endl
;
}
/*for(unsigned int i = 0; i < devices.size(); i++) {
cout << setw(30) << devices[i]->getClassName();
...
...
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