コード例 #1
0
ファイル: dtvconfparser.cpp プロジェクト: DocOnDev/mythtv
bool DTVConfParser::ParseConfOFDM(const QStringList &tokens)
{
    DTVChannelInfo chan;
    DTVMultiplex   mux;

    QStringList::const_iterator it = tokens.begin();

    PARSE_SKIP(unknown);
    PARSE_UINT(mux.frequency);
    PARSE_CONF(mux.inversion);
    PARSE_CONF(mux.bandwidth);
    PARSE_CONF(mux.hp_code_rate);
    PARSE_CONF(mux.lp_code_rate);
    PARSE_CONF(mux.modulation);
    PARSE_CONF(mux.trans_mode);
    PARSE_CONF(mux.guard_interval);
    PARSE_CONF(mux.hierarchy);
    PARSE_SKIP(unknown);
    PARSE_SKIP(unknown);
    PARSE_UINT(chan.serviceid);

    AddChannel(mux, chan);

    return true;
}
コード例 #2
0
ファイル: dtvconfparser.cpp プロジェクト: DocOnDev/mythtv
bool DTVConfParser::ParseConfATSC(const QStringList &tokens)
{
    DTVChannelInfo chan;
    DTVMultiplex   mux;

    QStringList::const_iterator it = tokens.begin();

    PARSE_STR(chan.name);
    PARSE_UINT(mux.frequency);
    PARSE_CONF(mux.modulation);
    PARSE_SKIP(Ignore_Video_PID);
    PARSE_SKIP(Ignore_Audio_PID);
    PARSE_UINT(chan.serviceid);

    AddChannel(mux, chan);

    return true;
}
コード例 #3
0
ファイル: dtvconfparser.cpp プロジェクト: DocOnDev/mythtv
bool DTVConfParser::ParseConfQAM(const QStringList &tokens)
{
    DTVChannelInfo chan;
    DTVMultiplex   mux;

    QStringList::const_iterator it = tokens.begin();

    PARSE_SKIP(unknown);
    PARSE_UINT(mux.frequency);
    PARSE_CONF(mux.inversion);
    PARSE_UINT(mux.symbolrate);
    PARSE_CONF(mux.fec);
    PARSE_CONF(mux.modulation);
    PARSE_SKIP(unknown);
    PARSE_SKIP(unknown);
    PARSE_UINT(chan.serviceid);

    AddChannel(mux, chan);

    return true;
}
コード例 #4
0
ファイル: dtvconfparser.cpp プロジェクト: DocOnDev/mythtv
bool DTVConfParser::ParseConfQPSK(const QStringList &tokens)
{
    DTVChannelInfo chan;
    DTVMultiplex   mux;

    QStringList::const_iterator it = tokens.begin();

    PARSE_STR(chan.name);
    PARSE_UINT_1000(mux.frequency);
    PARSE_CONF(mux.polarity);
    PARSE_SKIP(Satelite_Number);
    PARSE_UINT_1000(mux.symbolrate);
    PARSE_SKIP(unknown);
    PARSE_SKIP(unknown);
    PARSE_UINT(chan.serviceid);

    AddChannel(mux, chan);

    return true;
}
コード例 #5
0
ファイル: dtvconfparser.cpp プロジェクト: DocOnDev/mythtv
bool DTVConfParser::ParseVDR(const QStringList &tokens, int channelNo)
{
    DTVChannelInfo chan;
    DTVMultiplex   mux;

    QStringList::const_iterator it = tokens.begin();

    chan.lcn = channelNo;

// BBC ONE:754166:I999B8C34D34M16T2G32Y0:T:27500:600:601, 602:0:0:4168:0:0:0

    PARSE_SKIP(unknown);

    PARSE_UINT_1000(mux.frequency);

    if (it == tokens.end())
        return false;

    QString params = (*it++);
    while (!params.isEmpty())
    {
        QString ori = params;
        int s = (int) (params.toAscii().constData()[0]);
        params = params.mid(1);
        switch (s)
        {
            case 'I':
                mux.inversion.ParseVDR(params);
                break;
            case 'B':
                mux.bandwidth.ParseVDR(params);
                break;
            case 'C':
                mux.hp_code_rate.ParseVDR(params);
                break;
            case 'D':
                mux.lp_code_rate.ParseVDR(params);
                break;
            case 'M':
                mux.modulation.ParseVDR(params);
                break;
            case 'T':
                mux.trans_mode.ParseVDR(params);
                break;
            case 'G':
                mux.guard_interval.ParseVDR(params);
                break;
            case 'Y':
                mux.hierarchy.ParseVDR(params);
                break;
            case 'V':
            case 'H':
            case 'R':
            case 'L':
                mux.polarity.ParseVDR(ori);
                break;
            case 'S':
                mux.mod_sys.ParseVDR(params);
                break;
            case 'O':
                mux.rolloff.ParseVDR(params);
                break;
            default:
                return false;
        }
    }

    for (uint i = 0; i < 6; i++)
        PARSE_SKIP(unknown);

    PARSE_UINT(chan.serviceid);

    AddChannel(mux, chan);

    return true;
}
コード例 #6
0
ファイル: evaprocessinfo.c プロジェクト: novator24/libeva
EvaProcessInfo *
eva_process_info_get (guint          pid,
                      GError       **error)
{
  EvaProcessInfo *rv;
  char *filename = g_strdup_printf ("/proc/%u/stat", pid);
  FILE *fp = fopen (filename, "r");
  char *content;
  const char *at;
  const char *end_name;
  gint dummy_int;
  guint dummy_uint;
  if (fp == NULL)
    {
      /* TODO: remap some error codes,
         like ENOENT to EVA_ERROR_PROCESS_NOT_FOUND. */
      g_set_error (error, EVA_G_ERROR_DOMAIN,
                   eva_error_code_from_errno (errno),
                   "error opening %s: %s",
                   filename, g_strerror (errno));
      g_free (filename);
      return NULL;
    }
  content = eva_stdio_readline (fp);
  if (content == NULL)
    {
      fclose (fp);
      g_set_error (error, EVA_G_ERROR_DOMAIN,
                   EVA_ERROR_NO_DOCUMENT,
                   "expected line of text in %s", filename);
      g_free (filename);
      return NULL;
    }
  fclose (fp);
  fp = NULL;

  rv = g_new (EvaProcessInfo, 1);
  rv->exe_filename = NULL;

  at = content;

#define ERROR_CLEANUP_AND_RETURN()                      \
  G_STMT_START{                                         \
    g_free (rv);                                        \
    g_free (rv->exe_filename);                          \
    g_free (filename);                                  \
    g_free (content);                                   \
    return NULL;                                        \
  }G_STMT_END
#define PARSE_ERROR(type)                               \
  G_STMT_START{                                         \
    g_set_error (error, EVA_G_ERROR_DOMAIN,             \
                 EVA_ERROR_END_OF_FILE,                 \
                 "error parsing %s from %s",            \
                 type, filename);                       \
    ERROR_CLEANUP_AND_RETURN();                         \
  }G_STMT_END
#define PARSE_ERROR_EXPECTED(what)                      \
  G_STMT_START{                                         \
    g_set_error (error, EVA_G_ERROR_DOMAIN,             \
                 EVA_ERROR_END_OF_FILE,                 \
                 "expected %s in %s",                   \
                 what, filename);                       \
    ERROR_CLEANUP_AND_RETURN();                         \
  }G_STMT_END
#define PARSE_INT(lvalue, base)                         \
  G_STMT_START{                                         \
    char *end;                                          \
    lvalue = strtol (at, &end, base);                   \
    if (at == end)                                      \
      PARSE_ERROR ("int");                              \
    at = end;                                           \
    EVA_SKIP_WHITESPACE (at);                           \
  }G_STMT_END
#define PARSE_UINT(lvalue, base)                        \
  G_STMT_START{                                         \
    char *end;                                          \
    lvalue = strtoul (at, &end, base);                  \
    if (at == end)                                      \
      PARSE_ERROR ("uint");                             \
    at = end;                                           \
    EVA_SKIP_WHITESPACE (at);                           \
  }G_STMT_END

  /* 'pid' */
  PARSE_INT (rv->process_id, 0);

  /* 'comm' */
  if (*at != LPAREN)
    PARSE_ERROR_EXPECTED ("left-paren");
  at++;
  end_name = strchr (at, RPAREN);
  if (end_name == NULL)
    PARSE_ERROR_EXPECTED ("right-paren");
  rv->exe_filename = g_strndup (at, end_name - at);
  at = end_name + 1;
  EVA_SKIP_WHITESPACE (at);

  /* 'state' */
  if (*at == 0 || strchr ("RSDZTW", *at) == NULL)
    PARSE_ERROR_EXPECTED ("a valid process state, one of R,S,D,Z,T,W");
  rv->state = *at;
  at++;
  EVA_SKIP_WHITESPACE (at);

  /* 'ppid' */
  PARSE_INT (rv->parent_process_id, 0);

  /* 'pgrp' */
  PARSE_INT (rv->process_group_id, 0);

  /* 'session' */
  PARSE_INT (rv->session_id, 0);

  /* 'tty_nr' */
  PARSE_INT (rv->tty_id, 0);

  /* 'tpgid' */
  PARSE_INT (dummy_int, 0);

  /* 'flags' */
  PARSE_INT (dummy_int, 8);

  /* 'minflt' */
  PARSE_UINT (dummy_uint, 0);
  /* 'cminflt' */
  PARSE_UINT (dummy_uint, 0);
  /* 'majflt' */
  PARSE_UINT (dummy_uint, 0);
  /* 'cmajflt' */
  PARSE_UINT (dummy_uint, 0);

  /* 'utime' */
  PARSE_UINT (rv->user_runtime, 0);
  /* 'stime' */
  PARSE_UINT (rv->kernel_runtime, 0);
  /* 'cutime' */
  PARSE_UINT (rv->child_user_runtime, 0);
  /* 'cstime' */
  PARSE_UINT (rv->child_kernel_runtime, 0);

  /* 'priority' */
  PARSE_INT (dummy_int, 0);

  /* 'nice' */
  PARSE_INT (rv->nice, 0);

  /* '0' */
  PARSE_INT (dummy_int, 0);

  /* 'itrealvalue */
  PARSE_INT (dummy_int, 0);
  /* 'starttime' */
  PARSE_INT (dummy_int, 0);

  /* 'vsize' */
  PARSE_UINT (rv->virtual_memory_size, 0);

  /* 'rss' */
  PARSE_UINT (dummy_uint, 0);
  rv->resident_memory_size = dummy_uint * get_page_size ();

  /* 'rlim' */
  PARSE_UINT (dummy_uint, 0);

  /* TODO: there's more fields, but we don't much care.
     also the info in 'statm' is worth checking out */

  g_free (filename);
  g_free (content);

  return rv;
}