summaryrefslogtreecommitdiff
path: root/local/mib2c-conf.d/syntax-RowStatus-dependencies.m2i
blob: 9f14baf849ba9abb689c730ca1a6f7db5000710c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#############################################################  -*- c -*-
## generic include for XXX. Do not use directly.
##
## $Id$
########################################################################
@if $m2c_mark_boundary == 1@
/** START code generated by $RCSfile$ $Revision$ */
@end@
########################################################################
## {
    /*
     * check RowStatus dependencies
     */
    if (rowreq_ctx->column_set_flags & COLUMN_$node.uc_FLAG) {
        /*
         * check for valid RowStatus transition (old, new)
         * (Note: move transition check to $node_check_value
         *  to catch errors earlier)
         */
        rc = check_rowstatus_transition( ${m2c_undo_item}$node,
                                         ${m2c_data_item}$node );
        if (MFD_SUCCESS != rc)
            return rc;
        
@if $m2c_table_row_creation == 1@
        /*
         * row creation requirements
         */
        if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) {
            if (ROWSTATUS_DESTROY ==  ${m2c_data_item}$node) {
                rowreq_ctx->rowreq_flags |= MFD_ROW_DELETED;
            }
            else if (ROWSTATUS_CREATEANDGO ==  ${m2c_data_item}$node) {
                if ((rowreq_ctx->column_set_flags & $context.uc_REQUIRED_COLS)
                    != $context.uc_REQUIRED_COLS) {
                    DEBUGMSGTL(("${context}",
                                "required columns missing (0x%0x != 0x%0x)\n",
                                rowreq_ctx->column_set_flags, $context.uc_REQUIRED_COLS));
                    return MFD_CANNOT_CREATE_NOW;
                }
                ${m2c_data_item}$node = ROWSTATUS_ACTIVE;
            }
        } /* row creation */
        else {
@end@
            /*
             * row change requirements
             */
            /*
             * don't allow a destroy if any other value was changed, since
             * that might call data access routines with bad info.
             *
             * you may or may not require the row be notInService before it
             * can be destroyed.
             */
            if (ROWSTATUS_DESTROY == ${m2c_data_item}$node) {
@if $m2c_table_refcounts == 1@
                if (0 != rowreq_ctx->ref_count) {
                    DEBUGMSGTL(("$context",
                                "can't delete row, %d references\n",
                                rowreq_ctx->ref_count));
                    return MFD_NOT_VALID_NOW;
                }
@end@
                if (rowreq_ctx->column_set_flags & ~COLUMN_$node.uc_FLAG) {
                    DEBUGMSGTL(("$context",
                                "destroy must be only varbind for row\n"));
                    return MFD_NOT_VALID_NOW;
                }
                rowreq_ctx->rowreq_flags |= MFD_ROW_DELETED;

            } /* row destroy */
@if $m2c_table_refcounts == 1@
            else if(ROWSTATUS_NOTINSERVICE == ${m2c_data_item}$node) {
                if (0 != rowreq_ctx->ref_count) {
                    DEBUGMSGTL(("$context",
                                "can't deactivate row, %d references\n",
                                rowreq_ctx->ref_count));
                    return MFD_NOT_VALID_NOW;
                }
            } /* notInService */
@end@
@if $m2c_table_row_creation == 1@
        } /* row change */
@end@
    }
    else {
@if $m2c_table_row_creation == 1@
        /*
         * must have row status to create a row
         */
        if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) {
            DEBUGMSGTL(("$context",
                        "must use RowStatus to create rows\n"));
            return MFD_CANNOT_CREATE_NOW;
        }
@else@
        /*
         * row creation not supported
         */
        if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) {
            DEBUGMSGTL(("$context",
                        "row creation not supported\n"));
            return MFD_CANNOT_CREATE_EVER;
        }
@end@
    } /* row status not set */

## }
########################################################################
@if $m2c_mark_boundary == 1@
/** END code generated by $RCSfile$ $Revision$ */
@end@