Exemplo n.º 1
0
void
_eina_simple_xml_node_tag_free(Eina_Simple_XML_Node_Tag *tag)
{
   while (tag->children)
     {
        Eina_Simple_XML_Node *n = EINA_INLIST_CONTAINER_GET
          (tag->children, Eina_Simple_XML_Node);
        if (n->type == EINA_SIMPLE_XML_NODE_TAG)
          _eina_simple_xml_node_tag_free((Eina_Simple_XML_Node_Tag *)n);
        else
          _eina_simple_xml_node_data_free((Eina_Simple_XML_Node_Data *)n);
     }

   while (tag->attributes)
     {
        Eina_Simple_XML_Attribute *a = EINA_INLIST_CONTAINER_GET
          (tag->attributes, Eina_Simple_XML_Attribute);
        eina_simple_xml_attribute_free(a);
     }

   if (tag->base.parent)
     tag->base.parent->children = eina_inlist_remove
          (tag->base.parent->children, EINA_INLIST_GET(&tag->base));

   eina_stringshare_del(tag->name);
   EINA_MAGIC_SET(&tag->base, EINA_MAGIC_NONE);
   eina_mempool_free(_eina_simple_xml_tag_mp, tag);
}
Exemplo n.º 2
0
Comic_Chapter_Item *
comic_chapter_item_chapter_add(Comic_Chapter *cc, Comic_Chapter_Item *cci)
{
   Eina_Bool forward = EINA_TRUE;

   //DBG("(cc=%g, cci=%g)", cc->number, cci ? cci->cc->number : 0);
   if (!cc->csd->cs->chapters)
     return _comic_chapter_item_new(cc);

   if (!cci)
     {
        if (cc->number > cc->csd->cs->total / 2)
          {
             cci = EINA_INLIST_CONTAINER_GET(cc->csd->cs->chapters->last, Comic_Chapter_Item);
             forward = EINA_FALSE;
          }
        else
          cci = EINA_INLIST_CONTAINER_GET(cc->csd->cs->chapters, Comic_Chapter_Item);
     }
   if (cci->cc->number > cc->number)
     forward = EINA_FALSE;
   if (forward)
     {
        //DBG("ITER: FORWARD");
        for (; cci; cci = comic_chapter_item_next_get(cci))
          {
             if (cci->cc->number < cc->number) continue;
             cc->csd->chapters = eina_inlist_remove(cc->csd->chapters, EINA_INLIST_GET(cc));
             //DBG("INSERT: %g", cci->cc->number);
             cci->chapters = eina_inlist_sorted_insert(cci->chapters, EINA_INLIST_GET(cc), (Eina_Compare_Cb)_comic_chapter_sort_cb);
             cci->chapter_count++;
             _comic_chapter_item_update(cci, cc, EINA_FALSE);
             return cci;
          }
        return _comic_chapter_item_new(cc);
     }
    //DBG("ITER: BACKWARD");
    for (; cci; cci = comic_chapter_item_prev_get(cci))
      {
         if (cci->cc->number > cc->number) continue;
         cc->csd->chapters = eina_inlist_remove(cc->csd->chapters, EINA_INLIST_GET(cc));
         //DBG("INSERT: %g", cci->cc->number);
         cci->chapters = eina_inlist_sorted_insert(cci->chapters, EINA_INLIST_GET(cc), (Eina_Compare_Cb)_comic_chapter_sort_cb);
         cci->chapter_count++;
         _comic_chapter_item_update(cci, cc, EINA_FALSE);
         return cci;
      }
   return _comic_chapter_item_new(cc);
}
Exemplo n.º 3
0
/**
 * @brief Convert result to a string
 * @param res Result
 * @return Stringshared result
 */
const char *
esql_res_to_string(Esql_Res *res)
{
   Esql_Row *row;
   Esql_Cell *cell;
   EINA_SAFETY_ON_NULL_RETURN_VAL(res, NULL);
   EINA_SAFETY_ON_TRUE_RETURN_VAL(res->row_count > 1, NULL);
   if (!res->row_count) return NULL;
   row = EINA_INLIST_CONTAINER_GET(res->rows, Esql_Row);
   cell = EINA_INLIST_CONTAINER_GET(row->cells, Esql_Cell);
   EINA_SAFETY_ON_TRUE_RETURN_VAL(
     (cell->type != ESQL_CELL_TYPE_STRING) &&
     (cell->type != ESQL_CELL_TYPE_UNKNOWN), NULL);
   return eina_stringshare_add(cell->value.string);
}
Exemplo n.º 4
0
/**
 * @brief Convert result to a string
 * @param res Result
 * @return Stringshared result
 */
const char *
esql_res_to_string(const Esql_Res *res)
{
   const Esql_Row *row;
   const Eina_Value_Struct_Member *member;
   Eina_Value tmp, conv;

   EINA_SAFETY_ON_NULL_RETURN_VAL(res, NULL);
   EINA_SAFETY_ON_TRUE_RETURN_VAL(res->row_count > 1, NULL);
   if (!res->row_count) return NULL;
   row = EINA_INLIST_CONTAINER_GET(res->rows, Esql_Row);

   member = row->res->desc->members;
   if (!eina_value_struct_value_get(&(row->value), member->name, &tmp))
     return NULL;

   conv.type = EINA_VALUE_TYPE_STRINGSHARE;
   if (!eina_value_convert(&tmp, &conv)) goto error_convert;

   eina_value_flush(&tmp);
   return conv.value.ptr;  /* no flush, ptr is a stringshared string! */

 error_convert:
   eina_value_flush(&tmp);
   return NULL;
}
Exemplo n.º 5
0
/**
 * @brief Convert result to an unsigned long int
 * @param res Result
 * @return Unsigned long int
 */
unsigned long int
esql_res_to_ulong(const Esql_Res *res)
{
   const Esql_Row *row;
   const Eina_Value_Struct_Member *member;
   Eina_Value tmp, conv;
   unsigned long int ret;

   EINA_SAFETY_ON_NULL_RETURN_VAL(res, 0);
   EINA_SAFETY_ON_TRUE_RETURN_VAL(res->row_count > 1, 0);
   if (!res->row_count) return 0;
   row = EINA_INLIST_CONTAINER_GET(res->rows, Esql_Row);

   member = row->res->desc->members;
   if (!eina_value_struct_value_get(&(row->value), member->name, &tmp))
     return 0;

   conv.type = EINA_VALUE_TYPE_ULONG;
   if (!eina_value_convert(&tmp, &conv)) goto error_convert;

   eina_value_flush(&tmp);
   if (!eina_value_pget(&conv, &ret))
     return 0;

   return ret;

 error_convert:
   eina_value_flush(&tmp);
   return 0;
}
Exemplo n.º 6
0
/**
 * @brief Convert result to a timeval struct
 * @param res Result
 * @return Pointer to allocated struct timeval (must be freed)
 */
struct timeval *
esql_res_to_timeval(Esql_Res *res)
{
   Esql_Row *row;
   Esql_Cell *cell;
   struct timeval *ret;
   EINA_SAFETY_ON_NULL_RETURN_VAL(res, NULL);
   EINA_SAFETY_ON_TRUE_RETURN_VAL(res->row_count > 1, NULL);
   if (!res->row_count) return NULL;
   row = EINA_INLIST_CONTAINER_GET(res->rows, Esql_Row);
   cell = EINA_INLIST_CONTAINER_GET(row->cells, Esql_Cell);
   EINA_SAFETY_ON_TRUE_RETURN_VAL((cell->type != ESQL_CELL_TYPE_TIME) &&
     (cell->type != ESQL_CELL_TYPE_UNKNOWN), NULL);
   ret = calloc(1, sizeof(struct timeval));
   memcpy(ret, &cell->value.tv, sizeof(struct timeval));
   return ret;
}
Exemplo n.º 7
0
/**
 * @brief Convert result to a binary blob
 * @param res Result
 * @return Allocated binary blob (must be freed)
 */
unsigned char *
esql_res_to_blob(Esql_Res *res)
{
   Esql_Row *row;
   Esql_Cell *cell;
   unsigned char *ret;
   EINA_SAFETY_ON_NULL_RETURN_VAL(res, NULL);
   EINA_SAFETY_ON_TRUE_RETURN_VAL(res->row_count > 1, NULL);
   if (!res->row_count) return NULL;
   row = EINA_INLIST_CONTAINER_GET(res->rows, Esql_Row);
   cell = EINA_INLIST_CONTAINER_GET(row->cells, Esql_Cell);
   EINA_SAFETY_ON_TRUE_RETURN_VAL(
     (cell->type != ESQL_CELL_TYPE_BLOB) &&
     (cell->type != ESQL_CELL_TYPE_UNKNOWN), NULL);
   ret = malloc(cell->len);
   memcpy(ret, cell->value.blob, cell->len);
   return ret;
}
Exemplo n.º 8
0
/**
 * @brief Convert result to a double
 * @param res Result
 * @return The result
 */
double
esql_res_to_double(Esql_Res *res)
{
   Esql_Row *row;
   Esql_Cell *cell;
   EINA_SAFETY_ON_NULL_RETURN_VAL(res, 0.0);
   EINA_SAFETY_ON_TRUE_RETURN_VAL(res->row_count > 1, 0.0);
   if (!res->row_count) return 0.0;
   row = EINA_INLIST_CONTAINER_GET(res->rows, Esql_Row);
   cell = EINA_INLIST_CONTAINER_GET(row->cells, Esql_Cell);
   switch (cell->type)
     {
      case ESQL_CELL_TYPE_FLOAT:
        return cell->value.f;
        break;
      case ESQL_CELL_TYPE_DOUBLE:
        return cell->value.d;
        break;
      default:
        return 0.0;
     }
   return EINA_TRUE;
}
Exemplo n.º 9
0
static Eina_Bool
esql_row_iterator_next(Esql_Row_Iterator *it,
                       Esql_Row         **r)
{
   Eina_Inlist *l;

   if (!it->current) return EINA_FALSE;

   *r = (Esql_Row *)it->current;

   l = EINA_INLIST_GET((Esql_Row *)it->current);
   it->current = l ? EINA_INLIST_CONTAINER_GET(l->next, Esql_Row) : NULL;

   return EINA_TRUE;
}
Exemplo n.º 10
0
/**
 * @brief Convert result to a long long int
 * @param res Result
 * @return The result
 */
long long int
esql_res_to_lli(Esql_Res *res)
{
   Esql_Row *row;
   Esql_Cell *cell;
   EINA_SAFETY_ON_NULL_RETURN_VAL(res, 0);
   EINA_SAFETY_ON_TRUE_RETURN_VAL(res->row_count > 1, 0);
   if (!res->row_count) return 0;
   row = EINA_INLIST_CONTAINER_GET(res->rows, Esql_Row);
   cell = EINA_INLIST_CONTAINER_GET(row->cells, Esql_Cell);
   switch (cell->type)
     {
      case ESQL_CELL_TYPE_TINYINT:
        return cell->value.c;
      case ESQL_CELL_TYPE_SHORT:
        return cell->value.s;
      case ESQL_CELL_TYPE_LONG:
        return cell->value.i;
      case ESQL_CELL_TYPE_LONGLONG:
        return cell->value.l;
      default:
        return 0;
     }
}
Exemplo n.º 11
0
static void
_ecore_x_input_touch_info_clear(void)
{
   Eina_Inlist *l = _ecore_x_xi2_touch_info_list;
   Ecore_X_Touch_Device_Info *info = NULL;

   while (l)
     {
        info = EINA_INLIST_CONTAINER_GET(l, Ecore_X_Touch_Device_Info);
        l = eina_inlist_remove(l, l);
        if (info->slot) free(info->slot);
        free(info);
     }

   _ecore_x_xi2_touch_info_list = NULL;
}
Exemplo n.º 12
0
static void
_message_iterator_free(Eldbus_Message_Iter *iter)
{
   Eina_Inlist *lst, *next;
   Eldbus_Message_Iter *sub;
   if (!iter) return;

   lst = iter->iterators;
   while (lst)
     {
        next = lst->next;
        sub = EINA_INLIST_CONTAINER_GET(lst, Eldbus_Message_Iter);
        _message_iterator_free(sub);
        lst = next;
     }
   free(iter);
}
Exemplo n.º 13
0
void
comic_chapter_item_chapter_del(Comic_Chapter *cc)
{
   Comic_Chapter_Item *cci = cc->cci;

   cci->chapters = eina_inlist_remove(cci->chapters, EINA_INLIST_GET(cc));
   cci->chapter_count--;
   if (cc != cci->cc) return;

   if (cci->chapters)
     {
        cci->cc = EINA_INLIST_CONTAINER_GET(cci->chapters, Comic_Chapter);
        _comic_chapter_item_update(cci, cci->cc, EINA_TRUE);
        return;
     }

   cc->csd->cs->chapters = eina_inlist_remove(cc->csd->cs->chapters, EINA_INLIST_GET(cci));
   free(cci);
}
Exemplo n.º 14
0
static void
_esql_res_free(Esql_Res *res)
{
   Esql_Row *r;
   Eina_Inlist *l;

   DBG("res=%p (refcount=%d)", res, res->refcount);

   if (res->rows)
     EINA_INLIST_FOREACH_SAFE(res->rows, l, r)
       esql_row_free(r);

   if (res->desc)
     {
        /* memset is not needed, but leave it here to find if people
         * kept reference to values after row is removed, see below.
         */
        memset(res->desc, 0, sizeof(res->desc));
        free(res->desc);

        /* NOTE: after this point, if users are still holding 'desc' they will
         * have problems. This can be done if user calls eina_value_copy()
         * on some esql_row_value_struct_get()
         *
         * If this is an use case, add Eina_Value_Struct_Desc to some other
         * struct and do reference counting on it, increment on
         * alloc/copy, decrement on free.
         *
         * Remember that struct is created/ref on thread, and it is free'd
         * on main thread, then needs locking!
         */
     }

   if (res->e->pool)
     {
        Esql_Pool *ep = (Esql_Pool*)res->e;
        res->e = EINA_INLIST_CONTAINER_GET(ep->esqls, Esql);
     }
   res->e->backend.res_free(res);
   free(res->query);
   if (res->mempool) eina_mempool_del(res->mempool);
   esql_res_mp_free(res);
}
Exemplo n.º 15
0
/**
 * @brief Convert result to a binary blob
 * @param res Result
 * @return Allocated binary blob (must be freed)
 */
unsigned char *
esql_res_to_blob(const Esql_Res *res, unsigned int *size)
{
   const Esql_Row *row;
   const Eina_Value_Struct_Member *member;
   Eina_Value tmp, conv;
   Eina_Value_Blob blob;
   unsigned char *ret = NULL;

   if (size) *size = 0;

   EINA_SAFETY_ON_NULL_RETURN_VAL(res, NULL);
   EINA_SAFETY_ON_TRUE_RETURN_VAL(res->row_count > 1, NULL);
   if (!res->row_count) return NULL;
   row = EINA_INLIST_CONTAINER_GET(res->rows, Esql_Row);

   member = row->res->desc->members;
   if (!eina_value_struct_value_get(&(row->value), member->name, &tmp))
     return NULL;

   if (!eina_value_setup(&conv, EINA_VALUE_TYPE_BLOB)) goto error_setup;
   if (!eina_value_convert(&tmp, &conv)) goto error;
   if (!eina_value_pget(&conv, &blob)) goto error;

   ret = malloc(blob.size);
   EINA_SAFETY_ON_NULL_GOTO(ret, error);

   memcpy(ret, blob.memory, blob.size);
   if (size) *size = blob.size;

 error:
   eina_value_flush(&conv);
 error_setup:
   eina_value_flush(&tmp);
   return ret;
}
Exemplo n.º 16
0
Comic_Chapter_Item *
comic_chapter_item_next_get(Comic_Chapter_Item *cci)
{
   if (!EINA_INLIST_GET(cci)->next) return NULL;
   return EINA_INLIST_CONTAINER_GET(EINA_INLIST_GET(cci)->next, Comic_Chapter_Item);
}
Exemplo n.º 17
0
Comic_Chapter_Item *
comic_chapter_item_prev_get(Comic_Chapter_Item *cci)
{
   if (!EINA_INLIST_GET(cci)->prev) return NULL;
   return EINA_INLIST_CONTAINER_GET(EINA_INLIST_GET(cci)->prev, Comic_Chapter_Item);
}