adding _length() functions
authorVolker Birk <vb@pep-project.org>
Thu, 30 Apr 2015 19:01:58 +0200
changeset 2305b36a2663539
parent 223 9bbb443703bc
child 231 d862ff6c48c7
adding _length() functions
src/bloblist.c
src/bloblist.h
src/identity_list.c
src/identity_list.h
     1.1 --- a/src/bloblist.c	Thu Apr 23 18:00:45 2015 +0200
     1.2 +++ b/src/bloblist.c	Thu Apr 30 19:01:58 2015 +0200
     1.3 @@ -109,3 +109,19 @@
     1.4      return bloblist_add(bloblist->next, blob, size, mime_type, filename);
     1.5  }
     1.6  
     1.7 +DYNAMIC_API int bloblist_length(const bloblist_t *bloblist)
     1.8 +{
     1.9 +    int len = 1;
    1.10 +    bloblist_t *_bloblist;
    1.11 +
    1.12 +    assert(bloblist);
    1.13 +
    1.14 +    if (bloblist->data == NULL)
    1.15 +        return 0;
    1.16 +
    1.17 +    for (_bloblist = bloblist->next; _bloblist != NULL;
    1.18 +        _bloblist = _bloblist->next)
    1.19 +        len += 1;
    1.20 +
    1.21 +    return len;
    1.22 +}
     2.1 --- a/src/bloblist.h	Thu Apr 23 18:00:45 2015 +0200
     2.2 +++ b/src/bloblist.h	Thu Apr 30 19:01:58 2015 +0200
     2.3 @@ -78,6 +78,17 @@
     2.4          const char *mime_type, const char *filename);
     2.5  
     2.6  
     2.7 +// bloblist_length() - get length of bloblist
     2.8 +//
     2.9 +//  parameters:
    2.10 +//      bloblist (in)   bloblist struct to determine length of
    2.11 +//
    2.12 +//  return value:
    2.13 +//      length of bloblist in number of elements
    2.14 +
    2.15 +DYNAMIC_API int bloblist_length(const bloblist_t *bloblist);
    2.16 +
    2.17 +
    2.18  #ifdef __cplusplus
    2.19  }
    2.20  #endif
     3.1 --- a/src/identity_list.c	Thu Apr 23 18:00:45 2015 +0200
     3.2 +++ b/src/identity_list.c	Thu Apr 30 19:01:58 2015 +0200
     3.3 @@ -67,3 +67,12 @@
     3.4      }
     3.5  }
     3.6  
     3.7 +DYNAMIC_API int identity_list_length(const identity_list *id_list)
     3.8 +{
     3.9 +    int len = 0;
    3.10 +
    3.11 +    for (; id_list && id_list->ident; id_list = id_list->next)
    3.12 +        ++len;
    3.13 +
    3.14 +    return len;
    3.15 +}
     4.1 --- a/src/identity_list.h	Thu Apr 23 18:00:45 2015 +0200
     4.2 +++ b/src/identity_list.h	Thu Apr 30 19:01:58 2015 +0200
     4.3 @@ -67,6 +67,17 @@
     4.4  DYNAMIC_API identity_list *identity_list_add(identity_list *id_list, pEp_identity *ident);
     4.5  
     4.6  
     4.7 +// identity_list_length() - get length of identity_list
     4.8 +//
     4.9 +//  parameters:
    4.10 +//      id_list (in)        identity_list struct to determine length of
    4.11 +//
    4.12 +//  return value:
    4.13 +//      length of identity_list in number of elements
    4.14 +
    4.15 +DYNAMIC_API int identity_list_length(const identity_list *id_list);
    4.16 +
    4.17 +
    4.18  #ifdef __cplusplus
    4.19  }
    4.20  #endif