Перенес код в новую версию шаблона программ

pull/4/head
Igor Belitskiy 2 years ago
parent 2883b81cc3
commit 05008594c1

@ -8,10 +8,13 @@ MAKEFILE_PATH := $(dir $(MAKEFILE_FILEPATH))
CMAKE_COMMAND = cmake
CMAKE_SOURCE_DIR = $(MAKEFILE_PATH)source
CMAKE_BUILD_DIR = $(MAKEFILE_PATH)compile
#CMAKE_SOURCE_DIR = ./source
#CMAKE_BUILD_DIR = ./compile
DEPENDS = /bin/cmake
PREFIX ?= /usr
PKGNAME = $(MAKEFILE_DIR)
#PKGNAME = ubl-settings-manager
LATEST_TAG=
default_target: all
.PHONY: all init depend debug prepare check build uninstall install clean help
@ -21,11 +24,11 @@ all: init build
init:
@echo "Initialize ..."; \
if [ -d ".git" ]; then \
LATEST_TAG=$$(git describe --tags | sed 's/^v//'); \
LATEST_TAG=$$(git describe --tags | sed 's/^v//'|grep -oE "^[0-9]{1,}.[0-9]{1,}"); \
else \
LATEST_TAG="0.0"; \
fi; \
sed -r "s/^(string version_application = ).*/\1\"$${LATEST_TAG}\";/" -i source/${PKGNAME}.h; \
sed -r "s/^(string version_application).*/\1=\"$${LATEST_TAG}\";/" -i source/${PKGNAME}.h; \
echo "-- Build path: ${CMAKE_BUILD_DIR}"
depend:
@ -36,14 +39,16 @@ depend:
exit 1; \
fi; \
done; \
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B${CMAKE_BUILD_DIR} --check-build-system CMakeFiles/Makefile.cmake 1 || exit 1; \
echo "Check depends: OK"
# $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
debug:
@echo "Debug ..."
debug: init build
@echo "Debug ..."; \
if [ ! -d ${CMAKE_BUILD_DIR} ]; then \
$(CMAKE_COMMAND) -S${CMAKE_SOURCE_DIR} -B${CMAKE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="${PREFIX}"; \
fi; \
echo "${CMAKE_BUILD_DIR}/${PKGNAME}"; \
cp ${CMAKE_BUILD_DIR}/${PKGNAME} ./; \
echo "Debug: OK"
prepare:
@ -87,7 +92,9 @@ uninstall:
@$(RM) "${DESTDIR}${PREFIX}/bin/${PKGNAME}"
@$(RM) "${DESTDIR}${PREFIX}/share/applications/${PKGNAME}.desktop"
@$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.svg"
@$(RM) -rd "${DESTDIR}${PREFIX}/share/${PKGNAME}"
@$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.checked.svg"
@$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.warning.svg"
@$(RM) "${DESTDIR}${PREFIX}/share/polkit-1/actions/com.ublinux.${PKGNAME}.policy"
@if [ -z ${DESTDIR} ]; then \
[ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \
update-desktop-database --quiet &>/dev/null || true; \
@ -96,8 +103,10 @@ uninstall:
@echo "Uninstall: OK"
install: check uninstall
@cc source/my_device.c source/my_device.h source/filters.c source/filters.h source/ubl-cmake.h source/view_edit.h source/view_edit.c source/view_add.h source/view_add.c source/ubl-utils.h source/ubl-utils.c source/ubl-strings.h source/ubl-settings-resourcequota.h source/ubl-settings-resourcequota.c -o ubl-settings-resourcequota `pkg-config --cflags --libs gtk+-3.0 vte-2.91 webkit2gtk-4.0 webkit2gtk-web-extension-4.0` -g
@echo "Install ..."
#################################################### УДАЛИТЬ ПЕРЕД КОММИТОМ ################################################################################
@gcc compile/resources.c source/my_device.c source/philos_utils.c source/philos_utils.h source/my_device.h source/filters.c source/filters.h source/ubl-cmake.h source/view_edit.h source/view_edit.c source/view_add.h source/view_add.c source/ubl-utils.h source/ubl-utils.c source/ubl-strings.h source/ubl-settings-resourcequota.h source/ubl-settings-resourcequota.c -o ubl-settings-resourcequota `pkg-config --cflags --libs gtk+-3.0 vte-2.91 webkit2gtk-4.0 webkit2gtk-web-extension-4.0` -g
#################################################### УДАЛИТЬ ПЕРЕД КОММИТОМ ################################################################################
@for FILE_PO in $(wildcard *.po); do \
LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \
install -dm755 "${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES"; \
@ -112,14 +121,12 @@ install: check uninstall
done
@install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg"
@install -dm755 "${DESTDIR}${PREFIX}/share/polkit-1/actions"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/polkit-1/actions/" "com.ublinux.${PKGNAME}.policy"
@install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}"
@install -dm755 "${DESTDIR}/etc/xdg"
@install -dm755 "${DESTDIR}${PREFIX}/share/applications"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop"
@install -dm755 "${DESTDIR}${PREFIX}/share/${PKGNAME}"/{ui,css,images}
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/ui/" "${PKGNAME}.glade"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/css/" "${PKGNAME}.css"
@install -dm755 -d "${DESTDIR}${PREFIX}/share/${PKGNAME}/images"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/images/" "${PKGNAME}-banner.png"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.funnel.svg"
@ -129,6 +136,7 @@ install: check uninstall
[ -d "${DESTDIR}${PREFIX}/share/applications" ] && touch "${DESTDIR}${PREFIX}/share/applications" &>/dev/null || true; \
fi
@echo "Install: OK"
@sed -r "s/^(string version_application=\"*\").*/string version_application;/" -i source/${PKGNAME}.h; \
clean:
@echo "Clean ..."
@ -139,6 +147,14 @@ clean:
echo "Clean: OK"; \
fi
up_ver:
@CURRENT=$$(grep 'VERSION' ${FILE_VERSION} | cut -d" " -f2); \
MAJOR=$$(cut -d. -f1 <<< $${CURRENT}); \
MINOR=$$(cut -d. -f2 <<< $${CURRENT}); \
VER="$${MAJOR}.$$(($${MINOR}+1))"; \
sed "s/VERSION *[[:digit:]]*.*/VERSION $${VER}/" -i ${FILE_VERSION}; \
echo "Updated version to VERSION.md: $${CURRENT} to $${VER}"
help:
@echo "The following are some of the valid targets for this Makefile:"; \
echo "... all (the default if no target is provided)"; \
@ -148,4 +164,5 @@ help:
echo "... compile"; \
echo "... install"; \
echo "... uninstall"; \
echo "... clean"
echo "... clean"; \
echo "... up_ver"

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/ublinux/ui">
<file>ubl-settings-resourcequota.glade</file>
</gresource>
<gresource prefix="/com/ublinux/css">
<file>ubl-settings-resourcequota.css</file>
</gresource>
<gresource prefix="/com/ublinux/images">
<file>ubl-settings-resourcequota-banner.png</file>
</gresource>
</gresources>

@ -1,12 +1,12 @@
cmake_minimum_required(VERSION 3.23)
cmake_minimum_required(VERSION 3.7)
project(ubl-settings-resourcequota)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
include_directories(${GTK3_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS})
add_definitions(${GTK3_CFLAGS_OTHER})
pkg_check_modules(GTK REQUIRED gtk+-3.0)
include_directories(${GTK_INCLUDE_DIRS})
link_directories(${GTK_LIBRARY_DIRS})
add_definitions(${GTK_CFLAGS_OTHER})
pkg_check_modules(VTE291 REQUIRED vte-2.91)
include_directories(${VTE291_INCLUDE_DIRS})
@ -24,7 +24,42 @@ if(WEBKIT_LIBRARIES_FOUND)
add_definitions(${WEBKIT_CFLAGS_OTHER})
endif()
configure_file(ubl-cmake.h.in ubl-cmake.h)
configure_file(ubl-cmake.in ubl-cmake.h)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h DESTINATION ./)
set(GRESOURCE_C resources.c)
set(GRESOURCE_XML gresource.xml)
find_program(GLIB_COMPILE_RESOURCES NAMES glib-compile-resources REQUIRED)
add_custom_target(GLADE ubl-settings-resourcequota.glade)
set(DEPENDFILES
../ubl-settings-resourcequota.glade
../gresource.xml
../ubl-settings-resourcequota-banner.png
../ubl-settings-resourcequota.css
)
file(COPY ${DEPENDFILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
add_custom_command(
OUTPUT ${GRESOURCE_C}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${GLIB_COMPILE_RESOURCES}
ARGS
--generate-source
--target=${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}
${GRESOURCE_XML}
VERBATIM
MAIN_DEPENDENCY ${GRESOURCE_XML}
DEPENDS
${GLADE}
)
add_custom_target(
dummy-resource
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}
)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -lm")
@ -33,6 +68,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissin
-Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
-fstack-clash-protection -fcf-protection")
set(SOURCE_FILES
ubl-settings-resourcequota.c
ubl-settings-resourcequota.h
@ -47,15 +83,25 @@ set(SOURCE_FILES
ubl-strings.h
ubl-utils.h
ubl-utils.c
ubl-cmake.h)
ubl-cmake.h
philos_utils.c
philos_utils.h
${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h
)
set(LIBRARIES
${GTK3_LIBRARIES}
${GTK_LIBRARIES}
${WEBKIT_LIBRARIES}
${VTE291_LIBRARIES}
pthread)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C})
target_link_libraries(${PROJECT_NAME} PUBLIC ${LIBRARIES})
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_BINARY_DIR})
set_source_files_properties(
${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}
PROPERTIES GENERATED TRUE
)
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
add_dependencies(${PROJECT_NAME} dummy-resource)

@ -5,7 +5,7 @@ gboolean flag_filters[8];
filters_window *filters_setup_window(char* glade_path){
if (filters_widgets == NULL) {
filters_widgets = malloc(sizeof(filters_window));
GtkBuilder *builder = gtk_builder_new_from_file(glade_path);
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path);
filters_widgets->Window = yon_gtk_builder_get_widget(builder,"wndFilters");
filters_widgets->chbFilterTypeQouota = yon_gtk_builder_get_widget(builder,"chbFilterTypeQouota");
filters_widgets->chbQuotaVolume = yon_gtk_builder_get_widget(builder,"chbQuotaVolume");

@ -11,7 +11,7 @@
#include <libintl.h>
#include <getopt.h>
#include <libintl.h>
#include "philos_utils.h"
// Переменные
typedef struct {

@ -4,6 +4,7 @@
#include <locale.h>
#include <stdio.h>
#include <unistd.h>
#include "philos_utils.h"
typedef struct {
char** name_disk;
char** file_system;

@ -0,0 +1,969 @@
#include "philos_utils.h"
void philos_array_string_remove_char(char*** array, char* str_remove, int size) {
for (int index = 0; index < size; index++) {
(*array)[index] = yon_char_divide_search((*array)[index], str_remove, -1);
}
}
void philos_set_pow_size_memory(char* str_find, int** array_size,int index, char** array_size_pow) {
char* STR_KB = array_size_pow[0];
char* STR_MB = array_size_pow[1];
char* STR_GB = array_size_pow[2];
char* STR_TB = array_size_pow[3];
size_t length = strlen(str_find);
if (strstr(str_find,"K") != NULL) {
*array_size = philos_int_append(*array_size, &index, 0);
str_find = yon_char_divide(str_find, length-1);
str_find = yon_char_unite(str_find, " ", STR_KB, NULL);
index--;
}
else if (strstr(str_find,"M") != NULL) {
*array_size = philos_int_append(*array_size, &index, 1);
str_find = yon_char_divide(str_find, length-1);
str_find = yon_char_unite(str_find," ", STR_MB, NULL);
index--;
}
else if (strstr(str_find,"G") != NULL) {
*array_size = philos_int_append(*array_size, &index, 2);
str_find = yon_char_divide(str_find, length-1);
str_find = yon_char_unite(str_find," ", STR_GB, NULL);
index--;
}
else if (strstr(str_find,"T") != NULL) {
*array_size = philos_int_append(*array_size, &index, 3);
str_find = yon_char_divide(str_find, length-1);
str_find = yon_char_unite(str_find," ", STR_TB, NULL);
index--;
}
else if (strstr(str_find,"%%") != NULL) {
*array_size = philos_int_append(*array_size, &index, -1);
str_find = yon_char_divide(str_find, length-1);
index--;
}
else if (strstr(str_find,"-") != NULL) {
*array_size = philos_int_append(*array_size, &index, -1);
index--;
}
}
void philos_set_size_memory_integer_char(char* str_find, char*** array_data, int index) {
char* simv_del_array[10] = {"K","M","G","T","k","m","g","t"," ","%"};
for (size_t i = 0; i < 10; i++) {
if (strstr(str_find, simv_del_array[i])) {
str_find = yon_char_divide_search(str_find, simv_del_array[i], -1);
}
}
if (strstr(str_find, " ") != NULL) {
char* mem_s = yon_char_new(str_find);
yon_char_divide_search(mem_s, " ", -1);
*array_data = yon_char_parsed_append(*array_data, &index, mem_s);
}
if (strstr(str_find, "-") != NULL) {
*array_data = yon_char_parsed_append(*array_data, &index, "-");
}
else {
if (str_find[0] == '\"') {
yon_char_divide(str_find, 0);
size_t length = strlen(str_find);
str_find = yon_char_divide(str_find, length-2);
}
if (strstr(str_find, " ") == NULL) {
*array_data = yon_char_parsed_append(*array_data, &index, str_find);
}
}
}
void philos_free_string_array(char ***array, int size) {
if ((*array) == NULL) {
return;
}
for (int i = 0; i < size; i++){
free((*array)[i]);
}
if (size!= 0) {
free(*array);
(*array) = NULL;
}
}
void philos_free_string_array_n3(char ****array, int size) {
if ((*array) == NULL || size == 0) {
return;
}
int index_to_l2 = 0;
for (int i = 0; i < size; i++){
index_to_l2 = 0;
if ((*array)[i]!=NULL) {
while ((*array)[i][index_to_l2] != NULL) {
if ((*array)[i][index_to_l2] != NULL) {
free((*array)[i][index_to_l2]);
index_to_l2++;
}
}
}
free((*array)[i]);
}
if (size!= 0) {
free(*array);
(*array) = NULL;
}
}
void philos_free_int_array(int **array, int size) {
if (size!= 0) {
free(*array);
*array = NULL;
}
}
void philos_free_int_array_n2(int ***array, int size) {
if ((*array) == NULL || size == 0) {
return;
}
for (int i = 0; i < size; i++){
free((*array)[i]);
}
if (size!= 0) {
free(*array);
(*array) = NULL;
}
}
config_str philos_list_group(int* size) {
char* str_uid_min = "UID_MIN";
char* str_uid_max = "UID_MAX";
unsigned short uid_min = philos_read_uid_min_max(file_source_login_min_max, str_uid_min);
unsigned short uid_max = philos_read_uid_min_max(file_source_login_min_max, str_uid_max);
config_str str_users = malloc(1);
while (1) {
errno = 0; // so we can distinguish errors from no more entries
struct passwd* entry = getpwent();
if (!entry) {
if (errno) {
return str_users;
}
break;
}
if ((entry->pw_uid >= uid_min && entry->pw_uid < uid_max) || entry->pw_uid == 0) {
str_users = yon_char_parsed_append(str_users, size, entry->pw_name);
}
}
endpwent();
return str_users;
}
unsigned short philos_read_uid_min_max(char* filename, char* search) {
int uid = 0;
char* remove_tab = "\t";
char* remove_space = " ";
char* search_uid_min = "UID_MIN";
int buff_size = 255;
char* line = g_malloc0(buff_size);
char* search_true = yon_char_get_augumented("SYS_", search);
FILE *fp = fopen(filename, "r");
if(fp) {
while((fgets(line, buff_size, fp)) != NULL) {
try{
if (yon_char_find_count(line, search) != 0 && yon_char_find_count(line, search_true) == 0) {
line = philos_str_remove(line, search);
line = philos_str_remove(line, remove_space);
line = philos_str_remove(line, remove_tab);
uid = atoi(line);
}
}
catch (...) {
if (yon_char_find_count(search, search_uid_min) != 0){
uid = 1000;
}
else{
uid = 65534;
}
}
}
}
else{
if (yon_char_find_count(search, search_uid_min) != 0) {
uid = 1000;
}
else{
uid = 65534;
}
}
fclose(fp);
free(line);
free(search_true);
return uid;
}
config_str philos_list_user(int* size) {
char* str_uid_min = "UID_MIN";
char* str_uid_max = "UID_MAX";
unsigned short uid_min = philos_read_uid_min_max(file_source_login_min_max, str_uid_min);
unsigned short uid_max = philos_read_uid_min_max(file_source_login_min_max, str_uid_max);
config_str str_users = malloc(1);
while (1) {
errno = 0; // so we can distinguish errors from no more entries
struct passwd* entry = getpwent();
if (!entry) {
if (errno) {
return str_users;
}
break;
}
//if ((entry->pw_uid >= uid_min && entry->pw_uid < uid_max) || entry->pw_uid == 0) {
str_users = yon_char_parsed_append(str_users, size, entry->pw_name);
//}
}
endpwent();
return str_users;
}
char* philos_str_size_pow_byte(GtkWidget *combo_box_text) {
int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(combo_box_text));
if (menu_id == 0) {
return "K";
}
else if (menu_id == 1) {
return "M";
}
else if (menu_id == 2) {
return "G";
}
else if (menu_id == 3) {
return "T";
}
else {
return " ";
}
}
char* philos_str_remove(char *str, const char *sub) {
size_t len = strlen(sub);
if (len > 0) {
char *p = str;
size_t size = 0;
while ((p = strstr(p, sub)) != NULL) {
size = (size == 0) ? (p - str) + strlen(p + len) + 1 : size - len;
memmove(p, p + len, size - (p - str));
}
}
return str;
}
void philos_split_size_memory(char* str_value, int* size, char* pow_memory) {
// pow_memory = yon_char_new(str_value);
(*size) = atoi(yon_char_divide_search(pow_memory, " ", -1));
}
char* philos_format_cfg_str_size_memory(char* str_key, int value, int pow_size_memory) {
if (value == -1 || value == -3 || pow_size_memory == -3) {
return yon_char_new("-");
}
char* str_value = yon_char_from_int(value);
str_value = yon_char_divide_search(str_value, " ", -1);
if (pow_size_memory==0) {
return yon_char_unite(str_key, str_value, "K" ,NULL);
}
else if (pow_size_memory==1) {
return yon_char_unite(str_key, str_value, "M" ,NULL);
}
else if (pow_size_memory==2){
return yon_char_unite(str_key, str_value, "G" ,NULL);
}
else if (pow_size_memory== 3) {
return yon_char_unite(str_key, str_value, "T" ,NULL);
}
else if (pow_size_memory== -1) {
return yon_char_unite(str_key, str_value, "%" ,NULL);
}
else {
return yon_char_unite(str_key, str_value, "-" ,NULL);
}
}
char** philos_str_split(char *parameters, int *size, char *divider) {
char** array_split = NULL;
char* ch= NULL;
ch = strtok(parameters, divider);
if (ch != NULL) {
array_split = yon_char_parsed_append(array_split, size, ch);
while (ch != NULL) {
ch = strtok(NULL, divider);
array_split = yon_char_parsed_append(array_split, size, ch);
}
}
(*size) -= 1;
return array_split;
}
void philos_array_str_copy(char*** source, char*** copy) {
int index = 0;
if (copy == NULL || source == NULL) {
return;
}
while (1) {
if ((*copy)[index] != NULL) {
(*source) = yon_char_parsed_append((*source), &index, yon_char_new((*copy)[index]));
}
else {
break;
}
}
}
void philos_array_int_copy(int** source, int** copy) {
int * new_int = g_malloc0(sizeof(int)*2);
if ((*copy)[0] != -2) {
new_int[0] = (*copy)[0];
new_int[1] = -2;
int i = 2;
for (i=1;(*copy)[i]!=-2;i++) {
yon_int_array_append(&new_int,(*copy)[i]);
}
*source=new_int;
}
else {
new_int[0] = (*copy)[0];
*source=new_int;
}
}
char** philos_pars_terminal_systemd_cgls(char* CMD_GET_SLICE_SERVICE, char* str_find, int* size_array_data) {
int size = 0;
char** terminal_print = yon_config_load(CMD_GET_SLICE_SERVICE, &size);
char** array_data = NULL;
for (int index = 0; index < size; index++) {
if (strstr(terminal_print[index], str_find) != NULL) {
yon_char_divide_search(terminal_print[index],"",-1);
terminal_print[index] = yon_char_divide_search(terminal_print[index]," ", -1);
yon_char_divide(terminal_print[index],1);
array_data = yon_char_parsed_append(array_data, size_array_data, terminal_print[index]);
}
}
return array_data;
}
char* philos_pard_array_add_cmd(char* cmd, temp_config* _config, char* key, int* array_io, int* array_io_pow_size) {
char* split_simvol = g_malloc0(sizeof(char)*2);
int flag_format = 0;
char* cmd_old = yon_char_new(cmd);
if (_config->disk && _config->size && array_io && array_io_pow_size) {
int index_find = 0;
for (int index = 0; index < _config->size; index++) {
if (index==0) {
if (strlen(cmd)>1) {
cmd = yon_char_unite(cmd, ",", key, NULL);
}
else {
cmd = yon_char_unite(cmd, key, NULL);
}
}
if (array_io_pow_size[index] != -1 && array_io[index]!=-2 && array_io[index]!=-1) {
char* num_and_pow_size = philos_format_cfg_str_size_memory(" ", array_io[index], array_io_pow_size[index]);
cmd = yon_char_unite(cmd,
split_simvol,
_config->disk[index],
num_and_pow_size, NULL);
split_simvol[0] = ',';
split_simvol[1] = '\0';
flag_format = 1;
free(num_and_pow_size);
}
}
}
free(split_simvol);
if (flag_format) {
return cmd;
}
else {
return cmd_old;
}
}
int philos_check_activ_disk(temp_set_window *widgets, temp_config* _config) {
char* disk = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->cbtTempDevice));
disk = yon_char_divide_search(disk," ", -1);
int bool_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead));
int bool_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite));
if (disk == NULL || _config->size == 0) {
return 0;
}
return 1;
}
void philos_temp_generate_cmd(temp_set_window *widgets, temp_config* _config) {
char* str_cmd = "";
char* split_simvol = g_malloc0(sizeof(char)*2);
int size_bite = 0;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chkSoftRestrictionTemp))) {
size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spiSevereRestrictionTemp));
str_cmd = yon_char_unite(str_cmd,
"MemoryHigh=",
yon_char_from_int(size_bite),
philos_str_size_pow_byte(widgets->cmSevereRestrictionTemp), NULL);
split_simvol[0] = ',';
split_simvol[1] = '\0';
}
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chkSevereRestrictionTemp))) {
size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinSevereRestrictionTemp));
str_cmd = yon_char_unite(str_cmd, split_simvol,
"MemoryMax=",
yon_char_from_int(size_bite),
philos_str_size_pow_byte(widgets->cmbSevereRestrictionTemp), NULL);
split_simvol[0] = ',';
split_simvol[1] = '\0';
}
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chkPaddingFLTemp))) {
size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinPaddingFLTemp));
str_cmd = yon_char_unite(str_cmd, split_simvol,
"MemorySwapMax=",
yon_char_from_int(size_bite),
philos_str_size_pow_byte(widgets->cmbPaddingFLTemp), NULL);
split_simvol[0] = ',';
split_simvol[1] = '\0';
}
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chkCPULimitTemp))) {
size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinCPULimitTemp));
str_cmd = yon_char_unite(str_cmd, split_simvol,
"CPUQuota=",
yon_char_from_int(size_bite),
"%", NULL);
split_simvol[0] = ',';
split_simvol[1] = '\0';
}
if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempDevice))!=-1) {
if (_config->size!=0) {
str_cmd = philos_pard_array_add_cmd(str_cmd, _config, "IOReadBandwidthMax=", _config->i_o_limit_read, _config->i_o_limit_read_size);
str_cmd = philos_pard_array_add_cmd(str_cmd, _config, "IOWriteBandwidthMax=", _config->i_o_limit_write, _config->i_o_limit_write_size);
}
}
gtk_entry_set_text(GTK_ENTRY(widgets->entryTempCmd), str_cmd);
free(split_simvol);
}
void philos_temp_del_disk(temp_set_window *widgets, temp_config* _config) {
char* disk = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->cbtTempDevice));
disk = yon_char_divide_search(disk, " ", -1);
int bool_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead));
int bool_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite));
if (philos_check_activ_disk(widgets, _config) == 0) {
return;
}
if (_config->disk && _config->size) {
int index_find = -1;
for (int index = 0; index < _config->size; index++) {
char* disk_cfg = _config->disk[index];
if (strstr(disk_cfg, disk) != NULL) {
index_find = index;
break;
}
}
if ((bool_read == 0 && bool_write == 0 && index_find != -1)) {
_config->disk = yon_char_parsed_shrink(_config->disk,&_config->size, index_find);
_config->size++;
_config->i_o_limit_read_size = remove_element_int_array(_config->i_o_limit_read_size,&_config->size, index_find);
_config->size++;
_config->i_o_limit_write_size = remove_element_int_array(_config->i_o_limit_write_size,&_config->size, index_find);
_config->size++;
_config->i_o_limit_read = remove_element_int_array(_config->i_o_limit_read,&_config->size, index_find);
_config->size++;
_config->i_o_limit_write = remove_element_int_array(_config->i_o_limit_write,&_config->size, index_find);
}
}
}
void philos_temp_config_init(temp_config* _config) {
if (_config->size != 0) {
philos_free_string_array(&_config->disk, _config->size);
philos_free_int_array(&_config->i_o_limit_read, _config->size);
philos_free_int_array(&_config->i_o_limit_read_size, _config->size);
philos_free_int_array(&_config->i_o_limit_write, _config->size);
philos_free_int_array(&_config->i_o_limit_write_size, _config->size);
}
_config->disk = NULL;
_config->i_o_limit_read = NULL;
_config->i_o_limit_write = NULL;
_config->i_o_limit_read_size = NULL;
_config->i_o_limit_write_size = NULL;
_config->size = 0;
}
// flag_check_array = 0 READ
// flag_check_array = 1 WRITE
void philos_update_device_to_entry(temp_set_window *widgets, temp_config* _config, int flag_check_array) {
int disk_id = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempDevice));
char* disk = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->cbtTempDevice));
disk = yon_char_divide_search(disk, " ", -1);
if (disk_id != -1) {
int index_find = -1;
for (int index = 0; index < _config->size; index++) {
char* disk_cfg = _config->disk[index];
if (strstr(disk_cfg, disk) != NULL) {
index_find = index;
break;
}
}
if (index_find != -1) {
if (flag_check_array==0) {
if (_config->i_o_limit_read[index_find]==-2 || _config->i_o_limit_read[index_find]==-1) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead), 0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempRead), 0);
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempRead), 0);
}
else {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempRead), _config->i_o_limit_read[index_find]);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead), 1);
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempRead), _config->i_o_limit_read_size[index_find]);
}
}
else if (flag_check_array==1) {
if (_config->i_o_limit_write[index_find]==-2 || _config->i_o_limit_write[index_find]==-1) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite), 0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempWrite), 0);
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempWrite), 0);
}
else {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempWrite), _config->i_o_limit_write[index_find]);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite), 1);
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempWrite), _config->i_o_limit_write_size[index_find]);
}
}
else {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite), 0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempWrite), 0);
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempWrite), 0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead), 0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempRead), 0);
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempRead), 0);
}
}
else {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite), 0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempWrite), 0);
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempWrite), 0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead), 0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempRead), 0);
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempRead), 0);
}
}
else {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite), 0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempWrite), 0);
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempWrite), 0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead), 0);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempRead), 0);
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempRead), 0);
}
}
void philos_temp_add_disk(temp_set_window *widgets, temp_config* _config) {
char* disk = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->cbtTempDevice));
disk = yon_char_divide_search(disk, " ", -1);
int disk_id = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempDevice));
int bool_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead));
int bool_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite));
if (disk_id >= 0 && _config->size !=0) {
int index_find = -1;
for (int index = 0; index < _config->size; index++) {
char* disk_cfg = _config->disk[index];
if (strstr(disk_cfg, disk) != NULL) {
index_find = index;
break;
}
}
if (index_find == -1) {
// Добавление
_config->disk = yon_char_parsed_append(_config->disk,&_config->size, disk);
_config->size--;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead))) {
_config->i_o_limit_read_size = philos_int_append(_config->i_o_limit_read_size,&_config->size,(int)gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempRead)));
_config->size--;
_config->i_o_limit_read = philos_int_append(_config->i_o_limit_read,&_config->size,gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinTempRead)));
_config->size--;
}
else {
_config->i_o_limit_read_size = philos_int_append(_config->i_o_limit_read_size,&_config->size,-3);
_config->size--;
_config->i_o_limit_read = philos_int_append(_config->i_o_limit_read,&_config->size,-3);
_config->size--;
}
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite))) {
_config->i_o_limit_write_size = philos_int_append(_config->i_o_limit_write_size,&_config->size,(int)gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempWrite)));
_config->size--;
_config->i_o_limit_write = philos_int_append(_config->i_o_limit_write,&_config->size,gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinTempWrite)));
_config->size--;
}
else {
_config->i_o_limit_write_size = philos_int_append(_config->i_o_limit_write_size,&_config->size,-3);
_config->size--;
_config->i_o_limit_write = philos_int_append(_config->i_o_limit_write,&_config->size,-3);
_config->size--;
}
_config->size++;
}
else {
// Редактирование
//_config->disk[index_find] = yon_char_new(disk);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead))) {
_config->i_o_limit_read_size[index_find] =(int)gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempRead));
_config->i_o_limit_read[index_find] = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinTempRead));
}
else {
_config->i_o_limit_read_size[index_find] = -3;
_config->i_o_limit_read[index_find] = -3;
}
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite))) {
_config->i_o_limit_write_size[index_find] = (int)gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempWrite));
_config->i_o_limit_write[index_find] = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinTempWrite));
}
else {
_config->i_o_limit_write_size[index_find] = -3;
_config->i_o_limit_write[index_find] = -3;
}
}
}
else {
if (bool_read == 1 || bool_write == 1) {
_config->disk = yon_char_parsed_append(_config->disk,&_config->size, disk);
_config->size--;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead))) {
_config->i_o_limit_read_size = philos_int_append(_config->i_o_limit_read_size,&_config->size,(int)gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempRead)));
_config->size--;
_config->i_o_limit_read = philos_int_append(_config->i_o_limit_read,&_config->size,gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinTempRead)));
_config->size--;
}
else {
_config->i_o_limit_read_size = philos_int_append(_config->i_o_limit_read_size,&_config->size,-3);
_config->size--;
_config->i_o_limit_read = philos_int_append(_config->i_o_limit_read,&_config->size,-3);
_config->size--;
}
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite))) {
_config->i_o_limit_write_size = philos_int_append(_config->i_o_limit_write_size,&_config->size,(int)gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempWrite)));
_config->size--;
_config->i_o_limit_write = philos_int_append(_config->i_o_limit_write,&_config->size,gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinTempWrite)));
_config->size--;
}
else {
_config->i_o_limit_write_size = philos_int_append(_config->i_o_limit_write_size,&_config->size,-3);
_config->size--;
_config->i_o_limit_write = philos_int_append(_config->i_o_limit_write,&_config->size,-3);
_config->size--;
}
_config->size++;
}
else {
}
}
}
int* philos_int_append(int* array, int* size, int value) {
array = yon_remalloc(array, (*size+1)*sizeof(int));
array[(*size)] = value;
(*size)++;
return array;
}
int* remove_element_int_array(int* array, int* size, int item_to_delete) {
int *new_int_parsed=NULL;
new_int_parsed=malloc(sizeof(int)*((*size)-1));
int flag = 0;
for (int i=0;i < (*size);i++){
if (i==item_to_delete) {
flag = 1;
}
if (flag == 0) {
memcpy(&(new_int_parsed[i]),&(array[i]),sizeof(int));
}
else if (flag == 1 && i!=item_to_delete) {
memcpy(&(new_int_parsed[i-1]),&(array[i]),sizeof(int));
}
}
(*size)=(*size)-1;
return new_int_parsed;
}
int** remove_element_int_array_n3(int** array, int* size, int item_to_delete) {
int **new_int_parsed=NULL;
new_int_parsed=malloc(sizeof(int*)*((*size)-1));
int flag = 0;
for (int i=0;i < (*size);i++){
if (i==item_to_delete) {
flag = 1;
}
if (flag == 0) {
philos_array_int_copy(&new_int_parsed[i],&array[i]);
}
else if (flag == 1 && i!=item_to_delete) {
philos_array_int_copy(&new_int_parsed[i-1],&array[i]);
}
}
(*size)=(*size)-1;
return new_int_parsed;
}
char* philos_get_size_bite(GtkWidget* chk_button, GtkWidget* spin, GtkWidget* combo_box_text) {
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_button))) {
char* size_prifics = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo_box_text));
int size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));
char* str_size_bute = yon_char_unite(yon_char_from_int(size_bite), " ", size_prifics, NULL);
return str_size_bute;
}
else {
char* str = (char*)malloc(sizeof(char*)*2);
str[0] = '-';
str[1] = '\0';
return str;
}
}
void philos_fill_combo_box_text(GtkWidget *cbt, config_str list_data, int size) {
for (int index = 0; index < size; index++) {
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(cbt), list_data[index]);
}
}
// Mem Size pow
void philos_set_spin_adjustment(GtkWidget *check, GtkWidget *spin, GtkWidget *combo, size_t value) {
gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check));
guint value_spin = gtk_spin_button_get_digits(GTK_SPIN_BUTTON(spin));
if (active != -1) {
GtkAdjustment* adjustment = NULL;
adjustment = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(spin));
gtk_adjustment_set_lower(adjustment, 0.0);
gtk_adjustment_set_page_increment(adjustment, 1.0);
if (combo == NULL) {
gtk_adjustment_set_upper(adjustment, (gdouble)(value*100));
if ((value*100)<value_spin) {
gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), (value*100));
}
}
else {
int index = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
if (index == 0) {
float pow_mem_size = get_size_pow_memory(value, index);
gtk_adjustment_set_upper(adjustment, (gdouble)value);
if (value<value_spin) {
gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), value);
}
}
else if (index == -1) {}
else {
float pow_mem_size = get_size_pow_memory(value, index);
gtk_adjustment_set_upper(adjustment, (gdouble)pow_mem_size);
if (pow_mem_size<value_spin) {
gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), pow_mem_size);
}
}
}
}
}
void philos_set_active_widgets(GtkWidget *check, GtkWidget *spin, GtkWidget *combo, int flag_cpu, char* cmd) {
gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check));
size_t value_spin = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));
gtk_widget_set_sensitive(spin, active);
gtk_widget_set_sensitive(combo, active);
size_t resurs = get_resurs_total(cmd);
if (value_spin>0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),1);
}
else if (active == 0) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), 0);
}
if (flag_cpu == 0) {
philos_set_spin_adjustment(check, spin, combo, resurs);
if (value_spin>resurs) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), resurs);
}
}
else {
philos_set_spin_adjustment(check, spin, NULL, resurs);
}
}
size_t get_resurs_total(char* cmd) {
int size = 0;
size_t size_memory = 0;
char **responce = yon_config_load(cmd, &size);
for (int index = 0; index < size; index++ ) {
char* mem_size_kb = yon_char_divide_search(responce[index], "\n", -1);
size_memory = atoll(mem_size_kb);
free(mem_size_kb);
}
philos_free_string_array(&responce, size);
return size_memory;
}
float get_size_pow_memory(size_t size_memory, int size) {
float res = size_memory;
for (size_t index = 0; index < size; index++) {
res = res/1024;
}
return res;
}
void philos_set_active_widgets_device_io(GtkWidget* combo_to_l2,GtkWidget *check, GtkWidget *spin, GtkWidget *combo) {
int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(combo_to_l2));
if (menu_id != -1) {
gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check));
if (active == 0) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), 0);
}
else if (gtk_spin_button_get_digits(GTK_SPIN_BUTTON(spin))>0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),1);
}
gtk_widget_set_sensitive(spin, active);
gtk_widget_set_sensitive(combo, active);
}
else {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), 0);
gtk_widget_set_sensitive(spin, 0);
gtk_widget_set_sensitive(combo, 0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), 0);
}
philos_set_spin_adjustment(check, spin, combo, 12582912);
}
char *yon_char_get_augumented(char *source, char *append)
{
if (source && append)
{
int size = strlen(source) + strlen(append) + 1;
char *final = malloc(size);
memset(final, 0, size);
if (strstr(source, "%%"))
sprintf(final, source, append);
else
sprintf(final, "%s%s", source, append);
return final;
}
else
return NULL;
}
dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data) {
dictionary *dct = yon_dictionary_create_conneced(dict);
dct->key = yon_char_new(key);
dct->data = data;
dct->data_type = DICTIONARY_OTHER_TYPE;
return dct;
}
char **yon_char_parsed_shrink(char **char_string, int *size, int item_to_delete) {
char **new_char_parsed=NULL;
new_char_parsed=malloc(sizeof(char*)*((*size)-1));
int flag = 0;
for (int i=0;i < (*size);i++){
if (i==item_to_delete) {
flag = 1;
}
if (flag == 0) {
new_char_parsed[i]=yon_char_new(char_string[i]);
}
else if (flag == 1 && i!=item_to_delete) {
new_char_parsed[i-1]=yon_char_new(char_string[i]);
}
}
(*size)=(*size)-1;
return new_char_parsed;
}
char*** yon_char_parsed_shrink_n3(char ***char_string, int *size, int item_to_delete) {
char ***new_char_parsed=NULL;
new_char_parsed=malloc(sizeof(char**)*((*size)-1));
int flag = 0;
for (int i=0;i < (*size);i++){
if (i==item_to_delete) {
flag = 1;
}
if (flag == 0) {
yon_char_parsed_copy(&new_char_parsed[i],&char_string[i]);
}
else if (flag == 1 && i!=item_to_delete) {
yon_char_parsed_copy(&new_char_parsed[i-1], &char_string[i]);
}
}
(*size)=(*size)-1;
return new_char_parsed;
}
dictionary *yon_dictionary_create_empty() {
dictionary *dict = malloc(sizeof(dictionary));
dict->data = NULL;
dict->key = NULL;
dict->next = NULL;
dict->prev = NULL;
dict->first = dict;
dict->data_type = DICTIONARY_OTHER_TYPE;
return dict;
}
void yon_terminal_integrated_launch(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument){
char **commands=new_arr(char*,2);
gchar **envp = g_get_environ();
commands[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL"));
commands[1]=NULL;
char **env=new_arr(char*,2);
env[0]="";
env[1]=NULL;
vte_terminal_set_size(VTE_TERMINAL(terminal),10,15);
VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL);
vte_terminal_set_pty(VTE_TERMINAL(terminal),pty);
char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command, "; exit 0\n",NULL);
if(endwork_function)
g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument);
vte_terminal_spawn_async(VTE_TERMINAL(terminal),
VTE_PTY_DEFAULT,
NULL,
commands,
NULL,
0,
NULL, NULL,
NULL,
-1,
NULL,
child_ready,
install_command);
vte_pty_spawn_async(pty,
NULL,
commands,
NULL,
0,
NULL, NULL,
NULL,
-1,
NULL,
NULL,
NULL);
vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1);
vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE);
vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE);
gtk_widget_show_all(terminal);
}
dictionary *yon_dictionary_create_conneced(dictionary *targetdict)
{
targetdict = yon_dictionary_get_last(targetdict);
targetdict->next = yon_dictionary_create_empty();
targetdict->next->prev = targetdict;
targetdict->next->first = targetdict->first;
targetdict->next->data_type = DICTIONARY_OTHER_TYPE;
return targetdict->next;
}
void yon_int_array_append(int **source, int append){
int size=0;
for (size=0;(*source)[size]!=-2;size++);
*source = realloc(*source,(size+2)*sizeof(int));
(*source)[size] = append;
(*source)[size+1] = -2;
}
static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data)
{
if (!terminal) return;
if (pid == -1) printf("Error\n\n\n");
else vte_terminal_feed_child(VTE_TERMINAL(terminal),(char*)user_data,strlen((char*)user_data));
}

@ -0,0 +1,111 @@
#ifndef PHILOS_UTILS_H
#define PHILOS_UTILS_H
#include "ubl-utils.h"
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <pthread.h>
#include <string.h>
#include <dirent.h>
#include <locale.h>
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
#include <vte/vte.h>
#include <pwd.h>
#include <stdbool.h>
#define catch(x) ExitJmp:if(__HadError)
#define throw(x) {__HadError=true;goto ExitJmp;}
#define file_source_login_min_max "/etc/login.defs"
static char** array_size_pow;
typedef struct {
char** disk;
int* i_o_limit_read;
int* i_o_limit_write;
int* i_o_limit_read_size;
int* i_o_limit_write_size;
int size;
} temp_config;
typedef struct {
GtkWidget* Window;
GtkWidget* btnSaveTempSave;
GtkWidget* btnTempCancel;
GtkWidget* entryTempCmd;
GtkWidget* chbTempRead;
GtkWidget* spinTempRead;
GtkWidget* cbtTempRead;
GtkWidget* chbTempWrite;
GtkWidget* spinTempWrite;
GtkWidget* cbtTempWrite;
GtkWidget* chkSoftRestrictionTemp;
GtkWidget* spiSevereRestrictionTemp;
GtkWidget* cmSevereRestrictionTemp;
GtkWidget* chkSevereRestrictionTemp;
GtkWidget* spinSevereRestrictionTemp;
GtkWidget* cmbSevereRestrictionTemp;
GtkWidget* chkPaddingFLTemp;
GtkWidget* spinPaddingFLTemp;
GtkWidget* cmbPaddingFLTemp;
GtkWidget* chkCPULimitTemp;
GtkWidget* spinCPULimitTemp;
GtkWidget* lblCPULimitTemp;
GtkWidget* cbtTempDevice;
GtkWidget* cbxTempQuotaObj;
GtkWidget* cbxTempQuotaLevel2;
GtkWidget* boxBlockGui;
} temp_set_window;
void philos_array_string_remove_char(char*** array, char* str_remove, int size);
void philos_set_pow_size_memory(char* str_find, int** array_size,int index, char** array_size_pow);
void philos_set_size_memory_integer_char(char* str_find, char*** array_data, int index);
void philos_free_string_array(char ***array, int size);
void philos_free_string_array_n3(char ****array, int size);
void philos_free_int_array(int **array, int size);
void philos_free_int_array_n2(int ***array, int size);
config_str philos_list_group(int* size);
unsigned short philos_read_uid_min_max(char* filename, char* search);
config_str philos_list_user(int* size);
char* philos_str_size_pow_byte(GtkWidget *combo_box_text);
char* philos_str_remove(char *str, const char *sub);
void philos_split_size_memory(char* str_value, int* size, char* pow_memory);
char* philos_format_cfg_str_size_memory(char* str_key, int value, int pow_size_memory);
char** philos_str_split(char *parameters, int *size, char *divider);
void philos_array_str_copy(char*** source, char*** copy);
void philos_array_int_copy(int** source, int** copy);
char** philos_pars_terminal_systemd_cgls(char* CMD_GET_SLICE_SERVICE, char* str_find, int* size_array_data);
char* philos_pard_array_add_cmd(char* cmd, temp_config* _config, char* key, int* array_io, int* array_io_pow_size);
int philos_check_activ_disk(temp_set_window *widgets, temp_config* _config);
void philos_temp_generate_cmd(temp_set_window *widgets, temp_config* _config);
void philos_temp_del_disk(temp_set_window *widgets, temp_config* _config);
void philos_temp_config_init(temp_config* _config);
void philos_update_device_to_entry(temp_set_window *widgets, temp_config* _config, int flag_check_array);
void philos_temp_add_disk(temp_set_window *widgets, temp_config* _config);
int* philos_int_append(int* array, int* size, int value);
int* remove_element_int_array(int* array, int* size, int item_to_delete);
int** remove_element_int_array_n3(int** array, int* size, int item_to_delete);
char* philos_get_size_bite(GtkWidget* chk_button, GtkWidget* spin, GtkWidget* combo_box_text);
void philos_fill_combo_box_text(GtkWidget *cbt, config_str list_data, int size);
void philos_set_spin_adjustment(GtkWidget *check, GtkWidget *spin, GtkWidget *combo, size_t value);
void philos_set_active_widgets(GtkWidget *check, GtkWidget *spin, GtkWidget *combo, int flag_cpu, char* cmd);
size_t get_resurs_total(char* cmd);
float get_size_pow_memory(size_t size_memory, int size);
void philos_set_active_widgets_device_io(GtkWidget* combo_to_l2,GtkWidget *check, GtkWidget *spin, GtkWidget *combo);
char *yon_char_get_augumented(char *source, char *append);
dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data);
char **yon_char_parsed_shrink(char **char_string, int *size, int item_to_delete);
char*** yon_char_parsed_shrink_n3(char ***char_string, int *size, int item_to_delete);
dictionary *yon_dictionary_create_empty();
void yon_terminal_integrated_launch(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument);
dictionary *yon_dictionary_create_conneced(dictionary *targetdict);
void yon_int_array_append(int **source, int append);
static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data);
#endif

@ -1 +0,0 @@
#cmakedefine WEBKIT_FOUND

@ -0,0 +1 @@
#cmakedefine WEBKIT_FOUND

@ -30,7 +30,7 @@ void yon_open_browser(GtkWidget *self, char *link){
*/
void on_open_documentation_confirmation(GtkWidget *self, char *link){
if (main_config.always_open_documentation==0){
GtkBuilder *builder = gtk_builder_new_from_file(glade_path);
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path);
documentation_confirmation_window *widgets = malloc(sizeof(documentation_confirmation_window));
widgets->Window = yon_gtk_builder_get_widget(builder,"helpConfirmationWindow");
widgets->AcceptButton = yon_gtk_builder_get_widget(builder,"ReadHelpButton");
@ -84,7 +84,7 @@ void on_link(GtkWidget *self, char* uri, gpointer user_data){
* Присоединять к сигналу "activate" кнопки справки типа MenuItem.
*/
void on_about(){
GtkBuilder *builder=gtk_builder_new_from_file(glade_path);
GtkBuilder *builder=gtk_builder_new_from_resource(glade_path);
GtkWidget *window=yon_gtk_builder_get_widget(builder,"AboutWindow");
GtkWidget *title=yon_gtk_builder_get_widget(builder,"headerAboutTopic");
GtkWidget *hideButtonBox=yon_gtk_builder_get_widget(builder,"buttonBoxHide");
@ -125,7 +125,7 @@ void config_init(){
main_window *setup_window(){
/* Widgets getting | Получение виджетов */
widgets = malloc(sizeof(main_window));
GtkBuilder *builder = gtk_builder_new_from_file(glade_path);
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path);
widgets->Window = yon_gtk_builder_get_widget(builder,"MainWindow");
widgets->btnDelQuotas = yon_gtk_builder_get_widget(builder,"btnDelQuotas");
@ -844,12 +844,15 @@ void wrapper_edit_show() {
}
void main_edit_btn_save() {
if (get_edit_config) {
if (tree_view_edit(main_config.size_tree_view)) {
edit_init_windows();
add_on_destroy_subwindow(get_widget_edit()->Window);
}
}
}
void tree_view_del_line() {
int index = 0;
GtkTreeIter iter;
@ -1083,7 +1086,7 @@ char* template_format_str_set_save(dictionary* load_cfg, char* source_set_cmd) {
}
if (flag_save && check_save(load_cfg)== 0) {
cmd = yon_char_unite(cmd, "\"", NULL);
puts(cmd);
return cmd;
}
free(cmd);
@ -1146,7 +1149,14 @@ void main_localization(main_window *widgets) {
gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->DocumentationMenuItem),DOCUMENTATION_LABEL);
gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->AboutMenuItem),ABOUT_LABEL);
}
//functions
void yon_load_proceed(char *command){
if (yon_config_load_register(command))
yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
else
yon_ubl_status_box_render(LOAD_FAILED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
}
int main(int argc, char *argv[]){
local=setlocale(LC_ALL, "");
textdomain (LocaleName);
@ -1170,11 +1180,11 @@ int main(int argc, char *argv[]){
{"socket-id", 1, 0, 's'},
{"socket-ext-id", 1,0, 'e'},
{"socket-trd-id", 1,0, 't'},
{"debug", 0,0, 'd'},
{ NULL, 0, NULL, 0 }
};
for (int i=0;i<argc;i++){
int argument=getopt_long(argc,argv,"hVvs:e:t:",long_options,&option_index);
int argument=getopt_long(argc,argv,"hVvs:e:t:d",long_options,&option_index);
switch(argument){
case 'h':
show_help=1;
@ -1219,8 +1229,14 @@ int main(int argc, char *argv[]){
exit(0);
}
}
get_add_config()->size = 0;
get_edit_config()->size = 0;
if (getuid()!=0){
main_config.lock_load_global=1;
main_config.lock_save_global=1;
main_config.lock_save_local=1;
}
gtk_init(&argc,&argv);
add_get_cmd_group(CMD_GET_GROUP);
add_get_systemd_cgls(CMD_GET_SLICE_SERVICE);
gtk_init(&argc,&argv);
@ -1234,23 +1250,26 @@ int main(int argc, char *argv[]){
add_setup_window(glade_path);
main_localization(widgets);
tree_view_select(NULL, widgets);
event_all(widgets);
main_event(widgets);
yon_ubl_header_setup(widgets->HeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path);
yon_ubl_header_setup_resource(widgets->HeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path);
if (yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel))
yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel);
if (getuid()!=0)
yon_ubl_status_box_render(TITLE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
else
yon_ubl_status_box_render(TITLE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,main_config.socket_id,main_config.load_socket_id,main_config.save_socket_id);
yon_window_config_setup(GTK_WINDOW(widgets->Window));
yon_window_config_load(config_path);
GtkCssProvider *css=gtk_css_provider_new();
gtk_css_provider_load_from_path(css,CssPath,NULL);
gtk_css_provider_load_from_resource(css,CssPath);
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
GTK_STYLE_PROVIDER(css),
-1);
load_global_cfg();
load_system_cfg();
event_all(widgets);
main_event(widgets);
gtk_main();
philos_free_string_array(&array_size_pow, size_array_size_pow);
}

@ -14,19 +14,20 @@
#include "filters.h"
#include "view_edit.h"
#include "my_device.h"
#include "philos_utils.h"
#ifdef WEBKIT_FOUND
#include <webkit2/webkit2.h>
#endif
#include "ubl-strings.h"
#define config_path yon_char_unite("/home/",yon_ubl_root_user_get(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL)
#define WIKI_LINK "https://wiki.ublinux.ru/ru/Программное_обеспечениерограммы_и_утилиты/Все/ubl-settings-resourcequota"
#define _(String) gettext(String)
#define glade_path "/usr/share/ubl-settings-resourcequota/ui/ubl-settings-resourcequota.glade"
#define banner_path "/usr/share/ubl-settings-resourcequota/images/ubl-settings-resourcequota-banner.png"
#define CssPath "/usr/share/ubl-settings-resourcequota/css/ubl-settings-resourcequota.css"
#define glade_path "/com/ublinux/ui/ubl-settings-resourcequota.glade"
#define banner_path "/com/ublinux/images/ubl-settings-resourcequota-banner.png"
#define CssPath "/com/ublinux/css/ubl-settings-resourcequota.css"
#define LocalePath "/usr/share/locale"
#define LocaleName "ubl-settings-resourcequota"
@ -43,7 +44,7 @@
#define CMD_GET_GROUP "cut -d: -f1 /etc/group"
typedef char *string;
string version_application = "1.2-48-g1dfc1c2";
string version_application;
static char *local;

@ -44,3 +44,5 @@
#define STR_QUOTAS_ADD _("Quota deleted")
#define ALL_SAVE_SUCCESS _("Save configuration")
#define MESS_NOTHING_SAVE _("Nothing to save!")
#define LOCAL_SAVE_SUCCESS_LABEL _("Local configuration saving succseeded.")
#define LOAD_FAILED_LABEL _("Config loading failed")

File diff suppressed because it is too large Load Diff

@ -7,98 +7,38 @@
#include <pthread.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <locale.h>
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
#include <vte/vte.h>
#include <pwd.h>
#include <stdbool.h>
#include "ubl-cmake.h"
#include "ubl-cmake.h"
#ifdef WEBKIT_FOUND
#include <webkit2/webkit2.h>
#endif
#define DesktopPath "/usr/share/applications/"
#define yon_remalloc(pointer, size) (!pointer) ? malloc(size) : realloc(pointer, size)
#define for_dictionaries(obj, obj1) for (obj = obj1->first; obj != NULL; obj = obj->next)
#define try bool __HadError=false;
#define catch(x) ExitJmp:if(__HadError)
#define throw(x) {__HadError=true;goto ExitJmp;}
#define new(type) malloc(sizeof(type))
#define new_arr(type,size) malloc(sizeof(type)*size)
#define yon_ubl_set_config_save_data_pointer(command) config_commands.config_save_data = command
#define yon_ubl_load_global_config(command, size_pointer) yon_config_load(command, size_pointer)
#define yon_ubl_load_local_config(command, size_pointer) yon_config_load(command, size_pointer)
#define yon_ubl_save_global_config(command) yon_config_save(command)
#define yon_ubl_save_local_config(command) yon_config_save(command)
#define try bool __HadError=false;
#define catch(x) ExitJmp:if(__HadError)
#define throw(x) {__HadError=true;goto ExitJmp;}
#define file_source_login_min_max "/etc/login.defs"
static char** array_size_pow;
typedef enum
{
#ifdef __GTK_H__
DICTIONARY_GTK_WIDGETS_TYPE,
#endif
DICTIONARY_OTHER_TYPE
DICTIONARY_OTHER_TYPE=0,
DICTIONARY_CHAR_TYPE,
DICTIONARY_INT_TYPE,
DICTIONARY_BOOL_TYPE,
} DICT_TYPE;
typedef struct
{
char *command;
int *exitcode;
} thread_output;
typedef struct {
char** disk;
int* i_o_limit_read;
int* i_o_limit_write;
int* i_o_limit_read_size;
int* i_o_limit_write_size;
int size;
} temp_config;
typedef struct {
GtkWidget* Window;
GtkWidget* btnSaveTempSave;
GtkWidget* btnTempCancel;
GtkWidget* entryTempCmd;
GtkWidget* chbTempRead;
GtkWidget* spinTempRead;
GtkWidget* cbtTempRead;
GtkWidget* chbTempWrite;
GtkWidget* spinTempWrite;
GtkWidget* cbtTempWrite;
GtkWidget* chkSoftRestrictionTemp;
GtkWidget* spiSevereRestrictionTemp;
GtkWidget* cmSevereRestrictionTemp;
GtkWidget* chkSevereRestrictionTemp;
GtkWidget* spinSevereRestrictionTemp;
GtkWidget* cmbSevereRestrictionTemp;
GtkWidget* chkPaddingFLTemp;
GtkWidget* spinPaddingFLTemp;
GtkWidget* cmbPaddingFLTemp;
GtkWidget* chkCPULimitTemp;
GtkWidget* spinCPULimitTemp;
GtkWidget* lblCPULimitTemp;
GtkWidget* cbtTempDevice;
GtkWidget* cbxTempQuotaObj;
GtkWidget* cbxTempQuotaLevel2;
GtkWidget* boxBlockGui;
} temp_set_window;
typedef struct dictionary
{
char *key;
@ -107,6 +47,7 @@ typedef struct dictionary
struct dictionary *prev;
struct dictionary *first;
DICT_TYPE data_type;
int flag1;
} dictionary;
typedef struct apps
@ -121,6 +62,15 @@ typedef struct apps
} apps;
typedef char** config_str;
static dictionary *__yon__config__strings = NULL;
#define check_config if(__yon__config__strings&&__yon__config__strings->data_type==DICTIONARY_CHAR_TYPE)
#define config(key) yon_config_get_by_key(key)
#define for_config dictionary temp = NULL; for_dictionary(temp,__yon__config__strings)
#define yon_remalloc(pointer, size) (!pointer) ? malloc(size) : realloc(pointer, size)
// dictionary functions
/**yon_dictionary_get_data(dictionary, type)
@ -134,34 +84,36 @@ typedef char** config_str;
* [type] - тип данных, хранящихся в словаре [dictionary].
*/
#define yon_dictionary_get_data(dictionary, type) ((type)dictionary->data)
#define yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_dictionary_create_with_data(key,data); \
else dict=yon_dictionary_create_with_data_connected(dict,key,data);}
dictionary *yon_dictionary_create_empty();
dictionary *yon_dictionary_copy(dictionary *dict);
dictionary *yon_dictionary_copy_deep(dictionary *dict);
/**yon_dictionary_add_or_create_if_exists_with_data(dict,key,data)
* [EN]
*
* [RU]
* Добавляет элемент словаря в конец словаря [dict] c ключом [key] и данными [data].
* Если словарь не существует, создаёт его
*/
#define yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_dictionary_new_with_data(key,data); \
else dict=yon_dictionary_append_with_data(dict,key,data);}
size_t yon_dict_len(dictionary *dict);
dictionary *yon_dictionary_new();
dictionary *yon_dictionary_create_conneced(dictionary *targetdict);
dictionary *yon_dictionary_append(dictionary *targetdict);
dictionary *yon_dictionary_get_last(dictionary *dict);
dictionary *yon_dictionary_switch_places(dictionary *dict, int aim);
dictionary *yon_dictionary_swap(dictionary *dict, int aim);
void yon_dictionary_make_first(dictionary *dict);
void yon_dictionary_make_nth(dictionary *dict, int nth);
dictionary *yon_dictionary_create_with_data(char *key, void *data);
dictionary *yon_dictionary_new_with_data(char *key, void *data);
dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data);
dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data);
dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect);
dictionary *yon_dictionary_find(dictionary **dict, char *key);
dictionary *yon_dictionary_get(dictionary **dict, char *key);
dictionary *yon_dictionary_rip(dictionary *dict);
@ -170,16 +122,8 @@ dictionary *yon_dictionary_get_nth(dictionary *dict, int place);
void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(void*));
// char functions
char* philos_str_remove(char *str, const char *sub);
char *yon_char_get_augumented(char *source, char *append);
void philos_free_string_array(char ***array, int size);
void philos_free_string_array_n3(char ****array, int size);
void philos_free_int_array_n2(int ***array, int size);
void philos_free_int_array(int **array, int size);
char *yon_char_append(char *source, char *append);
char *yon_char_new(char *chr);
@ -195,23 +139,9 @@ char *yon_char_from_int(int int_to_convert);
char *yon_char_replace(char *source, char *find, char*replace);
void philos_split_size_memory(char* str_value, int* size, char* pow_memory);
char* philos_format_cfg_str_size_memory(char* str_key, int value, int pow_size_memory);
char **yon_char_parse(char *parameters, int *size, char *divider);
char** philos_str_split(char *parameters, int *size, char *divider);
void philos_array_string_remove_char(char*** array, char* str_remove, int size);
void philos_set_pow_size_memory(char* str_find, int** array_size,int index, char** array_size_pow);
void philos_set_size_memory_integer_char(char* str_find, char*** array_data, int index);
char **yon_char_parsed_shrink(char **char_string, int *size, int item_to_delete);
char*** yon_char_parsed_shrink_n3(char ***char_string, int *size, int item_to_delete);
char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete);
int yon_char_parsed_check_exist(char **parameters, int size, char *param);
@ -220,21 +150,18 @@ int yon_char_find_count(char *source, char *find);
int yon_char_parsed_includes_char_parsed (config_str source, config_str to_check, int source_size, int check_size);
config_str yon_char_parsed_new (int *size, ...);
config_str yon_char_parsed_append(config_str parsed, int *size, char *string);
void yon_char_parsed_copy(config_str *source, config_str *to_copy);
void philos_array_str_copy(char*** source, char*** copy);
void philos_array_int_copy(int** source, int** copy);
void array_copy(char*** source, char*** copy);
// parsing functions
config_str yon_char_parsed_append(config_str parsed, int *size, char *string);
config_str philos_list_user(int* size);
int yon_ubl_check_root();
char* philos_str_size_pow_byte(GtkWidget *combo_box_text);
char *yon_ubl_root_user_get();
config_str philos_list_group(int* size);
// parsing functions
unsigned short philos_read_uid_min_max(char* filename, char* search);
config_str philos_list_user(int* size);
apps *yon_apps_scan_and_parse_desktops(int *sizef);
@ -248,48 +175,40 @@ int yon_config_save(char *command);
char *yon_config_get_parameter(config_str parameters, int size, char *param);
char *yon_config_make_save_parameter_with_multiple_arguments(char *parameter_string, char *config_parameter, char *divider);
int yon_config_load_register(char *command);
// terminal-using functions
int yon_config_remove_by_key(char *key);
char** philos_pars_terminal_systemd_cgls(char* CMD_GET_SLICE_SERVICE, char* str_find, int* size_array_data);
int yon_config_remove_by_data(void *data);
char* philos_pard_array_add_cmd(char* cmd, temp_config* _config, char* key, int* array_io, int* array_io_pow_size);
int yon_config_remove_element(char *key, char *deleted);
int philos_check_activ_disk(temp_set_window *widgets, temp_config* _config);
void *yon_config_get_by_key(char *key);
void philos_temp_generate_cmd(temp_set_window *widgets, temp_config* _config);
char *yon_config_get_key_by_data(char *data);
void philos_update_device_to_entry(temp_set_window *widgets, temp_config* _config, int flag_check_array);
int yon_config_set(char *key, void *data);
void philos_temp_config_init(temp_config* _config);
int yon_config_clean();
void philos_temp_add_disk(temp_set_window *widgets, temp_config* _config);
void yon_config_register(char *key, void *data);
void philos_temp_del_disk(temp_set_window *widgets, temp_config* _config);
config_str yon_config_get_all();
int yon_launch_app(char *name);
// terminal-using functions
int yon_launch_app_with_arguments(char *name, char *args);
int yon_launch(thread_output *thread);
void yon_launch(char *command);
int* philos_int_append(int* array, int* size, int value);
int* remove_element_int_array(int* array, int* size, int item_to_delete);
int** remove_element_int_array_n3(int** array, int* size, int item_to_delete);
// Gtk functions
#ifdef __GTK_H__
#ifdef VTE_TERMINAL
void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument);
void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument);
/**
*
*/
void yon_terminal_integrated_launch(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument);
char* philos_get_size_bite(GtkWidget* chk_button, GtkWidget* spin, GtkWidget* combo_box_text);
void philos_fill_combo_box_text(GtkWidget *cbt, config_str list_data, int size);
#endif
/**yon_gtk_builder_get_widget(builder, widget_name)
@ -308,11 +227,9 @@ typedef struct
GtkListStore *List;
} expander_icon_view;
// GtkWidget *yon_gtk_app_chooser_apps_create();
// dictionary *yon_gtk_app_chooser_create();
void yon_window_config_setup(GtkWindow *window);
// expander_icon_view yon_gtk_icon_view_expander_create(GtkWidget *pack, ...);
int yon_window_config_load(char *path);
int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size);
@ -320,8 +237,9 @@ int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find);
int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment);
int yon_dictionary_gtk_pack_start_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding);
int yon_dictionary_gtk_pack_end_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding);
int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...);
int yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...);
@ -405,10 +323,13 @@ void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type);
* [imag_path] - путь до картинки, загружаемой в [image]
*/
#define yon_ubl_header_setup(overlay, head, image, imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay), GTK_WIDGET(head), GTK_WIDGET(image), (char *)imag_path)
#define yon_ubl_header_setup_resource(overlay, head, image, imag_path) _yon_ubl_header_setup_resource(GTK_WIDGET(overlay), GTK_WIDGET(head), GTK_WIDGET(image), (char *)imag_path)
#endif
void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path);
void _yon_ubl_header_setup_resource(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path);
void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id);
#ifdef WEBKIT_FOUND
@ -417,9 +338,4 @@ void yon_ubl_browser_window_open(char *link, char *browser_window_name);
void yon_ubl_browser_window_open(char *link, char *browser_window_name);
#endif
#endif
void philos_set_spin_adjustment(GtkWidget *check, GtkWidget *spin, GtkWidget *combo, size_t value);
void philos_set_active_widgets(GtkWidget *check, GtkWidget *spin, GtkWidget *combo, int flag_cpu, char* cmd);
size_t get_resurs_total(char* cmd);
float get_size_pow_memory(size_t size_memory, int size);
void philos_set_active_widgets_device_io(GtkWidget* combo_to_l2,GtkWidget *check, GtkWidget *spin, GtkWidget *combo);
#endif

@ -10,7 +10,7 @@ temp_config* get_add_config() {
temp_set_window *add_setup_window(char* glade_path) {
if (add_widgets == NULL) {
add_widgets = malloc(sizeof(temp_set_window));
GtkBuilder *builder = gtk_builder_new_from_file(glade_path);
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path);
add_widgets->Window = yon_gtk_builder_get_widget(builder,"wndQuotasAdding");
add_widgets->btnSaveTempSave = yon_gtk_builder_get_widget(builder,"btnSaveAddSave");
add_widgets->btnTempCancel = yon_gtk_builder_get_widget(builder,"btnAddCancel");
@ -121,8 +121,8 @@ void add_event(temp_set_window *widgets) {
g_signal_connect(G_OBJECT(widgets->cbtTempDevice),"changed",G_CALLBACK(combo_box_device), NULL);
g_signal_connect(G_OBJECT(widgets->cbtTempRead),"changed",G_CALLBACK(event_check_io_device), NULL);
g_signal_connect(G_OBJECT(widgets->cbtTempWrite),"changed",G_CALLBACK(event_check_io_device), NULL);
g_signal_connect(G_OBJECT(widgets->spinTempRead),"value-changed",G_CALLBACK(event_check_io_device), NULL);
g_signal_connect(G_OBJECT(widgets->spinTempWrite),"value-changed",G_CALLBACK(event_check_io_device), NULL);
g_signal_connect(G_OBJECT(widgets->spinTempRead),"changed",G_CALLBACK(event_check_io_device), NULL);
g_signal_connect(G_OBJECT(widgets->spinTempWrite),"changed",G_CALLBACK(event_check_io_device), NULL);
g_signal_connect(G_OBJECT(widgets->chbTempRead), "toggled", G_CALLBACK(event_check_io_device), NULL);
g_signal_connect(G_OBJECT(widgets->chbTempWrite), "toggled", G_CALLBACK(event_check_io_device), NULL);
}

@ -12,6 +12,7 @@
#include <getopt.h>
#include <libintl.h>
#include "my_device.h"
#include "philos_utils.h"
#define CMD_CPU "lscpu | grep \"CPU(s):\" |grep -oE \"[0-9]{1,}\""

@ -9,7 +9,7 @@ temp_config* get_edit_config() {
temp_set_window *edit_setup_window(char* glade_path){
if (edit_widgets == NULL) {
edit_widgets = malloc(sizeof(temp_set_window));
GtkBuilder *builder = gtk_builder_new_from_file(glade_path);
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path);
edit_widgets->Window = yon_gtk_builder_get_widget(builder,"wndQuotasEdit");
edit_widgets->btnTempCancel = yon_gtk_builder_get_widget(builder,"btnEditCancel");
edit_widgets->btnSaveTempSave = yon_gtk_builder_get_widget(builder,"btnSaveEditSave");
@ -46,21 +46,7 @@ temp_set_window *edit_setup_window(char* glade_path){
}
return edit_widgets;
}
void edit_config_init() {
if (obj_edit_config.size != 0) {
philos_free_string_array(&obj_edit_config.disk, obj_edit_config.size);
philos_free_int_array(&obj_edit_config.i_o_limit_read, obj_edit_config.size);
philos_free_int_array(&obj_edit_config.i_o_limit_write, obj_edit_config.size);
philos_free_int_array(&obj_edit_config.i_o_limit_read_size, obj_edit_config.size);
philos_free_int_array(&obj_edit_config.i_o_limit_write_size, obj_edit_config.size);
}
obj_edit_config.disk = NULL;
obj_edit_config.i_o_limit_read = NULL;
obj_edit_config.i_o_limit_write = NULL;
obj_edit_config.i_o_limit_read_size = NULL;
obj_edit_config.i_o_limit_write_size = NULL;
obj_edit_config.size = 0;
}
void edit_event(temp_set_window *widgets) {
g_signal_connect(G_OBJECT(widgets->btnTempCancel),"clicked",G_CALLBACK(edit_on_hide_subwindow),NULL);
g_signal_connect(G_OBJECT(widgets->Window), "destroy", G_CALLBACK(edit_destroy), NULL);
@ -71,12 +57,12 @@ void edit_event(temp_set_window *widgets) {
g_signal_connect(G_OBJECT(widgets->chbTempRead), "toggled", G_CALLBACK(edit_init_windows), NULL);
g_signal_connect(G_OBJECT(widgets->chbTempWrite), "toggled", G_CALLBACK(edit_init_windows), NULL);
g_signal_connect(G_OBJECT(widgets->spiSevereRestrictionTemp),"value-changed",G_CALLBACK(edit_init_windows), NULL);
g_signal_connect(G_OBJECT(widgets->spinSevereRestrictionTemp),"value-changed",G_CALLBACK(edit_init_windows), NULL);
g_signal_connect(G_OBJECT(widgets->spinPaddingFLTemp),"value-changed",G_CALLBACK(edit_init_windows), NULL);
g_signal_connect(G_OBJECT(widgets->spinCPULimitTemp),"value-changed",G_CALLBACK(edit_init_windows), NULL);
g_signal_connect(G_OBJECT(widgets->spinTempRead),"value-changed",G_CALLBACK(wrapper_edit_init_windows_size_memory), NULL);
g_signal_connect(G_OBJECT(widgets->spinTempWrite),"value-changed",G_CALLBACK(wrapper_edit_init_windows_size_memory), NULL);
g_signal_connect(G_OBJECT(widgets->spiSevereRestrictionTemp),"changed",G_CALLBACK(edit_init_windows), NULL);
g_signal_connect(G_OBJECT(widgets->spinSevereRestrictionTemp),"changed",G_CALLBACK(edit_init_windows), NULL);
g_signal_connect(G_OBJECT(widgets->spinPaddingFLTemp),"changed",G_CALLBACK(edit_init_windows), NULL);
g_signal_connect(G_OBJECT(widgets->spinCPULimitTemp),"changed",G_CALLBACK(edit_init_windows), NULL);
g_signal_connect(G_OBJECT(widgets->spinTempRead),"changed",G_CALLBACK(wrapper_edit_init_windows_size_memory), NULL);
g_signal_connect(G_OBJECT(widgets->spinTempWrite),"changed",G_CALLBACK(wrapper_edit_init_windows_size_memory), NULL);
g_signal_connect(G_OBJECT(widgets->cmSevereRestrictionTemp),"changed",G_CALLBACK(wrapper_edit_init_windows_size_memory), widgets->spiSevereRestrictionTemp);
g_signal_connect(G_OBJECT(widgets->cmbSevereRestrictionTemp),"changed",G_CALLBACK(wrapper_edit_init_windows_size_memory), widgets->spinSevereRestrictionTemp);
g_signal_connect(G_OBJECT(widgets->cmbPaddingFLTemp),"changed",G_CALLBACK(wrapper_edit_init_windows_size_memory), widgets->spinPaddingFLTemp);

@ -12,6 +12,7 @@
#include <getopt.h>
#include <libintl.h>
#include "my_device.h"
#include "philos_utils.h"
#define CMD_CPU "lscpu | grep \"CPU(s):\" |grep -oE \"[0-9]{1,}\""
#define CMD_SWAP "grep '^Swap' /proc/meminfo | grep \"SwapTotal\" |grep -oE \"[0-9]{1,}\""

@ -17,6 +17,9 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "Config loading failed"
msgstr ""
msgid "Remove"
msgstr ""

@ -20,6 +20,9 @@ msgstr ""
#: source/ubl-strings.h:8
#: source/ubl-strings.h:1
msgid "Config loading failed"
msgstr "Не удалось загрузить конфигурацию"
msgid "Quota deleted"
msgstr "Квота удалена"

Loading…
Cancel
Save