#############################################################  -*- c -*-
## generic include for XXX. Do not use directly.
##
## $Id: syntax-RowStatus-dependencies.m2i 12850 2005-09-27 15:42:43Z rstory $
########################################################################
@if $m2c_mark_boundary == 1@
/** START code generated by $RCSfile$ $Revision: 12850 $ */
@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: 12850 $ */
@end@
