diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-09-03 06:44:56 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-09-03 06:44:56 +0200 |
commit | 95e1c55437699aee29235e5ba2c919adbf51145e (patch) | |
tree | 70ad905a8f3e9544b8c41380eea404d3231f2e41 /src | |
parent | test libgamma::method_capabilities (diff) | |
download | libgammamm-95e1c55437699aee29235e5ba2c919adbf51145e.tar.gz libgammamm-95e1c55437699aee29235e5ba2c919adbf51145e.tar.bz2 libgammamm-95e1c55437699aee29235e5ba2c919adbf51145e.tar.xz |
libgamma_group_gid and libgamma_group_name
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/libgamma-error.hh | 72 | ||||
-rw-r--r-- | src/test.cc | 16 |
2 files changed, 86 insertions, 2 deletions
diff --git a/src/libgamma-error.hh b/src/libgamma-error.hh index a30b2c7..5fe1cbc 100644 --- a/src/libgamma-error.hh +++ b/src/libgamma-error.hh @@ -24,9 +24,29 @@ #include "libgamma-native.hh" + +#ifndef __WIN32__ +# define libgamma_gid_t gid_t +#else +# define libgamma_gid_t short +#endif + + + namespace libgamma { /** + * Class for `group_gid`. + */ + class GroupGid; + + /** + * Class for `group_name`. + */ + class GroupName; + + + /** * Prints an error to stderr in a `perror` fashion, * however this function will not translate the `libgamma` * errors into human-readable strings, it will simply @@ -64,8 +84,56 @@ namespace libgamma int value_of_error(const std::string* name); - /* TODO libgamma_group_gid */ - /* TODO libgamma_group_name */ + /** + * Class for `group_gid`. + */ + class GroupGid + { + public: + const GroupGid& operator =(const libgamma_gid_t& value) const + { + libgamma_group_gid = value; + return *this; + } + + operator libgamma_gid_t() const + { + return libgamma_group_gid; + } + }; + + /** + * Group that the user needs to be a member of if + * `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned. + */ + extern GroupGid group_gid; + + + /** + * Class for `group_name`. + */ + class GroupName + { + public: + const GroupName& operator =(const char* value) const + { + libgamma_group_name = value; + return *this; + } + + operator char*() const + { + return (char*)libgamma_group_name; + } + }; + + /** + * Group that the user needs to be a member of if + * `LIBGAMMA_DEVICE_REQUIRE_GROUP` is returned, + * `nullptr` if the name of the group + * `libgamma::group_gid` cannot be determined. + */ + extern GroupName group_name; } diff --git a/src/test.cc b/src/test.cc index fabaa00..c802c71 100644 --- a/src/test.cc +++ b/src/test.cc @@ -155,6 +155,22 @@ int main(void) std::cout << "fake: " << caps.fake << std::endl; std::cout << std::endl; + std::cout << libgamma::group_gid << std::endl; + libgamma::group_gid = 10; + std::cout << libgamma::group_gid << std::endl; + std::cout << std::endl; + + if (libgamma::group_name == nullptr) + std::cout << "(nullptr)" << std::endl; + else + std::cout << libgamma::group_name << std::endl; + libgamma::group_name = "test-group"; + if (libgamma::group_name == nullptr) + std::cout << "(nullptr)" << std::endl; + else + std::cout << libgamma::group_name << std::endl; + std::cout << std::endl; + delete crtc; delete partition; delete site; |