QString HDHRStreamHandler::TunerGet( const QString &name, bool report_error_return, bool print_error) const { QMutexLocker locker(&_hdhr_lock); if (!_hdhomerun_device) { LOG(VB_GENERAL, LOG_ERR, LOC + "Get request failed (not connected)"); return QString::null; } QString valname = QString("/tuner%1/%2").arg(_tuner).arg(name); char *value = NULL; char *error = NULL; if (hdhomerun_device_get_var( _hdhomerun_device, valname.toLocal8Bit().constData(), &value, &error) < 0) { LOG(VB_GENERAL, LOG_ERR, LOC + "Get request failed" + ENO); return QString::null; } if (report_error_return && error) { if (print_error) { LOG(VB_GENERAL, LOG_ERR, LOC + QString("DeviceGet(%1): %2") .arg(name).arg(error)); } return QString::null; } return QString(value); }
static int cmd_execute(void) { char *ret_value; char *ret_error; if (hdhomerun_device_get_var(hd, "/sys/boot", &ret_value, &ret_error) < 0) { fprintf(stderr, "communication error sending request to hdhomerun device\n"); return -1; } if (ret_error) { printf("%s\n", ret_error); return 0; } char *end = ret_value + strlen(ret_value); char *pos = ret_value; while (1) { if (pos >= end) { break; } char *eol_r = strchr(pos, '\r'); if (!eol_r) { eol_r = end; } char *eol_n = strchr(pos, '\n'); if (!eol_n) { eol_n = end; } char *eol = eol_r; if (eol_n < eol) { eol = eol_n; } char *sep = strchr(pos, ' '); if (!sep || sep > eol) { pos = eol + 1; continue; } *sep = 0; *eol = 0; char *item = pos; char *value = sep + 1; printf("set %s \"%s\"\n", item, value); cmd_set_internal(item, value); pos = eol + 1; } return 1; }
static int cmd_get(const char *item) { char *ret_value; char *ret_error; if (hdhomerun_device_get_var(hd, item, &ret_value, &ret_error) < 0) { fprintf(stderr, "communication error sending request to hdhomerun device\n"); return -1; } if (ret_error) { printf("%s\n", ret_error); return 0; } printf("%s\n", ret_value); return 1; }