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

Function main

examples/interfaces/09.service.cpp:92–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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
queryMethod · 0.45
insertTagMethod · 0.45
insertIntMethod · 0.45

Tested by

no test coverage detected