@ -2,12 +2,6 @@
// dictionary functions
/**yon_dictionary_new():
* [ EN ]
* Creates and returns empty dictionary
* [ RU ]
* С о з д а ё т и в о з в р а щ а е т п у с т о й с л о в а р ь .
*/
dictionary * yon_dictionary_new ( )
{
dictionary * dict = malloc ( sizeof ( dictionary ) ) ;
@ -20,24 +14,12 @@ dictionary *yon_dictionary_new()
return dict ;
}
/**yon_dictionary_copy(dictionary *dict)
* [ EN ]
*
* [ RU ]
* С о з д а ё т и в о з в р а щ а е т к о п и ю э л е м е н т а с л о в а р я [ dict ]
*/
dictionary * yon_dictinoary_copy ( dictionary * dict ) {
dictionary * dct = yon_dictionary_new_with_data ( dict - > key , dict - > data ) ;
dct - > data_type = dict - > data_type ;
return dct ;
}
/**yon_dictionary_copy_deep(dictionary *dict)
* [ EN ]
*
* [ RU ]
* С о з д а ё т п о л н у ю к о п и ю с л о в а р я [ dict ] и в о з в р а щ а е т п е р в ы й э л е м е н т
*/
dictionary * yon_dictionary_copy_deep ( dictionary * dict ) {
dictionary * dct = NULL ;
dictionary * newone = NULL ;
@ -48,69 +30,33 @@ dictionary *yon_dictionary_copy_deep(dictionary *dict){
return newone - > first ;
}
/**int yon_dictionary_set_data(dictionary *dict, void *data)
* [ EN ]
*
* [ RU ]
* У с т а н о в и т ь э л е м е н т у с л о в а р я [ dict ] з н а ч е н и е [ data ]
*/
int yon_dictionary_set_data ( dictionary * dict , void * data ) {
dict - > data = data ;
}
/**int yon_dictionary_set_key(dictionary *dict, char *key)
* [ EN ]
*
* [ RU ]
* И з м е н я е т к л ю ч э л е м е н т а с л о в а р я [ dict ] н а [ key ]
*/
int yon_dictionary_set_key ( dictionary * dict , char * key ) {
dict - > key = key ;
return 1 ;
}
/** int yon_dictionary_set(dictionary *dict, char *key, void *data)
* [ EN ]
*
* [ RU ]
* У с т а н а в л и в а е т з н а ч е н и е к л ю ч а э л е м е н т а с л о в а р я [ dict ] н а [ key ] и е г о д а н н ы е н а [ data ]
*/
int yon_dictionary_set ( dictionary * dict , char * key , void * data ) {
dict - > key = key ;
dict - > data = data ;
return 1 ;
}
/**int yon_dictionary_empty(dictionary *dict)
* [ EN ]
*
* [ RU ]
* О ч и щ а е т э л е м е н т с л о в а р я [ dict ] о т д а н н ы х
*/
int yon_dictionary_empty ( dictionary * dict ) {
dict - > data = NULL ;
dict - > data_type = DICTIONARY_OTHER_TYPE ;
return 1 ;
}
/**yon_dictionary_switch_to_last(dictionary **dict)
* [ EN ]
*
* [ RU ]
* П е р е к л ю ч а е т с л о в а р ь [ dict ] н а п о с л е д н и й э л е м е н т .
*/
void yon_dictionary_switch_to_last ( dictionary * * dict )
{
dictionary * dct = NULL , * dact = * dict ;
for_dictionaries ( dct , dact ) ;
}
/**yon_dictionary_create_conneced(dictionary *targetdict)
* [ EN ]
*
* [ RU ]
* С о з д а ё т н о в ы й э л е м е н т с л о в а р я [ targetdict ]
*/
dictionary * yon_dictionary_append ( dictionary * targetdict )
{
targetdict = yon_dictionary_get_last ( targetdict ) ;
@ -121,14 +67,6 @@ dictionary *yon_dictionary_append(dictionary *targetdict)
return targetdict - > next ;
}
/**yon_dictionary_get_last(dictionary *dict)
* [ EN ]
*
* [ RU ]
* В о з в р а щ а е т п о с л е д н и й э л е м е н т с л о в а р я [ dict ] .
* В о т л и ч а е о т yon_dictionary_switch_to_last ( )
* с л о в а р ь [ dict ] о с т а ё т с я н а п р е ж н е м э л е м е н т е .
*/
dictionary * yon_dictionary_get_last ( dictionary * dict )
{
if ( dict - > next ) {
@ -138,14 +76,6 @@ dictionary *yon_dictionary_get_last(dictionary *dict)
} else return dict ;
}
/**yon_dictionary_switch_places(dictionary *dict, int aim)
* [ EN ]
*
* [ RU ]
* М е н я е т э л е м е н т с л о в а р я [ dict ] м е с т а м и с д р у г и м э л е м е н т о м .
* е с л и [ aim ] < 0 э л е м е н т м е н я е т с я м е с т а м и с л е в ы м э л е м е н т о м ;
* е с л и [ aim ] > 0 э л е м е н т м е н я е т с я м е с т а м и с п р а в ы м э л е м е н т о м ;
*/
dictionary * yon_dictionary_swap ( dictionary * dict , int aim )
{
if ( aim < 0 )
@ -247,13 +177,6 @@ dictionary *yon_dictionary_swap(dictionary *dict, int aim)
}
}
/**yon_dictionary_make_first(dictionary *dict)
* [ EN ]
*
* [ RU ]
* У с т а н а в л и в а е т у к а з а т е л ь п е р в о г о э л е м е н т а с л о в а р я [ dict ]
* н а т е к у щ и й э л е м е н т . Н е и с п о л ь з о в а т ь .
*/
void yon_dictionary_make_first ( dictionary * dict )
{
for ( dictionary * dct = dict - > first ; dct ! = NULL ; dct = dct - > next )
@ -262,12 +185,6 @@ void yon_dictionary_make_first(dictionary *dict)
}
}
/**yon_dictionary_make_nth(dictionary *dict, int nth)
* [ EN ]
*
* [ RU ]
* П е р е м е щ а е т э л е м е н т с л о в а р я [ dict ] н а п о з и ц и ю [ nth ] .
*/
void yon_dictionary_make_nth ( dictionary * dict , int nth )
{
dictionary * dct = dict - > first ;
@ -286,12 +203,6 @@ void yon_dictionary_make_nth(dictionary *dict, int nth)
dct - > prev = dict ;
}
/**yon_dictionary_create_with_data(char *key, void *data)
* [ EN ]
*
* [ RU ]
* С о з д а ё т н о в ы й с л о в а р ь с к л ю ч о м [ key ] и у к а з а т е л е м н а д а н н ы е [ data ]
*/
dictionary * yon_dictionary_new_with_data ( char * key , void * data )
{
dictionary * dct = yon_dictionary_new ( ) ;
@ -301,12 +212,6 @@ dictionary *yon_dictionary_new_with_data(char *key, void *data)
return dct ;
}
/** 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_to_free , void ( * data_manipulation ) ( void * ) ) {
dictionary * dict = NULL ;
for_dictionaries ( dict , dictionary_to_free ) {
@ -319,13 +224,6 @@ void *yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipul
return NULL ;
}
/**yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data)
* [ EN ]
*
* [ RU ]
* С о з д а ё т н о в ы й э л е м е н т с л о в а р я , п р и с о е д и н я е м ы й в к о н е ц с л о в а р я [ dict ]
* с к л ю ч о м [ key ] и у к а з а т е л е м н а д а н н ы е [ data ]
*/
dictionary * yon_dictionary_append_with_data ( dictionary * dict , char * key , void * data )
{
dictionary * dct = yon_dictionary_append ( dict ) ;
@ -335,12 +233,6 @@ dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *d
return dct ;
}
/**yon_dictionary_connect(dictionary *old, dictionary *toconnect)
* [ EN ]
*
* [ RU ]
* П р и с о е д и н я е т с л о в а р ь [ toconnect ] в к о н е ц с л о в а р я [ old ] .
*/
dictionary * yon_dictionary_connect ( dictionary * old , dictionary * toconnect )
{
dictionary * dict = yon_dictionary_get_last ( old ) ;
@ -350,13 +242,6 @@ dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect)
return toconnect ;
}
/**yon_dictionary_get(dictionary **dict, char *key)
* [ EN ]
*
* [ RU ]
* В о з в р а щ а е т э л е м е н т с л о в а р я [ dict ] с к л ю ч о м [ key ] .
* Е с л и т а к о г о э л е м е н т а н е б ы л о о б н а р у ж е н о , в о з в р а щ а е т с я NULL
*/
dictionary * yon_dictionary_get ( dictionary * * dict , char * key )
{
dictionary * dct = * dict ;
@ -371,12 +256,6 @@ dictionary *yon_dictionary_get(dictionary **dict, char *key)
return NULL ;
}
/**yon_dictionary_rip(dictionary *dict)
* [ EN ]
*
* [ RU ]
* В ы р е з а е т э л е м е н т и з с л о в а р я и в о з в р а щ а е т в ы р е з а н н ы й э л е м е н т .
*/
dictionary * yon_dictionary_rip ( dictionary * dict )
{
if ( ! dict - > next & & ! dict - > prev ) return NULL ;
@ -412,12 +291,6 @@ dictionary *yon_dictionary_rip(dictionary *dict)
}
}
/**yon_dictionary_get_nth(dictionary *dict, int place)
* [ EN ]
*
* [ RU ]
* В о з в р а щ а е т [ place ] - й э л е м е н т с л о в а р я [ dict ]
*/
dictionary * yon_dictionary_get_nth ( dictionary * dict , int place )
{
if ( dict ) {
@ -444,10 +317,6 @@ int yon_char_find_last(char *source, char find){
return i ;
}
/**[EN]
*
* creates new char string by combining two char strings .
*/
char * yon_char_append ( char * source , char * append )
{
if ( source & & append )
@ -465,10 +334,6 @@ char *yon_char_append(char *source, char *append)
return NULL ;
}
/**[EN]
*
* creates new char string by copying another char .
*/
char * yon_char_new ( char * chr )
{
if ( chr ) {
@ -480,12 +345,6 @@ char *yon_char_new(char *chr)
return NULL ;
}
/**yon_char_unite(char *source, ...)
* [ En ]
*
* [ RU ]
* О б ъ е д и н я е т с т р о к у [ source ] с о в с е м и с т р о к а м и , н а п и с а н н ы м и в [ . . . ]
*/
char * yon_char_unite ( char * source , . . . ) {
va_list arglist ;
char * new_char = NULL ;
@ -501,10 +360,6 @@ char *yon_char_unite(char *source, ...){
return new_char ;
}
/**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 )
{
char * cut = NULL ;
@ -514,12 +369,6 @@ char *yon_cut(char *source, int size, int startpos)
return cut ;
}
/**yon_char_divide(char *source, int dividepos)
* [ EN ]
* divides source string in dividepos position ,
* returning left part of divided string and
* inserting right part to source string .
*/
char * yon_char_divide ( char * source , int dividepos )
{
if ( source ) {
@ -536,12 +385,6 @@ char *yon_char_divide(char *source, int dividepos)
return NULL ;
}
/**yon_char_find_count(char *source, char *find)
* [ EN ]
*
* [ RU ]
* С ч и т а е т к о л и ч е с т в о с и м в о л о в [ find ] в с т р о к е [ source ]
*/
int yon_char_find_count ( char * source , char * find ) {
char * working_string = yon_char_new ( source ) ;
int i = 0 ;
@ -556,24 +399,6 @@ int yon_char_find_count(char *source, char *find){
return i ;
}
/**yon_char_divide_search(char *source, char *dividepos, int delete_divider)
* [ EN ]
* char * yon_char_divide_search ( char * source , char * dividepos , int delete_divider )
* searches string [ dividepos ] in [ source ] string and divides it ,
* returning left part of divided string and
* inserting right part to [ source ] string .
* if [ delete_divider ] is 0 , left part will contain [ delete_divider ] substring , else
* if [ delete_divider ] is 1 it will stay in right part , else
* if [ delete_divider ] is - 1 it will be deleted from string .
*
* [ RU ]
* char * yon_char_divide_search ( char * source , char * dividepos , int delete_divider )
* И щ е т с т р о к у [ dividepos ] в с т р о к е [ source ] и д е л и т е ё в э т о м м е с т е ,
* в о з в р а щ а я л е в у ю ч а с т ь р а з д е л ё н н о й с т р о к и и у с т а н а в л и в а е т в [ source ] п р а в у ю ч а с т ь .
* Е с л и [ delete_divider ] р а в е н 0 , [ dividepos ] о с т а н е т с я в л е в о й с т р о к е , и н а ч е
* е с л и [ delete_divider ] р а в е н 1 , [ dividepos ] о с т а н е т с я в п р а в о й с т р о к е , и н а ч е
* е с л и [ delete_divider ] р а в е н - 1 , [ dividepos ] у д а л я е т с я и з с т р о к и .
*/
char * yon_char_divide_search ( char * source , char * dividepos , int delete_divider )
{
if ( source & & dividepos ) {
@ -588,15 +413,6 @@ char *yon_char_divide_search(char *source, char *dividepos, int delete_divider)
return source ;
}
/**yon_char_from_int(int int_to_convert)
* [ EN ]
* char * yon_char_from_int ( int int_to_convert )
* converts int to char * .
*
* [ RU ]
* char * yon_char_from_int ( int int_to_convert )
* К о н в е р т и р у е т int в char *
*/
char * yon_char_from_int ( int int_to_convert )
{
int i = 1 ;
@ -610,13 +426,6 @@ char *yon_char_from_int(int int_to_convert)
return ch ;
}
/**yon_char_from_float(int int_to_convert)
* [ EN ]
* converts float to char * .
*
* [ RU ]
* К о н в е р т и р у е т float в char *
*/
char * yon_char_from_float ( float int_to_convert )
{
int i = 1 ;
@ -630,13 +439,6 @@ char *yon_char_from_float(float int_to_convert)
return ch ;
}
/**yon_char_from_long(int int_to_convert)
* [ EN ]
* converts long to char * .
*
* [ RU ]
* К о н в е р т и р у е т long в char *
*/
char * yon_char_from_long ( long int_to_convert )
{
int i = 1 ;
@ -650,12 +452,6 @@ char *yon_char_from_long(long int_to_convert)
return ch ;
}
/**yon_char_replace(char *source, char *find, char*replace)
* [ EN ]
*
* [ RU ]
* З а м е н я е т в с т р о к е [ source ] в с е в х о ж д е н и я с т р о к и [ find ] н а [ replace ]
*/
char * yon_char_replace ( char * source , char * find , char * replace ) {
if ( ! strstr ( replace , find ) ) {
@ -676,12 +472,6 @@ char *yon_char_replace(char *source, char *find, char*replace){
return source ;
}
/**yon_char_parse(char *parameters, int *size, char *divider)
* [ EN ]
* Parses string [ parameters ] , divided by [ divider ] ,
* then returns parsed string array and sets [ size ] to
* size of returned array
*/
char * * yon_char_parse ( char * parameters , int * size , char * divider ) {
if ( parameters ) {
char * * string = NULL ;
@ -701,13 +491,6 @@ char **yon_char_parse(char *parameters, int *size, char *divider){
return NULL ;
}
/**yon_char_parsed_rip(char **char_string, int *size, int item_to_delete)
* [ EN ]
*
* [ RU ]
* У д а л я е т э л е м е н т [ item_to_delete ] и з м а с с и в а с т р о к [ char_string ] , р а з м е р а [ size ]
* В о з в р а щ а е т п о л у ч и в ш и й с я м а с с и в , в [ size ] з а г р у ж а е т с я р а з м е р н о в о г о м а с с и в а .
*/
char * * yon_char_parsed_rip ( char * * char_string , int * size , int item_to_delete ) {
char * * new_char_parsed = NULL ;
new_char_parsed = malloc ( sizeof ( char * ) * ( ( * size ) - 1 ) ) ;
@ -727,14 +510,6 @@ char **yon_char_parsed_rip(char **char_string, int *size, int item_to_delete){
return new_char_parsed ;
}
/**yon_char_parsed_check_exist(char **parameters, int size, char *param)
* [ EN ]
* Checks if [ parameters ] string array of length [ size ]
* has [ param ] element ;
* [ RU ]
* П р о в е р я е т е с т ь л и в м а с с и в е с т р о к [ parameters ] , р а з м е р а [ size ]
* э л е м е н т [ param ]
*/
int yon_char_parsed_check_exist ( char * * parameters , int size , char * param ) {
for ( int i = 0 ; i < size ; i + + ) {
@ -747,14 +522,6 @@ int yon_char_parsed_check_exist(char **parameters, int size, char *param){
return - 1 ;
}
/**yon_char_parsed_check_repeats(char **parameters, int size)
* [ EN ]
* Checks if [ parameters ] string array of length [ size ]
* has repeated elements ;
* [ RU ]
* П р о в е р я е т е с т ь л и в м а с с и в е с т р о к [ parameters ] , р а з м е р а [ size ]
* п о в т о р е н и я
*/
int yon_char_parsed_check_repeats ( char * * parameters , int size , int * first_overlap , int * second_overlap ) {
if ( parameters ) {
* first_overlap = 0 ;
@ -771,13 +538,6 @@ int yon_char_parsed_check_repeats(char **parameters, int size, int *first_overla
return 0 ;
}
/**yon_char_parsed_includes_char_parsed (config_str source, config_str to_check, int source_size, int check_size)
* [ EN ]
*
* [ RU ]
* П р о в е р я е т , в к л ю ч а е т л и в с е б я [ source ] р а з м е р а [ source_size ]
* м а с с и в с т р о к [ to_check ] р а з м е р а [ check_size ]
*/
int yon_char_parsed_includes_char_parsed ( config_str source , config_str to_check , int source_size , int check_size ) {
int overall_found = 0 ;
for ( int i = 0 ; i < source_size ; i + + ) {
@ -791,13 +551,6 @@ int yon_char_parsed_includes_char_parsed (config_str source, config_str to_check
else return 0 ;
}
/**yon_char_parsed_new (config_str old, int *old_size, ...)
* [ EN ]
*
* [ RU ]
* С о з д а ё т н о в ы й м а с с и в с т р о к . В [ size ] в ы г р у ж а е т с я е г о р а з м е р
* [ . . . ] - н е о г р а н и ч е н н о е к о л и ч е с т в о с т р о к .
*/
config_str yon_char_parsed_new ( int * size , . . . ) {
va_list arglist ;
config_str new_parsed = NULL ;
@ -823,12 +576,6 @@ void yon_char_parsed_free(config_str source, int size){
free ( source ) ;
}
/**yon_char_parsed_copy(config_str *source, config_str *to_copy)
* [ EN ]
*
* [ RU ]
* К о п и р у е т м а с с и в с т р о к [ to_copy ] в [ source ]
*/
void yon_char_parsed_copy ( config_str * source , config_str * to_copy ) {
if ( source & & ! * source & & to_copy ) {
int size = 0 ;
@ -840,12 +587,6 @@ void yon_char_parsed_copy(config_str *source, config_str *to_copy){
}
}
/**config_str yon_char_parsed_append(config_str parsed, int *size, char *string)
* [ EN ]
* Adds [ string ] at the end of [ parsed ] string array of [ size ] length .
* [ RU ]
* Д о б а в л я е т с т р о к у [ string ] в к о н е ц м а с с и в а с т р о к [ parsed ] с д л и н н о й [ size ] .
*/
config_str yon_char_parsed_append ( config_str parsed , int * size , char * string ) {
config_str new_parsed = realloc ( parsed , ( * size + 1 ) * sizeof ( char * ) ) ;
new_parsed [ ( * size ) ] = yon_char_new ( string ) ;
@ -853,24 +594,11 @@ config_str yon_char_parsed_append(config_str parsed, int *size, char *string){
return new_parsed ;
}
/**yon_ubl_check_root()
* [ EN ]
*
* [ RU ]
* В о з в р а щ а е т 1 е с л и п р и л о ж е н и е б ы л о з а п у щ е н о о т root
*/
int yon_ubl_check_root ( ) {
if ( getuid ( ) = = 0 ) return 1 ;
else return 0 ;
}
/**yon_ubl_root_user_get()
* [ EN ]
*
* [ RU ]
* В о з в р а щ а е т и м я п о л ь з о в а т е л я .
* Е с л и п о л ь з о в а т е л ь з а п у с т и л п р и л о ж е н и е ч е р е з root , в ы в о д и т с я и м я п о л ь з о в а т е л я , з а п у с т и в ш е г о п р и л о ж е н и е ч е р е з root
*/
char * yon_ubl_root_user_get ( ) {
char * user = NULL ;
if ( yon_ubl_check_root ( ) ) {
@ -912,12 +640,6 @@ config_str yon_ubl_get_all_users(int *user_size){
// parsing functions
/** yon_size_convert_automatic(int bytes, int *size)
* [ EN ]
*
* [ RU ]
*
*/
float yon_size_convert_automatic ( int bytes , int * size ) {
float byte_float = bytes ;
for ( * size = - 1 ; byte_float > 1024 ; * size = * size + 1 ) {
@ -1045,16 +767,6 @@ apps *yon_apps_get_by_name(apps *applist, char *name, int size)
return NULL ;
} ;
/**
* yon_dir_get_contents ( char * dir_path , int * size )
* [ EN ]
*
* [ RU ]
* П р о в е р я е т с у щ е с т в у е т л и п а п к а [ dir_path ] и
* в о з в р а щ а е т с п и с о к в с е х в л о ж е н н ы х ф а й л о в и п а п о к ,
* п е р е д а в а я в [ size ] д л и н у с п и с к а .
*/
config_str yon_dir_get_contents ( char * dir_path , int * size ) {
config_str dir = NULL ;
* size = 0 ;
@ -1112,13 +824,6 @@ static yon_config_parameter *__yon__config__strings = NULL;
# define yon_config_parameter_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_config_parameter_new_with_data(key,data); \
else dict = yon_config_parameter_append_with_data ( dict , key , data ) ; }
/**yon_config_load_register(char *command)
* [ EN ]
*
* [ RU ]
* В ы п о л н я е т к о м а н д у [ command ] .
* П о л у ч е н н ы е д а н н ы е п а р с я т с я и р е г и с т р и р у ю т с я в к о н ф и г .
*/
int yon_config_load_register ( YON_CONFIG_TYPE config_type , char * section , char * parameter , . . . ) {
if ( __yon__config__strings ) {
__yon__config__strings = yon_dictionary_free_all ( ( dictionary * ) __yon__config__strings , NULL ) ;
@ -1163,12 +868,6 @@ int yon_config_load_register(YON_CONFIG_TYPE config_type,char *section,char *par
else return 0 ;
}
/**yon_config_remove_by_key(char *key)
* [ EN ]
*
* [ RU ]
* У д а л я е т п а р а м е т р к о н ф и г а п о к л ю ч у [ key ]
*/
int yon_config_remove_by_key ( char * key ) {
check_config {
dictionary * dict = yon_dictionary_get ( ( dictionary * * ) & __yon__config__strings , key ) ;
@ -1180,12 +879,6 @@ int yon_config_remove_by_key(char *key){
return 0 ;
}
/**yon_config_remove_element(char *key, char *deleted)
* [ EN ]
*
* [ RU ]
* У д а л я е т э л е м е н т [ deleted ] и з м а с с и в а п а р а м е т р о в с к л ю ч о м [ key ]
*/
int yon_config_remove_element ( char * key , char * deleted ) {
check_config {
yon_config_parameter * dict = ( yon_config_parameter * ) yon_dictionary_get ( ( dictionary * * ) & __yon__config__strings , key ) ;
@ -1207,12 +900,6 @@ int yon_config_remove_element(char *key, char *deleted){
} else return 0 ;
}
/**yon_config_get_by_key(char *key)
* [ EN ]
*
* [ RU ]
* В о з в р а щ а е т з н а ч е н и е п а р а м е т р а к о н ф и г а с к л ю ч о м [ key ]
*/
void * yon_config_get_by_key ( char * key ) {
check_config {
dictionary * dict = NULL ;
@ -1240,31 +927,6 @@ void *yon_config_get_all_by_key(char *key, int *size){
}
}
/**yon_config_get_key_by_data(char *data)
* [ EN ]
*
* [ RU ]
* В о з в р а щ а е т к л ю ч п а р а м е т р а к о н ф и г а с о з н а ч е н и е м [ data ] .
* Е с л и п а р а м е т р с т а к и м з н а ч е н и е м н е н а й д е н , в о з в р а щ а е т с я NULL
*/
char * yon_config_get_key_by_data ( char * data ) {
check_config {
dictionary * dict = NULL ;
for_dictionaries ( dict , ( dictionary * ) __yon__config__strings ) {
if ( strcmp ( ( ( char * ) dict - > data ) , data ) = = 0 ) {
return dict - > key ;
}
}
}
return NULL ;
}
/**yon_config_set(char *key, void *data)
* [ EN ]
*
* [ RU ]
* П р о и з в о д и т п о и с к п о к о н ф и г у и з а м е н я е т з н а ч е н и е п а р а м е т р а с к л ю ч о м [ key ] н а н о в о е з н а ч е н и е [ data ] ;
*/
int yon_config_set ( char * key , void * data ) {
check_config {
yon_config_parameter * dict = ( yon_config_parameter * ) yon_dictionary_get ( ( dictionary * * ) & __yon__config__strings , key ) ;
@ -1274,13 +936,6 @@ int yon_config_set(char *key, void *data){
} else return 0 ;
}
/**yon_config_append(char *key, void *data)
* [ EN ]
*
* [ RU ]
* П р о и з в о д и т п о и с к п о к о н ф и г у и д о п о л н я е т з н а ч е н и е п а р а м е т р а с к л ю ч о м [ key ] з н а ч е н и е м [ data ] ;
*/
int yon_config_append ( char * key , char * data ) {
check_config {
yon_config_parameter * dict = ( yon_config_parameter * ) yon_dictionary_get ( ( dictionary * * ) & __yon__config__strings , key ) ;
@ -1292,13 +947,6 @@ int yon_config_append(char *key, char *data){
} else return 0 ;
}
/**yon_config_clean()
* [ EN ]
* Erase all parameters from config ;
* [ RU ]
* У д а л я е т в с е п а р а м е т р ы и з к о н ф и г а ;
*/
int yon_config_clean ( ) {
check_config {
__yon__config__strings = ( yon_config_parameter * ) yon_dictionary_free_all ( ( dictionary * ) __yon__config__strings , NULL ) ;
@ -1307,14 +955,6 @@ int yon_config_clean(){
else return 0 ;
}
/**yon_config_register(char *key, void *data)
* [ EN ]
*
* [ RU ]
* Р е г и с т р и р у е т н о в ы й п а р а м е т р к о н ф и г а .
* [ key ] - к л ю ч п а р а м е т р а ;
* [ data ] - з н а ч е н и е п а р а м е т р а ;
*/
void yon_config_register ( char * key , char * config_section , void * data ) {
if ( ! __yon__config__strings | | ! yon_dictionary_get ( ( dictionary * * ) & __yon__config__strings , key ) ) {
yon_config_parameter_add_or_create_if_exists_with_data ( __yon__config__strings , key , data ) ;
@ -1325,13 +965,6 @@ void yon_config_register(char *key, char *config_section, void *data){
__yon__config__strings - > section = yon_char_new ( config_section ) ;
}
/**yon_config_load(char *command, int *str_len)
* [ EN ]
*
* [ RU ]
* В ы п о л н я е т к о м а н д у [ command ] и в о з в р а щ а е т р а с п а р ш е н ы й р е з у л ь т а т в ы п о л н е н и я к о м а н д ы .
* В [ str_len ] в о з в р а щ а е т с я д л и н а в о з в р а щ а е м о г о м а с с и в а
*/
config_str yon_config_load ( char * command , int * str_len ) {
FILE * output = popen ( command , " r " ) ;
char * * output_strings = NULL ;
@ -1359,18 +992,6 @@ config_str yon_config_load(char *command, int *str_len){
}
}
/**int yon_config_save_registered(char *path)
* [ EN ]
* Saves config at [ path ] config .
* [ path ] can be :
* system
* global
* [ RU ]
* С о х р а н я е т к о н ф и г у р а ц и ю в [ path ] к о н ф и г .
* [ path ] м о ж е т б ы т ь
* system - л о к а л ь н ы й к о н ф и г
* global - г л о б а л ь н ы й к о н ф и г
*/
int yon_config_save_registered ( char * path ) {
check_config {
dictionary * dct ;
@ -1404,18 +1025,6 @@ int yon_config_save_registered(char *path){
} else return 1 ;
}
/**int yon_config_force_save_registered(char *path, char *section)
* [ EN ]
* Force config to save at [ path ] config ignoring parameter save status .
* [ path ] can be :
* system
* global
* [ RU ]
* П р и н у д и т е л ь н о с о х р а н я е т к о н ф и г у р а ц и ю в [ path ] к о н ф и г и г н о р и р у я с т а т у с п а р а м е т р а .
* [ path ] м о ж е т б ы т ь
* system - л о к а л ь н ы й к о н ф и г
* global - г л о б а л ь н ы й к о н ф и г
*/
int yon_config_force_save_registered ( char * path ) {
check_config {
dictionary * dct ;
@ -1448,13 +1057,6 @@ int yon_config_force_save_registered(char *path){
} else return 1 ;
}
/**yon_config_get_all(int *size)
* [ EN ]
*
* [ RU ]
* В о з в р а щ а е т м а с с и в с о в с е м и п а р а м е т р а м и к о н ф и г а , о к а н ч и в а ю щ а я с я NULL
* [ size ] - у к а з а т е л ь , в к о т о р ы й в ы г р у ж а е т с я д л и н а м а с с и в а
*/
config_str yon_config_get_all ( int * size ) {
check_config {
* size = 1 ;
@ -1472,14 +1074,6 @@ config_str yon_config_get_all(int *size){
} else return NULL ;
}
/**char *yon_config_get_parameter(config parameters, int size, char *param)
* [ EN ]
* Gets parameter [ param ] from parameter list [ parameters ] of size [ size ] ;
* or NULL if nothing were found
* [ RU ]
* В о з в р а щ а е т п а р а м е т р [ param ] и з м а с с и в а с т р о к [ parameters ] р а з м е р о м [ size ]
* и л и NULL е с л и т а к о й н е б ы л н а й д е н
*/
char * yon_config_get_parameter ( config_str parameters , int size , char * param )
{
if ( param [ 0 ] = = ' ' )
@ -1518,13 +1112,6 @@ config_str yon_file_open(char *file_path, int *size){
}
}
/**yon_file_create(char *path, char *name, int rules)
* [ EN ]
*
* [ RU ]
* С о з д а т ь ф а й л с н а з в а н и е м [ name ] , н а х о д я щ и м с я п о п у т и [ path ]
* С п р а в а м и д о с т у п а [ rules ] ( о т 0000 д о 0777 )
*/
int yon_file_create ( char * path , char * name , int rules ) {
if ( path & & name ) {
char * full_path = yon_char_unite ( path , " / " , name , NULL ) ;
@ -1545,13 +1132,6 @@ int yon_file_create(char *path, char *name, int rules){
}
}
/**yon_file_create_full_path(char *path, char *name, int rules)
* [ EN ]
*
* [ RU ]
* С о з д а т ь ф а й л п о п у т и [ path ]
* С п р а в а м и д о с т у п а [ rules ] ( о т 0000 д о 0777 )
*/
int yon_file_create_full_path ( char * path , int rules ) {
if ( path ) {
if ( access ( path , F_OK ) ) {
@ -1573,12 +1153,6 @@ int yon_file_create_full_path(char *path, int rules){
// terminal-using functions
/**yon_launch_app_with_arguments(char *name, char *args)
* [ EN ]
* Execute [ command ] in separate thread ;
* [ RU ]
* В ы п о л н и т ь к о м а н д у [ command ] в о т д е л ь н о м п о т о к е ;
*/
int yon_launch_app_with_arguments ( char * name , char * args )
{
char * path = yon_char_unite ( " /usr/bin/ " , name , " " , args , NULL ) ;
@ -1588,12 +1162,6 @@ int yon_launch_app_with_arguments(char *name, char *args)
pthread_create ( & thread_id , NULL , ( void * ) yon_launch , command ) ;
} ;
/**yon_launch(char *command)
* [ EN ]
* Execute command [ command ]
* [ RU ]
* В ы п о л н и т ь к о м а н д у [ command ]
*/
void yon_launch ( char * command )
{
system ( command ) ;
@ -1616,17 +1184,6 @@ static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer
else vte_terminal_feed_child ( VTE_TERMINAL ( terminal ) , ( char * ) user_data , strlen ( ( char * ) user_data ) ) ;
}
/**
* void yon_terminal_integrated_launch ( GtkWidget * place_to_show , void * endwork_function , void * endwork_function_argument )
* [ EN ]
* launches terminal with specific [ command ] ,
* terminal is shown in [ place_to_show ] container ,
* after terminal done its work [ endwork_function ] is called with [ endwork_function_argument ] argument .
* [ RU ]
* З а п у с к а е т т е р м и н а л с к о м а н д о й [ command ] ,
* т е р м и н а л д о б а в л я е т с я в к о н т е й н е р [ place_to_show ] в и д ж е т а ,
* п о с л е з а в е р ш е н и я р а б о т ы т е р м и н а л а в ы з ы в а е т с я ф у н к ц и я [ endwork_function ] с а р г у м е н т о м [ endwork_function_argument ] .
*/
void yon_terminal_integrated_launch ( GtkWidget * place_to_show , char * command , void * endwork_function , void * endwork_function_argument ) {
char * * commands = new_arr ( char * , 2 ) ;
gchar * * envp = g_get_environ ( ) ;
@ -1672,16 +1229,6 @@ void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, voi
gtk_widget_show_all ( terminal ) ;
}
/**yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument)
* [ EN ]
* launches terminal with specific [ command ] ,
* terminal is shown in [ place_to_show ] container ,
* after terminal done its work [ endwork_function ] is called with [ endwork_function_argument ] argument .
* [ RU ]
* З а п у с к а е т т е р м и н а л с к о м а н д о й [ command ] ,
* т е р м и н а л д о б а в л я е т с я в к о н т е й н е р [ place_to_show ] в и д ж е т а ,
* п о с л е з а в е р ш е н и я р а б о т ы т е р м и н а л а в ы з ы в а е т с я ф у н к ц и я [ endwork_function ] с а р г у м е н т о м [ endwork_function_argument ] .
*/
void yon_terminal_integrated_start ( GtkWidget * terminal , char * command , void * endwork_function , void * endwork_function_argument ) {
char * * commands = new_arr ( char * , 2 ) ;
gchar * * envp = g_get_environ ( ) ;
@ -1839,12 +1386,6 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end
}
}
/**yon_window_config_setup(GtkWindow *window)
* [ EN ]
*
* [ RU ]
* У с т а н а в л и в а е т у к а з а т е л ь н а о к н о д л я о т с л е ж и в а н и я е г о п о л о ж е н и я и р а з м е р а
*/
void yon_window_config_setup ( GtkWindow * window ) {
__yon_window_config_target_window = window ;
g_signal_connect ( G_OBJECT ( window ) , " delete-event " , G_CALLBACK ( yon_on_configured_window_destroy ) , NULL ) ;
@ -1856,12 +1397,6 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end
if ( __yon_main_window_config . fullscreen = = 1 ) gtk_window_maximize ( __yon_window_config_target_window ) ;
}
/**yon_window_config_load(char *path)
* [ EN ]
*
* [ RU ]
* З а г р у ж а е т к о н ф и г о к н а и и н и ц и а л и з и р у е т о т с л е ж и в а н и е е г о п а р а м е т р о в
*/
int yon_window_config_load ( char * path ) {
__yon_window_config_file = g_key_file_new ( ) ;
__yon_window_config_path = yon_char_new ( path ) ;
@ -1925,12 +1460,6 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end
return key ;
}
/**yon_window_config_add_custom_parameter(GtkWidget *widget, char *param_name, char *widget_property)
* [ EN ]
*
* [ RU ]
* Д о б а в л я е т п а р а м е т р в и д ж е т а [ widget ] п о н а з в а н и ю [ widget_property ] д л я о т с л е ж и в а н и я и с о х р а н я е т е г о в к о н ф и г п о д к л ю ч о м [ param_name ] .
*/
void yon_window_config_add_listener ( GtkWidget * widget , char * param_name , char * widget_property , enum YON_TYPE val_type ) {
__yon_listener_parameter * param = NULL ;
param = yon_remalloc ( param , sizeof ( __yon_listener_parameter ) ) ;
@ -2107,12 +1636,6 @@ GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){
// other Gtk functions
/**yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size)
* [ EN ]
*
* [ RU ]
* Д о б а в л я е т в К о м б о б о к с [ combo ] в с е с т р о к и и з м а с с и в а с т р о к [ parameters ] р а з м е р а [ size ]
*/
int yon_gtk_combo_box_fill ( GtkWidget * combo , config_str parameters , int size ) {
if ( combo & & parameters ) {
for ( int i = 0 ; i < size ; i + + ) {
@ -2123,13 +1646,6 @@ int yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size){
return 0 ;
}
/**yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find)
* [ EN ]
*
* [ RU ]
* П р о и в з о д и т п о и с к п о GtkComboBoxText [ combo_box ]
* в о з в р а щ а е т 1 е с л и э л е м е н т [ text_to_find ] н а й д е н , и н а ч е в о з в р а щ а е т 0
*/
int yon_gtk_combo_box_text_find ( GtkWidget * combo_box , char * text_to_find ) {
if ( combo_box & & text_to_find ) {
int active = gtk_combo_box_get_active ( GTK_COMBO_BOX ( combo_box ) ) ;
@ -2148,15 +1664,6 @@ void yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column){
gtk_tree_view_column_set_min_width ( column , width ) ;
}
/**yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...)
* [ EN ]
*
* [ RU ]
* Д о б в л я е т [ destination ] в с е в и д ж е т ы , п р о п и с а н н ы е п о с л е [ padding ] . Д о б а в л е н и е п р о и с х о д и т с н а ч а л а к о н т е й н е р а .
* [ expand ] - р а с ш и р я е м о с т ь в ы д е л е н н о г о д л я в и д ж е т о в м е с т а
* [ fill ] - з а п о л н я т ь л и в и д ж е т о м в с ё е м у в ы д е л е н н о е м е с т о
* [ padding ] - о т с т у п о д д р у г и х э л е м е н т о в
*/
int yon_dictionary_gtk_pack_start_multiple_widgets ( GtkBox * destination , gboolean expand , gboolean fill , int padding , . . . ) {
va_list args ;
va_start ( args , padding ) ;
@ -2168,15 +1675,6 @@ int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean
return 1 ;
}
/**yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...)
* [ EN ]
*
* [ RU ]
* Д о б в л я е т в [ destination ] в с е в и д ж е т ы , п р о п и с а н н ы е п о с л е [ padding ] . Д о б а в л е н и е п р о и с х о д и т с к о н ц а к о н т е й н е р а .
* [ expand ] - р а с ш и р я е м о с т ь в ы д е л е н н о г о д л я в и д ж е т о в м е с т а
* [ fill ] - з а п о л н я т ь л и в и д ж е т о м в с ё е м у в ы д е л е н н о е м е с т о
* [ padding ] - о т с т у п о д д р у г и х э л е м е н т о в
*/
int yon_dictionary_gtk_pack_end_multiple_widgets ( GtkBox * destination , gboolean expand , gboolean fill , int padding , . . . ) {
va_list args ;
va_start ( args , padding ) ;
@ -2366,24 +1864,6 @@ void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int ti
}
}
/**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)
* [ EN ]
* Set up plugs for using with GtkSockets insine ubl - settings - manager .
* [ main_window ] is container widget , which holds main application functionality .
* [ left_window ] is container widget , which holds widgets , have to be shown at left part of ubl - settings - manager header .
* [ right_window ] is container widget , which holds widgets , have to be shown at right part of ubl - settings - manager header .
* [ socket_main_id ] is id of socket for [ main_window ] .
* [ socket_left_id ] is id of socket for [ left_window ] .
* [ socket_right_id ] is id of socket for [ right_window ] .
* [ RU ]
* Н а с т р а и в а е т п л а г и д л я р а б о т ы с с о к е т а м и в у т и л и т е ubl - settings - manager .
* [ main_window ] - к о н т е й н е р о с н о в н о г о и н т е р ф е й с а п р и л о ж е н и я .
* [ left_window ] - к о н т е й н е р д л я в и д ж е т о в к о т о р ы е д о л ж н ы о т о б р а ж а т ь с я в л е в о й ч а с т и ш а п к и ubl - settings - manager .
* [ right_window ] - к о н т е й н е р д л я в и д ж е т о в к о т о р ы е д о л ж н ы о т о б р а ж а т ь с я в п р а в о й ч а с т и ш а п к и ubl - settings - manager .
* [ socket_main_id ] - id с о к е т а д л я [ main_window ] .
* [ socket_left_id ] - id с о к е т а д л я [ left_window ] .
* [ socket_right_id ] - id с о к е т а д л я [ right_window ] .
*/
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 ) {
if ( main_window & & socket_main_id > - 1 ) {
gtk_widget_hide ( gtk_widget_get_toplevel ( main_window ) ) ;
@ -2447,12 +1927,6 @@ void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWi
# ifdef WEBKIT_FOUND
/**yon_ubl_browser_window_open(char *link, char *browser_window_name)
* [ EN ]
* Launches integrated browser window , named [ browser_window_name ] at header with [ link ] .
* [ RU ]
* О т к р ы в а е т в с т р о е н н ы й б р а у з е р с и м е н е м [ browser_window_name ] и п о к а з ы в а е м о й с т р а н и ц е й п о с с ы л к е [ link ]
*/
void yon_ubl_browser_window_open ( char * link , char * browser_window_name ) {
GtkWidget * browser = gtk_window_new ( GTK_WINDOW_TOPLEVEL ) ;
GtkWidget * web_place = gtk_box_new ( GTK_ORIENTATION_VERTICAL , 0 ) ;
@ -2471,14 +1945,6 @@ void yon_ubl_browser_window_open(char *link, char *browser_window_name){
}
# else
/**yon_ubl_browser_window_open(char *link, char *browser_window_name)
* [ EN ]
* Launches browser with [ link ] .
* [ browser_window_name ] is ' t used . It ' s needed for compatibility with webkit version of that function .
* [ RU ]
* О т к р ы в а е т б р а у з е р с о с т р а н и ц е й п о с с ы л к е [ link ]
* [ browser_window_name ] н е и с п о л ь з у е т с я . Н у ж н а д л я с о в м е с т и м о с т и с webkit в е р с и е й э т о й ф у н к ц и и .
*/
void yon_ubl_browser_window_open ( char * link , char * browser_window_name ) {
char * user = getenv ( " SUDO_USER " ) ;
if ( ! user )