diff --git a/Readme.md b/Readme.md old mode 100644 new mode 100755 index 306dec2..523406b --- a/Readme.md +++ b/Readme.md @@ -18,6 +18,9 @@ This is a small bash script that should be piped through ```unzip -l file.zip``` ### 5. `packet.py` A small packet I use for testing. ```scapy``` needed. +### 6. `cpp-project-gen.py` +A small script to generate a c++ project structure. + ## Installation No installation is necessary for these scripts. They are standalone Python scripts that can be run from the command line. Ensure you have Python installed on your system, navigate to the directory containing these scripts, and execute them with Python. For example: diff --git a/cpp-project-gen.py b/cpp-project-gen.py new file mode 100644 index 0000000..5dd4f0f --- /dev/null +++ b/cpp-project-gen.py @@ -0,0 +1,109 @@ +import os + +def create_file(path, content=""): + with open(path, 'w') as file: + file.write(content) + +def create_cpp_project_structure(project_name): + # Define the folder structure + folders = [ + f"{project_name}/include/{project_name}", + f"{project_name}/src", + f"{project_name}/tests", + f"{project_name}/third_party", + f"{project_name}/build", + f"{project_name}/docs" + ] + + # Create the folders + for folder in folders: + os.makedirs(folder, exist_ok=True) + + # Define the content for CMakeLists.txt + cmake_content = f"""cmake_minimum_required(VERSION 3.10) +project({project_name} VERSION 1.0) + +# Specify C++ standard +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# Add include directory +include_directories(include) + +# Add executable +add_executable({project_name} src/main.cpp src/example.cpp) + +# Add library (if you have one) +add_library(example src/example.cpp) +target_include_directories(example PUBLIC include) + +# Link library to executable +target_link_libraries({project_name} example) + +# Add tests +enable_testing() +add_subdirectory(tests) +""" + + # Define the content for tests/CMakeLists.txt + tests_cmake_content = """add_executable(runTests test_example.cpp) +target_link_libraries(runTests gtest gtest_main) +add_test(NAME ExampleTest COMMAND runTests) +""" + + # Define the content for main.cpp + main_cpp_content = """#include +int main() { + std::cout << "Hello, World!" << std::endl; + return 0; +} +""" + + # Define the content for example.h + example_h_content = f"""#ifndef {project_name.upper()}_EXAMPLE_H +#define {project_name.upper()}_EXAMPLE_H + +void exampleFunction(); + +#endif // {project_name.upper()}_EXAMPLE_H +""" + + # Define the content for example.cpp + example_cpp_content = f"""#include "{project_name}/example.h" +#include + +void exampleFunction() {{ + std::cout << "This is an example function." << std::endl; +}} +""" + + # Define the content for test_example.cpp + test_example_content = """#include + +TEST(ExampleTest, BasicAssertions) { + // Expect two strings to be equal. + EXPECT_EQ("hello", "hello"); + // Expect equality. + EXPECT_EQ(7 * 6, 42); +} +""" + + # Define the content for README.md + readme_content = f"""# {project_name} +This is the {project_name} project. +""" + + # Create files with the defined content + create_file(f"{project_name}/CMakeLists.txt", cmake_content) + create_file(f"{project_name}/tests/CMakeLists.txt", tests_cmake_content) + create_file(f"{project_name}/src/main.cpp", main_cpp_content) + create_file(f"{project_name}/include/{project_name}/example.h", example_h_content) + create_file(f"{project_name}/src/example.cpp", example_cpp_content) + create_file(f"{project_name}/tests/test_example.cpp", test_example_content) + create_file(f"{project_name}/README.md", readme_content) + + print(f"C++ project '{project_name}' structure generated successfully.") + +# Prompt the user for a project name +project_name = input("Enter the project name: ") +create_cpp_project_structure(project_name) diff --git a/packet.py b/packet.py old mode 100644 new mode 100755 index 42975fb..340dfc6 --- a/packet.py +++ b/packet.py @@ -1,7 +1,7 @@ from scapy.all import sendp, Ether, IP, UDP destination_ip = '255.255.255.255' -source_ip = '192.168.1.121' +source_ip = '192.168.100.223' source_mac = '8c:16:45:68:54:80' destination_mac = 'ff:ff:ff:ff:ff:ff' # Broadcast MAC address source_port = 14236 diff --git a/sizegetter.py b/sizegetter.py old mode 100644 new mode 100755 diff --git a/unzipdir.py b/unzipdir.py old mode 100644 new mode 100755 diff --git a/zipremove.py b/zipremove.py old mode 100644 new mode 100755 diff --git a/zipsize b/zipsize old mode 100644 new mode 100755