Skip to content

Documentation #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 15 additions & 30 deletions Documentation/cpu/cpu.rst
Original file line number Diff line number Diff line change
@@ -1,48 +1,33 @@
.. _cpu_info_functions:
.. _cpu_information_functions:

CPU Information Functions
-------------------------

This module provides functions for retrieving and displaying CPU information on Linux systems.

Functions
^^^^^^^^^
This module contains functions for printing CPU information.

.. code-block:: c

void print_cpu_info(void)

Prints a summary of CPU information to the console.

.. note::
This function displays a maximum of 19 lines of information.

Returns:
None

-------
Prints a formatted summary of the first 19 lines of CPU information from the /proc/cpuinfo file.

.. code-block:: c

void print_full_cpu_info(void)

Prints the complete CPU information to the console.
Prints the complete contents of the /proc/cpuinfo file.

.. note::
Returns:
None
Common Steps:

-------

Example
-------

.. code-block:: c
1) Prints a formatted header for the CPU information.
2) Attempts to open the /proc/cpuinfo file for reading.
3) If the file is opened successfully:
- Reads lines from the file and prints them within the formatted output.
- Closes the file.
4) If the file cannot be opened, prints an error message.
5) Prints a closing footer for the CPU information.

#include "cpu/cpu_info.h"
Differences:

int main() {
print_cpu_info();
// print_full_cpu_info(); // Uncomment to print full information
return 0;
}
- print_cpu_info prints only the first 19 lines of the file.
- print_full_cpu_info prints the entire contents of the file.
52 changes: 52 additions & 0 deletions Documentation/hlp/hlp.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.. _spynix_printing_functions:

Spynix Printing Functions
-------------------------

This module contains functions for printing various visual elements in the Spynix tool.

Functions
^^^^^^^^^

.. code-block:: c

void print_banner(void)

Prints an ASCII banner with the Spynix name.

-------

.. code-block:: c

void print_logo(void)

Prints an ASCII art logo of the Spynix tool.

-------

.. code-block:: c

void print_err_info(void)

Prints an error message instructing the user to use the help option for valid commands.

-------

.. code-block:: c

void print_hlp_info(void)

Prints a comprehensive help menu, including:

- Description of the Spynix tool
- Information options (help, version, banner, logo)
- Available hardware information options (all, system, cpu, ram, rom, net)
- Advanced options (full CPU information)

-------

.. code-block:: c

void print_ver_info(void)

Prints the current version of Spynix along with a link to its GitHub repository.
34 changes: 34 additions & 0 deletions Documentation/net/net.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.. _print_net_info_function:

Network Information Function
----------------------------

This module contains a function for printing network information.

.. code-block:: c

void print_net_info(char *hostname)

Prints network information for both the specified hostname and the local system.

:param char *hostname: The hostname for which to retrieve network information.

Steps:

Hostname Information:

a. Retrieves the hostent structure for the given hostname using gethostbyname.
b. Prints the hostname and its associated IP addresses.

Local Interface Information:

a. Retrieves the list of network interfaces using getifaddrs.
b. Iterates through the list of interfaces:
Prints the interface name.
For IPv4 interfaces:
Prints the IP address.
Prints the netmask.

Error Handling:

- Exits with an error message if either `gethostbyname` or `getifaddrs` fails.
25 changes: 25 additions & 0 deletions Documentation/ram/ram.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.. _print_ram_info_function:

RAM Information Function
------------------------

This module contains a function for printing RAM information.

.. code-block:: c

void print_ram_info(void)

Prints a formatted summary of RAM information, including:

- System uptime
- Total RAM
- Free RAM

Steps:

1) Retrieves system information using the sysinfo function.
2) Prints a formatted header for the RAM information.
3) Prints the uptime in hours.
4) Calculates and prints the total RAM in MiB.
5) Calculates and prints the free RAM in MiB.
6) Prints a closing footer for the RAM information.
26 changes: 26 additions & 0 deletions Documentation/rom/rom.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.. _print_rom_info_function:

ROM Information Function
------------------------

This module contains a function for printing ROM (disk) information.

.. code-block:: c

void print_rom_info(void)

Prints a formatted summary of ROM information, including:

- Total disk space
- Free disk space
- Used disk space

Steps:

1) Prints a formatted header for the ROM information.
2) Retrieves file system information for the root directory using statvfs.
3) If statvfs is successful:
- Calculates and prints the total disk space in MiB.
- Calculates and prints the free disk space in MiB.
- Calculates and prints the used disk space in MiB.
4) Prints a closing footer for the ROM information.
30 changes: 30 additions & 0 deletions Documentation/sys/sys.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. _print_sys_info_function:

System Information Function
---------------------------

This module contains a function for printing system information.

.. code-block:: c

void print_sys_info(void)

Prints a formatted summary of system information, including:

- System name
- Host name
- Kernel release
- System version
- Machine type

Steps:

1) Retrieves system information using the uname function.
2) Prints a formatted header for the system information.
3) Prints each of the following system information fields:
- System name
- Host name
- Kernel release
- System version
- Machine type
4) Prints a closing footer for the system information.
10 changes: 10 additions & 0 deletions src/cpu/cpu_info.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright 2024 Andrew Kushyk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/

#include <stdio.h>

void print_cpu_info(void) {
Expand Down
10 changes: 10 additions & 0 deletions src/hlp/hlp_info.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright 2024 Andrew Kushyk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/

#include <stdio.h>

void print_banner(void){
Expand Down
10 changes: 10 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright 2024 Andrew Kushyk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/

#include <string.h>
#include "sys/sys_info.h"
#include "ram/ram_info.h"
Expand Down
10 changes: 10 additions & 0 deletions src/net/net_info.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright 2024 Andrew Kushyk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/

#include <ifaddrs.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
10 changes: 10 additions & 0 deletions src/ram/ram_info.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright 2024 Andrew Kushyk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/

#include <stdio.h>
#include <sys/sysinfo.h>

Expand Down
10 changes: 10 additions & 0 deletions src/rom/rom_info.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright 2024 Andrew Kushyk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/

#include <stdio.h>
#include <sys/statvfs.h>

Expand Down
10 changes: 10 additions & 0 deletions src/sys/sys_info.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
* Copyright 2024 Andrew Kushyk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/

#include <stdio.h>
#include <sys/utsname.h>

Expand Down