Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int32_t dvbapi_get_descrambler_info(void)
- {
- int32_t ret = 0;
- // In enigma2 all ca devices are listed under adapter0. In addition we only
- // need to ask one ca device to get the total number of descramblers. In
- // PC installations, there are no ca devices, so we use a predefined value.
- if(cfg.dvbapi_boxtype == BOXTYPE_PC || cfg.dvbapi_boxtype == BOXTYPE_PC_NODMX)
- {
- ca_descramblers_total = INDEX_MAX_NET;
- return 1; // nothing else to do for PCs
- }
- int32_t fd = 0, ca_offset = 0;
- char device_path[128], device_path2[128];
- if(cfg.dvbapi_boxtype == BOXTYPE_DUCKBOX ||
- cfg.dvbapi_boxtype == BOXTYPE_DBOX2 ||
- cfg.dvbapi_boxtype == BOXTYPE_UFS910)
- {
- ca_offset = 1;
- }
- // Ask device for exact number of ca descramblers
- snprintf(device_path2, sizeof(device_path2), devices[selected_box].ca_device, ca_offset);
- snprintf(device_path, sizeof(device_path), devices[selected_box].path, 0);
- if (!cs_strncat(device_path, device_path2, sizeof(device_path)))
- return ret;
- DIR *dir = NULL;
- struct dirent *ep = NULL;
- ca_descramblers_total = 0;
- snprintf(device_path2, sizeof(device_path2), devices[selected_box].path, 0);
- if ((dir = opendir(device_path2)) != NULL)
- {
- while ((ep = readdir(dir)) != NULL)
- {
- if (strcmp(ep->d_name, ".") != 0 && strcmp(ep->d_name, "..") != 0)
- {
- // search for ca0, ca1...
- if (ep->d_name[0] == 'c' && ep->d_name[1] == 'a')
- {
- ca_descramblers_total += 1;
- }
- }
- }
- closedir(dir);
- }
- if (ca_descramblers_total > 0)
- {
- cs_log("Detected %s device, total available descramblers: %d", device_path, ca_descramblers_total);
- ret = 1;
- }
- else
- {
- // Use a safe default in case we fail to get the exact number
- ca_descramblers_total = INDEX_MAX_LOCAL;
- cs_log("Detected %s device, guesing safe count of total available descramblers: %d", device_path, ca_descramblers_total);
- ret = 0;
- }
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement