sync/gen_actions.ysl2
author Thomas
Thu, 27 Jun 2019 09:29:20 +0200
branchsequoia_windows
changeset 3878 37426cf0d1fe
parent 3515 287699a9aa7c
permissions -rw-r--r--
Merge with ENGINE-581
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
vb@2829
    27
krista@2271
    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@3515
    53
                return memcmp(t1->buf, t2->buf, t1->size) > 0;
vb@2902
    54
            }
vb@2902
    55
krista@2271
    56
            ||
vb@2829
    57
            apply "func:distinctName(//condition)", 0;
vb@2913
    58
            apply "func:distinctName(//action)", 0;
vb@2915
    59
            apply "/protocol/fsm", 0;
krista@2271
    60
        }
krista@2271
    61
    }
krista@2271
    62
vb@2829
    63
    template "condition" | #error condition «@name» not implemented\n
vb@2829
    64
    template "action" | #error action «@name» not implemented\n
vb@2829
    65
vb@2829
    66
    function "condition" {
vb@2829
    67
        param "content";
vb@2829
    68
        ||
vb@2829
    69
        PEP_STATUS «@name»(PEP_SESSION session, bool *result)
vb@2829
    70
        {
vb@2829
    71
            assert(session && result);
vb@2829
    72
            if (!(session && result))
vb@2829
    73
                return PEP_ILLEGAL_VALUE;
krista@2271
    74
krista@2271
    75
        ||
vb@2829
    76
        copy "$content";
vb@2829
    77
        ||
krista@2271
    78
vb@2829
    79
            return PEP_STATUS_OK;
krista@2271
    80
        }
krista@2271
    81
krista@2271
    82
        ||
krista@2271
    83
    }
krista@2271
    84
vb@2829
    85
    function "action" {
vb@2829
    86
        param "content";
vb@2829
    87
        ||
vb@2829
    88
        PEP_STATUS «@name»(PEP_SESSION session)
vb@2829
    89
        {
vb@2829
    90
            assert(session);
vb@2829
    91
            if (!session)
vb@2829
    92
                return PEP_ILLEGAL_VALUE;
krista@2271
    93
krista@2271
    94
        ||
vb@2829
    95
        copy "$content";
krista@2271
    96
        ||
krista@2271
    97
krista@2271
    98
            return PEP_STATUS_OK;
krista@2271
    99
        }
krista@2271
   100
krista@2271
   101
        ||
krista@2271
   102
    }
vb@2914
   103
vb@2914
   104
    function "fsm" {
vb@2914
   105
        param "content";
vb@2914
   106
        ||
vb@2914
   107
        PEP_STATUS «@name»TimeoutHandler(PEP_SESSION session)
vb@2914
   108
        {
vb@2914
   109
            assert(session);
vb@2914
   110
            if (!session)
vb@2914
   111
                return PEP_ILLEGAL_VALUE;
vb@2914
   112
vb@2914
   113
        ||
vb@2914
   114
        copy "$content";
vb@2914
   115
        ||
vb@2914
   116
vb@2914
   117
            return PEP_STATUS_OK;
vb@2914
   118
        }
vb@2914
   119
vb@2914
   120
        ||
vb@2914
   121
    }
krista@2271
   122
}
krista@2271
   123