Example #1
0
/*
 * Constructor for the Eupnp_HTTP_Request structure
 *
 * Receives pointers to starting points and lengths of the method, uri
 * and http version attributes and constructs the object. Also initializes the
 * headers array. For dealing with headers, refer to the
 * eupnp_http_request_header_* functions.
 *
 * @param method starting point of the method
 * @param method_len method length
 * @param uri starting point of the uri
 * @param uri_len uri length
 * @param httpver starting point of the http version
 * @param httpver_len http version length
 *
 * @return Eupnp_HTTP_Request instance
 */
Eupnp_HTTP_Request *
eupnp_http_request_new(const char *method, int method_len, const char *uri, int uri_len, const char *httpver, int httpver_len)
{
   Eupnp_HTTP_Request *h;
   h = calloc(1, sizeof(Eupnp_HTTP_Request));

   if (!h)
     {
	eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
	ERROR("Could not create HTTP message.\n");
	return NULL;
     }

   h->headers = eina_array_new(10);

   if (!h->headers)
     {
	ERROR("Could not allocate memory for HTTP headers table.\n");
	free(h);
	return NULL;
     }

   h->method = eina_stringshare_add_length(method, method_len);

   if (!h->method)
     {
	ERROR("Could not stringshare HTTP request method.\n");
	eina_array_free(h->headers);
	free(h);
	return NULL;
     }

   h->http_version = eina_stringshare_add_length(httpver, httpver_len);

   if (!h->http_version)
     {
	ERROR("Could not stringshare HTTP request version.\n");
	eina_array_free(h->headers);
	eina_stringshare_del(h->method);
	free(h);
	return NULL;
     }

   h->uri = eina_stringshare_add_length(uri, uri_len);

   if (!h->uri)
     {
	ERROR("Could not stringshare HTTP request URI.\n");
	eina_array_free(h->headers);
	eina_stringshare_del(h->method);
	eina_stringshare_del(h->http_version);
	free(h);
	return NULL;
     }

   return h;
}
Example #2
0
void render_state_del(Render_State *state)
{
  assert(ea_count(state->currstate) == 0);
  assert(ea_count(state->ready) == 0);
  assert(state->pending == 0);
  
  eina_array_free(state->currstate);
  eina_array_free(state->ready);

  free(state);
}
Example #3
0
/*
 * Destructor for the Eupnp_HTTP_Request structure
 *
 * Frees the object and its attributes, including headers added.
 *
 * @param r previously created request
 */
void
eupnp_http_request_free(Eupnp_HTTP_Request *r)
{
   if (!r)
      return;

   if (r->method)
      eina_stringshare_del(r->method);
   if (r->http_version)
      eina_stringshare_del(r->http_version);
   if (r->uri)
      eina_stringshare_del(r->uri);

   if (r->headers)
     {
	Eina_Array_Iterator it;
	Eupnp_HTTP_Header *h;
	int i;

	EINA_ARRAY_ITER_NEXT(r->headers, i, h, it)
	   eupnp_http_header_free(h);

	eina_array_free(r->headers);
     }

   free(r);
}
Example #4
0
void
emotion_modules_shutdown(void)
{
   Emotion_Engine_Registry_Entry *re;

#ifdef EMOTION_STATIC_BUILD_XINE
   xine_module_shutdown();
#endif
#if defined(EMOTION_STATIC_BUILD_GSTREAMER) || defined(EMOTION_STATIC_BUILD_GSTREAMER1)
   gstreamer_module_shutdown();
#endif
#ifdef EMOTION_STATIC_BUILD_GENERIC
   generic_module_shutdown();
#endif

   if (_emotion_modules)
     {
        eina_module_list_free(_emotion_modules);
        eina_array_free(_emotion_modules);
        _emotion_modules = NULL;
     }

   EINA_LIST_FREE(_emotion_engine_registry, re)
     {
        WRN("Engine was not unregistered: %p", re->engine);
        _emotion_engine_registry_entry_free(re);
     }
Example #5
0
/* will dlclose all the modules loaded and free all the structs */
void
evas_module_shutdown(void)
{
   Eina_Module *en;
   char *path;
   int i;

   for (i = 0; evas_static_module[i].shutdown; ++i)
     evas_static_module[i].shutdown();

   EINA_LIST_FREE(eina_evas_modules, en)
     eina_module_free(en);

   eina_hash_free(evas_modules[EVAS_MODULE_TYPE_ENGINE]);
   evas_modules[EVAS_MODULE_TYPE_ENGINE] = NULL;
   eina_hash_free(evas_modules[EVAS_MODULE_TYPE_IMAGE_LOADER]);
   evas_modules[EVAS_MODULE_TYPE_IMAGE_LOADER] = NULL;
   eina_hash_free(evas_modules[EVAS_MODULE_TYPE_IMAGE_SAVER]);
   evas_modules[EVAS_MODULE_TYPE_IMAGE_SAVER] = NULL;
   eina_hash_free(evas_modules[EVAS_MODULE_TYPE_OBJECT]);
   evas_modules[EVAS_MODULE_TYPE_OBJECT] = NULL;

   EINA_LIST_FREE(evas_module_paths, path)
     free(path);

   eina_array_free(evas_engines);
   evas_engines = NULL;
}
Example #6
0
/*
 * Constructor for the Eupnp_HTTP_Response structure
 *
 * Receives pointers to starting points and lengths of the http version, status
 * code and http version attributes and constructs the object. Also initializes
 * the headers array. For dealing with headers, refer to the
 * eupnp_http_response_header_* functions.
 *
 * @param httpver starting point of the http version
 * @param httpver_len http version length
 * @param status_code starting point of the status code
 * @param status_len status length
 * @param reason_phrase starting point of the reason phrase
 * @param reason_phrase_len reason phrase length
 *
 * @return Eupnp_HTTP_Response instance
 */
Eupnp_HTTP_Response *
eupnp_http_response_new(const char *httpver, int httpver_len, const char *status_code, int status_code_len, const char *reason_phrase, int reason_phrase_len)
{
   Eupnp_HTTP_Response *r;
   r = calloc(1, sizeof(Eupnp_HTTP_Response));

   if (!r)
     {
	eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
	ERROR("Could not create HTTP response.\n");
	return NULL;
     }

   r->headers = eina_array_new(10);

   if (!r->headers)
     {
	ERROR("Could not allocate memory for HTTP headers.\n");
	free(r);
	return NULL;
     }

   r->http_version = eina_stringshare_add_length(httpver, httpver_len);

   if (!r->http_version)
     {
	ERROR("Could not stringshare http response version.\n");
	eina_array_free(r->headers);
	free(r);
	return NULL;
     }

   r->status_code = strtol(status_code, NULL, 10);
   r->reason_phrase = eina_stringshare_add_length(reason_phrase,
						    reason_phrase_len);

   if (!r->reason_phrase)
     {
	ERROR("Could not stringshare http response phrase.\n");
	eina_array_free(r->headers);
	eina_stringshare_del(r->http_version);
	free(r);
	return NULL;
     }

   return r;
}
Example #7
0
static void _mempool_shutdown(void)
{
   eina_module_list_free(_modules);
   if (_modules)
     eina_array_free(_modules);
   /* TODO delete the list */
   eina_shutdown();
}
Example #8
0
void render_node_del(Render_Node *node)
{
  int i;
  
  if (node->inputs) {
    for(i=0;i<ea_count(node->inputs);i++)
      tiledata_del(ea_data(node->inputs, i));
    eina_array_free(node->inputs);
  }
  
  if (node->f_source)
    eina_array_free(node->f_source);
  
  if (node->tile && !cache_tile_get(&node->tile->hash))
    tile_del(node->tile);
  
  free(node);
}
Example #9
0
static void _free_files(Eina_Array* files)
{
    char* item;
    Eina_Array_Iterator iterator;
    unsigned int i;
    EINA_ARRAY_ITER_NEXT(files, i, item, iterator)
        free(item);
    eina_array_free(files);
}
Example #10
0
static void
_free_eina_array(Eina_Array *array, _free_func free_cb)
{
   if (!array)
      return;

   while (eina_array_count(array))
      free_cb(eina_array_pop(array));

   eina_array_free(array);
}
static void
_properties_names_array_free(Eina_Array *properties_names)
{
   Eina_Array_Iterator it;
   void *name;
   unsigned int i;

   EINA_ARRAY_ITER_NEXT(properties_names, i, name, it)
     free(name);

   eina_array_free(properties_names);
}
Example #12
0
static void _mempool_shutdown(void)
{
   unsigned int i;
   Eina_Array_Iterator it;
   Eina_Module *module;	
   eina_module_list_free(_modules);
   if (_modules)
     {
        EINA_ARRAY_ITER_NEXT(_modules, i, module, it)
          free(module);
        eina_array_free(_modules);
     }
   eina_shutdown();
}
Example #13
0
END_TEST

START_TEST(eina_binshare_collision)
{
   Eina_Array *ea;
   char buffer[50];
   int i;

   srand(time(NULL));

   eina_init();

   ea = eina_array_new(256);
   fail_if(!ea);

   for (i = 0; i < 10000; ++i)
     {
        eina_convert_itoa(rand(), buffer);
        eina_array_push(ea,
                        (void *)eina_binshare_add_length(buffer, strlen(buffer)));
        if (rand() > RAND_MAX / 2)
          {
             const char *r = eina_binshare_add_length(buffer, strlen(buffer));
             fail_if(r == NULL);
          }
     }

   for (i = 0; i < 10000; ++i)
     {
        const char *r;

        eina_convert_itoa(60000 - i, buffer);
        eina_array_push(ea,
                        (void *)eina_binshare_add_length(buffer, strlen(buffer)));
        r = eina_binshare_add_length(buffer, strlen(buffer));
        fail_if(r == NULL);
        r = eina_binshare_add_length(buffer, strlen(buffer));
        fail_if(r == NULL);
     }

   for (i = 0; i < 200; ++i)
      eina_binshare_del(eina_array_data_get(ea, i));

   for (i = 0; i < 1000; ++i)
      eina_binshare_del(eina_array_pop(ea));

   eina_shutdown();

   eina_array_free(ea);
}
Example #14
0
static void
eina_bench_lookup_evas(int request)
{
   Evas_Hash *hash = NULL;
   Eina_Array *array = NULL;
   int *tmp_val;
   Eina_Array_Iterator it;
   unsigned int i;
   unsigned int j;

   array = eina_array_new(10000);

   for (i = 0; i < (unsigned int)request; ++i)
     {
        char tmp_key[10];

        tmp_val = malloc(sizeof (int));

        if (!tmp_val)
           continue;

        eina_convert_itoa(i, tmp_key);
        *tmp_val = i;

        hash = evas_hash_add(hash, tmp_key, tmp_val);

        eina_array_push(array, tmp_val);
     }

   srand(time(NULL));

   for (j = 0; j < 200; ++j)
      for (i = 0; i < (unsigned int)request; ++i)
        {
           char tmp_key[10];

           eina_convert_itoa(rand() % request, tmp_key);

           tmp_val = evas_hash_find(hash, tmp_key);
        }

   evas_hash_free(hash);

   EINA_ARRAY_ITER_NEXT(array, i, tmp_val, it)
     free(tmp_val);

   eina_array_free(array);
}
Example #15
0
void
eet_loader_shutdown(void)
{
   eina_hash_free(cache);
   cache = NULL;

   if (stack) eina_array_free(stack);
   stack = NULL;

   lru = eina_list_free(lru);

   eet_shutdown();
   eina_shutdown();

   elixir_loader_unregister(&eet_loader);
}
Example #16
0
void
ecore_imf_module_shutdown(void)
{
   if (modules)
     {
        eina_hash_free(modules);
        modules = NULL;
     }
   if (module_list)
     {
        eina_module_list_free(module_list);
        eina_array_free(module_list);
        module_list = NULL;
     }

   eina_prefix_free(pfx);
   pfx = NULL;
}
Example #17
0
void
etui_modules_shutdown(void)
{
    Etui_Provider_Registry_Entry *re;

    /* TODO : STATIC modules */
#ifdef ETUI_BUILD_STATIC_EPUB
    etui_module_epub_shutdown();
#endif

#ifdef ETUI_BUILD_STATIC_DJVU
    etui_module_djvu_shutdown();
#endif

#ifdef ETUI_BUILD_STATIC_IMG
    etui_module_img_shutdown();
#endif

#ifdef ETUI_BUILD_STATIC_PS
    etui_module_ps_shutdown();
#endif

#ifdef ETUI_BUILD_STATIC_PDF
    etui_module_pdf_shutdown();
#endif

    if (_etui_modules)
    {
        eina_module_list_free(_etui_modules);
        eina_array_free(_etui_modules);
        _etui_modules = NULL;
    }

	eina_hash_free(_etui_providers);

    EINA_LIST_FREE(_etui_provider_registries, re)
    {
        WRN("Engine was not unregistered: %p", re->provider);
        _etui_provider_registry_entry_free(re);
    }
Eina_Bool
eina_mempool_shutdown(void)
{
   /* builtin backends */
#ifdef EINA_STATIC_BUILD_BUDDY
   buddy_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_CHAINED_POOL
   chained_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_EMEMOA_FIXED
   ememoa_fixed_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_EMEMOA_UNKNOWN
   ememoa_unknown_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_FIXED_BITMAP
   fixed_bitmap_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_ONE_BIG
   one_big_shutdown();
#endif
#ifdef EINA_STATIC_BUILD_PASS_THROUGH
   pass_through_shutdown();
#endif
   /* dynamic backends */
   eina_module_list_free(_modules);
   if (_modules)
      eina_array_free(_modules);

   if (_backends)
      eina_hash_free(_backends);

   eina_log_domain_unregister(_eina_mempool_log_dom);
   _eina_mempool_log_dom = -1;

   return EINA_TRUE;
}
Example #19
0
/*
 * Destructor for the Eupnp_HTTP_Response structure
 *
 * Frees the object and its attributes, including headers added.
 *
 * @param r previously created response
 */
void
eupnp_http_response_free(Eupnp_HTTP_Response *r)
{
   if (!r) return;

   if (r->http_version)
      eina_stringshare_del(r->http_version);
   if (r->reason_phrase)
      eina_stringshare_del(r->reason_phrase);

   if (r->headers)
     {
	Eina_Array_Iterator it;
	Eupnp_HTTP_Header *h;
	int i;

	EINA_ARRAY_ITER_NEXT(r->headers, i, h, it)
	   eupnp_http_header_free(h);

	eina_array_free(r->headers);
     }

   free(r);
}
Example #20
0
static Eina_Value *
azy_value_deserialize_struct_json(cJSON *object)
{
   Eina_Array *st_members, *st_values;
   unsigned int offset = 0, z = 0;
   Eina_Value *value_st = NULL;
   Eina_Value_Struct_Member *members;
   Eina_Value_Struct_Desc *st_desc;
   const char *name;
   cJSON *child;

   st_desc = azy_value_util_struct_desc_new();
   st_members = eina_array_new(1);
   st_values = eina_array_new(1);

   for (child = object->child; child; child = child->next)
     {
        Eina_Value_Struct_Member *m;
        const Eina_Value_Type *type;
        Eina_Value *v;

        type = _azy_value_type_get(child);
        if (!type) goto end;
        name = child->string;
        m = (Eina_Value_Struct_Member*)calloc(1, sizeof(Eina_Value_Struct_Member));
        m->name = eina_stringshare_add(name);
        offset = azy_value_util_type_offset(type, offset);
        m->offset = offset;
        offset += azy_value_util_type_size(type);
        m->type = type;
        eina_array_push(st_members, m);

        v = azy_value_deserialize_json(child);
        if (!v) goto end;
        eina_array_push(st_values, v);
        z++;
     }
   if (!z)
     {
        free(st_desc);
        goto end;
     }

   members = (Eina_Value_Struct_Member*)malloc(eina_array_count(st_members) * sizeof(Eina_Value_Struct_Member));
   for (z = 0; z < eina_array_count(st_members); z++)
     {
        Eina_Value_Struct_Member *m = (Eina_Value_Struct_Member*)eina_array_data_get(st_members, z);
        members[z].name = m->name;
        members[z].offset = m->offset;
        members[z].type = m->type;
        free(m);
     }

   //setup
   st_desc->members = members;
   st_desc->member_count = eina_array_count(st_members);
   st_desc->size = offset;
   value_st = eina_value_struct_new(st_desc);

   //filling with data
   for (z = 0; z < eina_array_count(st_values); z++)
     {
        Eina_Value *v = (Eina_Value*)eina_array_data_get(st_values, z);
        eina_value_struct_value_set(value_st, members[z].name, v);
        eina_value_free(v);
     }

end:
   eina_array_free(st_members);
   eina_array_free(st_values);
   return value_st;
}
Example #21
0
void filter_del(Filter *f)
{
  Eina_Hash *metas;
  
  lime_config_reset(f);
  
  pthread_mutex_destroy(&f->lock);
  
  /*if (f->node->con_trees_in && ea_count(f->node->con_trees_in))
    filter_deconfigure(((Con*)ea_data(f->node->con_trees_in, 0))->source->filter);*/
  
  if (f->node->con_trees_in) {
    if (ea_count(f->node->con_trees_in))
      con_del_real(ea_pop(f->node->con_trees_in));
    eina_array_free(f->node->con_trees_in);
    f->node->con_trees_in = NULL;
  }
  
  if (f->node->con_trees_out) {
    if (ea_count(f->node->con_trees_out))
      con_del_real(ea_pop(f->node->con_trees_out));
    eina_array_free(f->node->con_trees_out);
    f->node->con_trees_out = NULL;
  }
  
  if (f->node_orig->con_trees_in) {
    if (ea_count(f->node_orig->con_trees_in))
      con_del(ea_pop(f->node_orig->con_trees_in));
    eina_array_free(f->node_orig->con_trees_in);
    f->node_orig->con_trees_in = NULL;
  }
  
  if (f->node_orig->con_trees_out) {
    if (ea_count(f->node_orig->con_trees_out))
      con_del(ea_pop(f->node_orig->con_trees_out));
    eina_array_free(f->node_orig->con_trees_out);
    f->node_orig->con_trees_out = NULL;
  }
  
  if (f->node->con_ch_in)
    eina_array_free(f->node->con_ch_in);
  
  if (f->del)
    f->del(f);
  else
    printf("FIXME! del filter %s!\n", f->fc->shortname);
  
  while(ea_count(f->metas))
    meta_del(ea_pop(f->metas));
  
  eina_array_free(f->metas);
  eina_array_free(f->in);
  eina_array_free(f->out);
  eina_array_free(f->tune);
  eina_array_free(f->settings);
  eina_array_free(f->core);
  fg_node_del(f->node);
  fg_node_del(f->node_orig); 
  
  eina_array_free(f->data);
  
  if (f->mode_buffer)
    filter_mode_buffer_del(f->mode_buffer);
  if (f->mode_iter)
    filter_mode_iter_del(f->mode_iter);
  
  if (f->tw_s)
    free(f->tw_s);
  if (f->th_s)
    free(f->th_s);
    
  free(f);
}
Example #22
0
char *
_nedje_text_escape(const char *text)
{
   Eina_Strbuf *txt;
   char *ret;
   const char *text_end;
   size_t text_len;
   Eina_Array *arr;
   const char *cur_tag = NULL;

   if (!text) return NULL;

   txt = eina_strbuf_new();
   text_len = strlen(text);
   arr = eina_array_new(3);

   text_end = text + text_len;
   while (text < text_end)
     {
        int advance;

        if ((text[0] == '<') && text[1])
          {
             const char *tag, *popped;
             Eina_Bool closing = EINA_FALSE;

             if (text[1] == '/') //closing tag
               {
                  closing = EINA_TRUE;
                  tag = _get_tag(text + 2);
               }
             else
               tag = _get_tag(text + 1);
             if (closing)
               {
                  if (cur_tag && (tag != cur_tag))
                    {
                       /* tag mismatch: autoclose all failure tags
                        * not technically required by the spec,
                        * but it makes me feel better about myself
                        */
                       do
                         {
                            popped = eina_array_pop(arr);
                            if (eina_array_count(arr))
                              cur_tag = eina_array_data_get(arr, eina_array_count(arr) - 1);
                            else
                              cur_tag = NULL;
                            eina_strbuf_append_printf(txt, "</%c>", popped[1]);
                         } while (cur_tag && (popped != tag));
                       advance = 4;
                    }
                  else if (cur_tag)
                    {
                       /* tag match: just pop */
                       popped = eina_array_pop(arr);
                       if (eina_array_count(arr))
                         cur_tag = eina_array_data_get(arr, eina_array_count(arr) - 1);
                       else
                         cur_tag = NULL;
                       eina_strbuf_append_printf(txt, "</%c>", popped[1]);
                       advance = 4;
                    }
                  else
                    {
                       /* no current tag: escape */
                       advance = _text_escape(txt, text);
                    }
               }
             else
               {
                  if (tag)
                    {
                       cur_tag = tag;
                       eina_array_push(arr, tag);
                       eina_strbuf_append_printf(txt, "<%c>", tag[1]);
                       advance = 3;
                    }
                  else
                    advance = _text_escape(txt, text);
               }
          }
        else if (text[0] == '&')
          {
             const char *s;

             s = strchr(text, ';');
             if (s)
               s = evas_textblock_escape_string_range_get(text, s + 1);
             if (s)
               {
                  eina_strbuf_append_char(txt, text[0]);
                  advance = 1;
               }
             else
               advance = _text_escape(txt, text);
          }
        else
          advance = _text_escape(txt, text);

        text += advance;
     }

   eina_array_free(arr);
   ret = eina_strbuf_string_steal(txt);
   eina_strbuf_free(txt);
   return ret;
}