sophuwu.site > bashprompt
added some maybe hostname/ip stuff
sophuwu sophie@skisiel.com
Fri, 19 Apr 2024 09:08:58 +0200
commit

2b680ea6d64ceb95aaf3ee816e314474e5e584b3

parent

61810009a99e74b9abe14d4f1c1f800a8a79dccd

3 files changed, 42 insertions(+), 1 deletions(-)

jump to
M .gitignore.gitignore

@@ -2,3 +2,4 @@ .idea

a.out build pbin +cmake-build-debug
M CMakeLists.txtCMakeLists.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; + +}