#include <my_global.h>#include <my_sys.h>#include <m_string.h>#include <hash.h>Include dependency graph for instance_map.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Classes | |
| class | Instance_map |
| class | Instance_map::Iterator |
Functions | |
| int | load_all_groups (char ***groups, const char *filename) |
| void | free_groups (char **groups) |
| int | create_instance_in_file (const LEX_STRING *instance_name, const Named_value_arr *options) |
| int create_instance_in_file | ( | const LEX_STRING * | instance_name, | |
| const Named_value_arr * | options | |||
| ) |
Definition at line 561 of file instance_map.cc.
References Options::Main::config_file, ER_ACCESS_OPTION_FILE, ER_CONF_FILE_DOES_NOT_EXIST, errno, Named_value::get_name(), Named_value::get_value(), LEX_STRING::length, log_error(), MAX_OPTION_LEN, MAX_OPTION_STR_LEN, my_access, my_close(), MY_NABP, my_open(), my_write, MYF, NEWLINE, NEWLINE_LEN, NullS, options(), LEX_STRING::str, strxnmov(), and W_OK.
Referenced by Instance_map::complete_initialization(), and Create_instance::execute().
00563 { 00564 File cnf_file; 00565 00566 if (my_access(Options::Main::config_file, W_OK)) 00567 { 00568 log_error("Error: configuration file (%s) does not exist.", 00569 (const char *) Options::Main::config_file); 00570 return ER_CONF_FILE_DOES_NOT_EXIST; 00571 } 00572 00573 cnf_file= my_open(Options::Main::config_file, O_WRONLY | O_APPEND, MYF(0)); 00574 00575 if (cnf_file <= 0) 00576 { 00577 log_error("Error: can not open configuration file (%s): %s.", 00578 (const char *) Options::Main::config_file, 00579 (const char *) strerror(errno)); 00580 return ER_ACCESS_OPTION_FILE; 00581 } 00582 00583 if (my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP)) || 00584 my_write(cnf_file, (byte*)"[", 1, MYF(MY_NABP)) || 00585 my_write(cnf_file, (byte*)instance_name->str, instance_name->length, 00586 MYF(MY_NABP)) || 00587 my_write(cnf_file, (byte*)"]", 1, MYF(MY_NABP)) || 00588 my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP))) 00589 { 00590 log_error("Error: can not write to configuration file (%s): %s.", 00591 (const char *) Options::Main::config_file, 00592 (const char *) strerror(errno)); 00593 my_close(cnf_file, MYF(0)); 00594 return ER_ACCESS_OPTION_FILE; 00595 } 00596 00597 for (int i= 0; options && i < options->get_size(); ++i) 00598 { 00599 char option_str[MAX_OPTION_STR_LEN]; 00600 char *ptr; 00601 int option_str_len; 00602 Named_value option= options->get_element(i); 00603 00604 ptr= strxnmov(option_str, MAX_OPTION_LEN + 1, option.get_name(), NullS); 00605 00606 if (option.get_value()[0]) 00607 ptr= strxnmov(ptr, MAX_OPTION_LEN + 2, "=", option.get_value(), NullS); 00608 00609 option_str_len= ptr - option_str; 00610 00611 if (my_write(cnf_file, (byte*)option_str, option_str_len, MYF(MY_NABP)) || 00612 my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP))) 00613 { 00614 log_error("Error: can not write to configuration file (%s): %s.", 00615 (const char *) Options::Main::config_file, 00616 (const char *) strerror(errno)); 00617 my_close(cnf_file, MYF(0)); 00618 return ER_ACCESS_OPTION_FILE; 00619 } 00620 } 00621 00622 my_close(cnf_file, MYF(0)); 00623 00624 return 0; 00625 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void free_groups | ( | char ** | groups | ) |
| int load_all_groups | ( | char *** | groups, | |
| const char * | filename | |||
| ) |
1.4.7

