diff options
Diffstat (limited to 'includes')
54 files changed, 3263 insertions, 0 deletions
diff --git a/includes/alpha/processor-platform.h b/includes/alpha/processor-platform.h new file mode 100644 index 00000000..7dfdd91c --- /dev/null +++ b/includes/alpha/processor-platform.h @@ -0,0 +1,29 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PROCESSOR_PLATFORM_H__ +#define __PROCESSOR_PLATFORM_H__ + +struct _Processor { + gchar *model_name; + gfloat bogomips, cpu_mhz; + gchar *strmodel; + gchar *cycle_frequency_hz_str; +}; + +#endif /* __PROCESSOR_PLATFORM_H__ */ diff --git a/includes/arm/processor-platform.h b/includes/arm/processor-platform.h new file mode 100644 index 00000000..a168db68 --- /dev/null +++ b/includes/arm/processor-platform.h @@ -0,0 +1,44 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PROCESSOR_PLATFORM_H__ +#define __PROCESSOR_PLATFORM_H__ + +#include "cpu_util.h" + +struct _Processor { + gchar *model_name; + gchar *linux_name; + gchar *flags; + gfloat bogomips; + + gint id; + gfloat cpu_mhz; /* for devices.c, identical to cpukhz_max/1000 */ + cpu_topology_data *cputopo; + cpufreq_data *cpufreq; + + gchar *cpu_implementer; + gchar *cpu_architecture; + gchar *cpu_variant; + gchar *cpu_part; + gchar *cpu_revision; + + gint mode; +}; + +#endif /* __PROCESSOR_PLATFORM_H__ */ diff --git a/includes/benchmark.h b/includes/benchmark.h new file mode 100644 index 00000000..08392ad2 --- /dev/null +++ b/includes/benchmark.h @@ -0,0 +1,87 @@ +#ifndef __BENCHMARK_H__ +#define __BENCHMARK_H__ + +#include "hardinfo.h" +#include "util_sysobj.h" /* for SEQ() */ + +#define BENCH_PTR_BITS ((unsigned int)sizeof(void*) * 8) + +extern ProgramParameters params; + +enum BenchmarkEntries { + BENCHMARK_BLOWFISH_SINGLE, + BENCHMARK_BLOWFISH_THREADS, + BENCHMARK_BLOWFISH_CORES, + BENCHMARK_ZLIB, + BENCHMARK_CRYPTOHASH, + BENCHMARK_FIB, + BENCHMARK_NQUEENS, + BENCHMARK_FFT, + BENCHMARK_RAYTRACE, + BENCHMARK_SBCPU_SINGLE, + BENCHMARK_SBCPU_ALL, + BENCHMARK_SBCPU_QUAD, + BENCHMARK_MEMORY_SINGLE, + BENCHMARK_MEMORY_DUAL, + BENCHMARK_MEMORY_QUAD, + BENCHMARK_MEMORY_ALL, + BENCHMARK_GUI, + BENCHMARK_N_ENTRIES +}; + +void benchmark_bfish_single(void); +void benchmark_bfish_threads(void); +void benchmark_bfish_cores(void); +void benchmark_memory_single(void); +void benchmark_memory_dual(void); +void benchmark_memory_quad(void); +void benchmark_memory_all(void); +void benchmark_sbcpu_single(void); +void benchmark_sbcpu_all(void); +void benchmark_sbcpu_quad(void); +void benchmark_cryptohash(void); +void benchmark_fft(void); +void benchmark_fib(void); +void benchmark_fish(void); +void benchmark_gui(void); +void benchmark_nqueens(void); +void benchmark_raytrace(void); +void benchmark_zlib(void); + +typedef struct { + double result; + double elapsed_time; + int threads_used; + int revision; + char extra[256]; /* no \n, ; or | */ + char user_note[256]; /* no \n, ; or | */ +} bench_value; + +#define EMPTY_BENCH_VALUE {-1.0f,0,0,-1,""} + +char *bench_value_to_str(bench_value r); +bench_value bench_value_from_str(const char* str); + +/* Note: + * benchmark_parallel_for(): element [start] included, but [end] is excluded. + * callback(): expected to processes elements [start] through [end] inclusive. + */ +bench_value benchmark_parallel_for(gint n_threads, guint start, guint end, + gpointer callback, gpointer callback_data); + +bench_value benchmark_parallel(gint n_threads, gpointer callback, gpointer callback_data); + +bench_value benchmark_crunch_for(float seconds, gint n_threads, + gpointer callback, gpointer callback_data); + +extern bench_value bench_results[BENCHMARK_N_ENTRIES]; + +/* in bench_util.c */ + +/* guarantee a minimum size of data + * or return null */ +gchar *get_test_data(gsize min_size); +char *md5_digest_str(const char *data, unsigned int len); +#define bench_msg(msg, ...) fprintf (stderr, "[%s] " msg "\n", __FUNCTION__, ##__VA_ARGS__) + +#endif /* __BENCHMARK_H__ */ diff --git a/includes/binreloc.h b/includes/binreloc.h new file mode 100644 index 00000000..3bf48bc6 --- /dev/null +++ b/includes/binreloc.h @@ -0,0 +1,68 @@ +/* + * BinReloc - a library for creating relocatable executables + * Written by: Hongli Lai <h.lai@chello.nl> + * http://autopackage.org/ + * + * This source code is public domain. You can relicense this code + * under whatever license you want. + * + * See http://autopackage.org/docs/binreloc/ for + * more information and how to use this. + */ + +#ifndef __BINRELOC_H__ +#define __BINRELOC_H__ + +#include <glib.h> + +G_BEGIN_DECLS + + +/** These error codes can be returned by br_init(), br_init_lib(), gbr_init() or gbr_init_lib(). */ +typedef enum { + /** Cannot allocate memory. */ + GBR_INIT_ERROR_NOMEM, + /** Unable to open /proc/self/maps; see errno for details. */ + GBR_INIT_ERROR_OPEN_MAPS, + /** Unable to read from /proc/self/maps; see errno for details. */ + GBR_INIT_ERROR_READ_MAPS, + /** The file format of /proc/self/maps is invalid; kernel bug? */ + GBR_INIT_ERROR_INVALID_MAPS, + /** BinReloc is disabled (the ENABLE_BINRELOC macro is not defined). */ + GBR_INIT_ERROR_DISABLED +} GbrInitError; + + +#ifndef BINRELOC_RUNNING_DOXYGEN +/* Mangle symbol names to avoid symbol collisions with other ELF objects. */ + #define gbr_find_exe UfUy21856259474323_gbr_find_exe + #define gbr_find_exe_dir UfUy21856259474323_gbr_find_exe_dir + #define gbr_find_prefix UfUy21856259474323_gbr_find_prefix + #define gbr_find_bin_dir UfUy21856259474323_gbr_find_bin_dir + #define gbr_find_sbin_dir UfUy21856259474323_gbr_find_sbin_dir + #define gbr_find_data_dir UfUy21856259474323_gbr_find_data_dir + #define gbr_find_locale_dir UfUy21856259474323_gbr_find_locale_dir + #define gbr_find_lib_dir UfUy21856259474323_gbr_find_lib_dir + #define gbr_find_libexec_dir UfUy21856259474323_gbr_find_libexec_dir + #define gbr_find_etc_dir UfUy21856259474323_gbr_find_etc_dir + + +#endif +gboolean gbr_init (GError **error); +gboolean gbr_init_lib (GError **error); + +gchar *gbr_find_exe (const gchar *default_exe); +gchar *gbr_find_exe_dir (const gchar *default_dir); +gchar *gbr_find_prefix (const gchar *default_prefix); +gchar *gbr_find_bin_dir (const gchar *default_bin_dir); +gchar *gbr_find_sbin_dir (const gchar *default_sbin_dir); +gchar *gbr_find_data_dir (const gchar *default_data_dir); +gchar *gbr_find_locale_dir (const gchar *default_locale_dir); +gchar *gbr_find_lib_dir (const gchar *default_lib_dir); +gchar *gbr_find_libexec_dir (const gchar *default_libexec_dir); +gchar *gbr_find_etc_dir (const gchar *default_etc_dir); + + +G_END_DECLS + +#endif /* __BINRELOC_H__ */ diff --git a/includes/blowfish.h b/includes/blowfish.h new file mode 100644 index 00000000..3f33e945 --- /dev/null +++ b/includes/blowfish.h @@ -0,0 +1,33 @@ +/*
+blowfish.h: Header file for blowfish.c
+
+Copyright (C) 1997 by Paul Kocher
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+See blowfish.c for more information about this file.
+*/
+
+
+typedef struct {
+ unsigned long P[16 + 2];
+ unsigned long S[4][256];
+} BLOWFISH_CTX;
+
+void Blowfish_Init(BLOWFISH_CTX *ctx, unsigned char *key, int keyLen);
+void Blowfish_Encrypt(BLOWFISH_CTX *ctx, unsigned long *xl, unsigned long *xr);
+void Blowfish_Decrypt(BLOWFISH_CTX *ctx, unsigned long *xl, unsigned long *xr);
+
+
+
diff --git a/includes/callbacks.h b/includes/callbacks.h new file mode 100644 index 00000000..421cff5e --- /dev/null +++ b/includes/callbacks.h @@ -0,0 +1,45 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __CALLBACKS_H__ +#define __CALLBACKS_H__ + +#include <gtk/gtk.h> + +void cb_about(); +void cb_about_module(GtkAction *action); +void cb_generate_report(); +void cb_quit(); +void cb_refresh(); +void cb_copy_to_clipboard(); +void cb_side_pane(); +void cb_toolbar(); +void cb_open_web_page(); +void cb_open_online_docs(); +void cb_open_online_docs_context(); +void cb_sync_manager(); +void cb_report_bug(); +void cb_donate(); +void cb_connect_to(); +void cb_manage_hosts(); +void cb_connect_host(GtkAction * action); +void cb_local_computer(); +void cb_act_as_server(); +void cb_sync_on_startup(); + +#endif /* __CALLBACKS_H__ */ diff --git a/includes/computer.h b/includes/computer.h new file mode 100644 index 00000000..f8589d77 --- /dev/null +++ b/includes/computer.h @@ -0,0 +1,186 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __COMPUTER_H__ +#define __COMPUTER_H__ + +#include "hardinfo.h" +#include "x_util.h" + +typedef struct _Computer Computer; +typedef struct _OperatingSystem OperatingSystem; +typedef struct _MemoryInfo MemoryInfo; +typedef struct _UptimeInfo UptimeInfo; +typedef struct _LoadInfo LoadInfo; +typedef struct _DisplayInfo DisplayInfo; +typedef struct _Distro Distro; + +typedef struct _AlsaInfo AlsaInfo; +typedef struct _AlsaCard AlsaCard; + +typedef struct _FileSystem FileSystem; +typedef struct _FileSystemEntry FileSystemEntry; + +struct _AlsaCard { + gchar *alsa_name; + gchar *friendly_name; +/* + gchar *board; + gchar revision, compat_class; + gint subsys_vendorid, subsys_id; + + gint cap_dac_res, cap_adc_res; + gboolean cap_3d_enh; + + gint curr_mic_gain; + gboolean curr_3d_enh, + curr_loudness, + curr_simstereo; + gchar *curr_mic_select; +*/ +}; + +struct _AlsaInfo { + GSList *cards; +}; + +struct _DisplayInfo { + /* old stuff */ + gint width, height; + + /* new stuff */ + xinfo *xi; /* x info */ + wl_info *wl; /* wayland info */ + + gchar *display_server; + + /* don't free */ + const gchar *vendor; /* X vendor; points to xrr->xi->vendor */ + const gchar *session_type; /* points to wl->xdg_session_type */ +}; + +struct _LoadInfo { + float load1, load5, load15; +}; + +struct _UptimeInfo { + int days, hours, minutes; +}; + +struct _Computer { + MemoryInfo *memory; + OperatingSystem *os; + DisplayInfo *display; + AlsaInfo *alsa; + + gchar *date_time; +}; + +#include "distro_flavors.h" + +struct _OperatingSystem { + gchar *kernel; + gchar *kcmdline; + gchar *libc; + gchar *distrocode; + gchar *distroid; + gchar *distro; + gchar *hostname; + gchar *language; + gchar *homedir; + gchar *kernel_version; + + gchar *languages; + + gchar *desktop; + gchar *username; + + gchar *boots; + + gchar *entropy_avail; + + const DistroFlavor* distro_flavor; +}; + +struct _MemoryInfo { + gint total, used, free, cached; + gfloat ratio; +}; + +struct _Distro { + gchar *distro; + gchar *codename; + gchar *id; +}; + +#define get_str(field_name,ptr) \ + if (g_str_has_prefix(tmp[0], field_name)) { \ + ptr = g_strdup(tmp[1]); \ + g_strfreev(tmp); \ + continue; \ + } +#define get_int(field_name,ptr) \ + if (g_str_has_prefix(tmp[0], field_name)) { \ + ptr = atoi(tmp[1]); \ + g_strfreev(tmp); \ + continue; \ + } +#define get_float(field_name,ptr) \ + if (g_str_has_prefix(tmp[0], field_name)) { \ + ptr = atof(tmp[1]); \ + g_strfreev(tmp); \ + continue; \ + } + +extern gchar *users; +extern gchar *groups; +extern gchar *fs_list; +extern GHashTable *_module_hash_table; +extern Computer *computer; +extern gchar *module_list; + +gchar *computer_get_formatted_loadavg(); +gchar *computer_get_formatted_uptime(); +gchar *computer_get_alsacards(Computer * computer); +gchar *computer_get_entropy_avail(void); +gchar *computer_get_aslr(void); +gchar *computer_get_dmesg_status(void); +const gchar *computer_get_selinux(void); +gchar *computer_get_lsm(void); + +OperatingSystem *computer_get_os(void); +AlsaInfo *computer_get_alsainfo(void); +MemoryInfo *computer_get_memory(void); +UptimeInfo *computer_get_uptime(void); +DisplayInfo *computer_get_display(void); +void computer_free_display(DisplayInfo *di); + +void scan_modules_do(void); +void scan_filesystems(void); +void scan_users_do(void); + +/* Memory Usage */ +extern GHashTable *memlabels; +void init_memory_labels(void); +void scan_memory_do(void); +void scan_boots_real(void); +void scan_languages(OperatingSystem *os); +void scan_groups_do(void); + +void kernel_module_icon_init(void); + +#endif /* __COMPUTER_H__ */ diff --git a/includes/cpu_util.h b/includes/cpu_util.h new file mode 100644 index 00000000..1adbf491 --- /dev/null +++ b/includes/cpu_util.h @@ -0,0 +1,52 @@ +#ifndef __CPU_UTIL_H__ +#define __CPU_UTIL_H__ + +#include "hardinfo.h" + +#ifndef PROC_CPUINFO +#define PROC_CPUINFO "/proc/cpuinfo" +#endif + +#define STRIFNULL(f,cs) if (f == NULL) f = g_strdup(cs); +#define UNKIFNULL(f) STRIFNULL(f, _("(Unknown)") ) +#define EMPIFNULL(f) STRIFNULL(f, "") + +const gchar *byte_order_str(void); + +/* from /sys/devices/system/cpu/cpu%d/%s */ +gchar* get_cpu_str(const gchar* file, gint cpuid); +gint get_cpu_int(const char* item, int cpuid, int null_val); + +/* space delimted list of flags, finds flag */ +int processor_has_flag(gchar * strflags, gchar * strflag); + +typedef struct { + gint id; + gint cpukhz_max, cpukhz_min, cpukhz_cur; + gchar *scaling_driver, *scaling_governor; + gint transition_latency; + gchar *shared_list; +} cpufreq_data; + +typedef struct { + gint id; /* thread */ + gint socket_id; + gint core_id; + gint book_id; + gint drawer_id; +} cpu_topology_data; + +cpufreq_data *cpufreq_new(gint id); +void cpufreq_update(cpufreq_data *cpufd, int cur_only); +void cpufreq_free(cpufreq_data *cpufd); + +gchar *cpufreq_section_str(cpufreq_data *cpufd); + +cpu_topology_data *cputopo_new(gint id); +void cputopo_free(cpu_topology_data *cputd); + +gchar *cputopo_section_str(cpu_topology_data *cputd); + +int cpu_procs_cores_threads_nodes(int *p, int *c, int *t, int *n); + +#endif diff --git a/includes/devices.h b/includes/devices.h new file mode 100644 index 00000000..e2ab8f7f --- /dev/null +++ b/includes/devices.h @@ -0,0 +1,102 @@ +#ifndef __DEVICES_H__ +#define __DEVICES_H__ + +#include "hardinfo.h" +#include "processor-platform.h" +#include "dmi_util.h" + +typedef struct _Processor Processor; + +#define WALK_UNTIL(x) while((*buf != '\0') && (*buf != x)) buf++ + +#define GET_STR(field_name,ptr) \ + if (!ptr && strstr(tmp[0], field_name)) { \ + ptr = g_markup_escape_text(g_strstrip(tmp[1]), strlen(tmp[1])); \ + g_strfreev(tmp); \ + continue; \ + } + +#define get_str(field_name,ptr) \ + if (g_str_has_prefix(tmp[0], field_name)) { \ + ptr = g_strdup(tmp[1]); \ + g_strfreev(tmp); \ + continue; \ + } +#define get_int(field_name,ptr) \ + if (g_str_has_prefix(tmp[0], field_name)) { \ + ptr = atoi(tmp[1]); \ + g_strfreev(tmp); \ + continue; \ + } +#define get_float(field_name,ptr) \ + if (g_str_has_prefix(tmp[0], field_name)) { \ + ptr = atof(tmp[1]); \ + g_strfreev(tmp); \ + continue; \ + } + + +/* Processor */ +GSList *processor_scan(void); +void get_processor_strfamily(Processor * processor); +gchar *processor_get_detailed_info(Processor * processor); +gchar *processor_get_info(GSList * processors); +gchar *processor_name(GSList * processors); +gchar *processor_name_default(GSList * processors); +gchar *processor_describe(GSList * processors); +gchar *processor_describe_default(GSList * processors); +gchar *processor_describe_by_counting_names(GSList * processors); +gchar *processor_frequency_desc(GSList *processors); + +/* Printers */ +void init_cups(void); + +/* Battery */ +void scan_battery_do(void); + +/* PCI */ +void scan_pci_do(void); + +/* Printers */ +void scan_printers_do(void); + +/* Sensors */ +#define SENSORS_GROUP_BY_TYPE 1 + +void scan_sensors_do(void); +void sensor_init(void); +void sensor_shutdown(void); +void __scan_dtree(void); +void scan_gpu_do(void); +gboolean __scan_udisks2_devices(void); +void __scan_ide_devices(void); +void __scan_scsi_devices(void); +void __scan_input_devices(void); +void __scan_usb(void); +void __scan_dmi(void); + +extern gchar *battery_list; +extern gchar *input_icons; +extern gchar *input_list; +extern gchar *lginterval; +extern gchar *meminfo; +extern gchar *pci_list; +extern gchar *printer_icons; +extern gchar *printer_list; +extern gchar *sensors; +extern gchar *sensor_icons; +extern gchar *storage_icons; +extern gchar *storage_list; +extern gchar *usb_list; +extern gchar *usb_icons; +extern GHashTable *_pci_devices; +extern GHashTable *sensor_compute; +extern GHashTable *sensor_labels; +extern GModule *cups; + +extern gchar *dmi_info; +extern gchar *dtree_info; +extern gchar *gpu_list; +extern gchar *gpu_summary; + +#endif /* __DEVICES_H__ */ diff --git a/includes/distro_flavors.h b/includes/distro_flavors.h new file mode 100644 index 00000000..c316eeb6 --- /dev/null +++ b/includes/distro_flavors.h @@ -0,0 +1,37 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2019 L. A. F. Pereira <l@tia.mat.br> + * This file Burt P. <pburt0@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __DISTRO_FLAVORS_H__ +#define __DISTRO_FLAVORS_H__ + +typedef struct { + const char *name; + const char *icon; + const char *url; +} DistroFlavor; + +typedef struct UbuntuFlavor { + const DistroFlavor base; + const char *package; +} UbuntuFlavor; + +/* items are const; free with g_slist_free() */ +GSList *ubuntu_flavors_scan(void); + +#endif diff --git a/includes/dmi_util.h b/includes/dmi_util.h new file mode 100644 index 00000000..2fec1a04 --- /dev/null +++ b/includes/dmi_util.h @@ -0,0 +1,69 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2017 L. A. F. Pereira <l@tia.mat.br> + * This file + * Copyright (C) 2017 Burt P. <pburt0@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __DMI_UTIL_H__ +#define __DMI_UTIL_H__ + +#include <inttypes.h> + +typedef uint32_t dmi_handle; +typedef uint32_t dmi_type; + +/* -1 = yes, but will be ignored + * 0 = no + * 1 = yes */ +int dmi_str_status(const char *id_str); +char *dmi_get_str(const char *id_str); /* ignore nonsense */ +char *dmi_get_str_abs(const char *id_str); /* include nonsense */ + +/* if chassis_type is <=0 it will be fetched from DMI. + * with_val = true, will return a string like "[3] Desktop" instead of just + * "Desktop". */ +char *dmi_chassis_type_str(int chassis_type, gboolean with_val); + +typedef struct { + dmi_handle id; + uint32_t size; + dmi_type type; + const char *type_str; /* untranslated, use _() for translation */ +} dmi_handle_ext; + +typedef struct { + uint32_t count; + dmi_handle *handles; + dmi_handle_ext *handles_ext; +} dmi_handle_list; + +/* get a list of handles that match a dmi_type */ +dmi_handle_list *dmidecode_handles(const dmi_type *type); +void dmi_handle_list_free(dmi_handle_list *hl); + +/* get a list of handles which have a name, and/or optional value, and/or limit to an optional dmi_type + * dmidecode_match_value("Name", NULL, NULL) : all dmi handles with an item called "Name" + * dmidecode_match_value("Name", "Value", NULL) : all dmi_handles with an item called "Name" that has a value of "Value" + * dmidecode_match_value("Name", "Value", &dt) : all dmi_handles with "Name: Value" that are of type stored in dt */ +dmi_handle_list *dmidecode_match_value(const char *name, const char *value, const dmi_type *type); + +/* get the first value for name, limiting to optional dmi_type and/or optional handle */ +char *dmidecode_match(const char *name, const dmi_type *type, const dmi_handle *handle); + +void dmidecode_cache_free(); + +#endif diff --git a/includes/dt_util.h b/includes/dt_util.h new file mode 100644 index 00000000..bec9af1c --- /dev/null +++ b/includes/dt_util.h @@ -0,0 +1,101 @@ + +#ifndef _DT_UTIL_H_ +#define _DT_UTIL_H_ + +#include <stdint.h> + +/* some not-quite-complete stuff that can be disabled */ +#define DTEX_PHREFS 1 + +#ifndef DTR_ROOT +#define DTR_ROOT dtr_find_device_tree_root() +#endif + +enum { + DT_TYPE_ERR, + + DT_NODE, + DTP_UNK, /* arbitrary-length byte sequence */ + DTP_EMPTY, /* empty property */ + DTP_STR, /* null-delimited list of strings */ + DTP_HEX, /* list of 32-bit values displayed in hex */ + DTP_UINT, /* unsigned int list */ + DTP_UINT64, /* unsigned int64 list */ + DTP_INTRUPT, /* interrupt-specifier list */ + DTP_INTRUPT_EX, /* extended interrupt-specifier list */ + DTP_OVR, /* all in /__overrides__ */ + DTP_PH, /* phandle */ + DTP_PH_REF, /* reference to phandle */ + DTP_REG, /* <#address-cells, #size-cells> */ + DTP_CLOCKS, /* <phref, #clock-cells> */ + DTP_GPIOS, /* <phref, #gpio-cells> */ + DTP_DMAS, /* dma-specifier list */ + DTP_OPP1, /* list of operating points, pairs of (kHz,uV) */ + DTP_PH_REF_OPP2, /* phandle reference to opp-v2 table */ +}; + +/* simplest, no aliases, doesn't require an existing dt. + * use dtr_get_prop_str() for complete. */ +char* dtr_get_string(const char *p, int decode); + +typedef uint32_t dt_uint; /* big-endian */ +typedef uint64_t dt_uint64; /* big-endian */ + +typedef struct _dtr dtr; +typedef struct _dtr_obj dtr_obj; + +dtr *dtr_new(const char *base_path); /* NULL for DTR_ROOT */ +void dtr_free(dtr *); +int dtr_was_found(dtr *); +const char *dtr_base_path(dtr *); +char *dtr_messages(dtr *); /* returns a message log */ + +dtr_obj *dtr_obj_read(dtr *, const char *dtp); +void dtr_obj_free(dtr_obj *); +int dtr_obj_type(dtr_obj *); +char *dtr_obj_alias(dtr_obj *); +char *dtr_obj_symbol(dtr_obj *); +char *dtr_obj_path(dtr_obj *); /* device tree path */ +char *dtr_obj_full_path(dtr_obj *); /* system path */ +dtr_obj *dtr_get_parent_obj(dtr_obj *); + +/* find property/node 'name' relative to node + * if node is NULL, then from root */ +dtr_obj *dtr_get_prop_obj(dtr *, dtr_obj *node, const char *name); +char *dtr_get_prop_str(dtr *, dtr_obj *node, const char *name); +uint32_t dtr_get_prop_u32(dtr *, dtr_obj *node, const char *name); +uint64_t dtr_get_prop_u64(dtr *, dtr_obj *node, const char *name); + +/* attempts to render the object as a string */ +char* dtr_str(dtr_obj *obj); + +int dtr_guess_type(dtr_obj *obj); +char *dtr_elem_phref(dtr *, dt_uint e, int show_path, const char *extra); +char *dtr_elem_hex(dt_uint e); +char *dtr_elem_byte(uint8_t e); +char *dtr_elem_uint(dt_uint e); +char *dtr_list_byte(uint8_t *bytes, unsigned long count); +char *dtr_list_hex(dt_uint *list, unsigned long count); + +int dtr_cellv_find(dtr_obj *obj, char *qprop, int limit); + +char *dtr_maps_info(dtr *); /* returns hardinfo shell section */ + +const char *dtr_find_device_tree_root(void); + +/* write to the message log */ +void dtr_msg(dtr *s, char *fmt, ...); + +/* operating-points v0,v1,v2 */ +typedef struct { + uint32_t version; /* opp version, 0 = clock-frequency only */ + uint32_t phandle; /* v2 only */ + uint32_t khz_min; + uint32_t khz_max; + uint32_t clock_latency_ns; +} dt_opp_range; + +/* free result with g_free() */ +dt_opp_range *dtr_get_opp_range(dtr *, const char *name); + +#endif diff --git a/includes/e2k/processor-platform.h b/includes/e2k/processor-platform.h new file mode 100644 index 00000000..c6361823 --- /dev/null +++ b/includes/e2k/processor-platform.h @@ -0,0 +1,72 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2020 EntityFX <artem.solopiy@gmail.com> and MCST Elbrus Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PROCESSOR_PLATFORM_H__ +#define __PROCESSOR_PLATFORM_H__ + +#include "cpu_util.h" + +/* + +E2K /proc/cpuinfo: + + +processor : 0 +vendor_id : E8C-SWTX +cpu family : 4 +model : 7 +model name : E8C +revision : 2 +cpu MHz : 1299.912740 +cache0 : level=1 type=Instruction scope=Private size=128K line_size=256 associativity=4 +cache1 : level=1 type=Data scope=Private size=64K line_size=32 associativity=4 +cache2 : level=2 type=Unified scope=Private size=512K line_size=64 associativity=4 +cache3 : level=3 type=Unified scope=Private size=16384K line_size=64 associativity=16 +bogomips : 2600.68 + +*/ + + +typedef struct _ProcessorCache ProcessorCache; + +struct _ProcessorCache { + gint level; + gint number_of_sets; + gint physical_line_partition; + gint size; + gchar *type; + gint ways_of_associativity; + gint uid; /* uid is unique among caches with the same (type, level) */ + gchar *shared_cpu_list; /* some kernel's don't give a uid, so try shared_cpu_list */ + gint phy_sock; +}; + +//e2k processor structure +struct _Processor { + gint id; + gfloat cpu_mhz; + gchar *model_name; + gchar *vendor_id; + gfloat bogomips; + + gint model, family, revision; + + GSList *cache; +}; + +#endif /* __PROCESSOR_PLATFORM_H__ */ diff --git a/includes/egg-markdown.h b/includes/egg-markdown.h new file mode 100644 index 00000000..1a2b03f4 --- /dev/null +++ b/includes/egg-markdown.h @@ -0,0 +1,84 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2008 Richard Hughes <richard@hughsie.com> + * Copyright (C) 2009 L.Pereira <l@tia.mat.br> + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __EGG_MARKDOWN_H +#define __EGG_MARKDOWN_H + +#include <glib-object.h> + +G_BEGIN_DECLS + +#define EGG_TYPE_MARKDOWN (egg_markdown_get_type ()) +#define EGG_MARKDOWN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGG_TYPE_MARKDOWN, EggMarkdown)) +#define EGG_MARKDOWN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EGG_TYPE_MARKDOWN, EggMarkdownClass)) +#define EGG_IS_MARKDOWN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGG_TYPE_MARKDOWN)) +#define EGG_IS_MARKDOWN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGG_TYPE_MARKDOWN)) +#define EGG_MARKDOWN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGG_TYPE_MARKDOWN, EggMarkdownClass)) +#define EGG_MARKDOWN_ERROR (egg_markdown_error_quark ()) +#define EGG_MARKDOWN_TYPE_ERROR (egg_markdown_error_get_type ()) + +#define EGG_MARKDOWN_MAX_LINE_LENGTH 2048 + +typedef struct EggMarkdownPrivate EggMarkdownPrivate; + +typedef struct +{ + GObject parent; + EggMarkdownPrivate *priv; +} EggMarkdown; + +typedef struct +{ + GObjectClass parent_class; + void (* active_changed) (EggMarkdown *self, + gboolean active); +} EggMarkdownClass; + +typedef enum { + EGG_MARKDOWN_OUTPUT_TEXT, + EGG_MARKDOWN_OUTPUT_PANGO, + EGG_MARKDOWN_OUTPUT_HTML, + EGG_MARKDOWN_OUTPUT_UNKNOWN +} EggMarkdownOutput; + +GType egg_markdown_get_type (void); +EggMarkdown *egg_markdown_new (void); +gboolean egg_markdown_set_output (EggMarkdown *self, + EggMarkdownOutput output); +gboolean egg_markdown_set_max_lines (EggMarkdown *self, + gint max_lines); +gboolean egg_markdown_set_smart_quoting (EggMarkdown *self, + gboolean smart_quoting); +gboolean egg_markdown_set_escape (EggMarkdown *self, + gboolean escape); +gboolean egg_markdown_set_autocode (EggMarkdown *self, + gboolean autocode); +gchar *egg_markdown_parse (EggMarkdown *self, + const gchar *text); +void egg_markdown_clear (EggMarkdown *self); +gchar *egg_markdown_get_link_uri (EggMarkdown *self, + const gint link_id); + +G_END_DECLS + +#endif /* __EGG_MARKDOWN_H */ + diff --git a/includes/expr.h b/includes/expr.h new file mode 100644 index 00000000..18d0cc65 --- /dev/null +++ b/includes/expr.h @@ -0,0 +1,48 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __EXPR_H__ +#define __EXPR_H__ + +typedef struct _MathToken MathToken; + +typedef enum { + TOKEN_OPERATOR, + TOKEN_VARIABLE, + TOKEN_VALUE +} MathTokenType; + +struct _MathToken { + union { + gfloat value; + gchar op; + } val; + MathTokenType type; +}; + +#define math_postfix_free math_infix_free + +GSList *math_infix_to_postfix(GSList *infix); +void math_infix_free(GSList *infix, gboolean free_tokens); + +GSList *math_string_to_infix(gchar *string); +GSList *math_string_to_postfix(gchar *string); + +gfloat math_postfix_eval(GSList *postfix, gfloat at_value); +gfloat math_string_eval(gchar *string, gfloat at_value); + +#endif /* __EXPR_H__ */ diff --git a/includes/fftbench.h b/includes/fftbench.h new file mode 100644 index 00000000..7c0afc3d --- /dev/null +++ b/includes/fftbench.h @@ -0,0 +1,19 @@ +#ifndef __FFTBENCH_H__ +#define __FFTBENCH_H__ + +#include <glib.h> + +typedef struct _FFTBench FFTBench; + +struct _FFTBench { + double **a, *b, *r; + int *p; +}; + +FFTBench *fft_bench_new(void); +void fft_bench_run(FFTBench *fftbench); +void fft_bench_free(FFTBench *fftbench); + +#endif /* __FFTBENCH_H__ */ + + diff --git a/includes/gettext.h b/includes/gettext.h new file mode 100644 index 00000000..fcdb2051 --- /dev/null +++ b/includes/gettext.h @@ -0,0 +1,47 @@ + +#ifndef __GETTEXT_H__ +#define __GETTEXT_H__ + +#include <string.h> +#include <libintl.h> +#include <locale.h> + +static const char * +__pgettext_expr (const char *msgctxt, const char *msgid) +{ + size_t msgctxt_len = strlen (msgctxt) + 1; + size_t msgid_len = strlen (msgid) + 1; + const char *translation; +#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + char msg_ctxt_id[msgctxt_len + msgid_len]; +#else + char buf[1024]; + char *msg_ctxt_id = + (msgctxt_len + msgid_len <= sizeof (buf) + ? buf + : (char *) malloc (msgctxt_len + msgid_len)); + if (msg_ctxt_id != NULL) +#endif + { + int found_translation; + memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); + msg_ctxt_id[msgctxt_len - 1] = '\004'; + memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); + translation = gettext (msg_ctxt_id); + found_translation = (translation != msg_ctxt_id); +#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + if (msg_ctxt_id != buf) + free (msg_ctxt_id); +#endif + if (found_translation) + return translation; + } + return msgid; +} + +#define _(STRING) gettext(STRING) +#define N_(STRING) (STRING) +#define C_(CTX, STRING) __pgettext_expr(CTX, STRING) +#define NC_(CTX, STRING) (STRING) + +#endif diff --git a/includes/gpu_util.h b/includes/gpu_util.h new file mode 100644 index 00000000..c0089ffb --- /dev/null +++ b/includes/gpu_util.h @@ -0,0 +1,61 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2017 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __GPU_UTIL_H__ +#define __GPU_UTIL_H__ + +#include <stdint.h> +#include "pci_util.h" +#include "dt_util.h" + +typedef struct nvgpu { + char *model; + char *bios_version; + char *uuid; +} nvgpu; + +typedef struct gpud { + char *id; /* ours */ + char *nice_name; + char *vendor_str; + char *device_str; + char *location; + uint32_t khz_min, khz_max; /* core */ + uint32_t mem_khz_min, mem_khz_max; /* memory */ + + char *drm_dev; + char *sysfs_drm_path; + pcid *pci_dev; + + char *dt_compat, *dt_status, *dt_name, *dt_path; + const char *dt_vendor, *dt_device; + dt_opp_range *dt_opp; + + nvgpu *nv_info; + /* ... */ + + struct gpud *next; /* this is a linked list */ +} gpud; + +gpud *gpu_get_device_list(); +int gpud_list_count(gpud *); +void gpud_list_free(gpud *); + +void gpud_free(gpud *); + +#endif diff --git a/includes/guibench.h b/includes/guibench.h new file mode 100644 index 00000000..16f34218 --- /dev/null +++ b/includes/guibench.h @@ -0,0 +1,24 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2009 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __GUIBENCH_H__ +#define __GUIBENCH_H__ + +double guibench(void); + +#endif /* __GUIBENCH_H__ */
\ No newline at end of file diff --git a/includes/hardinfo.h b/includes/hardinfo.h new file mode 100644 index 00000000..872a29fc --- /dev/null +++ b/includes/hardinfo.h @@ -0,0 +1,234 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __HARDINFO_H__ +#define __HARDINFO_H__ + +#include <stdio.h> +#include <string.h> +#include <ctype.h> +#include <unistd.h> +#include <gtk/gtk.h> +#include "config.h" +#include "shell.h" +#include "vendor.h" +#include "gettext.h" +#include "info.h" +#include "format_early.h" + +#define HARDINFO2_COPYRIGHT_LATEST_YEAR 2024 + +#ifndef LOCALEDIR +#define LOCALEDIR "/usr/share/locale" +#endif + +typedef enum { + MODULE_FLAG_NONE = 0, + MODULE_FLAG_NO_REMOTE = 1<<0, + MODULE_FLAG_HAS_HELP = 1<<1, + MODULE_FLAG_HIDE = 1<<2, +} ModuleEntryFlags; + +typedef struct _ModuleEntry ModuleEntry; +typedef struct _ModuleAbout ModuleAbout; +typedef struct _FileTypes FileTypes; +typedef struct _ProgramParameters ProgramParameters; + +struct _ProgramParameters { + gboolean create_report; + gboolean force_all_details; /* for create_report, include any "moreinfo" that exists for any item */ + gboolean show_version; + gboolean gui_running; + gboolean list_modules; + gboolean autoload_deps; + gboolean skip_benchmarks; + gboolean quiet; + + /* + * OK to use the common parts of HTML(4.0) and Pango Markup + * in the value part of a key/value. + * Including the (b,big,i,s,sub,sup,small,tt,u) tags. + * https://developer.gnome.org/pango/stable/PangoMarkupFormat.html + */ + gboolean markup_ok; + int fmt_opts; + + gint report_format; + gint max_bench_results; + + gchar **use_modules; + gchar *run_benchmark; + gchar *bench_user_note; + gchar *result_format; + gchar *path_lib; + gchar *path_data; + gchar *argv0; +}; + +struct _FileTypes { + gchar *name; + gchar *mime_type; + gchar *extension; + gpointer data; +}; + +struct _ModuleEntry { + gchar *name; + gchar *icon; + gpointer callback; + gpointer scan_callback; + guint32 flags; +}; + +struct _ModuleAbout { + const gchar *description; + const gchar *author; + const gchar *version; + const gchar *license; +}; + +/* String utility functions */ +void remove_quotes(gchar *str); +char *strend(gchar *str, gchar chr); +void remove_linefeed(gchar *str); +gchar *strreplacechr(gchar *string, gchar *replace, gchar new_char); +gchar *strreplace(gchar *string, gchar *replace, gchar *replacement); + +/* Widget utility functions */ +void widget_set_cursor(GtkWidget *widget, GdkCursorType cursor_type); +gint tree_view_get_visible_height(GtkTreeView *tv); + +/* File Chooser utility functions */ +void file_chooser_open_expander(GtkWidget *chooser); +void file_chooser_add_filters(GtkWidget *chooser, FileTypes *filters); +gchar *file_chooser_get_extension(GtkWidget *chooser, FileTypes *filters); +gchar *file_chooser_build_filename(GtkWidget *chooser, gchar *extension); +gpointer file_types_get_data_by_name(FileTypes *file_types, gchar *name); + +/* Misc utility functions */ +#if !(RELEASE == 1) +#define DEBUG_AUTO_FREE 2 +#endif +#include "auto_free.h" +#define idle_free(ptr) auto_free(ptr) + +gchar *find_program(gchar *program_name); +gchar *size_human_readable(gfloat size); +void nonblock_sleep(guint msec); +GSList *modules_get_list(void); +GSList *modules_load_selected(void); +GSList *modules_load_all(void); +void module_unload_all(void); +const ModuleAbout *module_get_about(ShellModule *module); +gchar *seconds_to_string(unsigned int seconds); + +gchar *h_strdup_cprintf(const gchar *format, gchar *source, ...) + __attribute__((format(gnu_printf, 1, 3))); +gchar *h_strconcat(gchar *string1, ...); +void h_hash_table_remove_all (GHashTable *hash_table); + +void module_entry_scan_all_except(ModuleEntry *entries, gint except_entry); +void module_entry_scan_all(ModuleEntry *entries); +void module_entry_reload(ShellModuleEntry *module_entry); +void module_entry_scan(ShellModuleEntry *module_entry); +gchar *module_entry_function(ShellModuleEntry *module_entry); +const gchar *module_entry_get_note(ShellModuleEntry *module_entry); +gchar *module_entry_get_field(ShellModuleEntry * module_entry, gchar * field); +gchar *module_entry_get_moreinfo(ShellModuleEntry * module_entry, gchar * field); + +/* BinReloc stuff */ +gboolean binreloc_init(gboolean try_hardcoded); + +/* GTK UI stuff */ +gboolean ui_init(int *argc, char ***argv); +void parameters_init(int *argc, char ***argv, ProgramParameters *params); +extern ProgramParameters params; + +/* Module stuff */ +gchar *module_call_method(gchar *method); +gchar *module_call_method_param(gchar * method, gchar * parameter); + +/* Sysfs stuff */ +gfloat h_sysfs_read_float(const gchar *endpoint, const gchar *entry); +gint h_sysfs_read_int(const gchar *endpoint, const gchar *entry); +gint h_sysfs_read_hex(const gchar *endpoint, const gchar *entry); +gchar *h_sysfs_read_string(const gchar *endpoint, const gchar *entry); + +#define SCAN_START() static gboolean scanned = FALSE; if (reload) scanned = FALSE; if (scanned) return; +#define SCAN_END() scanned = TRUE; + +#define _CONCAT(a,b) a ## b +#define CONCAT(a,b) _CONCAT(a,b) + +void moreinfo_init(void); +void moreinfo_shutdown(void); +void moreinfo_add_with_prefix(gchar *prefix, gchar *key, gchar *value); +void moreinfo_add(gchar *key, gchar *value); +void moreinfo_del_with_prefix(gchar *prefix); +void moreinfo_clear(void); +gchar *moreinfo_lookup_with_prefix(gchar *prefix, gchar *key); +gchar *moreinfo_lookup(gchar *key); + +#if !GLIB_CHECK_VERSION(2,44,0) + /* g_strv_contains() requires glib>2.44 + * fallback for older versions in hardinfo/util.c */ +gboolean g_strv_contains(const gchar * const * strv, const gchar *str); +#endif + +/* in gg_key_file_parse_string_as_value.c */ +gchar * +gg_key_file_parse_string_as_value (const gchar *string, const gchar list_separator); + +gchar *hardinfo_clean_grpname(const gchar *v, int replacing); +/* Hardinfo labels that have # are truncated and/or hidden. + * Labels can't have $ because that is the delimiter in + * moreinfo. + * replacing = true will free v */ +gchar *hardinfo_clean_label(const gchar *v, int replacing); +/* hardinfo uses the values as {ht,x}ml, apparently */ +gchar *hardinfo_clean_value(const gchar *v, int replacing); + +/* Same as hardinfo_spawn_command_line_sync(), but calls shell_status_pulse() + * before. */ +gboolean hardinfo_spawn_command_line_sync(const gchar *command_line, + gchar **standard_output, + gchar **standard_error, + gint *exit_status, + GError **error); + +/* a marker in text to point out problems, using markup where possible */ +const char *problem_marker(); + +/* a version of g_strescape() that allows escaping extra characters. + * use with g_strcompress() as normal. */ +gchar * +gg_strescape (const gchar *source, + const gchar *exceptions, + const gchar *extra); + +/* hinote helpers */ +#define note_max_len 512 +#define note_printf(note_buff, fmt, ...) \ + snprintf((note_buff) + strlen(note_buff), note_max_len - strlen(note_buff) - 1, \ + fmt, ##__VA_ARGS__) +#define note_print(note_buff, str) note_printf((note_buff), "%s", str) +gboolean note_cond_bullet(gboolean cond, gchar *note_buff, const gchar *desc_str); +gboolean note_require_tool(const gchar *tool, gchar *note_buff, const gchar *desc_str); +int cpu_procs_cores_threads(int *p, int *c, int *t); + +#endif /* __HARDINFO_H__ */ diff --git a/includes/help-viewer.h b/includes/help-viewer.h new file mode 100644 index 00000000..85c78edf --- /dev/null +++ b/includes/help-viewer.h @@ -0,0 +1,43 @@ +/* + * HelpViewer - Simple Help file browser + * Copyright (C) 2009 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __HELP_VIEWER_H__ +#define __HELP_VIEWER_H__ + +typedef struct _HelpViewer HelpViewer; + +struct _HelpViewer { + GtkWidget *window; + GtkWidget *status_bar; + + GtkWidget *btn_back, *btn_forward; + GtkWidget *text_view; + GtkWidget *text_search; + + gchar *current_file; + gchar *help_directory; + + GSList *back_stack, *forward_stack; +}; + +HelpViewer *help_viewer_new(const gchar *help_dir, const gchar *help_file); +void help_viewer_open_page(HelpViewer *help_viewer, const gchar *page); +void help_viewer_destroy(HelpViewer *help_viewer); + +#endif /* __HELP_VIEWER_H__ */ + diff --git a/includes/ia64/processor-platform.h b/includes/ia64/processor-platform.h new file mode 100644 index 00000000..d118fe86 --- /dev/null +++ b/includes/ia64/processor-platform.h @@ -0,0 +1,40 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PROCESSOR_PLATFORM_H__ +#define __PROCESSOR_PLATFORM_H__ + +#include "cpu_util.h" + +struct _Processor { + gint id; + gfloat cpu_mhz; /* for devices.c, identical to cpukhz_max/1000 */ + cpu_topology_data *cputopo; + cpufreq_data *cpufreq; + + gchar *model_name; + gchar *vendor_id; + gfloat bogomips; + gchar *strmodel; + + gchar *family, *arch, *archrev, *features; + gint model, revision; + gint cpu_regs; +}; + +#endif /* __PROCESSOR_PLATFORM_H__ */ diff --git a/includes/iconcache.h b/includes/iconcache.h new file mode 100644 index 00000000..b71924c3 --- /dev/null +++ b/includes/iconcache.h @@ -0,0 +1,30 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __ICONCACHE_H__ +#define __ICONCACHE_H__ + +#include <gtk/gtk.h> + +void icon_cache_init(void); +GdkPixbuf *icon_cache_get_pixbuf(const gchar *file); +GtkWidget *icon_cache_get_image(const gchar *file); +GdkPixbuf *icon_cache_get_pixbuf_at_size(const gchar *file, gint wid, gint hei); +GtkWidget *icon_cache_get_image_at_size(const gchar *file, gint wid, gint hei); + +#endif /* __ICONCACHE_H__ */ diff --git a/includes/info.h b/includes/info.h new file mode 100644 index 00000000..77894518 --- /dev/null +++ b/includes/info.h @@ -0,0 +1,114 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2017 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#pragma once + +#include <stdarg.h> +#include <glib.h> + +enum InfoGroupSort { + INFO_GROUP_SORT_NONE, + INFO_GROUP_SORT_NAME_ASCENDING, + INFO_GROUP_SORT_NAME_DESCENDING, + INFO_GROUP_SORT_VALUE_ASCENDING, + INFO_GROUP_SORT_VALUE_DESCENDING, + INFO_GROUP_SORT_TAG_ASCENDING, + INFO_GROUP_SORT_TAG_DESCENDING, + INFO_GROUP_SORT_MAX, +}; + +struct Info { + GArray *groups; + + const gchar *column_titles[5]; + + ShellViewType view_type; + + int reload_interval; + + gboolean column_headers_visible; + gboolean zebra_visible; + gboolean normalize_percentage; +}; + +struct InfoGroup { + const gchar *name; + enum InfoGroupSort sort; + + GArray *fields; + + /* scaffolding fields */ + const gchar *computed; +}; + +struct InfoField { + const gchar *name; + const gchar *value; + const gchar *icon; + + int update_interval; + gboolean highlight; /* select in GUI, highlight in report (flag:*) */ + gboolean report_details; /* show moreinfo() in report (flag:!) */ + gboolean value_has_vendor; /* (flag:^) */ + gboolean label_is_escaped; /* if the label will need g_strcompress() before display use */ + + gboolean free_name_on_flatten; + gboolean free_value_on_flatten; + + /* scaffolding fields */ + gchar *tag; /* moreinfo() lookup tag */ +}; + +struct Info *info_new(void); + +void info_remove_group(struct Info *info, guint index); +struct InfoGroup *info_add_group(struct Info *info, const gchar *group_name, ...); +void info_group_strip_extra(struct InfoGroup *group); + +void info_add_computed_group(struct Info *info, const gchar *name, const gchar *value); +void info_add_computed_group_wo_extra(struct Info *info, const gchar *name, const gchar *value); + +void info_group_add_field(struct InfoGroup *group, struct InfoField field); +void info_group_add_fields(struct InfoGroup *group, ...); +void info_group_add_fieldsv(struct InfoGroup *group, va_list ap); + +struct InfoField info_field_printf(const gchar *name, const gchar *format, ...) + __attribute__((format(printf, 2, 3))); + +#define info_field_full(...) \ + (struct InfoField) { __VA_ARGS__ } + +#define info_field(n, v, ...) \ + info_field_full(.name = (n), .value = (v), __VA_ARGS__) + +#define info_field_update(n, ui, ...) \ + info_field_full(.name = (n), .value = "...", .update_interval = (ui), \ + __VA_ARGS__) + +#define info_field_last() \ + (struct InfoField) {} + +void info_set_column_title(struct Info *info, const gchar *column, const gchar *title); +void info_set_column_headers_visible(struct Info *info, gboolean setting); +void info_set_zebra_visible(struct Info *info, gboolean setting); +void info_set_normalize_percentage(struct Info *info, gboolean setting); +void info_set_view_type(struct Info *info, ShellViewType setting); +void info_set_reload_interval(struct Info *info, int setting); + +gchar *info_flatten(struct Info *info); +struct Info *info_unflatten(const gchar *str); diff --git a/includes/loadgraph.h b/includes/loadgraph.h new file mode 100644 index 00000000..d176e816 --- /dev/null +++ b/includes/loadgraph.h @@ -0,0 +1,55 @@ +/* + * Simple Load Graph + * Copyright (C) 2006 L. A. F. Pereira <l@tia.mat.br> + * + * The Simple Load Graph is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License, version 2.1, as published by the Free Software Foundation. + * + * The Simple Load Graph is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the Simple Load Graph; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + + +#ifndef __LOADGRAPH_H__ +#define __LOADGRAPH_H__ + +#include <stdlib.h> +#include <gtk/gtk.h> +#include <math.h> + +typedef struct _LoadGraph LoadGraph; + +typedef enum { + LG_COLOR_GREEN = 0x4FB05A, + LG_COLOR_BLUE = 0x4F58B0, + LG_COLOR_RED = 0xB04F4F +} LoadGraphColor; + +LoadGraph *load_graph_new(gint size); +void load_graph_destroy(LoadGraph *lg); +void load_graph_configure_expose(LoadGraph *lg); +GtkWidget *load_graph_get_framed(LoadGraph *lg); + +void load_graph_update(LoadGraph *lg, gdouble value); +void load_graph_update_ex(LoadGraph *lg, guint line, gdouble value); + +void load_graph_set_color(LoadGraph *lg, LoadGraphColor color); +void load_graph_clear(LoadGraph *lg); + +void load_graph_set_data_suffix(LoadGraph *lg, gchar *suffix); +gchar *load_graph_get_data_suffix(LoadGraph *lg); + +void load_graph_set_title(LoadGraph *lg, const gchar *title); +const gchar *load_graph_get_title(LoadGraph *lg); + +gint load_graph_get_height(LoadGraph *lg); + +#endif /* __LOADGRAPH_H__ */ diff --git a/includes/loongarch64/processor-platform.h b/includes/loongarch64/processor-platform.h new file mode 100644 index 00000000..43ba0a26 --- /dev/null +++ b/includes/loongarch64/processor-platform.h @@ -0,0 +1,31 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PROCESSOR_PLATFORM_H__ +#define __PROCESSOR_PLATFORM_H__ + +struct _Processor { + gchar *vendor_id; + gchar *family; + gchar *model_name; + gint revision; + gfloat cpu_mhz, bogomips; + gchar *features; +}; + +#endif /* __PROCESSOR_PLATFORM_H__ */ diff --git a/includes/m68k/processor-platform.h b/includes/m68k/processor-platform.h new file mode 100644 index 00000000..5e38bc11 --- /dev/null +++ b/includes/m68k/processor-platform.h @@ -0,0 +1,29 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PROCESSOR_PLATFORM_H__ +#define __PROCESSOR_PLATFORM_H__ + +struct _Processor { + gchar *model_name; + gfloat bogomips, cpu_mhz; + + gchar *fpu_name, *mmu_name, *calibration; +}; + +#endif /* __PROCESSOR_PLATFORM_H__ */ diff --git a/includes/markdown-text-view.h b/includes/markdown-text-view.h new file mode 100644 index 00000000..11d184a2 --- /dev/null +++ b/includes/markdown-text-view.h @@ -0,0 +1,70 @@ +/* + * Markdown Text View + * GtkTextView subclass that supports Markdown syntax + * + * Copyright (C) 2009 L.Pereira <l@tia.mat.br> + * Portions Copyright (C) 2007-2008 Richard Hughes <richard@hughsie.com> + * Portions Copyright (C) GTK+ Team (based on hypertext textview demo) + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef __MARKDOWN_TEXTVIEW_H__ +#define __MARKDOWN_TEXTVIEW_H__ + +#include <gtk/gtk.h> +#include "egg-markdown.h" + +G_BEGIN_DECLS +#define TYPE_MARKDOWN_TEXTVIEW (markdown_textview_get_type()) +#define MARKDOWN_TEXTVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_MARKDOWN_TEXTVIEW, MarkdownTextView)) +#define MARKDOWN_TEXTVIEW_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST((obj), MARKDOWN_TEXTVIEW, MarkdownTextViewClass)) +#define IS_MARKDOWN_TEXTVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_MARKDOWN_TEXTVIEW)) +#define IS_MARKDOWN_TEXTVIEW_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((obj), TYPE_MARKDOWN_TEXTVIEW)) +#define MARKDOWN_TEXTVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_MARKDOWN_TEXTVIEW, MarkdownTextViewClass)) + +typedef struct _MarkdownTextView MarkdownTextView; +typedef struct _MarkdownTextViewClass MarkdownTextViewClass; + +struct _MarkdownTextView { + GtkTextView parent; + + EggMarkdown *markdown; + gboolean hovering_over_link; + gchar *image_directory; +}; + +struct _MarkdownTextViewClass { + GtkTextViewClass parent_class; + + void (*link_clicked) (MarkdownTextView *text_view, gchar *uri); + void (*hovering_over_link) (MarkdownTextView *text_view, gchar *uri); + void (*hovering_over_text) (MarkdownTextView *text_view); + void (*file_load_complete) (MarkdownTextView *text_view, gchar *file); +}; + +GtkWidget *markdown_textview_new(); +gboolean markdown_textview_load_file(MarkdownTextView * textview, + const gchar * file_name); +gboolean markdown_textview_set_text(MarkdownTextView * textview, + const gchar * text); +void markdown_textview_clear(MarkdownTextView * textview); +void markdown_textview_set_image_directory(MarkdownTextView * self, + const gchar * directory); +GType markdown_textview_get_type(); +G_END_DECLS + +#endif /* __MARKDOWN_TEXTVIEW_H__ */ diff --git a/includes/md5.h b/includes/md5.h new file mode 100644 index 00000000..1522170c --- /dev/null +++ b/includes/md5.h @@ -0,0 +1,26 @@ +/* See md5.c for explanation and copyright information. */ + +#ifndef MD5_H +#define MD5_H + +/* Unlike previous versions of this code, uint32 need not be exactly + 32 bits, merely 32 bits or more. Choosing a data type which is 32 + bits instead of 64 is not important; speed is considerably more + important. ANSI guarantees that "unsigned long" will be big enough, + and always using it seems to have few disadvantages. */ +typedef unsigned long uint32; + +struct MD5Context { + uint32 buf[4]; + uint32 bits[2]; + unsigned char in[64]; +}; + +void MD5Init (struct MD5Context *context); +void MD5Update (struct MD5Context *context, + unsigned char const *buf, unsigned len); +void MD5Final (unsigned char digest[16], + struct MD5Context *context); +void MD5Transform (uint32 buf[4], const unsigned char in[64]); + +#endif /* !MD5_H */ diff --git a/includes/menu.h b/includes/menu.h new file mode 100644 index 00000000..d5e8aeeb --- /dev/null +++ b/includes/menu.h @@ -0,0 +1,26 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __MENU_H__ +#define __MENU_H__ + +#include <shell.h> + + +void menu_init(Shell *shell); + +#endif /* __MENU_H__ */ diff --git a/includes/mips/processor-platform.h b/includes/mips/processor-platform.h new file mode 100644 index 00000000..394ba99e --- /dev/null +++ b/includes/mips/processor-platform.h @@ -0,0 +1,28 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PROCESSOR_PLATFORM_H__ +#define __PROCESSOR_PLATFORM_H__ + +struct _Processor { + gchar *model_name; + gchar *vendor_id; + gfloat bogomips, cpu_mhz; +}; + +#endif /* __PROCESSOR_PLATFORM_H__ */ diff --git a/includes/network.h b/includes/network.h new file mode 100644 index 00000000..13d54872 --- /dev/null +++ b/includes/network.h @@ -0,0 +1,15 @@ +#ifndef __NETWORK_H__ +#define __NETWORK_H__ + +#include "hardinfo.h" + +extern gchar *smb_shares_list; +extern gchar *nfs_shares_list; +extern gchar *network_interfaces; +extern gchar *network_icons; + +void scan_net_interfaces(void); +void scan_samba(void); +void scan_nfs_shared_directories(void); + +#endif /* __NETWORK_H__ */ diff --git a/includes/nqueens.h b/includes/nqueens.h new file mode 100644 index 00000000..a4be93f0 --- /dev/null +++ b/includes/nqueens.h @@ -0,0 +1,13 @@ +/* + * N-Queens Problem Solver + * Found somewhere on the Internet; can't remember where. Possibly Wikipedia. + */ +#ifndef __NQUEENS_H__ +#define __NQUEENS_H__ + +int nqueens(int y); + + +#endif /* __NQUEENS_H__ */ + + diff --git a/includes/parisc/processor-platform.h b/includes/parisc/processor-platform.h new file mode 100644 index 00000000..b7485bda --- /dev/null +++ b/includes/parisc/processor-platform.h @@ -0,0 +1,42 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PROCESSOR_PLATFORM_H__ +#define __PROCESSOR_PLATFORM_H__ + +#include "cpu_util.h" + +struct _Processor { + gint id; + gfloat cpu_mhz; /* for devices.c, identical to cpukhz_max/1000 */ + cpu_topology_data *cputopo; + cpufreq_data *cpufreq; + + gchar *model_name; + gchar *vendor_id; + gchar *flags; + gfloat bogomips; + gchar *has_fpu; + gchar *strmodel; + + gchar *cpu_family; + gchar *icache_str, *dcache_str; + gchar *hversion, *sversion; +}; + +#endif /* __PROCESSOR_PLATFORM_H__ */ diff --git a/includes/pci_util.h b/includes/pci_util.h new file mode 100644 index 00000000..f2d1d605 --- /dev/null +++ b/includes/pci_util.h @@ -0,0 +1,78 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2017 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PCI_UTIL_H__ +#define __PCI_UTIL_H__ + +#include <stdint.h> + +#define SYSFS_PCI_ROOT "/sys/bus/pci/devices" + +char *pci_address_str(uint32_t dom, uint32_t bus, uint32_t dev, uint32_t func); + +typedef struct pcid { + uint32_t domain; + uint32_t bus; + uint32_t device; + uint32_t function; + uint32_t class; + uint32_t vendor_id; + uint32_t device_id; + uint32_t sub_vendor_id; + uint32_t sub_device_id; + uint32_t revision; + char *slot_str; + char *class_str; + char *vendor_id_str; + char *device_id_str; + char *sub_vendor_id_str; + char *sub_device_id_str; + + char *driver; /* Kernel driver in use */ + char *driver_list; /* Kernel modules */ + + float pcie_speed_max; /* GT/s */ + float pcie_speed_curr; /* GT/s */ + uint32_t pcie_width_max; + uint32_t pcie_width_curr; + + /* ... */ + +} pcid; + +pcid *pci_get_device(uint32_t dom, uint32_t bus, uint32_t dev, uint32_t func); +pcid *pci_get_device_str(const char *addy); +#define pcid_new() g_new0(pcid, 1) +gint pcid_cmp_by_addy(gconstpointer a, gconstpointer b); +void pcid_free(pcid *); + +typedef GSList* pcid_list; +/* examples: + * to get all pci devices: + * pcid_list list = pci_get_device_list(0, 0); + * to get all display controllers: + * pcid_list list = pci_get_device_list(0x300, 0x3ff); + */ +pcid_list pci_get_device_list(uint32_t class_min, uint32_t class_max); +#define pcid_list_count(l) g_slist_length(l); +#define pcid_list_free(l) g_slist_free_full(l, (GDestroyNotify)pcid_free) + +const gchar *find_pci_ids_file(); +char *pci_lookup_ids_vendor_str(uint32_t id); + +#endif diff --git a/includes/ppc/processor-platform.h b/includes/ppc/processor-platform.h new file mode 100644 index 00000000..df1fcbaa --- /dev/null +++ b/includes/ppc/processor-platform.h @@ -0,0 +1,36 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PROCESSOR_PLATFORM_H__ +#define __PROCESSOR_PLATFORM_H__ + +#include "cpu_util.h" + +struct _Processor { + gint id; + gfloat cpu_mhz; /* for devices.c, identical to cpukhz_max/1000 */ + cpu_topology_data *cputopo; + cpufreq_data *cpufreq; + + gchar *model_name; + gchar *revision; + /* gint cache_size; */ + gfloat bogomips; +}; + +#endif /* __PROCESSOR_PLATFORM_H__ */ diff --git a/includes/report.h b/includes/report.h new file mode 100644 index 00000000..47b510c1 --- /dev/null +++ b/includes/report.h @@ -0,0 +1,103 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __REPORT_H__ +#define __REPORT_H__ +#include <gtk/gtk.h> +#include <shell.h> + +typedef enum { + REPORT_FORMAT_HTML, + REPORT_FORMAT_TEXT, + REPORT_FORMAT_SHELL, + N_REPORT_FORMAT +} ReportFormat; + +typedef enum { + REPORT_COL_PROGRESS = 1<<0, + REPORT_COL_VALUE = 1<<1, + REPORT_COL_EXTRA1 = 1<<2, + REPORT_COL_EXTRA2 = 1<<3, + REPORT_COL_TEXTVALUE= 1<<4 +} ReportColumn; + +typedef struct _ReportDialog ReportDialog; +typedef struct _ReportContext ReportContext; + +struct _ReportContext { + ShellModuleEntry *entry; + gchar *output; + + void (*header) (ReportContext *ctx); + void (*footer) (ReportContext *ctx); + void (*title) (ReportContext *ctx, gchar *text); + void (*subtitle) (ReportContext *ctx, gchar *text); + void (*subsubtitle) (ReportContext *ctx, gchar *text); + void (*keyvalue) (ReportContext *ctx, gchar *key, gchar *value, gsize longest_key); + + void (*details_start) (ReportContext *ctx, gchar *key, gchar *value, gsize longest_key); + void (*details_section) (ReportContext *ctx, gchar *name); + void (*details_keyvalue) (ReportContext *ctx, gchar *key, gchar *value, gsize longest_key); + void (*details_end) (ReportContext *ctx); + + ReportFormat format; + + gboolean first_table; + gboolean in_details; + + gboolean show_column_headers; + guint columns, parent_columns; + GHashTable *column_titles; + GHashTable *icon_refs; + GHashTable *icon_data; +}; + +struct _ReportDialog { + GtkWidget *dialog; + GtkWidget *filechooser; + GtkWidget *btn_cancel; + GtkWidget *btn_generate; + GtkWidget *btn_sel_all; + GtkWidget *btn_sel_none; + GtkWidget *treeview; + + GtkTreeModel *model; +}; + +void report_dialog_show(); + +ReportContext *report_context_html_new(); +ReportContext *report_context_text_new(); +ReportContext *report_context_shell_new(); + +void report_header (ReportContext *ctx); +void report_footer (ReportContext *ctx); +void report_title (ReportContext *ctx, gchar *text); +void report_subtitle (ReportContext *ctx, gchar *text); +void report_subsubtitle (ReportContext *ctx, gchar *text); +void report_key_value (ReportContext *ctx, gchar *key, gchar *value, gsize longest_key); +void report_table (ReportContext *ctx, gchar *text); +void report_details (ReportContext *ctx, gchar *key, gchar *value, gchar *details, gsize longest_key); + +void report_create_from_module_list(ReportContext *ctx, GSList *modules); +gchar *report_create_from_module_list_format(GSList *modules, ReportFormat format); + +void report_context_free(ReportContext *ctx); +void report_module_list_free(GSList *modules); + +#endif /* __REPORT_H__ */ diff --git a/includes/riscv/processor-platform.h b/includes/riscv/processor-platform.h new file mode 100644 index 00000000..b2c1c69c --- /dev/null +++ b/includes/riscv/processor-platform.h @@ -0,0 +1,36 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PROCESSOR_PLATFORM_H__ +#define __PROCESSOR_PLATFORM_H__ + +#include "cpu_util.h" + +struct _Processor { + gint id; /* hart */ + gfloat cpu_mhz; /* for devices.c, identical to cpukhz_max/1000 */ + cpu_topology_data *cputopo; + cpufreq_data *cpufreq; + + gchar *model_name; + gchar *mmu, *isa, *uarch; + gchar *flags; /* expanded from isa */ + gfloat bogomips; /* not used */ +}; + +#endif /* __PROCESSOR_PLATFORM_H__ */ diff --git a/includes/s390/processor-platform.h b/includes/s390/processor-platform.h new file mode 100644 index 00000000..2edee105 --- /dev/null +++ b/includes/s390/processor-platform.h @@ -0,0 +1,36 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PROCESSOR_PLATFORM_H__ +#define __PROCESSOR_PLATFORM_H__ + +#include "cpu_util.h" + +struct _Processor { + gint id; + gfloat cpu_mhz; /* for devices.c, identical to cpukhz_max/1000 */ + cpu_topology_data *cputopo; + cpufreq_data *cpufreq; + + gchar *model_name; /* vendor_id */ + gchar *proc_str; + gfloat bogomips; + +}; + +#endif /* __PROCESSOR_PLATFORM_H__ */ diff --git a/includes/sh/processor-platform.h b/includes/sh/processor-platform.h new file mode 100644 index 00000000..e8ba7686 --- /dev/null +++ b/includes/sh/processor-platform.h @@ -0,0 +1,32 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PROCESSOR_PLATFORM_H__ +#define __PROCESSOR_PLATFORM_H__ + +struct _Processor { + gchar *model_name; + gchar *vendor_id; + gfloat bogomips, cpu_mhz; + + gfloat bus_mhz, mod_mhz; + + gchar *family; +}; + +#endif /* __PROCESSOR_PLATFORM_H__ */ diff --git a/includes/sha1.h b/includes/sha1.h new file mode 100644 index 00000000..8b5c0b2f --- /dev/null +++ b/includes/sha1.h @@ -0,0 +1,30 @@ +/* + * SHA-1 in C + * By Steve Reid <steve@edmweb.com> + * 100% Public Domain + */ + +#ifndef __SHA1_H__ +#define __SHA1_H__ + +#include <glib.h> + +#ifndef LITTLE_ENDIAN +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +#define LITTLE_ENDIAN /* This should be #define'd if true. */ +#endif /* G_BYTE_ORDER */ +#endif /* LITTLE_ENDIAN */ + + +typedef struct { + guint32 state[20]; + guint32 count[2]; + guchar buffer[64]; +} SHA1_CTX; + +void SHA1Transform(guint32 state[5], guchar buffer[64]); +void SHA1Init(SHA1_CTX* context); +void SHA1Update(SHA1_CTX* context, guchar* data, unsigned int len); +void SHA1Final(guchar digest[20], SHA1_CTX* context); + +#endif /* __SHA1_H__ */ diff --git a/includes/shell.h b/includes/shell.h new file mode 100644 index 00000000..ab39106c --- /dev/null +++ b/includes/shell.h @@ -0,0 +1,260 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __SHELL_H__ +#define __SHELL_H__ + +#include <gtk/gtk.h> + +#include "loadgraph.h" +#include "help-viewer.h" + +typedef struct _Shell Shell; +typedef struct _ShellTree ShellTree; +typedef struct _ShellInfoTree ShellInfoTree; +typedef struct _ShellNote ShellNote; +typedef struct _DetailView DetailView; + +typedef struct _ShellModule ShellModule; +typedef struct _ShellModuleMethod ShellModuleMethod; +typedef struct _ShellModuleEntry ShellModuleEntry; + +typedef struct _ShellFieldUpdate ShellFieldUpdate; +typedef struct _ShellFieldUpdateSource ShellFieldUpdateSource; + +typedef enum { + SHELL_ORDER_DESCENDING, + SHELL_ORDER_ASCENDING, +} ShellOrderType; + +typedef enum { + SHELL_PACK_RESIZE = 1 << 0, + SHELL_PACK_SHRINK = 1 << 1 +} ShellPackOptions; + +typedef enum { + SHELL_VIEW_NORMAL, + SHELL_VIEW_DUAL, + SHELL_VIEW_LOAD_GRAPH, + SHELL_VIEW_PROGRESS, + SHELL_VIEW_PROGRESS_DUAL, + SHELL_VIEW_DETAIL, + SHELL_VIEW_N_VIEWS +} ShellViewType; + +typedef enum { + TREE_COL_PBUF, + TREE_COL_NAME, + TREE_COL_MODULE_ENTRY, + TREE_COL_MODULE, + TREE_COL_SEL, + TREE_NCOL +} ShellTreeColumns; + +typedef enum { + INFO_TREE_COL_NAME, + INFO_TREE_COL_VALUE, + INFO_TREE_COL_DATA, + INFO_TREE_COL_PBUF, + INFO_TREE_COL_PROGRESS, + INFO_TREE_COL_EXTRA1, + INFO_TREE_COL_EXTRA2, + INFO_TREE_NCOL +} ShellInfoTreeColumns; + +struct _Shell { + GtkWidget *window, *vbox; + GtkWidget *status, *progress; + GtkWidget *remote_label; + GtkWidget *notebook; + GtkWidget *hbox, *vpaned; + + GtkWindow *transient_dialog; + + ShellTree *tree; + ShellInfoTree *info_tree; + ShellModule *selected_module; + ShellModuleEntry *selected; + ShellNote *note; + DetailView *detail_view; + LoadGraph *loadgraph; + + GtkActionGroup *action_group; + GtkUIManager *ui_manager; + GSList *merge_ids; + + ShellViewType view_type; + gboolean normalize_percentage; + + gint _pulses; + ShellOrderType _order_type; + + GKeyFile *hosts; + HelpViewer *help_viewer; +}; + +struct _DetailView { + GtkWidget *scroll; + GtkWidget *view; + GtkWidget *detail_box; +}; + +struct _ShellTree { + GtkWidget *scroll; + GtkWidget *view; + GtkTreeModel *model; + GtkTreeSelection *selection; + + GSList *modules; +}; + +struct _ShellInfoTree { + GtkWidget *scroll; + GtkWidget *view; + GtkTreeModel *model; + GtkTreeSelection *selection; + + GtkTreeViewColumn *col_progress, *col_value, *col_extra1, *col_extra2, *col_textvalue; +}; + +struct _ShellNote { + GtkWidget *event_box; + GtkWidget *label; +}; + +struct _ShellModule { + gchar *name; + GdkPixbuf *icon; + GModule *dll; + + gconstpointer (*aboutfunc)(void); + gchar *(*summaryfunc) (); + void (*deinit) (); + + guchar weight; + + GSList *entries; +}; + +struct _ShellModuleMethod { + gchar *name; + gpointer function; +}; + +struct _ShellModuleEntry { + gchar *name; + GdkPixbuf *icon; + gchar *icon_file; + gboolean selected; + gint number; + guint32 flags; + + gchar *(*func) (); + void (*scan_func) (); + + gchar *(*fieldfunc) (gchar * entry); + gchar *(*morefunc) (gchar * entry); + gchar *(*notefunc) (gint entry); +}; + +struct _ShellFieldUpdate { + ShellModuleEntry *entry; + gchar *field_name; +}; + +struct _ShellFieldUpdateSource { + guint source_id; + ShellFieldUpdate *sfu; +}; + +void shell_init(GSList *modules); +void shell_do_reload(void); + +Shell *shell_get_main_shell(); + +void shell_action_set_enabled(const gchar *action_name, + gboolean setting); +gboolean shell_action_get_enabled(const gchar *action_name); +gboolean shell_action_get_active(const gchar *action_name); +void shell_action_set_active(const gchar *action_name, + gboolean setting); +void shell_action_set_property(const gchar *action_name, + const gchar *property, + gboolean setting); + +void shell_set_transient_dialog(GtkWindow *dialog); + +void shell_set_side_pane_visible(gboolean setting); +void shell_set_note_from_entry(ShellModuleEntry *entry); +void shell_ui_manager_set_visible(const gchar *path, + gboolean setting); + +void shell_status_update(const gchar *message); +void shell_status_pulse(void); +void shell_status_set_percentage(gint percentage); +void shell_status_set_enabled(gboolean setting); + +void shell_view_set_enabled(gboolean setting); + +void shell_clear_timeouts(Shell *shell); +void shell_clear_tree_models(Shell *shell); +void shell_clear_field_updates(void); +void shell_set_title(Shell *shell, char *subtitle); + +void shell_add_modules_to_gui(gpointer _shell_module, gpointer _shell_tree); + +void shell_save_hosts_file(void); +void shell_update_remote_menu(void); + +void shell_set_remote_label(Shell *shell, gchar *label); + +/* decode special information in keys + * + * key syntax: + * [$[<flags>][<tag>]$]<name>[#[<dis>]] + * flags: + * [[!][*][^]] + * ! = show details (moreinfo) in reports + * * = highlight/select this row + * ^ = value is/has a vendor string + * @ = label is escaped with key_label_escape() + */ +gboolean key_is_flagged(const gchar *key); /* has $[<flags>][<tag>]$ at the start of the key */ +gboolean key_is_highlighted(const gchar *key); /* flag '*' = select/highlight */ +gboolean key_wants_details(const gchar *key); /* flag '!' = report should include the "moreinfo" */ +gboolean key_value_has_vendor_string(const gchar *key); /* flag '^' = try and match the value to a vendor */ +#define key_label_escape(LBL) (gg_strescape(LBL, NULL, "=$#")) +gboolean key_label_is_escaped(const gchar *key); /* flag '@' = the label part is key_label_escape()-d and + * needs to be g_strcompress()-ed before use. + * key_get_components() will do this automatically for label. */ +gchar *key_mi_tag(const gchar *key); /* moreinfo lookup tag */ +const gchar *key_get_name(const gchar *key); /* get the key's name, flagged or not */ +/* + * example for key = "$*!Foo$Bar#7": + * flags = "$*!^Foo$" // key_is/wants_*() still works on flags + * tag = "Foo" // the moreinfo/icon tag + * name = "Bar#7" // the full unique name + * label = "Bar" // the label displayed + * dis = "7" + */ +void key_get_components(const gchar *key, + gchar **flags, gchar **tag, gchar **name, gchar **label, gchar **dis, + gboolean null_empty); + +#endif /* __SHELL_H__ */ + + diff --git a/includes/socket.h b/includes/socket.h new file mode 100644 index 00000000..8dd4d439 --- /dev/null +++ b/includes/socket.h @@ -0,0 +1,36 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __HI_SOCKET_H__ +#define __HI_SOCKET_H__ + +typedef struct _Socket Socket; + +struct _Socket { + gint sock; +}; + +Socket *sock_connect(gchar * host, gint port); +int sock_write(Socket * s, gchar * str); +int sock_read(Socket * s, gchar * buffer, gint size); +void sock_close(Socket * s); + +int sock_ready_to_read(Socket *s); +int sock_ready_to_write(Socket *s); + +#endif /* __HI_SOCKET_H__ */ diff --git a/includes/sparc/processor-platform.h b/includes/sparc/processor-platform.h new file mode 100644 index 00000000..c0e6f5cc --- /dev/null +++ b/includes/sparc/processor-platform.h @@ -0,0 +1,29 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PROCESSOR_PLATFORM_H__ +#define __PROCESSOR_PLATFORM_H__ + +struct _Processor { + gchar *model_name; + gchar *has_fpu; + gfloat cpu_mhz; + gchar *cpucaps; +}; + +#endif /* __PROCESSOR_PLATFORM_H__ */ diff --git a/includes/stock.h b/includes/stock.h new file mode 100644 index 00000000..d3efffdb --- /dev/null +++ b/includes/stock.h @@ -0,0 +1,36 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __STOCK_H__ +#define __STOCK_H__ + +#define HI_STOCK_CLIPBOARD "hi-stock-clipboard" +#define HI_STOCK_REFRESH "hi-stock-refresh" +#define HI_STOCK_REPORT "hi-stock-report" +#define HI_STOCK_INTERNET "hi-stock-internet" +#define HI_STOCK_MODULE "hi-stock-module" +#define HI_STOCK_ABOUT_MODULES "hi-stock-about-modules" +#define HI_STOCK_SYNC_MENU "hi-stock-sync-menu" +#define HI_STOCK_DONATE "hi-stock-donate" +#define HI_STOCK_SERVER "hi-stock-server" + +void stock_icons_init(void); +void stock_icon_register(gchar *filename, gchar *stock_id); +void stock_icon_register_pixbuf(GdkPixbuf *pixbuf, gchar *stock_id); + +#endif /* __STOCK_H__ */ diff --git a/includes/storage_util.h b/includes/storage_util.h new file mode 100644 index 00000000..7774e71f --- /dev/null +++ b/includes/storage_util.h @@ -0,0 +1,22 @@ +#include "vendor.h" +#include "pci_util.h" + +// udisks2 drive info extended +typedef struct u2driveext { + udiskd *d; + pcid *nvme_controller; + struct{ + gchar *oui; + gchar *vendor; + } wwid_oui; + vendor_list vendors; +} u2driveext; + + +GSList *get_udisks2_drives_ext(); + +u2driveext* u2drive_ext(udiskd * udisks_drive_data); +void u2driveext_free(u2driveext *u); + +void udisks2_shutdown(void); +void storage_shutdown(void); diff --git a/includes/syncmanager.h b/includes/syncmanager.h new file mode 100644 index 00000000..3b886b0f --- /dev/null +++ b/includes/syncmanager.h @@ -0,0 +1,42 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __SYNCMANAGER_H__ +#define __SYNCMANAGER_H__ + +#include <gtk/gtk.h> + +typedef struct _SyncEntry SyncEntry; + +struct _SyncEntry { + const gchar *name; + const gchar *file_name; + + gchar *(*generate_contents_for_upload)(gsize *size); + + gboolean selected; +}; + +void sync_manager_add_entry(SyncEntry *entry); +void sync_manager_clear_entries(void); +void sync_manager_show(GtkWidget *parent); +gint sync_manager_count_entries(void); + +void sync_manager_update_on_startup(void); + +#endif /* __SYNCMANAGER_H__ */ diff --git a/includes/test-utils.h b/includes/test-utils.h new file mode 100644 index 00000000..21cac6b5 --- /dev/null +++ b/includes/test-utils.h @@ -0,0 +1,24 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "libsoup/soup-types.h" + +void test_init (int argc, char **argv, GOptionEntry *entries); +void test_cleanup (void); + +extern int debug_level, errors; +extern gboolean expect_warning; +void debug_printf (int level, const char *format, ...) G_GNUC_PRINTF (2, 3); + +#ifdef HAVE_APACHE +void apache_init (void); +void apache_cleanup (void); +#endif + +SoupSession *soup_test_session_new (GType type, ...); +void soup_test_session_abort_unref (SoupSession *session); + +SoupServer *soup_test_server_new (gboolean in_own_thread); +SoupServer *soup_test_server_new_ssl (gboolean in_own_thread); + diff --git a/includes/udisks2_util.h b/includes/udisks2_util.h new file mode 100644 index 00000000..9b26f6dd --- /dev/null +++ b/includes/udisks2_util.h @@ -0,0 +1,69 @@ +#include "vendor.h" + +typedef struct udiskp { + gchar *block; + gchar *type; + gchar *version; + gchar *label; + guint64 size; + struct udiskp* next; +} udiskp; + +enum{ + UDSK_INTPVAL_SKIP = 0, + UDSK_INTPVAL_DIMENSIONLESS = 1, + UDSK_INTPVAL_MILISECONDS = 2, + UDSK_INTPVAL_HOURS = 3, + UDSK_INTPVAL_SECTORS = 4, + UDSK_INTPVAL_CELSIUS = 5, +}; + +typedef struct udisksa { + guint8 id; + gchar *identifier; + gint value; + gint worst; + gint threshold; + gint64 interpreted; + guint8 interpreted_unit; // enum + struct udisksa* next; +} udisksa; + +typedef struct udiskd { + gchar *model; + gchar *vendor; + gchar *revision; + gchar *block_dev; + gchar *serial; + gchar *wwid; + gchar *connection_bus; + gchar *partition_table; + udiskp *partitions; + gboolean ejectable; + gboolean removable; + gint32 rotation_rate; + guint64 size; + gchar *media; + gchar **media_compatibility; + gboolean pm_supported; + gboolean aam_supported; + gboolean apm_supported; + gboolean smart_supported; + gboolean smart_enabled; + gboolean smart_failing; + guint64 smart_poweron; + gint64 smart_bad_sectors; + gint32 smart_temperature; + udisksa *smart_attributes; +} udiskd; + +typedef struct udiskt { + gchar *drive; + gint32 temperature; +} udiskt; +void udisks2_init(); +void udisks2_shutdown(); +GSList *get_udisks2_temps(); +GSList *get_udisks2_all_drives_info(); +void udiskt_free(udiskt *u); +void udiskd_free(udiskd *u); diff --git a/includes/uidefs.h b/includes/uidefs.h new file mode 100644 index 00000000..c3042492 --- /dev/null +++ b/includes/uidefs.h @@ -0,0 +1,66 @@ +#ifndef __UIDEFS_H__ +#define __UIDEFS_H__ + +#include "config.h" + +#if RELEASE +#define DEBUG_TOOLBAR_ITEMS +#else /* !RELEASE */ +#define DEBUG_TOOLBAR_ITEMS \ + "<separator/>" \ + "<toolitem name=\"ReportBug\" action=\"ReportBugAction\" />" +#endif /* !RELEASE */ + +#define SYNC_MANAGER_MENU_ITEMS \ + "<separator/>" \ + "<menuitem name=\"SyncManager\" action=\"SyncManagerAction\" " \ + "always-show-image=\"true\"/>" \ + "<menuitem name=\"SyncOnStartup\" action=\"SyncOnStartupAction\"/>" +#define SYNC_MANAGER_TOOL_ITEMS \ + "<toolitem name=\"SyncManager\" action=\"SyncManagerAction\"/>" + +char *uidefs_str = + "<ui>" + " <menubar>" + " <menu name=\"InformationMenu\" action=\"InformationMenuAction\">" + " <menuitem name=\"Report\" action=\"ReportAction\" />" + " <menuitem name=\"Copy\" action=\"CopyAction\" />" + SYNC_MANAGER_MENU_ITEMS \ + " <separator/>" + " <menuitem name=\"Quit\" action=\"QuitAction\" />" + " </menu>" + " <menu name=\"ViewMenu\" action=\"ViewMenuAction\">" + " <menuitem name=\"SidePane\" action=\"SidePaneAction\"/>" + " <menuitem name=\"Toolbar\" action=\"ToolbarAction\"/>" + " <separator/>" + " <separator name=\"LastSep\"/>" + " <menuitem name=\"Refresh\" action=\"RefreshAction\"/>" + " </menu>" + " <menu name=\"HelpMenu\" action=\"HelpMenuAction\">" + " <menuitem name=\"WebPage\" action=\"HomePageAction\"/>" + " <menuitem name=\"ReportBug\" action=\"ReportBugAction\"/>" + " <menuitem name=\"About\" action=\"AboutAction\"/>" + " </menu>" + " </menubar>" + " <toolbar action=\"MainMenuBar\" action=\"MainMenuBarAction\">" + " <placeholder name=\"ToolItems\">" + " <toolitem name=\"Refresh\" action=\"RefreshAction\"/>" + " <separator/>" + " <toolitem name=\"Report\" action=\"ReportAction\"/>" + " <toolitem name=\"Copy\" action=\"CopyAction\"/>" + " <separator/>" + DEBUG_TOOLBAR_ITEMS \ + SYNC_MANAGER_TOOL_ITEMS \ + " </placeholder>" + " </toolbar>" + "</ui>"; + +/*DISABLED + " <separator/>" + " <menu name=\"HelpMenuModules\" " + "action=\"HelpMenuModulesAction\">" + " <separator name=\"LastSep\"/>" + " </menu>" +*/ + +#endif /* __UIDEFS_H__ */ diff --git a/includes/usb_util.h b/includes/usb_util.h new file mode 100644 index 00000000..736a9237 --- /dev/null +++ b/includes/usb_util.h @@ -0,0 +1,78 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2017 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __USB_UTIL_H__ +#define __USB_UTIL_H__ + +/* this is a linked list */ +typedef struct usbd { + int bus, dev; + int vendor_id, product_id; + char *vendor; + char *product; + char *manufacturer; + char *device; + char *serial; + + int dev_class; + int dev_subclass; + int dev_protocol; + char *dev_class_str; + char *dev_subclass_str; + char *dev_protocol_str; + + char *usb_version; + char *device_version; /* bcdDevice */ + + int max_curr_ma; + + int speed_mbs; + + vendor_list vendors; + + gboolean user_scan; /* not scanned as root */ + struct usbi *if_list; + + struct usbd *next; +} usbd; + +/* another linked list */ +typedef struct usbi { + int if_number; + int if_class; + int if_subclass; + int if_protocol; + char *if_label; + char *if_class_str; + char *if_subclass_str; + char *if_protocol_str; + char *driver; + + struct usbi *next; +} usbi; + +usbd *usb_get_device_list(); +int usbd_list_count(usbd *); +void usbd_list_free(usbd *); +void usb_lookup_ids_vendor_product_str(gint vendor_id, gint product_id, + gchar **vendor_str, gchar **product_str); + +usbd *usb_get_device(int bus, int dev, const gchar* sysfspath); +void usbd_free(usbd *); + +#endif diff --git a/includes/vendor.h b/includes/vendor.h new file mode 100644 index 00000000..213adaf8 --- /dev/null +++ b/includes/vendor.h @@ -0,0 +1,79 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __VENDOR_H__ +#define __VENDOR_H__ +#include "gg_slist.h" + +typedef GSList* vendor_list; +#define vendor_list_append(vl, v) g_slist_append(vl, (Vendor*)v) +#define vendor_list_concat(vl, ext) g_slist_concat(vl, ext) +vendor_list vendor_list_concat_va(int count, vendor_list vl, ...); /* count = -1 for NULL terminated list */ +#define vendor_list_free(vl) g_slist_free(vl) +#define vendor_list_remove_duplicates(vl) gg_slist_remove_duplicates(vl) +vendor_list vendor_list_remove_duplicates_deep(vendor_list vl); + +enum { + VENDOR_MATCH_RULE_WORD_IGNORE_CASE = 0, + VENDOR_MATCH_RULE_WORD_MATCH_CASE = 1, + VENDOR_MATCH_RULE_EXACT = 2, + VENDOR_MATCH_RULE_WORD_PREFIX_IGNORE_CASE = 3, + VENDOR_MATCH_RULE_WORD_PREFIX_MATCH_CASE = 4, + VENDOR_MATCH_RULE_WORD_SUFFIX_IGNORE_CASE = 5, + VENDOR_MATCH_RULE_WORD_SUFFIX_MATCH_CASE = 6, + /* "ST" hits for "ST3600A" but not "AST" or "STMicro" or "STEC" */ + VENDOR_MATCH_RULE_NUM_PREFIX_IGNORE_CASE = 7, + VENDOR_MATCH_RULE_NUM_PREFIX_MATCH_CASE = 8, +}; + +typedef struct { + char *match_string; + int match_rule; /* VENDOR_MATCH_RULE_* enum */ + char *name; + char *name_short; + char *url; + char *url_support; + char *wikipedia; /* wikipedia page title (assumes en:, otherwise include langauge), usually more informative than the vendor's page */ + char *note; /* a short stored comment */ + char *ansi_color; + + unsigned long file_line; + unsigned long ms_length; + unsigned long weight; + gboolean has_parens; +} Vendor; + +void vendor_init(void); +void vendor_cleanup(void); +/* end list of strings with NULL */ +const Vendor *vendor_match(const gchar *id_str, ...) + __attribute__((sentinel)); +vendor_list vendors_match(const gchar *id_str, ...) + __attribute__((sentinel)); +const gchar *vendor_get_name(const gchar *id_str); +const gchar *vendor_get_shortest_name(const gchar *id_str); +const gchar *vendor_get_url(const gchar *id_str); +gchar *vendor_get_link(const gchar *id_str); +gchar *vendor_get_link_from_vendor(const Vendor *v); +void vendor_free(Vendor *v); + +vendor_list vendors_match_core(const gchar *str, int limit); + +extern gboolean vendor_die_on_error; + +#endif /* __VENDOR_H__ */ diff --git a/includes/x86/processor-platform.h b/includes/x86/processor-platform.h new file mode 100644 index 00000000..0e9a276b --- /dev/null +++ b/includes/x86/processor-platform.h @@ -0,0 +1,63 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2006 L. A. F. Pereira <l@tia.mat.br> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __PROCESSOR_PLATFORM_H__ +#define __PROCESSOR_PLATFORM_H__ + +#include "cpu_util.h" + +typedef struct _ProcessorCache ProcessorCache; + +struct _ProcessorCache { + gint level; + gint number_of_sets; + gint physical_line_partition; + gint size; + gchar *type; + gint ways_of_associativity; + gint uid; /* uid is unique among caches with the same (type, level) */ + gchar *shared_cpu_list; /* some kernel's don't give a uid, so try shared_cpu_list */ + gint phy_sock; +}; + +struct _Processor { + gchar *model_name; + gchar *vendor_id; + gchar *flags; + gchar *bugs; + gchar *pm; /* power management features */ + gint cache_size; + gfloat bogomips; + gchar *microcode; + + gint id; + gfloat cpu_mhz; /* for devices.c, identical to cpukhz_max/1000 */ + cpu_topology_data *cputopo; + cpufreq_data *cpufreq; + + gchar *has_fpu; + gchar *bug_fdiv, *bug_hlt, *bug_f00f, *bug_coma; + + gint model, family, stepping; + gchar *strmodel; + + GSList *cache; + +}; + +#endif /* __PROCESSOR_PLATFORM_H__ */ diff --git a/includes/x_util.h b/includes/x_util.h new file mode 100644 index 00000000..4d398c94 --- /dev/null +++ b/includes/x_util.h @@ -0,0 +1,104 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2017 L. A. F. Pereira <l@tia.mat.br> + * This file + * Copyright (C) 2017 Burt P. <pburt0@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 or later. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __X_UTIL_H__ +#define __X_UTIL_H__ + +/* wayland information (lives here in x_util for now) */ +typedef struct { + char *xdg_session_type; + char *display_name; +} wl_info; + +wl_info *get_walyand_info(); +void wl_free(wl_info *); + +typedef struct { + char *glx_version; + int direct_rendering; + char *ogl_vendor, *ogl_renderer; + + char *ogl_core_version, *ogl_core_sl_version; + char *ogl_version, *ogl_sl_version; /* compat */ + char *ogles_version, *ogles_sl_version; +} glx_info; + +glx_info *glx_create(); +gboolean fill_glx_info(glx_info *glx); +void glx_free(glx_info *glx); + +typedef struct { + int number; + int px_width; + int px_height; + int min_px_width; + int min_px_height; + int max_px_width; + int max_px_height; +} x_screen; + +typedef struct { + /* I guess it is kindof like gpu? */ + int reserved; /* TODO: */ +} x_provider; + +typedef struct { + char name[64]; + int connected; + int screen; /* index into xrr_info.screens[], look there for x screen number */ + int px_width; + int px_height; + int px_offset_x; + int px_offset_y; + int mm_width; + int mm_height; +} x_output; + +typedef struct { + int reserved; /* TODO: */ +} x_monitor; + +typedef struct { + char *display_name; + int screen_count; + x_screen *screens; + int provider_count; + x_provider *providers; + int output_count; + x_output *outputs; + int monitor_count; + x_monitor *monitors; +} xrr_info; + +xrr_info *xrr_create(); +gboolean fill_xrr_info(xrr_info *xrr); +void xrr_free(xrr_info *xrr); + +typedef struct { + int nox; /* complete failure to find X */ + char *display_name, *vendor, *version, *release_number; + xrr_info *xrr; + glx_info *glx; +} xinfo; + +xinfo *xinfo_get_info(); +void xinfo_free(xinfo *xi); + +#endif |