stashing changes to switch branches ENGINE-109
authorKrista Grothoff <krista@pep-project.org>
Mon, 17 Oct 2016 13:06:59 +0200
branchENGINE-109
changeset 12828e9c3ecdf40f
parent 1276 a926b9e401ee
child 1292 c310459ec5d3
stashing changes to switch branches
src/pEpEngine.c
     1.1 --- a/src/pEpEngine.c	Thu Oct 13 16:24:40 2016 +0200
     1.2 +++ b/src/pEpEngine.c	Mon Oct 17 13:06:59 2016 +0200
     1.3 @@ -877,6 +877,56 @@
     1.4      return PEP_STATUS_OK;
     1.5  }
     1.6  
     1.7 +DYNAMIC_API PEP_STATUS trustwords_for_id_pair(
     1.8 +    PEP_SESSION session, pEp_identity* id1, pEp_identity* id2,
     1.9 +    char* lang, char **words, size_t *wsize, int max_words_per_id
    1.10 +)
    1.11 +{
    1.12 +    assert(session);
    1.13 +    assert(id1);
    1.14 +    assert(id2);
    1.15 +    assert(id1->fpr);
    1.16 +    assert(id2->fpr);
    1.17 +    assert(words);
    1.18 +    assert(wsize);
    1.19 +    assert(max_words_per_id >= 0);
    1.20 +    
    1.21 +    if (!(session && id1 && id2 && words && wsize && max_words_per_id >= 0) ||
    1.22 +        !(id1->fpr) || (!id2->fpr))
    1.23 +        return PEP_ILLEGAL_VALUE;
    1.24 +    
    1.25 +    const char *source1 = id1->fpr;
    1.26 +    const char *source2 = id2->fpr;
    1.27 +    
    1.28 +    *words = NULL;
    1.29 +    *wsize = 0;
    1.30 +
    1.31 +    char* first_set = NULL;
    1.32 +    char* second_set = NULL;
    1.33 +    size_t first_wsize = 0;
    1.34 +    size_t second_wsize = 0;
    1.35 +    PEP_STATUS status;
    1.36 +    
    1.37 +    if (source1 > source2) {
    1.38 +        status = trustwords(session, source2, lang, &first_set, &first_wsize, max_words_per_id);
    1.39 +        if (status != PEP_STATUS_OK)
    1.40 +            return status;
    1.41 +        status = trustwords(session, source1, lang, &second_set, &second_wsize, max_words_per_id); 
    1.42 +        if (status != PEP_STATUS_OK)
    1.43 +            return status;
    1.44 +    }
    1.45 +    else {
    1.46 +        status = trustwords(session, source1, lang, &first_set, &first_wsize, max_words_per_id);
    1.47 +        if (status != PEP_STATUS_OK)
    1.48 +            return status;
    1.49 +        status = trustwords(session, source2, lang, &second_set, &second_wsize, max_words_per_id); 
    1.50 +        if (status != PEP_STATUS_OK)
    1.51 +            return status;
    1.52 +    }
    1.53 +    
    1.54 +}
    1.55 +
    1.56 +
    1.57  pEp_identity *new_identity(
    1.58          const char *address, const char *fpr, const char *user_id,
    1.59          const char *username