NAWA  0.8
Web Application Framework for C++
oss.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2019-2021 Tobias Flaig.
8  *
9  * This file is part of nawa.
10  *
11  * nawa is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License,
13  * version 3, as published by the Free Software Foundation.
14  *
15  * nawa is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with nawa. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef NAWA_OPERATINGSYSTEMSPECIFIC_H
25 #define NAWA_OPERATINGSYSTEMSPECIFIC_H
26 
27 #include <climits>
28 #include <nawa/systemconfig.h>
29 #include <string>
30 #include <sys/stat.h>
31 #include <unistd.h>
32 
33 namespace nawa::oss {
34  inline time_t getLastModifiedTimeOfFile(struct stat const& fileStat) {
35 #ifdef NAWA_OS_LINUX
36  return fileStat.st_mtim.tv_sec;
37 #else
38  return fileStat.st_mtimespec.tv_sec;
39 #endif
40  }
41 
42  inline std::string getSystemHostname() {
43 #ifdef NAWA_OS_LINUX
44  char chostname[HOST_NAME_MAX + 1];
45 #else
46  char chostname[_POSIX_HOST_NAME_MAX + 1];
47 #endif
48  gethostname(chostname, sizeof chostname);
49  return std::string(chostname);
50  }
51 
52  inline std::string getProgramInvocationName() {
53 #ifdef NAWA_OS_LINUX
54  return std::string(program_invocation_short_name);
55 #else
56  return std::string(getprogname());
57 #endif
58  }
59 
60 #ifdef NAWA_OS_LINUX
61  inline gid_t* getGIDPtrForGetgrouplist(gid_t* in) {
62  return in;
63  }
64 #else
65  inline int* getGIDPtrForGetgrouplist(gid_t* in) {
66  return (int*) in;
67  }
68 #endif
69 }
70 
71 #endif//NAWA_OPERATINGSYSTEMSPECIFIC_H
Definition: oss.h:33
int * getGIDPtrForGetgrouplist(gid_t *in)
Definition: oss.h:65
std::string getProgramInvocationName()
Definition: oss.h:52
time_t getLastModifiedTimeOfFile(struct stat const &fileStat)
Definition: oss.h:34
std::string getSystemHostname()
Definition: oss.h:42
This file will be configured by CMake and contains system attributes.