src/pEp_internal.h
branchtest_diphoton
changeset 2089 174f5577c0aa
parent 1860 1975a3b9bc37
parent 2048 4612060c1d49
child 2166 4c7f95dacc6a
child 2239 9fce961e7ae9
     1.1 --- a/src/pEp_internal.h	Tue Aug 08 15:00:18 2017 +0200
     1.2 +++ b/src/pEp_internal.h	Thu Sep 21 17:03:26 2017 +0200
     1.3 @@ -31,6 +31,12 @@
     1.4  #endif
     1.5  #define CRASHDUMP_MAX_LINES 32767
     1.6  
     1.7 +// p≡p full string, NUL-terminated
     1.8 +#ifndef PEP_SUBJ_STRING
     1.9 +#define PEP_SUBJ_STRING {0x70,0xE2,0x89,0xA1,0x70,0x00}
    1.10 +#define PEP_SUBJ_BYTELEN 5
    1.11 +#endif
    1.12 +
    1.13  #include "platform.h"
    1.14  
    1.15  #ifdef WIN32
    1.16 @@ -56,7 +62,11 @@
    1.17  #include <stdio.h>
    1.18  #include <ctype.h>
    1.19  
    1.20 +#ifdef SQLITE3_FROM_OS
    1.21 +#include <sqlite3.h>
    1.22 +#else
    1.23  #include "sqlite3.h"
    1.24 +#endif
    1.25  
    1.26  #define _EXPORT_PEP_ENGINE_DLL
    1.27  #include "pEpEngine.h"
    1.28 @@ -179,7 +189,7 @@
    1.29          size_t psize, char **ctext, size_t *csize
    1.30  );
    1.31  
    1.32 -// #ifdef NDEBUG
    1.33 +// #if defined(NDEBUG) || defined(NOLOG)
    1.34  // #define DEBUG_LOG(TITLE, ENTITY, DESC)
    1.35  // #else
    1.36  #ifdef ANDROID
    1.37 @@ -313,6 +323,30 @@
    1.38      return comparison == 0;
    1.39  }
    1.40  
    1.41 +static inline bool _identity_me(
    1.42 +        pEp_identity * identity
    1.43 +    )
    1.44 +{
    1.45 +    return identity->user_id && strcmp(identity->user_id, PEP_OWN_USERID) == 0;
    1.46 +}
    1.47 +
    1.48 +// size is the length of the bytestr that's coming in. This is really only intended
    1.49 +// for comparing two full strings. If charstr's length is different from bytestr_size,
    1.50 +// we'll return a non-zero value.
    1.51 +static inline int _unsigned_signed_strcmp(const unsigned char* bytestr, const char* charstr, int bytestr_size) {
    1.52 +    int charstr_len = strlen(charstr);
    1.53 +    if (charstr_len != bytestr_size)
    1.54 +        return -1; // we don't actually care except that it's non-zero
    1.55 +    return memcmp(bytestr, charstr, bytestr_size);
    1.56 +}
    1.57 +
    1.58 +// This is just a horrible example of C type madness. UTF-8 made me do it.
    1.59 +static inline char* _pep_subj_copy() {
    1.60 +    unsigned char pepstr[] = PEP_SUBJ_STRING;
    1.61 +    void* retval = calloc(1, sizeof(unsigned char)*PEP_SUBJ_BYTELEN + 1);
    1.62 +    memcpy(retval, pepstr, PEP_SUBJ_BYTELEN);
    1.63 +    return (char*)retval;
    1.64 +}
    1.65  
    1.66  #ifdef DEBUG_ERRORSTACK
    1.67      PEP_STATUS session_add_error(PEP_SESSION session, const char* file, unsigned line, PEP_STATUS status);