| 1384 | |
| 1385 | |
| 1386 | void SRVR_enum_attachments(ULONG& att_cnt, ULONG& dbs_cnt, ULONG& svc_cnt) |
| 1387 | /************************************** |
| 1388 | * |
| 1389 | * S R V R _ e n u m _ a t t a c h m e n t s |
| 1390 | * |
| 1391 | ************************************** |
| 1392 | * |
| 1393 | * Functional description |
| 1394 | * Queries the service manager to enumerate |
| 1395 | * active attachments to the server. |
| 1396 | * |
| 1397 | **************************************/ |
| 1398 | { |
| 1399 | att_cnt = dbs_cnt = svc_cnt = 0; |
| 1400 | |
| 1401 | // TODO: we need some way to return a number of active services |
| 1402 | // using the service manager. It could be either isc_info_svc_svr_db_info2 |
| 1403 | // that adds the third counter, or a completely new information tag. |
| 1404 | |
| 1405 | DispatcherPtr provider; |
| 1406 | |
| 1407 | static const UCHAR spb_attach[] = |
| 1408 | { |
| 1409 | isc_spb_version, isc_spb_current_version, |
| 1410 | isc_spb_user_name, 6, 'S', 'Y', 'S', 'D', 'B', 'A' |
| 1411 | }; |
| 1412 | |
| 1413 | LocalStatus ls; |
| 1414 | CheckStatusWrapper status(&ls); |
| 1415 | ServService iface(provider->attachServiceManager(&status, "service_mgr", |
| 1416 | sizeof(spb_attach), spb_attach)); |
| 1417 | |
| 1418 | if (iface.hasData()) |
| 1419 | { |
| 1420 | static const UCHAR spb_query[] = {isc_info_svc_svr_db_info}; |
| 1421 | |
| 1422 | UCHAR buffer[BUFFER_XLARGE]; |
| 1423 | iface->query(&status, 0, NULL, sizeof(spb_query), spb_query, sizeof(buffer), buffer); |
| 1424 | const UCHAR* p = buffer; |
| 1425 | |
| 1426 | if ((!(status.getState() & IStatus::STATE_ERRORS)) && *p++ == isc_info_svc_svr_db_info) |
| 1427 | { |
| 1428 | while (*p != isc_info_flag_end) |
| 1429 | { |
| 1430 | switch (*p++) |
| 1431 | { |
| 1432 | case isc_spb_dbname: |
| 1433 | { |
| 1434 | const USHORT length = (USHORT) gds__vax_integer(p, sizeof(USHORT)); |
| 1435 | p += sizeof(USHORT) + length; |
| 1436 | } |
| 1437 | break; |
| 1438 | case isc_spb_num_att: |
| 1439 | att_cnt = (ULONG) gds__vax_integer(p, sizeof(ULONG)); |
| 1440 | p += sizeof(ULONG); |
| 1441 | break; |
| 1442 | case isc_spb_num_db: |
| 1443 | dbs_cnt = (ULONG) gds__vax_integer(p, sizeof(ULONG)); |
no test coverage detected