sync/gen_actions.ysl2
author us@chu.huenfield.org
Tue, 25 Dec 2018 14:46:45 +0100
branchsync
changeset 3209 c15b4ca2b52a
parent 2921 8bae76a4f918
child 3515 287699a9aa7c
permissions -rw-r--r--
Replace use of Sequoia's backend with a custom key store.

- Sequoia's key store doesn't meet pep's needs (in particular, the
ability to search on a key's user id) and trying to shoehorn pep's
needs onto Sequoia's key store abstractions is just introducing
overhead with no appreciable gain in functionality.

- This patch changes the Sequoia backend to use a local sqlite
database to store the public keys.
krista@2271
     1
// This file is under GNU General Public License 3.0
krista@2271
     2
// see LICENSE.txt
krista@2271
     3
vb@2829
     4
// generate conditions and actions
krista@2271
     5
vb@2906
     6
// Copyleft (c) 2017, 2018, p≡p foundation
krista@2271
     7
krista@2271
     8
// Written by Volker Birk
krista@2271
     9
vb@2921
    10
krista@2271
    11
include yslt.yml2
krista@2271
    12
vb@2829
    13
decl _func *name (*type) alias - {
vb@2829
    14
    template %name=*name, %type=*type, "%type[@name='%name']"
vb@2829
    15
        call *type with "content" content;
vb@2829
    16
};
vb@2829
    17
vb@2829
    18
decl condition is _func (*type="condition");
vb@2829
    19
decl action is _func (*type="action");
vb@2916
    20
decl timeout is _func (*type="fsm");
vb@2914
    21
krista@2271
    22
tstylesheet {
krista@2271
    23
    include standardlib.ysl2
krista@2271
    24
    include ./functions.ysl2
krista@2271
    25
vb@2844
    26
    include ./cond_act_*.yml2
krista@2271
    27
vb@2829
    28
    template "/protocol" {
vb@2829
    29
        document "generated/{@name}_actions.c", "text" {
vb@2829
    30
            ||
vb@2829
    31
            // This file is under GNU General Public License 3.0
vb@2829
    32
            // see LICENSE.txt
krista@2271
    33
vb@2830
    34
            #include "pEp_internal.h"
vb@2830
    35
            #include "map_asn1.h"
vb@2830
    36
vb@2829
    37
            #include "«@name»_impl.h"
vb@2829
    38
            `` for "fsm" | #include "«@name»_fsm.h"
krista@2271
    39
vb@2902
    40
            static bool _TID_greater(TID_t *t1, TID_t *t2)
vb@2902
    41
            {
vb@2903
    42
                assert(t1 && t2);
vb@2903
    43
                if (t1 && !t2)
vb@2903
    44
                    return true;
vb@2903
    45
                if (!t1)
vb@2903
    46
                    return false;
vb@2903
    47
vb@2902
    48
                if (t1->size > t2->size)
vb@2902
    49
                    return true;
vb@2902
    50
                if (t2->size > t1->size)
vb@2902
    51
                    return false;
vb@2902
    52
vb@2902
    53
                for (int i=0; i<t1->size; i++) {
vb@2902
    54
                    if (t1->buf[i] > t2->buf[i])
vb@2902
    55
                        return true;
vb@2904
    56
                    if (t2->buf[i] > t1->buf[i])
vb@2904
    57
                        return false;
vb@2902
    58
                }
vb@2902
    59
vb@2902
    60
                return false;
vb@2902
    61
            }
vb@2902
    62
krista@2271
    63
            ||
vb@2829
    64
            apply "func:distinctName(//condition)", 0;
vb@2913
    65
            apply "func:distinctName(//action)", 0;
vb@2915
    66
            apply "/protocol/fsm", 0;
krista@2271
    67
        }
krista@2271
    68
    }
krista@2271
    69
vb@2829
    70
    template "condition" | #error condition «@name» not implemented\n
vb@2829
    71
    template "action" | #error action «@name» not implemented\n
krista@2271
    72
vb@2829
    73
    function "condition" {
vb@2829
    74
        param "content";
vb@2829
    75
        ||
vb@2829
    76
        PEP_STATUS «@name»(PEP_SESSION session, bool *result)
vb@2829
    77
        {
vb@2829
    78
            assert(session && result);
vb@2829
    79
            if (!(session && result))
vb@2829
    80
                return PEP_ILLEGAL_VALUE;
vb@2829
    81
vb@2829
    82
        ||
vb@2829
    83
        copy "$content";
krista@2271
    84
        ||
krista@2271
    85
vb@2829
    86
            return PEP_STATUS_OK;
krista@2271
    87
        }
krista@2271
    88
krista@2271
    89
        ||
krista@2271
    90
    }
krista@2271
    91
vb@2829
    92
    function "action" {
vb@2829
    93
        param "content";
krista@2271
    94
        ||
vb@2829
    95
        PEP_STATUS «@name»(PEP_SESSION session)
krista@2271
    96
        {
vb@2829
    97
            assert(session);
vb@2829
    98
            if (!session)
krista@2271
    99
                return PEP_ILLEGAL_VALUE;
krista@2271
   100
krista@2271
   101
        ||
vb@2829
   102
        copy "$content";
krista@2271
   103
        ||
krista@2271
   104
vb@2829
   105
            return PEP_STATUS_OK;
krista@2271
   106
        }
krista@2271
   107
krista@2271
   108
        ||
krista@2271
   109
    }
vb@2914
   110
vb@2914
   111
    function "fsm" {
vb@2914
   112
        param "content";
vb@2914
   113
        ||
vb@2914
   114
        PEP_STATUS «@name»TimeoutHandler(PEP_SESSION session)
vb@2914
   115
        {
vb@2914
   116
            assert(session);
vb@2914
   117
            if (!session)
vb@2914
   118
                return PEP_ILLEGAL_VALUE;
vb@2914
   119
vb@2914
   120
        ||
vb@2914
   121
        copy "$content";
vb@2914
   122
        ||
vb@2914
   123
vb@2914
   124
            return PEP_STATUS_OK;
vb@2914
   125
        }
vb@2914
   126
vb@2914
   127
        ||
vb@2914
   128
    }
krista@2271
   129
}
krista@2271
   130