diff --git a/source/libublsettings-config.c b/source/libublsettings-config.c index 9b446bf..62ee961 100644 --- a/source/libublsettings-config.c +++ b/source/libublsettings-config.c @@ -532,7 +532,8 @@ int yon_config_load_config(YON_CONFIG_TYPE config_type, ...){ int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *parameter, ...){ if (config_type!=YON_CONFIG_BOTH){ if (__yon__config__strings){ - __yon__config__strings = yon_dictionary_free_all((dictionary*)__yon__config__strings,NULL); + yon_dictionary_free_all((dictionary*)__yon__config__strings,NULL); + __yon__config__strings=NULL; } va_list args; va_start(args,parameter); @@ -834,7 +835,8 @@ int yon_config_set(char *key, void *data){ int yon_config_clean(){ check_config{ - __yon__config__strings = (yon_config_parameter*)yon_dictionary_free_all((dictionary*)__yon__config__strings, NULL); + yon_dictionary_free_all((dictionary*)__yon__config__strings, NULL); + __yon__config__strings = NULL; return 1; } else return 0; diff --git a/source/libublsettings-dictionary.c b/source/libublsettings-dictionary.c index ec8ad12..b5906ad 100644 --- a/source/libublsettings-dictionary.c +++ b/source/libublsettings-dictionary.c @@ -31,15 +31,19 @@ dictionary *yon_dictionary_copy_deep(dictionary *dict){ } int yon_dictionary_set_data(dictionary *dict, void *data){ + if (!dict) return 0; dict->data=data; + return 1; } int yon_dictionary_set_key(dictionary *dict, char *key){ + if (!dict||yon_char_is_empty(key)) return 0; dict->key=key; return 1; } int yon_dictionary_set(dictionary *dict, char *key, void *data){ + if (!dict||yon_char_is_empty(key)) return 0; dict->key=key; dict->data=data; return 1; @@ -222,7 +226,7 @@ void *yon_dictionary_free(dictionary *dictionary_to_free){ } } -void *yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipulation)(void*)){ +void yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipulation)(void*)){ if (dictionary_to_free){ dictionary *dict=NULL; for_dictionaries(dict,dictionary_to_free){ @@ -232,7 +236,6 @@ void *yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipul free(dict->prev); } free(dict); - return NULL; } } @@ -245,22 +248,24 @@ dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *d return dct; } -dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect) +int yon_dictionary_connect(dictionary *old, dictionary *toconnect) { + if (!old||!toconnect) return 0; dictionary *dict = yon_dictionary_get_last(old); dict->next = toconnect; toconnect->prev = dict; toconnect->first = dict->first; - return toconnect; + return 1; } -dictionary *yon_dictionary_merge(dictionary *dict1,dictionary *dict2){ +int yon_dictionary_merge(dictionary *dict1,dictionary *dict2){ + if (!dict1||!dict2) return 0; dictionary *dct = NULL; for_dictionaries(dct,dict2){ if (!yon_dictionary_get(&dict1,dct->key)) yon_dictionary_connect(dict1,dct); } - return dict1; + return 1; } dictionary *yon_dictionary_get(dictionary **dict, char *key) diff --git a/source/libublsettings.h b/source/libublsettings.h index 102c9cf..14edaba 100644 --- a/source/libublsettings.h +++ b/source/libublsettings.h @@ -16,14 +16,19 @@ #define DesktopPath "/usr/share/applications/" - -/**for_dictionaries(element, stack) - * [EN] +/** + * @brief Works like for, but is used to enumerate dictionary elements. * - * [RU] - * Работает как for, но нужен для перечисления элементов словаря типа dictioary [stack]. Каждый цикл текущий элемент попадает в [element] -*/ -#define for_dictionaries(element, stack) for (element = stack->first; element != NULL; element = element->next) + * Работает как for, но нужен для перечисления элементов словаря. + * + * @param iterator Type: dictionary* + * + * dictionary element iterator. + * @param stack Type: dictinoary* + * + * dictionary pointer. + */ +#define for_dictionaries(iterator, stack) for (iterator = stack->first; iterator != NULL; iterator = iterator->next) #define new(type) malloc(sizeof(type)) #define new_arr(type,size) malloc(sizeof(type)*size) @@ -48,15 +53,30 @@ typedef enum struct type_name *prev;\ struct type_name *first;\ DICT_TYPE data_type; + /** + * @brief Named dictionary structure. + * * Структура именованого списка. - * [key] - ключ элемента - * [data] - хранимое значение - * [next] - следующий элемент списка - * [prev] - предыдущий элемент списка - * [first] - первый элемент списка - * [data_type] - Тип значения в словаре -*/ + * @param key dictionary element key. + * + * Ключ элемента словаря. + * @param data dictionary element value. + * + * Значение элемента словаря. + * @param next next dictionary element. + * + * Следующий элемент словаря. + * @param prev previous dictionary element. + * + * Предыдущий элемент словаря. + * @param first first dictionary element. + * + * Следующий элемент словаря. + * @param data_type value type. + * + * Тип значения. + */ typedef struct dictionary { char *key; @@ -67,299 +87,663 @@ typedef struct dictionary DICT_TYPE data_type; } dictionary; - - - -typedef struct apps -{ - char *Name; - int Type; - char *Categories; - char *Exec; - char *Icon; - int Pluggable; - int DualPluggable; -} apps; - typedef char** config_str; -/**config(key) - * Возвращает элемент конфигурации ubconfig с ключом [key] или NULL если такого нет -*/ +/** + * @brief Get configuration parameter value. + * + * Получение значения параметра конфигурации. + * @param key Key of configuration parameter. + * + * Ключ параметра конфигурации. + * @return Type: char* + * + * Value of configuration parameter or NULL. + * + * Значение парамерта конфигурации или NULL. + */ #define config(key) yon_config_get_by_key(key) +/** + * @brief Allocates or reallocates memory. + * + * Выделение или перевыделение памяти. + * @param pointer If NULL, uses malloc(), otherwise uses realloc(). + * + * Если NULL, используется malloc(), иначе realloc(). + * @param size Size of memory allocation. + * + * Размер выделенной памяти. + * @return Type: void* + * Newly allocated memory. + * + * Новая выделенная память. + */ #define yon_remalloc(pointer, size) (!pointer) ? malloc(size) : realloc(pointer, size) + + // dictionary functions -/**yon_dictionary_get_data(dictionary, type) - * [EN] - * Gets data from dictionary. - * [dictionary] is dictionary, from which data should be extracted; - * [type] is type of data, [dictionary] contains. - * [RU] - * Возвращает данные из словаря. - * [dictionary] - словарь из которого достаются данные. - * [type] - тип данных, хранящихся в словаре [dictionary]. -*/ +/** + * @brief Gets data from dictionary element. + * + * Получение значения элемента словаря. + * @param dictionary dictionary element. + * + * Элемент словаря. + * @param type type of value, dictionary element contains. + * + * Тип значения, содержащегося в элементе словаря. + * @return Type: void* + * Value, dictionary element contains. + * + * Значение, которое содержит элемент словаря. + */ #define yon_dictionary_get_data(dictionary, type) ((type)dictionary->data) -/**yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) - * [EN] +/** + * @brief Creates new or appends new element to dictionary. * - * [RU] - * Добавляет элемент словаря в конец словаря [dict] c ключом [key] и данными [data]. - * Если словарь не существует, создаёт его -*/ + * Создаёт новый элемент словаря. + * + * --- + * + * @param dict dictionary*, where new element will be added to. + * + * Словарь в который будет добавлен новый элемент. + * + * --- + * + * @param key char*, new allocated element's key. + * + * Ключ нового элемента. + * + * --- + * + * @param data void*, data of any type. + * + * Данные любого типа + * + */ #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);} -/**yon_dictionary_new(): - * [EN] - * Creates and returns empty dictionary - * [RU] - * Создаёт и возвращает пустой словарь. +/** + * @brief Creates and returns empty dictionary. + * + * Создаёт и возвращает пустой словарь. + * + * --- + * + * @return A newly allocated dictionary. + * + * The caller of the method takes ownership of the returned data, and is responsible for freeing it. + * + * Новый выделенный dictionary*. + * + * Вызывающий метод берёт на себя ответственность за возвращаемые данные и отвечает за их освобождение. */ dictionary *yon_dictionary_new(); -/**yon_dictionary_copy(dictionary *dict) - * [EN] +/** + * @brief copies dictionary. * - * [RU] - * Создаёт и возвращает копию элемента словаря [dict] -*/ + * Копирует словарь. + * + * --- + * @param dict dictionary to copy. + * + * словарь для копирования. + * + * --- + * @return A new allocated dictionary* + * + * The caller of the method takes ownership of the returned data, and is responsible for freeing it. + * + * Новый выделенный dictionary* + * + * Вызывающий метод берёт на себя ответственность за возвращаемые данные и отвечает за их освобождение. + */ dictionary *yon_dictinoary_copy(dictionary *dict); -/**yon_dictionary_copy_deep(dictionary *dict) - * [EN] +/** + * @brief Creates a deep copy of the dictionary and returns the first element. * - * [RU] - * Создаёт полную копию словаря [dict] и возвращает первый элемент -*/ + * Создаёт полную копию словаря и возвращает первый элемент. + * + * --- + * @param dict first element of dictionary to copy. + * + * Первый элемент копируемого словаря. + * + * --- + * @return A new allocated dictionary* + * + * The caller of the method takes ownership of the returned data, and is responsible for freeing it. + * + * Новый выделенный dictionary* + * + * Вызывающий метод берёт на себя ответственность за возвращаемые данные и отвечает за их освобождение. + */ dictionary *yon_dictionary_copy_deep(dictionary *dict); -/**int yon_dictionary_set_data(dictionary *dict, void *data) - * [EN] +/** + * @brief Set a data to dictionary element. * - * [RU] - * Установить элементу словаря [dict] значение [data] -*/ + * Установить элементу словаря значение. + * + * --- + * @param dict dictionary element to set data. + * + * Элемент словаря в который устанавливается новое значение. + * @param data new value for dictionaty + * + * Новое значение словаря. + * + * --- + * @return 0 if failed, 1 if succeeded. + * + * 0 при провале, 1 при успехе + */ int yon_dictionary_set_data(dictionary *dict, void *data); -/**int yon_dictionary_set_key(dictionary *dict, char *key) - * [EN] +/** + * @brief Change dioctionary element's key. * - * [RU] - * Изменяет ключ элемента словаря [dict] на [key] -*/ + * Изменяет ключ элемента словаря. + * + * --- + * @param dict dictionary element for key change. + * + * Элемент словаря для изменения ключа. + * @param key + * @return 0 if failed, 1 if succeeded. + * + * 0 при провале, 1 при успехе + */ int yon_dictionary_set_key(dictionary *dict, char *key); -/** int yon_dictionary_set(dictionary *dict, char *key, void *data) - * [EN] +/** + * @brief Sets dictionary element's key and data * - * [RU] -* Устанавливает значение ключа элемента словаря [dict] на [key] и его данные на [data] -*/ + * Устанавливает значение ключа элемента словаря и его данные + * + * --- + * @param dict dictionary element for change. + * + * Элемент словаря для изменения. + * @param key new key for dictionary element. + * + * Новый ключ для элемента словаря. + * @param data new value for dictionary element. + * + * Новое значение элемента словаря. + * + * --- + * @return 0 if failed, 1 if succeeded. + * + * 0 при провале, 1 при успехе. + */ int yon_dictionary_set(dictionary *dict, char *key, void *data); -/**int yon_dictionary_empty(dictionary *dict) - * [EN] +/** + * @brief Cleans dictionary element. * - * [RU] - * Очищает элемент словаря [dict] от данных -*/ + * Очищает элемент словаря. + * @param dict target dictionary element. + * + * Очищаемый элемент словаря. + * @return 0 if failed, 1 if succeeded. + * + * 0 при провале, 1 при успехе. + */ int yon_dictionary_empty(dictionary *dict); -/**yon_dictionary_switch_to_last(dictionary **dict) - * [EN] +/** + * @brief Switch dictionary to last element. * - * [RU] - * Переключает словарь [dict] на последний элемент. -*/ + * Переключает словарь на последний элемент. + * + * --- + * @param dict Dictionary to pointer. + * + * Указатель на словарь. + */ void yon_dictionary_switch_to_last(dictionary **dict); -/**yon_dictionary_create_conneced(dictionary *targetdict) - * [EN] +/** + * @brief Appends dictionary with new element. * - * [RU] - * Создаёт новый элемент словаря [targetdict] -*/ + * Дополнить словарь новым элементом. + * + * --- + * @param targetdict dictionary to append. + * + * Словарь для дополнения. + * @return A new allocated dictionary*, element of dictionary. + * + * Новый выделенный dictionary*, элемент словаря. + */ dictionary *yon_dictionary_append(dictionary *targetdict); -/**yon_dictionary_get_last(dictionary *dict) - * [EN] + +/** + * @brief Returns the last element of the dictionary. + * Unlike yon_dictionary_switch_to_last() + * the dictionary remains at its previous element. * - * [RU] - * Возвращает последний элемент словаря [dict]. + * Возвращает последний элемент словаря. * В отличае от yon_dictionary_switch_to_last() - * словарь [dict] остаётся на прежнем элементе. -*/ + * словарь остаётся на прежнем элементе. + * @param dict The dictionary whose last element will be retrieved. + * + * Словарь, последний элемент которого будет получен. + * @return Type: dictionary* + * + * The last element of dictionary. + */ dictionary *yon_dictionary_get_last(dictionary *dict); -/**yon_dictionary_switch_places(dictionary *dict, int aim) - * [EN] +/** + * @brief iterate dictionary element position. * - * [RU] - * Меняет элемент словаря [dict] местами с другим элементом. - * если [aim]<0 элемент меняется местами с левым элементом; - * если [aim]>0 элемент меняется местами с правым элементом; -*/ + * Меняет элемент словаря местами с другим элементом. + * @param dict The moving dictionary element. + * + * Перемещаемый элемент словаря. + * @param aim if <0, element switches with left element; + * if >0, element switches with right element; + * + * если <0 элемент меняется местами с левым элементом; + * если >0 элемент меняется местами с правым элементом; + * @return Type: dictionary* + * + * dictionary element, swapped with current. + * + * Элемент словаря с которым текущий поменялся местами. + */ dictionary *yon_dictionary_swap(dictionary *dict, int aim); -/**yon_dictionary_make_first(dictionary *dict) - * [EN] +/** + * @brief Sets the first element pointer of the dictionary + * to the current element. Do not use * - * [RU] - * Устанавливает указатель первого элемента словаря [dict] - * на текущий элемент. Не использовать. -*/ + * Устанавливает указатель первого элемента словаря + * на текущий элемент. Не использовать + * @param dict + */ void yon_dictionary_make_first(dictionary *dict); -/**yon_dictionary_make_nth(dictionary *dict, int nth) - * [EN] +/** + * @brief Moves dictionary element to new position. * - * [RU] - * Перемещает элемент словаря [dict] на позицию [nth]. -*/ + * Перемещает элемент словаря на новую позицию. + * @param dict dictionary element to move. + * + * Перемещаемый элемент словаря. + * @param nth new position for dictionary element. + * + * новоя позиция для элемента словаря. + */ void yon_dictionary_make_nth(dictionary *dict, int nth); -/**yon_dictionary_create_with_data(char *key, void *data) - * [EN] +/** + * @brief Create new dictionary element with key and value. * - * [RU] - * Создаёт новый словарь с ключом [key] и указателем на данные [data] -*/ + * Создать новый элемент словаря с ключом и значением. + * @param key new dictionary element's key. + * + * Ключ нового элемента словаря. + * @param data new dictionary element's value. + * + * Значение нового элемента словаря. + * @return Type: dictionary* + * + * New dictionary element. + * + * Новый элемент словаря. + */ dictionary *yon_dictionary_new_with_data(char *key, void *data); -/**yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data) - * [EN] +/** + * @brief Create and append dictionary element to dictionary with key and value. * - * [RU] - * Создаёт новый элемент словаря, присоединяемый в конец словаря [dict] - * с ключом [key] и указателем на данные [data] -*/ + * Создать новый элемент словаря, присоединяемый в конец словаря + * с ключом и значением. + * @param dict dictionary to append with new element. + * + * Словарь к которому добавляется элемент. + * @param key new dictionary element's key; + * + * Ключ нового элемента словаря. + * @param data New dictionary element's value. + * + * Значение нового элемента словаря. + * @return Type: dictionary* + * + * New allocated dictionary element. + * + * Новый выделенный элемент словаря. + */ dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data); -/**yon_dictionary_connect(dictionary *old, dictionary *toconnect) - * [EN] +/** + * @brief Connect dictionary element to the end of dictionary. * - * [RU] - * Присоединяет словарь [toconnect] в конец словаря [old]. -*/ -dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect); + * Присоединение элемента словаря в конец словаря. + * @param target Dictionary to connect element. + * + * Словарь для присоединения элемента. + * @param append An appendable dictionary element. + * + * Присоединяемый элемент словаря. + * @return Type: int. + * + * 0 if failed, 1 if success. + * + * 0 при провале, 1 при успехе. + */ +int yon_dictionary_connect(dictionary *target, dictionary *append); -dictionary *yon_dictionary_merge(dictionary *dict1,dictionary *dict2); +/** + * @brief Merge second dictionary into first. + * + * Объединить два словаря в один. + * @param dict1 Dictionary which other dictionary connects to. + * + * Словарь с которым объединяется другой словарь. + * @param dict2 Dictionary to connect. + * + * Присоединяемый словарь. + * @return Type: int + * + * 0 if failed, 1 if success. + * + * 0 при провале, 1 при успехе. + */ +int yon_dictionary_merge(dictionary *dict1,dictionary *dict2); -/**yon_dictionary_get(dictionary **dict, char *key) - * [EN] +/** + * @brief Get dictionary element by key. * - * [RU] - * Возвращает элемент словаря [dict] с ключом [key]. - * Если такого элемента не было обнаружено, возвращается NULL -*/ + * Возвращает элемент словаря с ключом. + * @param dict dictionary link. + * + * Ссылка на словарь. + * @param key key of requested dictionary element. + * + * Ключ запрашиваемого элемента словаря. + * @return Type: dictionary* + * + * Dictionary element with requested key or NULL. + * + * "Элемент словаря с разыскиваемым ключом или NULL." + */ dictionary *yon_dictionary_get(dictionary **dict, char *key); -/**yon_dictionary_rip(dictionary *dict) - * [EN] +/** + * @brief Free dictionary element. * - * [RU] - * Вырезает элемент из словаря и возвращает ближайший элемент. -*/ + * Освобождает элемент словаря. + * @param dict Dictionary element to free. + * Освобождаемый элемент списка. + * @return Type: dictionary* + * + * Closest valid dictionary element. + * + * Ближайший валидный элемент словаря. + */ dictionary *yon_dictionary_rip(dictionary *dict); -/**yon_dictionary_get_nth(dictionary *dict, int place) - * [EN] +/** + * @brief Get dictionary element of specific position. * - * [RU] - * Возвращает [place]-й элемент словаря [dict] -*/ + * Получить элемент списка на конкретной позиции. + * @param dict First dictionary element. + * + * Первый элемент словаря. + * @param place Desired dictionary element position. + * + * Желаемая позиция элемента словаря. + * @return Type: dictionary* + * + * Dictionary element on desired position or NULL. + * + * Элемент словаря на желаемой позиции или NULL. + */ dictionary *yon_dictionary_get_nth(dictionary *dict, int place); -/** void *yon_dictionary_free_all(dictionary *dictionary,void *data_manipulation) - * [EN] - * Frees memory of dictionary [dictionary_to_free]. - * [RU] - * Освобождает память элемента словаря [dictionary_to_free]. -*/ +/** + * @brief Frees memory of dictionary element. + * + * Освобождает память элемента словаря. + * @param dictionary_to_free + * @return Type: void* + * Value, freed dictionary element was containing. + * + * Значение, которое содержалось в освобождённом словаре. + */ void *yon_dictionary_free(dictionary *dictionary_to_free); -/** void *yon_dictionary_free_all(dictionary *dictionary,void *data_manipulation) - * [EN] - * Frees whole [dictionary] and activates [data_manipulation] function if not NULL with [dictionary]->data argument for each dictionary. - * [RU] - * Освобождает память для всех элементов словаря [dictionary] и активирует функцию [data_manipulation], если она была передана, с аргументом [dictionary]->data на каждый элемент словаря. -*/ -void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(void*)); +/** + * @brief Frees whole dictionary. + * + * Освобождает память для всех элементов словаря. + * @param dictionary + * @param data_manipulation Function, activated, if not NULL, for every dictionary element in dictionary. + * + * Функция, активируемая, если не NULL, для каждого элемента словаря в словаре. + */ +void yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(void*)); + +// [[ deprecated ]] +// dictionary *yon_dictionary_sort(dictionary *dict); -[[ deprecated ]] -dictionary *yon_dictionary_sort(dictionary *dict); +// [[__warnattr("Function is yon_dictionary_check_loops() is untested")]]; dictionary *yon_dictionary_check_loops(dictionary *target); // char functions +/** + * @brief Macros for yon_char_divide_search function to get right part from string, freeing left part. + * + * Макросы для функции yon_char_divide_search для извлечения правой части из строки, освобождая левую часть. + * @param str string + * @param find string to find + * @param delete_divider + */ #define yon_char_divide_search_self(str,find,delete_divider) {char *temp = str; str = yon_char_divide_search(str,find,delete_divider); free(temp);} +/** + * @brief check if string is empty. + * + * Проверить пустая ли строка. + * @param string + */ #define yon_char_is_empty(string) !(string&&strcmp(string,"")) +/** + * @brief Macros. If string is not empty, returns string, otherwise returns other string. + * + * @param string String to check. If string is empty, returns other string. + * + * @param opposite If main shring is empty, returns this string. + * + */ #define yon_char_return_if_exist(string,opposite) string&&strcmp(string,"")?string:opposite -#define yon_char_remove_last_symbol(target,symbol) {if (target[strlen(target)-1]==symbol) target[strlen(target)-1]='\0';} - -char *yon_char_conenct_if_true(); +/** + * @brief Macros. Removes last string symbol. + * + * Макрос. Удаление последнего символа строки. + * @param string + * @param symbol If last string symbol is same, removes it, otherwise does nothing. + * + * Если последний символ строки совпадает, он удаляется, иначе ничего не происходит + */ +#define yon_char_remove_last_symbol(string,symbol) {if (string[strlen(string)-1]==symbol) string[strlen(string)-1]='\0';} +/** + * @brief Find last symbol in sting. + * + * Найти последний символ в строке. + * @param find Symbol to find. + * + * Искомый символ. + * @return Type: int + * + * The location of the last character being searched for. + * + * Местоположение последнего искомого символа. + */ int yon_char_find_last(char *source, char find); -/**[EN] +/** + * @brief Create new string by combining two strings. * - * Creates new char string by combining two char strings. - * [RU] - * Создаёт новую строку, состоящую из двух входящих. + * Создать новую строку, состоящую из двух входящих. + * @param append Appending string. + * + * Присоединяемая строка. + * @return Type: char* + * A new allocated string, containing both input strings. + * + * Новая выделенная строка, состоящая из обеих входящих строк. */ char *yon_char_append(const char *source, const char *append); -/**[EN] +/** + * @brief Create new string by appending string with symbol. * - * Creates new char string by combining two char strings. - * [RU] - * Создаёт новую строку, состоящую из строки [source] - * с добавлением символа [append] в конец. + * Создать новую строку соединением строки и символа + * @param append Appending symbol. + * + * Прибавляемый символ. + * @return Type: char* + * + * A new allocated string. + * + * Новая выделенная строка. */ char *yon_char_append_c(const char *source, char append); +/** + * @brief Append string with another string, inserting another string between + * + * Добавляет к строке другую строку, добавляя между ними разделитель. + * @param target Appending string. + * + * Добавляемая строка. + * @param divider Divider. A string, which divides source string into substrings. + * + * Разделитель. Строка, разделяющая основную строку на подстроки. + * @return Type: char* + * + * A newly allocated string. + * + * Новая выделенная строка. + */ char *yon_char_append_element(char *source,char *target, char *divider); + +/** + * @brief Remove substring from string. + * + * Удалить подстроку из строки. + * @param target Substring to remove. + * + * Удаляемая подстрока. + * @param divider Divider. Main string divides into substrings to compare. + * @return Type: char* + * + * A newly allocated string with reniver substing. + * + * Новая выделенная строка с удалённой подстрокой. + */ char *yon_char_remove_element(char *source,char *target, char *divider); -/**[EN] +/** + * @brief Copy string. + * + * Копировать строку. + * @return Type: char* + * + * A newly allocated string. * - * creates new char string by copying another char. + * Новая выделенная строка. */ char *yon_char_new(const char *chr); -/**yon_char_unite(const char *source, ...) - * [En] +/** + * @brief Unite multiple strings. * - * [RU] - * Объединяет строку [source] со всеми строками, написанными в [...]. Последний элемент должен быть NULL -*/ + * Объединить несколько строк. + * @param source First string to unite. + * + * Первая объединяемая строка. + * @param ... Multiple strings, edning with NULL. + * + * Произвольное количество строк, заканчивающееся NULL. + * @return Type: char* + * + * A newly allocated string. + * + * Новая выделенная строка. + */ char *yon_char_unite(const char *source, ...); -/**yon_cut(char *source, int size, int startpos) - * [EN] - * cuts source string by size length from startpos position. - */ char *yon_cut(char *source, int size, int startpos); - +/** + * @brief Check if string begins with substring. + * + * Проверить начинается ли строка с подстроки. + * @param haystack String to check. + * + * Проверяемая строка. + * @param needle Substring searched in the beginning of main string. + * + * Подстрока, искомая в начале основной строки. + * @return Type: boolean + */ int yon_char_check_begins_with(char *haystack, char *needle); +/** + * @brief Check if string array has string, beginning with substring. + * + * Проверить есть ли в массиве строк строка, начинающаяся с подстроки. + * @param target String array to check. + * + * Проверяемый массив строк. + * @param size Pointer to size of string array. + * + * Указатель на размер массива строк + * @param compare String to search in string array. + * + * Искомая строка. + * @return Type: char* + * + * If substring was found, full string is returned, otherwise, NULL. + * + * Если подстрока была найдена возвращается полная строка, иначе NULL. + */ char *yon_char_parsed_check_exist_begins_with(char **target, int size, char *compare); -/**yon_char_wrap_to_lines(char *target, unsigned int line_count, unsigned int *final_size) - * [EN] +/** + * @brief Split a string into a given number of lines. * - * [RU] - * Делит строку [target] на [line_count] частей по пробелу и - * возвращает массив строк длиной [final_size] + * Разделить строку на заданное количество строк. + * @param line_count Number of lines. + * + * Количество строк. + * @param final_size Pointer to return the size of the string array. + * + * Указатель для возврата размера массива строк. + * @return Type: config_str + * + * Newly allocated string array with splitted input string. + * + * Новый выделенный массив строк с разделённой входной строкой. */ config_str yon_char_wrap_to_lines(char *target, unsigned int line_count, unsigned int *final_size); @@ -369,6 +753,14 @@ config_str yon_char_wrap_to_lines(char *target, unsigned int line_count, unsigne * returning left part of divided string and * inserting right part to source string. */ + +/** + * @brief Divide a sting at position. + * + * @param source + * @param dividepos + * @return char* + */ char *yon_char_divide(char *source, int dividepos); /**yon_char_divide_search(char *source, char *dividepos, int delete_divider) @@ -672,12 +1064,6 @@ int yon_get_size_get_from_letter(char size); */ char *yon_size_get_mod(int size); -apps *yon_apps_scan_and_parse_desktops(int *sizef); - -void yon_apps_sort(apps *applist, int size); - -apps *yon_apps_get_by_name(apps *applist, char *name, int size); - /**yon_file_path_proceed_spaces(char *path) * [EN] *