MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / main

Function main

examples/interfaces/10.backup.cpp:84–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82
83
84int main()
85{
86 int rc = 0;
87
88 // Status wrapper
89 ThrowStatusWrapper status(master->getStatus());
90
91 // Declare pointers to required interfaces
92 IProvider* prov = master->getDispatcher();
93 IUtil* utl = master->getUtilInterface();
94 IService* svc = NULL;
95 IXpbBuilder* spb1 = NULL;
96 IXpbBuilder* spb2 = NULL;
97
98 try
99 {
100 printf("** Attaching to service manager...\n");
101
102 // Prepare SPB to attach to service manager
103 spb1 = utl->getXpbBuilder(&status, IXpbBuilder::SPB_ATTACH, NULL, 0);
104 spb1->insertString(&status, isc_spb_user_name, "sysdba");
105 spb1->insertString(&status, isc_spb_password, "masterkey");
106 // In case when your program is expected to be used on a server
107 // with multiple security database it's very good idea to specify
108 // DB expected to be used by services (you anyway need separate
109 // services connectons for databases with different user list location).
110 spb1->insertString(&status, isc_spb_expected_db, "employee.fdb");
111
112 // Attach to service manager
113 svc = prov->attachServiceManager(&status, "service_mgr", spb1->getBufferLength(&status),
114 spb1->getBuffer(&status));
115
116 // In the simplest case sendItems parameter may be NULL
117 // Building receiveItems is mostly trivial
118 const unsigned char receiveItems[] = {isc_info_svc_server_version};
119
120 // Output buffer
121 unsigned char results[1024];
122
123 printf("** Demo of making backup using service manager...\n");
124
125 // Build service start SPB
126 spb2 = utl->getXpbBuilder(&status, IXpbBuilder::SPB_START, NULL, 0);
127 spb2->insertTag(&status, isc_action_svc_backup);
128 spb2->insertString(&status, isc_spb_dbname, "employee.fdb");
129 spb2->insertString(&status, isc_spb_bkp_file, "employee.fbk");
130 spb2->insertInt(&status, isc_spb_options, isc_spb_bkp_no_garbage_collect);
131
132 // Start service
133 svc->start(&status, spb2->getBufferLength(&status), spb2->getBuffer(&status));
134
135 // Prepare receiveItems block
136 const unsigned char receiveItems2[] = {isc_info_svc_line};
137
138 // Query service output
139 do
140 {
141 svc->query(&status, 0, NULL, sizeof(receiveItems2), receiveItems2, sizeof(results), results);

Callers

nothing calls this directly

Calls 15

printInfoFunction · 0.70
getStatusMethod · 0.45
getDispatcherMethod · 0.45
getUtilInterfaceMethod · 0.45
getXpbBuilderMethod · 0.45
insertStringMethod · 0.45
attachServiceManagerMethod · 0.45
getBufferLengthMethod · 0.45
getBufferMethod · 0.45
insertTagMethod · 0.45
insertIntMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected