/** \details Initialize mapistore named properties MySQL backend \param mem_ctx pointer to the memory context \param lp_ctx pointer to the loadparm context \param nprops_ctx pointer on pointer to the namedprops context to return \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error */ enum mapistore_error mapistore_namedprops_mysql_init(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, struct namedprops_context **nprops_ctx) { enum mapistore_error retval; struct namedprops_context *nprops = NULL; struct namedprops_mysql_params parms; MYSQL *conn = NULL; /* Sanity checks */ MAPISTORE_RETVAL_IF(!lp_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL); MAPISTORE_RETVAL_IF(!nprops_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL); /* Retrieve smb.conf arguments */ retval = mapistore_namedprops_mysql_parameters(lp_ctx, &parms); if (retval != MAPISTORE_SUCCESS) { DEBUG(0, ("[%s:%d] ERROR: parsing MySQL named properties " "parametric option failed with %s\n", __FUNCTION__, __LINE__, mapistore_errstr(retval))); MAPISTORE_RETVAL_ERR(retval, NULL); } /* Establish MySQL connection */ if (parms.sock) { // FIXME DEBUG(0, ("Not implemented connect through unix socket to mysql")); } else { char *connection_string = connection_string_from_parameters(mem_ctx, &parms); MAPISTORE_RETVAL_IF(!connection_string, MAPISTORE_ERR_NOT_INITIALIZED, NULL); create_connection(connection_string, &conn); } MAPISTORE_RETVAL_IF(!conn, MAPISTORE_ERR_NOT_INITIALIZED, NULL); /* Initialize the database */ if (!is_schema_created(conn) || is_database_empty(conn)) { retval = initialize_database(conn, parms.data); MAPISTORE_RETVAL_IF(retval != MAPISTORE_SUCCESS, retval, NULL); } /* Create context */ nprops = talloc_zero(mem_ctx, struct namedprops_context); MAPISTORE_RETVAL_IF(!nprops, MAPISTORE_ERR_NO_MEMORY, NULL); nprops->backend_type = NAMEDPROPS_BACKEND_MYSQL; nprops->create_id = create_id; nprops->get_mapped_id = get_mapped_id; nprops->get_nameid = get_nameid; nprops->get_nameid_type = get_nameid_type; nprops->next_unused_id = next_unused_id; nprops->transaction_commit = transaction_commit; nprops->transaction_start = transaction_start; nprops->data = conn; talloc_set_destructor(nprops, mapistore_namedprops_mysql_destructor); *nprops_ctx = nprops; return MAPISTORE_SUCCESS; }
} END_TEST START_TEST (test_initialize_database) { enum mapistore_error retval; /* test sanity checks */ retval = initialize_database(NULL, NULL); ck_assert_int_eq(retval, MAPISTORE_ERR_DATABASE_INIT); ck_assert(is_database_empty(conn) == true); retval = initialize_database(conn, NAMEDPROPS_MYSQL_SCHEMA_PATH); ck_assert_int_eq(retval, MAPISTORE_SUCCESS); ck_assert(is_database_empty(conn) == false); } END_TEST
int main() { struct _database_ db; char command[20], username[20], password[20], name[20]; printf("Done check 0\n"); scanf("%s",&command); if(!strcmp(command,"create")) { printf("Enter Username and Password\n"); printf("Username: "******"%s", &username); printf("Password: "******"%s", &password); } initialize_database(&db,username,password); printf("Done check 1\n"); create_schema(&db); printf("Done check 2\n"); printf("Enter Project Name: ") scanf("%s", name); int id=create_new_project(&db,name); printf("id = %d SUCCESS\n",id); add_single_file(&db,1,"C:\\Users\\Jatinder Dhawan\\Desktop\\git\\abc.png",3); printf("=======================\n"); find_in_database(&db,"C:\\Users\\Jatinder Dhawan\\Desktop\\git\\abc.png","C:\\Users\\Jatinder Dhawan\\Desktop\\git\\abc.png"); printf("=======================\n"); get_project_id(&db,"git_pro"); struct file_list* start=(struct file_list*)malloc(sizeof(struct file_list)); struct file_list*make=start; start->_version =5; start->number_of_files=3; start->name="sjvndfjv"; start->path="C:\\Users\\Jatinder Dhawan\\Desktop\\database\\credentials.txt"; start->next=(struct file_list*)malloc(sizeof(struct file_list)); start=start->next; start->_version =5; start->number_of_files=3; start->name="sjvndfjv"; start->path="C:\\Users\\Jatinder Dhawan\\Desktop\\database\\tempo.txt"; start->next=NULL; add_multiple_file(&db,make,1,3); update_project_version(&db,"git_pro"); return 0 ; }
int main(int argc, char* argv[]) { if (argc != 2) { std::cerr << "Usage: " << argv[0] << " INFILE\n"; exit(1); } std::string output_format("SQLite"); std::string input_filename(argv[1]); std::string output_filename("multipolygon.db"); OGRDataSource* data_source = initialize_database(output_format, output_filename); osmium::area::ProblemReporterOGR problem_reporter(data_source); osmium::area::Assembler::config_type assembler_config(&problem_reporter); assembler_config.enable_debug_output(); osmium::area::MultipolygonCollector<osmium::area::Assembler> collector(assembler_config); std::cerr << "Pass 1...\n"; osmium::io::Reader reader1(input_filename); collector.read_relations(reader1); reader1.close(); std::cerr << "Pass 1 done\n"; index_type index_pos; index_type index_neg; location_handler_type location_handler(index_pos, index_neg); location_handler.ignore_errors(); TestHandler test_handler(data_source); std::cerr << "Pass 2...\n"; osmium::io::Reader reader2(input_filename); osmium::apply(reader2, location_handler, test_handler, collector.handler([&test_handler](const osmium::memory::Buffer& area_buffer) { osmium::apply(area_buffer, test_handler); })); reader2.close(); std::cerr << "Pass 2 done\n"; OGRDataSource::DestroyDataSource(data_source); OGRCleanupAll(); }