Ejemplo n.º 1
0
OMX_ERRORTYPE
tiz_vector_init (tiz_vector_t ** app_vector, size_t a_elem_size)
{
  tiz_vector_t * p_vec = NULL;

  assert (app_vector);
  assert (a_elem_size > 0);

  if (NULL
      == (p_vec = (tiz_vector_t *) tiz_mem_calloc (1, sizeof (tiz_vector_t))))
    {
      return OMX_ErrorInsufficientResources;
    }

  if (NULL == (p_vec->p_icd = (UT_icd *) tiz_mem_calloc (1, sizeof (UT_icd))))
    {
      tiz_mem_free (p_vec);
      return OMX_ErrorInsufficientResources;
    }

  p_vec->p_icd->sz = a_elem_size;
  utarray_new (p_vec->p_uta, p_vec->p_icd);
  *app_vector = p_vec;

  TIZ_LOG (TIZ_PRIORITY_TRACE, "Initializing vector [%p] with elem size [%d]",
           p_vec, a_elem_size);

  return OMX_ErrorNone;
}
Ejemplo n.º 2
0
static bool
dump_rmdb (const char * p_dest_path)
{
  bool rv = false;

  /* Dump the rm db */
  size_t total_len = strlen (pg_dump_script)
    + strlen (pg_rmdb_path)
    + strlen (p_dest_path) + 4;
  char *p_cmd = tiz_mem_calloc (1, total_len);

  if (p_cmd)
    {
      snprintf(p_cmd, total_len -1, "%s %s %s",
               pg_dump_script, pg_rmdb_path, p_dest_path);
      if (-1 != system (p_cmd))
        {
          TIZ_LOG(TIZ_TRACE, "Successfully run [%s] script...", p_cmd);
          rv = true;
        }
      else
        {
          TIZ_LOG(TIZ_TRACE,
                  "Error while executing db dump shell script...");
        }
      tiz_mem_free (p_cmd);
    }

  return rv;
}
Ejemplo n.º 3
0
static bool
refresh_rm_db (void)
{
  bool rv = false;

  /* Re-fresh the rm db */
  size_t total_len = strlen (pg_init_script)
    + strlen (pg_sqlite_script)
    + strlen (pg_rmdb_path) + 4;
  char *p_cmd = tiz_mem_calloc (1, total_len);

  if (p_cmd)
    {
      snprintf(p_cmd, total_len -1, "%s %s %s",
               pg_init_script, pg_sqlite_script, pg_rmdb_path);
      if (-1 != system (p_cmd))
        {
          TIZ_LOG(TIZ_TRACE, "Successfully run [%s] script...", p_cmd);
          rv = true;
        }
      else
        {
          TIZ_LOG(TIZ_TRACE,
                  "Error while executing db init shell script...");
        }
      tiz_mem_free (p_cmd);
    }

  return rv;
}
Ejemplo n.º 4
0
OMX_ERRORTYPE tiz_shuffle_lst_init (tiz_shuffle_lst_ptr_t *app_shuffle_lst,
                                    const size_t a_list_size)
{
  OMX_ERRORTYPE rc = OMX_ErrorInsufficientResources;
  tiz_shuffle_lst_t *p_shuffle_lst = NULL;

  assert (NULL != app_shuffle_lst);
  assert (a_list_size > 0);

  p_shuffle_lst = tiz_mem_calloc (1, sizeof(tiz_shuffle_lst_t));
  if (p_shuffle_lst)
    {
      p_shuffle_lst->length = a_list_size;
      if (OMX_ErrorNone == (rc = init_lst (p_shuffle_lst)))
        {
          srand (time (NULL));
          shuffle_lst (p_shuffle_lst->p_lst, p_shuffle_lst->length);
        }
    }

  if (OMX_ErrorNone != rc)
    {
      destroy_lst (p_shuffle_lst);
      p_shuffle_lst = NULL;
    }

  *app_shuffle_lst = p_shuffle_lst;
  return rc;
}
Ejemplo n.º 5
0
static OMX_ERRORTYPE
obtain_url (cc_http_prc_t * ap_prc)
{
  OMX_ERRORTYPE rc = OMX_ErrorNone;
  const long pathname_max = PATH_MAX + NAME_MAX;

  assert (ap_prc);
  assert (!ap_prc->p_content_uri_);

  ap_prc->p_content_uri_
    = tiz_mem_calloc (1, sizeof (OMX_PARAM_CONTENTURITYPE) + pathname_max + 1);

  tiz_check_null_ret_oom (ap_prc->p_content_uri_);

  ap_prc->p_content_uri_->nSize
    = sizeof (OMX_PARAM_CONTENTURITYPE) + pathname_max + 1;
  ap_prc->p_content_uri_->nVersion.nVersion = OMX_VERSION;

  tiz_check_omx (
    tiz_api_GetParameter (tiz_get_krn (handleOf (ap_prc)), handleOf (ap_prc),
                          OMX_IndexParamContentURI, ap_prc->p_content_uri_));
  TIZ_NOTICE (handleOf (ap_prc), "URI [%s]",
              ap_prc->p_content_uri_->contentURI);
  /* Verify we are getting an http scheme */
  if (strncasecmp ((const char *) ap_prc->p_content_uri_->contentURI, "http://",
                   7)
      && strncasecmp ((const char *) ap_prc->p_content_uri_->contentURI,
                      "https://", 8))
    {
      rc = OMX_ErrorContentURIError;
    }

  return rc;
}
Ejemplo n.º 6
0
static OMX_ERRORTYPE
obtain_next_url (dirble_prc_t * ap_prc, int a_skip_value)
{
  OMX_ERRORTYPE rc = OMX_ErrorNone;
  const long pathname_max = PATH_MAX + NAME_MAX;

  assert (ap_prc);
  assert (ap_prc->p_dirble_);

  if (!ap_prc->p_uri_param_)
    {
      ap_prc->p_uri_param_ = tiz_mem_calloc (
        1, sizeof (OMX_PARAM_CONTENTURITYPE) + pathname_max + 1);
    }

  tiz_check_null_ret_oom (ap_prc->p_uri_param_ != NULL);

  ap_prc->p_uri_param_->nSize
    = sizeof (OMX_PARAM_CONTENTURITYPE) + pathname_max + 1;
  ap_prc->p_uri_param_->nVersion.nVersion = OMX_VERSION;

  {
    const char * p_next_url
      = a_skip_value > 0 ? tiz_dirble_get_next_url (ap_prc->p_dirble_,
                                                    ap_prc->remove_current_url_)
                         : tiz_dirble_get_prev_url (
                             ap_prc->p_dirble_, ap_prc->remove_current_url_);
    ap_prc->remove_current_url_ = false;
    tiz_check_null_ret_oom (p_next_url != NULL);

    {
      const OMX_U32 url_len = strnlen (p_next_url, pathname_max);
      TIZ_TRACE (handleOf (ap_prc), "URL [%s]", p_next_url);

      /* Verify we are getting an http scheme */
      if (!p_next_url || !url_len
          || (memcmp (p_next_url, "http://", 7) != 0
              && memcmp (p_next_url, "https://", 8) != 0))
        {
          rc = OMX_ErrorContentURIError;
        }
      else
        {
          strncpy ((char *) ap_prc->p_uri_param_->contentURI, p_next_url,
                   url_len);
          ap_prc->p_uri_param_->contentURI[url_len] = '\000';

          /* Song metadata is now available, update the IL client */
          rc = update_metadata (ap_prc);
        }
    }
  }

  return rc;
}
static bool
refresh_rm_db (void)
{
  bool rv = false;
  const char *p_rmdb_path = NULL;
  const char *p_sqlite_path = NULL;
  const char *p_init_path = NULL;
  const char *p_rmd_path = NULL;

  p_rmdb_path = tiz_rcfile_get_value("resource-management", "rmdb");
  p_sqlite_path = tiz_rcfile_get_value("resource-management",
                                       "rmdb.sqlite_script");
  p_init_path = tiz_rcfile_get_value("resource-management",
                                     "rmdb.init_script");

  p_rmd_path = tiz_rcfile_get_value("resource-management", "rmd.path");

  if (!p_rmdb_path || !p_sqlite_path || !p_init_path || !p_rmd_path)

    {
      TIZ_LOG(TIZ_PRIORITY_TRACE, "Test data not available...");
    }
  else
    {
      pg_rmd_path = strndup (p_rmd_path, PATH_MAX);

      TIZ_LOG(TIZ_PRIORITY_TRACE, "RM daemon [%s] ...", pg_rmd_path);

      /* Re-fresh the rm db */
      size_t total_len = strlen (p_init_path)
        + strlen (p_sqlite_path)
        + strlen (p_rmdb_path) + 4;
      char *p_cmd = tiz_mem_calloc (1, total_len);
      if (p_cmd)
        {
          snprintf(p_cmd, total_len -1, "%s %s %s",
                  p_init_path, p_sqlite_path, p_rmdb_path);
          if (-1 != system (p_cmd))
            {
              TIZ_LOG(TIZ_PRIORITY_TRACE, "Successfully run [%s] script...", p_cmd);
              rv = true;
            }
          else
            {
              TIZ_LOG(TIZ_PRIORITY_TRACE, 
                      "Error while executing db init shell script...");
            }
          tiz_mem_free (p_cmd);
        }
    }

  return rv;
}
Ejemplo n.º 8
0
static void
obtain_audio_encoding_from_headers (scloud_prc_t * ap_prc,
                                    const char * ap_header, const size_t a_size)
{
  assert (ap_prc);
  assert (ap_header);
  {
    const char * p_end = ap_header + a_size;
    const char * p_value = (const char *) memchr (ap_header, ':', a_size);
    char name[64];

    if (p_value && (size_t) (p_value - ap_header) < sizeof (name))
      {
        memcpy (name, ap_header, p_value - ap_header);
        name[p_value - ap_header] = 0;

        /* skip the colon */
        ++p_value;

        /* strip the value */
        while (p_value < p_end && !is_valid_character (*p_value))
          {
            ++p_value;
          }

        while (p_end > p_value && !is_valid_character (p_end[-1]))
          {
            --p_end;
          }

        {
          char * p_info = tiz_mem_calloc (1, (p_end - p_value) + 1);
          memcpy (p_info, p_value, p_end - p_value);
          p_info[(p_end - p_value)] = '\0';
          TIZ_TRACE (handleOf (ap_prc), "header name  : [%s]", name);
          TIZ_TRACE (handleOf (ap_prc), "header value : [%s]", p_info);

          if (strncasecmp (name, "Content-Type", 12) == 0)
            {
              obtain_coding_type (ap_prc, p_info);
              /* Now set the new coding type value on the output port */
              (void) set_audio_coding_on_port (ap_prc);
            }
          else if (strncasecmp (name, "Content-Length", 14) == 0)
            {
              obtain_content_length (ap_prc, p_info);
            }
          tiz_mem_free (p_info);
        }
      }
  }
}
Ejemplo n.º 9
0
static OMX_ERRORTYPE httpr_mp3port_SetConfig (const void *ap_obj,
                                              OMX_HANDLETYPE ap_hdl,
                                              OMX_INDEXTYPE a_index,
                                              OMX_PTR ap_struct)
{
  httpr_mp3port_t *p_obj = (httpr_mp3port_t *)ap_obj;
  OMX_ERRORTYPE rc = OMX_ErrorNone;

  TIZ_TRACE (ap_hdl, "[%s]...", tiz_idx_to_str (a_index));

  assert (NULL != p_obj);

  if (OMX_TizoniaIndexConfigIcecastMetadata == a_index)
    {
      OMX_TIZONIA_ICECASTMETADATATYPE *p_metadata
          = (OMX_TIZONIA_ICECASTMETADATATYPE *)ap_struct;
      OMX_U32 stream_title_len
          = strnlen ((char *)p_metadata->cStreamTitle,
                     OMX_TIZONIA_MAX_SHOUTCAST_METADATA_SIZE + 1);
      if (stream_title_len > OMX_TIZONIA_MAX_SHOUTCAST_METADATA_SIZE)
        {
          rc = OMX_ErrorBadParameter;
        }
      else
        {
          TIZ_TRACE (ap_hdl, "stream_title_len [%d] Stream title [%s]...",
                     stream_title_len, p_metadata->cStreamTitle);

          tiz_mem_free (p_obj->p_stream_title_);
          p_obj->p_stream_title_ = tiz_mem_calloc (1, stream_title_len + 1);
          if (NULL != p_obj->p_stream_title_)
            {
              strncpy (p_obj->p_stream_title_, (char *)p_metadata->cStreamTitle,
                       stream_title_len);
              p_obj->p_stream_title_[stream_title_len] = '\000';
            }

          TIZ_TRACE (ap_hdl, "stream_title_len [%d] Stream title [%s]...",
                     stream_title_len, p_obj->p_stream_title_);
        }
    }
  else
    {
      /* Delegate to the base port */
      rc = super_SetConfig (typeOf (ap_obj, "httprmp3port"), ap_obj, ap_hdl,
                            a_index, ap_struct);
    }

  return rc;
}
Ejemplo n.º 10
0
static OMX_ERRORTYPE
fr_proc_allocate_resources (void *ap_obj, OMX_U32 a_pid)
{
  fr_prc_t *p_obj = ap_obj;
  const tiz_srv_t *p_parent = ap_obj;
  OMX_ERRORTYPE ret_val = OMX_ErrorNone;
  void *p_krn = tiz_get_krn (p_parent->p_hdl_);

  assert (ap_obj);

  if (!(p_obj->p_uri_param_))
    {
      p_obj->p_uri_param_ = tiz_mem_calloc
        (1, sizeof (OMX_PARAM_CONTENTURITYPE) + OMX_MAX_STRINGNAME_SIZE);

      if (NULL == p_obj->p_uri_param_)
        {
          TIZ_LOG (TIZ_ERROR, "Error allocating memory "
                   "for the content uri struct");
          return OMX_ErrorInsufficientResources;
        }

      p_obj->p_uri_param_->nSize = sizeof (OMX_PARAM_CONTENTURITYPE)
        + OMX_MAX_STRINGNAME_SIZE - 1;
      p_obj->p_uri_param_->nVersion.nVersion = OMX_VERSION;
    }

  if (OMX_ErrorNone != (ret_val = tiz_api_GetParameter
                        (p_krn,
                         p_parent->p_hdl_,
                         OMX_IndexParamContentURI, p_obj->p_uri_param_)))
    {
      TIZ_LOG (TIZ_ERROR, "Error retrieving URI param from port");
      return ret_val;
    }

  TIZ_LOG (TIZ_NOTICE, "Retrieved URI [%s]",
           p_obj->p_uri_param_->contentURI);

  if ((p_obj->p_file_
       = fopen ((const char *) p_obj->p_uri_param_->contentURI, "r")) == 0)
    {
      TIZ_LOG (TIZ_ERROR, "Error opening file from  URI string");
      return OMX_ErrorInsufficientResources;
    }

  return OMX_ErrorNone;
}
Ejemplo n.º 11
0
static OMX_ERRORTYPE
store_metadata (dirble_prc_t * ap_prc, const char * ap_header_name,
                const char * ap_header_info)
{
  OMX_ERRORTYPE rc = OMX_ErrorNone;
  OMX_CONFIG_METADATAITEMTYPE * p_meta = NULL;
  size_t metadata_len = 0;
  size_t info_len = 0;

  assert (ap_prc);
  if (ap_header_name && ap_header_info)
    {
      info_len = strnlen (ap_header_info, OMX_MAX_STRINGNAME_SIZE - 1) + 1;
      metadata_len = sizeof (OMX_CONFIG_METADATAITEMTYPE) + info_len;

      if (NULL == (p_meta = (OMX_CONFIG_METADATAITEMTYPE *) tiz_mem_calloc (
                     1, metadata_len)))
        {
          rc = OMX_ErrorInsufficientResources;
        }
      else
        {
          const size_t name_len
            = strnlen (ap_header_name, OMX_MAX_STRINGNAME_SIZE - 1) + 1;
          strncpy ((char *) p_meta->nKey, ap_header_name, name_len - 1);
          p_meta->nKey[name_len - 1] = '\0';
          p_meta->nKeySizeUsed = name_len;

          strncpy ((char *) p_meta->nValue, ap_header_info, info_len - 1);
          p_meta->nValue[info_len - 1] = '\0';
          p_meta->nValueMaxSize = info_len;
          p_meta->nValueSizeUsed = info_len;

          p_meta->nSize = metadata_len;
          p_meta->nVersion.nVersion = OMX_VERSION;
          p_meta->eScopeMode = OMX_MetadataScopeAllLevels;
          p_meta->nScopeSpecifier = 0;
          p_meta->nMetadataItemIndex = 0;
          p_meta->eSearchMode = OMX_MetadataSearchValueSizeByIndex;
          p_meta->eKeyCharset = OMX_MetadataCharsetASCII;
          p_meta->eValueCharset = OMX_MetadataCharsetASCII;

          rc = tiz_krn_store_metadata (tiz_get_krn (handleOf (ap_prc)), p_meta);
        }
    }
  return rc;
}
Ejemplo n.º 12
0
static OMX_ERRORTYPE
httpr_prc_config_change (const void * ap_prc, const OMX_U32 a_pid,
                         const OMX_INDEXTYPE a_config_idx)
{
  const httpr_prc_t * p_prc = ap_prc;
  OMX_ERRORTYPE rc = OMX_ErrorNone;

  assert (ap_prc);

  if (p_prc->p_server_ && OMX_TizoniaIndexConfigIcecastMetadata == a_config_idx
      && ARATELIA_HTTP_RENDERER_PORT_INDEX == a_pid)
    {
      OMX_TIZONIA_ICECASTMETADATATYPE * p_metadata
        = (OMX_TIZONIA_ICECASTMETADATATYPE *) tiz_mem_calloc (
          1, sizeof (OMX_TIZONIA_ICECASTMETADATATYPE)
               + OMX_TIZONIA_MAX_SHOUTCAST_METADATA_SIZE + 1);

      tiz_check_null_ret_oom (p_metadata);

      /* Retrieve the updated icecast metadata from the input port */
      TIZ_INIT_OMX_PORT_STRUCT (*p_metadata, ARATELIA_HTTP_RENDERER_PORT_INDEX);
      p_metadata->nSize = sizeof (OMX_TIZONIA_ICECASTMETADATATYPE)
                          + OMX_TIZONIA_MAX_SHOUTCAST_METADATA_SIZE;

      if (OMX_ErrorNone
          != (rc = tiz_api_GetConfig (
                tiz_get_krn (handleOf (p_prc)), handleOf (p_prc),
                OMX_TizoniaIndexConfigIcecastMetadata, p_metadata)))
        {
          TIZ_ERROR (handleOf (p_prc),
                     "[%s] : Error retrieving "
                     "OMX_TizoniaIndexConfigIcecastMetadata from port",
                     tiz_err_to_str (rc));
        }
      else
        {
          httpr_srv_set_stream_title (p_prc->p_server_,
                                      p_metadata->cStreamTitle);
        }

      tiz_mem_free (p_metadata);
      p_metadata = NULL;
    }
  return rc;
}
static OMX_ERRORTYPE
_ctx_init (cc_ctx_t * app_ctx)
{
  int i;
  check_common_context_t *p_ctx =
    tiz_mem_calloc (1, sizeof (check_common_context_t));

  if (!p_ctx)
    {
      return OMX_ErrorInsufficientResources;
    }

  for (i=0 ; i < MAX_EVENTS ; i++)
    {
      p_ctx->signaled[i] = OMX_FALSE;
      p_ctx->event[i] = OMX_EventMax;
    }

  if (tiz_mutex_init (&p_ctx->mutex))
    {
      tiz_mem_free (p_ctx);
      return OMX_ErrorInsufficientResources;
    }

  if (tiz_cond_init (&p_ctx->cond))
    {
      tiz_mutex_destroy (&p_ctx->mutex);
      tiz_mem_free (p_ctx);
      return OMX_ErrorInsufficientResources;
    }

  p_ctx->state = OMX_StateMax;
  p_ctx->p_hdr = NULL;
  p_ctx->flags = 0;
  p_ctx->port  = 0;
  p_ctx->index = 0;

  * app_ctx = p_ctx;

  return OMX_ErrorNone;

}
OMX_ERRORTYPE graph::gmusicops::dump_metadata_item (const OMX_U32 index)
{
  OMX_ERRORTYPE rc = OMX_ErrorNone;
  OMX_CONFIG_METADATAITEMTYPE *p_meta = NULL;
  size_t metadata_len = 0;
  size_t value_len = 0;

  value_len = OMX_MAX_STRINGNAME_SIZE;
  metadata_len = sizeof(OMX_CONFIG_METADATAITEMTYPE) + value_len;

  if (NULL == (p_meta = (OMX_CONFIG_METADATAITEMTYPE *)tiz_mem_calloc (
                   1, metadata_len)))
  {
    rc = OMX_ErrorInsufficientResources;
  }
  else
  {
    p_meta->nSize = metadata_len;
    p_meta->nVersion.nVersion = OMX_VERSION;
    p_meta->eScopeMode = OMX_MetadataScopeAllLevels;
    p_meta->nScopeSpecifier = 0;
    p_meta->nMetadataItemIndex = index;
    p_meta->eSearchMode = OMX_MetadataSearchValueSizeByIndex;
    p_meta->eKeyCharset = OMX_MetadataCharsetASCII;
    p_meta->eValueCharset = OMX_MetadataCharsetASCII;
    p_meta->nKeySizeUsed = 0;
    p_meta->nValue[0] = '\0';
    p_meta->nValueMaxSize = OMX_MAX_STRINGNAME_SIZE;
    p_meta->nValueSizeUsed = 0;

    rc = OMX_GetConfig (handles_[0], OMX_IndexConfigMetadataItem, p_meta);
    if (OMX_ErrorNone == rc)
    {
      TIZ_PRINTF_CYN ("   %s%s : %s\n", index ? "  " : "", p_meta->nKey,
                      p_meta->nValue);
    }

    tiz_mem_free (p_meta);
    p_meta = NULL;
  }
  return rc;
}
OMX_ERRORTYPE
graph::httpservops::configure_stream_metadata ()
{
  OMX_ERRORTYPE rc = OMX_ErrorNone;

  // Set the stream title on to the renderer's input port
  OMX_TIZONIA_ICECASTMETADATATYPE *p_metadata = NULL;
  if (NULL == (p_metadata = (OMX_TIZONIA_ICECASTMETADATATYPE *)tiz_mem_calloc (
                   1, sizeof(OMX_TIZONIA_ICECASTMETADATATYPE)
                      + OMX_TIZONIA_MAX_SHOUTCAST_METADATA_SIZE)))
  {
    rc = OMX_ErrorInsufficientResources;
  }
  else
  {
    p_metadata->nVersion.nVersion = OMX_VERSION;
    p_metadata->nPortIndex = 0;

    // Obtain the stream title
    std::string stream_title = probe_ptr_->get_stream_title ();
    snprintf ((char *)p_metadata->cStreamTitle,
              OMX_TIZONIA_MAX_SHOUTCAST_METADATA_SIZE, "StreamTitle='%s';",
              stream_title.c_str ());
    p_metadata->nSize = sizeof(OMX_TIZONIA_ICECASTMETADATATYPE)
                        + strlen ((char *)p_metadata->cStreamTitle);

    TIZ_LOG (TIZ_PRIORITY_TRACE, "p_metadata->cStreamTitle [%s]...",
             p_metadata->cStreamTitle);

    rc = OMX_SetConfig (handles_[1], static_cast< OMX_INDEXTYPE >(
                                         OMX_TizoniaIndexConfigIcecastMetadata),
                        p_metadata);

    tiz_mem_free (p_metadata);
    p_metadata = NULL;
  }

  return rc;
}
Ejemplo n.º 16
0
static OMX_ERRORTYPE
alloc_uri (oggdmux_prc_t * ap_prc)
{
  OMX_ERRORTYPE rc = OMX_ErrorNone;
  const long pathname_max = PATH_MAX + NAME_MAX;

  assert (ap_prc);
  assert (!ap_prc->p_uri_);

  if (!(ap_prc->p_uri_ = tiz_mem_calloc (
          1, sizeof (OMX_PARAM_CONTENTURITYPE) + pathname_max + 1)))
    {
      TIZ_ERROR (handleOf (ap_prc),
                 "Error allocating memory for the content uri struct");
      rc = OMX_ErrorInsufficientResources;
    }
  else
    {
      ap_prc->p_uri_->nSize
        = sizeof (OMX_PARAM_CONTENTURITYPE) + pathname_max + 1;
      ap_prc->p_uri_->nVersion.nVersion = OMX_VERSION;

      if (OMX_ErrorNone
          != (rc = tiz_api_GetParameter (
                tiz_get_krn (handleOf (ap_prc)), handleOf (ap_prc),
                OMX_IndexParamContentURI, ap_prc->p_uri_)))
        {
          TIZ_ERROR (handleOf (ap_prc),
                     "[%s] : Error retrieving the URI param from port",
                     tiz_err_to_str (rc));
        }
      else
        {
          TIZ_NOTICE (handleOf (ap_prc), "URI [%s]",
                      ap_prc->p_uri_->contentURI);
        }
    }
  return rc;
}
Ejemplo n.º 17
0
OMX_ERRORTYPE
tiz_rcfile_init (tiz_rcfile_t **pp_rc)
{
  int i;
  tiz_rcfile_t *p_rc = NULL;
  char *p_env_str = NULL;

  assert (pp_rc);

  /* load rc files */
  TIZ_LOG (TIZ_PRIORITY_TRACE, "Looking for [%d] rc files...", g_nrcfiles);

  snprintf(rcfiles[0].name, sizeof(rcfiles[0].name) - 1, "%s",
           getenv("TIZONIA_RC_FILE") ? getenv("TIZONIA_RC_FILE") : "");

  snprintf (rcfiles[1].name, sizeof(rcfiles[0].name) - 1, "%s/tizonia.conf",
            SYSCONFDIR);

  if (g_nrcfiles >= 3 && (p_env_str = getenv ("HOME")))
    {
      TIZ_LOG (TIZ_PRIORITY_TRACE, "HOME [%s] ...", p_env_str);
      snprintf (rcfiles[2].name, sizeof(rcfiles[2].name) - 1,
                "%s/.tizonia.conf", p_env_str ? p_env_str : "");
    }

  if (!(p_rc = (tiz_rcfile_t *)tiz_mem_calloc (1, sizeof(tiz_rcfile_t))))
    {
      TIZ_LOG (TIZ_PRIORITY_TRACE,
               "Could not allocate memory "
               "for tiz_rcfile_t...");
      return OMX_ErrorInsufficientResources;
    }

  for (i = 0; i < g_nrcfiles; i++)
    {
      TIZ_LOG (TIZ_PRIORITY_TRACE, "Checking for rc file at [%s]",
               rcfiles[i].name);
      /* Check file existence and user's read access */
      if (0 != access (rcfiles[i].name, R_OK))
        {
          TIZ_LOG (TIZ_PRIORITY_TRACE,
                   "rc file [%s] does not exist or "
                   "user has no read access permission",
                   rcfiles[i].name);
          continue;
        }

      /* Store stat's ctime */
      if (stat_ctime (rcfiles[i].name, &rcfiles[i].ctime) != 0)
        {
          TIZ_LOG (TIZ_PRIORITY_TRACE, "stat_ctime for [%s] failed",
                   rcfiles[i].name);
        }

      rcfiles[i].exists = 1;

      if (0 != load_rc_file (&rcfiles[i], p_rc))
        {
          TIZ_LOG (TIZ_PRIORITY_TRACE, "Loading [%s] rc file failed",
                   rcfiles[i].name);
        }
      else
        {
          TIZ_LOG (TIZ_PRIORITY_TRACE, "Loading [%s] rc file succeeded",
                   rcfiles[i].name);
        }
    }

  if (p_rc->count)
    {
      *pp_rc = p_rc;
    }
  else
    {
      *pp_rc = NULL;
    }

  return OMX_ErrorNone;
}
Ejemplo n.º 18
0
static /*@null@ */ void *
os_calloc (/*@null@ */ tiz_soa_t * p_soa, size_t a_size)
{
  return p_soa ? tiz_soa_calloc (p_soa, a_size) : tiz_mem_calloc (1, a_size);
}
Ejemplo n.º 19
0
static int get_node (const tiz_rcfile_t *ap_rc, char *str, keyval_t **app_kv)
{
  int ret = 0;
  char *needle = strstr (str, "=");
  char *key = strndup (trimwhitespace (str), needle - str);
  char *value_start = str + (needle - str) + 1;
  char *value = strndup (trimlistseparator (trimwhitespace (value_start)),
                         strlen (str) - (needle - str));
  keyval_t *p_kv = NULL;
  value_t *p_v = NULL;
  value_t *p_next_v = NULL;

  assert (ap_rc);
  assert (str);
  assert (app_kv);

  TIZ_LOG (TIZ_PRIORITY_TRACE, "key : [%s]", trimwhitespace (key));
  TIZ_LOG (TIZ_PRIORITY_TRACE, "val : [%s]",
           trimlistseparator (trimwhitespace (value)));

  /* Find if the key exists already */
  p_kv = find_node (ap_rc, key);
  if (!p_kv)
    {
      p_kv = (keyval_t *)tiz_mem_calloc (1, sizeof(keyval_t));
      p_v = (value_t *)tiz_mem_calloc (1, sizeof(value_t));

      if (!p_kv || !p_v)
        {
          tiz_mem_free (p_kv);
          p_kv = NULL;
          tiz_mem_free (p_v);
          p_v = NULL;
          tiz_mem_free (value);
          value = NULL;
          tiz_mem_free (key);
          key = NULL;
          ret = -1;
        }
      else
        {
          p_v->p_value = value;
          p_kv->p_key = key;
          p_kv->p_value_list = p_v;
          p_kv->p_value_iter = p_v;
          p_kv->valcount++;
          p_kv->p_next = NULL;
          ret = 1;
        }
    }
  else
    {
      /* There is already a node with that key */
      /* Need to check if this node holds value lists */
      if (is_list (key))
        {
          /* Add another value to the list */
          TIZ_LOG (TIZ_PRIORITY_TRACE, "Found list Key [%s]", key);
          p_v = (value_t *)tiz_mem_calloc (1, sizeof(value_t));
          p_v->p_value = value;

          p_next_v = p_kv->p_value_list;

          for (;;)
            {
              if (!p_next_v->p_next)
                {
                  p_next_v->p_next = p_v;
                  p_kv->valcount++;
                  TIZ_LOG (TIZ_PRIORITY_TRACE,
                           "Added value - "
                           "new valcount [%d]",
                           p_kv->valcount);
                  break;
                }
              p_next_v = p_next_v->p_next;
            }

          ret = 0;
        }
      else
        {
          /* Replace the existing value */
          TIZ_LOG (TIZ_PRIORITY_TRACE,
                   "Replacing existing value [%s] "
                   "key [%s]",
                   p_kv->p_value_list->p_value, p_kv->p_key);
          tiz_mem_free (p_kv->p_value_list->p_value);
          p_kv->p_value_list->p_value = value;
          p_kv->valcount = 1;
          ret = 0;
        }
      tiz_mem_free (key);
    }

  if (-1 != ret)
    {
      *app_kv = p_kv;
    }

  return ret;
}
Ejemplo n.º 20
0
static /*@null@ */ void *
pqueue_calloc ( /*@null@ */ tiz_soa_t * p_soa, size_t a_size)
{
    return NULL != p_soa
           ? tiz_soa_calloc (p_soa, a_size) : tiz_mem_calloc (1, a_size);
}
Ejemplo n.º 21
0
static int extractkeyval (FILE *ap_file, char *ap_str, keyval_t **app_last_kv,
                          tiz_rcfile_t *ap_tiz_rcfile)
{
  int len;
  int ret = 0;
  int is_new = 0;
  keyval_t *p_kv = NULL;
  value_t *p_v = NULL, *p_next_v = NULL;

  is_new = get_node (ap_tiz_rcfile, ap_str, &p_kv);

  if (!p_kv)
    {
      TIZ_LOG (TIZ_PRIORITY_TRACE,
               "Could not allocate memory "
               "for keyval_t...");
      return OMX_ErrorInsufficientResources;
    }

  /* Check if this is an existent node or not */
  if (is_new)
    {
      /* This is a new node */
      TIZ_LOG (TIZ_PRIORITY_TRACE,
               "Linking new kv [%p] [%p] pair - "
               "value [%s]",
               app_last_kv, p_kv, p_kv->p_value_list->p_value);
      (*app_last_kv) = p_kv;
      p_v = p_kv->p_value_list;
    }
  else
    {
      p_v = p_kv->p_value_list;
      for (;;)
        {
          if (!p_v->p_next)
            {
              break;
            }
          p_v = p_v->p_next;
        }
    }

  while (fgets (pat, PAT_SIZE, ap_file) != NULL)
    {
      if (strstr (pat, ";"))
        {
          TIZ_LOG (TIZ_PRIORITY_TRACE, "val : [%s]",
                   trimlistseparator (trimwhitespace (pat)));

          p_next_v = (value_t *)tiz_mem_calloc (1, sizeof(value_t));

          /* TODO : Use strndup */
          p_next_v->p_value = strdup (trimlistseparator (trimwhitespace (pat)));

          p_v->p_next = p_next_v;
          p_v = p_next_v;
          p_kv->valcount++;
          TIZ_LOG (TIZ_PRIORITY_TRACE,
                   "Added value - "
                   "new valcount [%d]",
                   p_kv->valcount);
        }
      else
        {
          len = strlen (pat);
          if (pat[len - 1] == '\n')
            {
              pat[len - 1] = '\0';
            }

          if (strlen (pat) > 1)
            {
              ret = 1;
            }
          break;
        }
    }

  TIZ_LOG (TIZ_PRIORITY_TRACE, "ret : [%d]", ret);

  return ret;
}