added some maybe hostname/ip stuff
sophuwu sophie@skisiel.com
Fri, 19 Apr 2024 09:08:58 +0200
3 files changed,
42 insertions(+),
1 deletions(-)
M
CMakeLists.txt
→
CMakeLists.txt
@@ -3,4 +3,5 @@ project(bashprompt)
set(CMAKE_CXX_STANDARD 17) -add_executable(bashprompt main.cpp) +add_executable(ip ip.cpp) +add_executable(bashprompt main.cpp)
A
ip.cpp
@@ -0,0 +1,39 @@
+#include <string> +#include <cstdlib> +#include <cstdio> + +typedef std::string str; +typedef unsigned int ud; +typedef unsigned char ub; + +struct ip4{ + str hexid = "0x"; + ub val[4]={0,0,0,0}; + str s(char join = 0, int useColor = 0); + str getid(); +}; +str ip4::s(char join, int useColor) { + return str(std::to_string(val[0]) + "." + std::to_string(val[1]) + "." + std::to_string(val[2]) + "." + std::to_string(val[3])); +} +str ip4::getid() { + std::system("hostid"); + for (char i = 0; i < 4; i++) { + p[i] = (ub) + } + return id; +} + +int main() { + + ud id = hostid(); + printf("hostid: %lx\n", id); + printf("hostid: %lx\n", ); + + unsigned char ipr[4]; + for (char i = 0; i < 4; i++) { + + } + printf("ip: %u.%u.%u.%u\n", ipr[0], ipr[1], ipr[2], ipr[3]); + return 0; + +}