Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
c4090b67
Commit
c4090b67
authored
Jan 03, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Permission: use std::map instead of GHashTable
parent
ddf11237
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
22 deletions
+9
-22
Main.cxx
src/Main.cxx
+0
-1
Permission.cxx
src/Permission.cxx
+9
-19
Permission.hxx
src/Permission.hxx
+0
-2
No files found.
src/Main.cxx
View file @
c4090b67
...
@@ -538,7 +538,6 @@ int mpd_main(int argc, char *argv[])
...
@@ -538,7 +538,6 @@ int mpd_main(int argc, char *argv[])
volume_finish
();
volume_finish
();
mapper_finish
();
mapper_finish
();
path_global_finish
();
path_global_finish
();
finishPermissions
();
pc_free
(
global_player_control
);
pc_free
(
global_player_control
);
command_finish
();
command_finish
();
update_global_finish
();
update_global_finish
();
...
...
src/Permission.cxx
View file @
c4090b67
...
@@ -25,6 +25,9 @@ extern "C" {
...
@@ -25,6 +25,9 @@ extern "C" {
#include "conf.h"
#include "conf.h"
}
}
#include <map>
#include <string>
#include <glib.h>
#include <glib.h>
#include <stdbool.h>
#include <stdbool.h>
...
@@ -38,7 +41,7 @@ extern "C" {
...
@@ -38,7 +41,7 @@ extern "C" {
#define PERMISSION_CONTROL_STRING "control"
#define PERMISSION_CONTROL_STRING "control"
#define PERMISSION_ADMIN_STRING "admin"
#define PERMISSION_ADMIN_STRING "admin"
static
GHashTable
*
permission_passwords
;
static
std
::
map
<
std
::
string
,
unsigned
>
permission_passwords
;
static
unsigned
permission_default
;
static
unsigned
permission_default
;
...
@@ -78,9 +81,6 @@ void initPermissions(void)
...
@@ -78,9 +81,6 @@ void initPermissions(void)
unsigned
permission
;
unsigned
permission
;
const
struct
config_param
*
param
;
const
struct
config_param
*
param
;
permission_passwords
=
g_hash_table_new_full
(
g_str_hash
,
g_str_equal
,
g_free
,
NULL
);
permission_default
=
PERMISSION_READ
|
PERMISSION_ADD
|
permission_default
=
PERMISSION_READ
|
PERMISSION_ADD
|
PERMISSION_CONTROL
|
PERMISSION_ADMIN
;
PERMISSION_CONTROL
|
PERMISSION_ADMIN
;
...
@@ -104,9 +104,8 @@ void initPermissions(void)
...
@@ -104,9 +104,8 @@ void initPermissions(void)
permission
=
parsePermissions
(
separator
+
1
);
permission
=
parsePermissions
(
separator
+
1
);
g_hash_table_replace
(
permission_passwords
,
permission_passwords
.
insert
(
std
::
make_pair
(
password
,
password
,
permission
));
GINT_TO_POINTER
(
permission
));
}
while
((
param
=
config_get_next_param
(
CONF_PASSWORD
,
param
)));
}
while
((
param
=
config_get_next_param
(
CONF_PASSWORD
,
param
)));
}
}
...
@@ -118,23 +117,14 @@ void initPermissions(void)
...
@@ -118,23 +117,14 @@ void initPermissions(void)
int
getPermissionFromPassword
(
char
const
*
password
,
unsigned
*
permission
)
int
getPermissionFromPassword
(
char
const
*
password
,
unsigned
*
permission
)
{
{
bool
found
;
auto
i
=
permission_passwords
.
find
(
password
);
gpointer
key
,
value
;
if
(
i
==
permission_passwords
.
end
())
found
=
g_hash_table_lookup_extended
(
permission_passwords
,
password
,
&
key
,
&
value
);
if
(
!
found
)
return
-
1
;
return
-
1
;
*
permission
=
GPOINTER_TO_INT
(
value
)
;
*
permission
=
i
->
second
;
return
0
;
return
0
;
}
}
void
finishPermissions
(
void
)
{
g_hash_table_destroy
(
permission_passwords
);
}
unsigned
getDefaultPermissions
(
void
)
unsigned
getDefaultPermissions
(
void
)
{
{
return
permission_default
;
return
permission_default
;
...
...
src/Permission.hxx
View file @
c4090b67
...
@@ -29,8 +29,6 @@
...
@@ -29,8 +29,6 @@
int
getPermissionFromPassword
(
char
const
*
password
,
unsigned
*
permission
);
int
getPermissionFromPassword
(
char
const
*
password
,
unsigned
*
permission
);
void
finishPermissions
(
void
);
unsigned
getDefaultPermissions
(
void
);
unsigned
getDefaultPermissions
(
void
);
void
initPermissions
(
void
);
void
initPermissions
(
void
);
...
...
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