home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / share / snmp / mib2c-data / parent-set.m2i < prev    next >
Encoding:
Text File  |  2007-02-07  |  14.8 KB  |  429 lines

  1. #############################################################  -*- c -*-
  2. ## generic include for XXX. Do not use directly.
  3. ##
  4. ## $Id: parent-set.m2i,v 1.24.2.2 2005/01/06 17:26:27 rstory Exp $
  5. ########################################################################
  6. @if $m2c_mark_boundary == 1@
  7. /** START code generated by $RCSfile: parent-set.m2i,v $ $Revision: 1.24.2.2 $ */
  8. @end@
  9. ########################################################################
  10. ##//####################################################################
  11. ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  12. ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  13. @if $m2c_processing_type eq 'h'@
  14.  
  15. @   if $m2c_table_row_creation == 1@
  16. int ${context}_validate_index( ${context}_registration_ptr ${context}_reg,
  17.                                ${context}_rowreq_ctx *rowreq_ctx);
  18. @   end@
  19. int ${context}_undo_setup( ${context}_rowreq_ctx *rowreq_ctx);
  20. int ${context}_undo_cleanup( ${context}_rowreq_ctx *rowreq_ctx);
  21. int ${context}_commit( ${context}_rowreq_ctx *rowreq_ctx);
  22. int ${context}_undo_commit( ${context}_rowreq_ctx *rowreq_ctx);
  23. @   if $m2c_irreversible_commit == 1@
  24. int ${context}_irreversible_commit( ${context}_rowreq_ctx *rowreq_ctx);
  25. @   end@
  26.  
  27. @end@ // m2c_processing_type eq 'h'
  28. ########################################################################
  29. ##//####################################################################
  30. ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  31. ##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  32. @if $m2c_processing_type eq 'c'@
  33. ##
  34. ## MASTER COPY OF THIS FLOWCHART IS IN agent/helpers/baby_steps.c
  35. ##
  36.     /*
  37.      * NOTE: if you update this chart, please update the versions in
  38.      *       local/mib2c-conf.d/parent-set.m2i
  39.      *       agent/mibgroup/helpers/baby_steps.c
  40.      * while you're at it.
  41.      */
  42.     /*
  43.      ***********************************************************************
  44.      * Baby Steps Flow Chart (2004.06.05)                                  *
  45.      *                                                                     *
  46.      * +--------------+    +================+    U = unconditional path    *
  47.      * |optional state|    ||required state||    S = path for success      *
  48.      * +--------------+    +================+    E = path for error        *
  49.      ***********************************************************************
  50.      *
  51.      *                        +--------------+
  52.      *                        |     pre      |
  53.      *                        |   request    |
  54.      *                        +--------------+
  55.      *                               | U
  56. @if $m2c_table_row_creation == 1@
  57.      * +-------------+        +==============+
  58.      * |    row    |f|<-------||  object    ||
  59.      * |  create   |1|      E ||  lookup    ||
  60.      * +-------------+        +==============+
  61.      *     E |   | S                 | S
  62.      *       |   +------------------>|
  63.      *       |                +==============+
  64.      *       |              E ||   check    ||
  65.      *       |<---------------||   values   ||
  66. @else@
  67.      *                        +==============+
  68.      *       +----------------||  object    ||
  69.      *       |              E ||  lookup    ||
  70.      *       |                +==============+
  71.      *       |                       | S
  72.      *       |                +==============+
  73.      *       |              E ||   check    ||
  74.      *       |<---------------||   values   ||
  75. @end@ # row creation
  76.      *       |                +==============+
  77.      *       |                       | S
  78.      *       |                +==============+
  79.      *       |       +<-------||   undo     ||
  80.      *       |       |      E ||   setup    ||
  81.      *       |       |        +==============+
  82.      *       |       |               | S
  83.      *       |       |        +==============+
  84.      *       |       |        ||    set     ||-------------------------->+
  85.      *       |       |        ||   value    || E                         |
  86.      *       |       |        +==============+                           |
  87.      *       |       |               | S                                 |
  88.      *       |       |        +--------------+                           |
  89.      *       |       |        |    check     |-------------------------->|
  90.      *       |       |        |  consistency | E                         |
  91.      *       |       |        +--------------+                           |
  92.      *       |       |               | S                                 |
  93.      *       |       |        +==============+         +==============+  |
  94.      *       |       |        ||   commit   ||-------->||     undo   ||  |
  95.      *       |       |        ||            || E       ||    commit  ||  |
  96.      *       |       |        +==============+         +==============+  |
  97.      *       |       |               | S                     U |<--------+
  98.      *       |       |        +--------------+         +==============+
  99.      *       |       |        | irreversible |         ||    undo    ||
  100.      *       |       |        |    commit    |         ||     set    ||
  101.      *       |       |        +--------------+         +==============+
  102.      *       |       |               | U                     U |
  103.      *       |       +-------------->|<------------------------+
  104.      *       |                +==============+
  105.      *       |                ||   undo     ||
  106.      *       |                ||  cleanup   ||
  107.      *       |                +==============+
  108.      *       +---------------------->| U
  109. @if $m2c_table_row_creation == 1@
  110.      *                               |
  111.      *                          (err && f1)------------------->+
  112.      *                               |                         |
  113.      *                        +--------------+         +--------------+
  114.      *                        |    post      |<--------|      row     |
  115.      *                        |   request    |       U |    release   |
  116.      *                        +--------------+         +--------------+
  117. @else@
  118.      *                        +--------------+
  119.      *                        |    post      |
  120.      *                        |   request    |
  121.      *                        +--------------+
  122. @end@ # row creation
  123.      *
  124.      */
  125.  
  126. @if $m2c_table_row_creation == 1@
  127. /**
  128.  * verify specified index is valid.
  129.  *
  130.  * This check is independent of whether or not the values specified for
  131.  * the columns of the new row are valid. Column values and row consistency
  132.  * will be checked later. At this point, only the index values should be
  133.  * checked.
  134.  *
  135.  * All of the individual index validation functions have been called, so this
  136.  * is the place to make sure they are valid as a whole when combined. If
  137.  * you only have one index, 
  138.  * 
  139.  *
  140.  *
  141.  * @param ${context}_reg
  142.  *        Pointer to the user registration data
  143.  * @param ${context}_rowreq_ctx
  144.  *        Pointer to the users context.
  145.  * @retval MFD_SUCCESS            : success
  146.  * @retval MFD_CANNOT_CREATE_NOW  : index not valid right now
  147.  * @retval MFD_CANNOT_CREATE_EVER : index never valid
  148.  */
  149. int
  150. ${context}_validate_index( ${context}_registration_ptr ${context}_reg,
  151.                            ${context}_rowreq_ctx *rowreq_ctx)
  152. {
  153.     int rc = MFD_SUCCESS;
  154.  
  155.     DEBUGMSGTL(("verbose:${context}:${context}_validate_index","called\n"));
  156.  
  157.     /** we should have a non-NULL pointer */
  158.     netsnmp_assert( NULL != rowreq_ctx );
  159.  
  160.     /*
  161.      * TODO:430:M: |-> Validate potential $context index.
  162.      */
  163.     if(1) {
  164.         snmp_log(LOG_WARNING,"invalid index for a new row in the "
  165.                  "${context} table.\n");
  166.         /*
  167.          * determine failure type.
  168.          *
  169.          * If the index could not ever be created, return MFD_NOT_EVER
  170.          * If the index can not be created under the present circumstances
  171.          * (even though it could be created under other circumstances),
  172.          * return MFD_NOT_NOW.
  173.          */
  174.         if(0) {
  175.             return MFD_CANNOT_CREATE_EVER;
  176.         }
  177.         else {
  178.             return MFD_CANNOT_CREATE_NOW;
  179.         }
  180.     }
  181.  
  182.     return rc;
  183. } /* ${context}_validate_index */
  184.  
  185. @end@ # row creation
  186. ##----------------------------------------------------------------------
  187. /**
  188.  * Setup up context with information needed to undo a set request.
  189.  *
  190.  * This function will be called before the individual node undo setup
  191.  * functions are called. If you need to do any undo setup that is not
  192.  * related to a specific column, you can do it here.
  193.  *
  194. @if $m2c_undo_embed == 0@
  195. @   if $m2c_data_init == 1@
  196.  * Note that the undo context has been allocated with
  197.  * ${context}_allocate_data(), but may need extra
  198.  * initialization similar to what you may have done in
  199.  * ${context}_rowreq_ctx_init().
  200. @   end@
  201. @end@
  202.  * Note that an individual node's undo_setup function will only be called
  203.  * if that node is being set to a new value.
  204.  *
  205.  * If there is any setup specific to a particular column (e.g. allocating
  206.  * memory for a string), you should do that setup in the node's undo_setup
  207.  * function, so it won't be done unless it is necessary.
  208.  *
  209.  * @param rowreq_ctx
  210.  *        Pointer to the table context (${context}_rowreq_ctx)
  211.  *
  212.  * @retval MFD_SUCCESS : success
  213.  * @retval MFD_ERROR   : error. set will fail.
  214.  */
  215. int
  216. ${context}_undo_setup( ${context}_rowreq_ctx *rowreq_ctx)
  217. {
  218.     int rc = MFD_SUCCESS;
  219.  
  220.     DEBUGMSGTL(("verbose:${context}:${context}_undo_setup","called\n"));
  221.  
  222.     /** we should have a non-NULL pointer */
  223.     netsnmp_assert( NULL != rowreq_ctx );
  224.  
  225.     /*
  226.      * TODO:451:M: |-> Setup $context undo.
  227.      * set up $context undo information, in preparation for a set.
  228.      */
  229.  
  230.     return rc;
  231. } /* ${context}_undo_setup */
  232.  
  233. /**
  234.  * Cleanup up context undo information.
  235.  *
  236.  * This function will be called after set/commit processing. If you
  237.  * allocated any resources in undo_setup, this is the place to release
  238.  * those resources.
  239.  *
  240.  * This function is called regardless of the success or failure of the set
  241.  * request. If you need to perform different steps for cleanup depending
  242.  * on success or failure, you can add a flag to the rowreq_ctx.
  243.  *
  244.  * @param rowreq_ctx
  245.  *        Pointer to the table context (${context}_rowreq_ctx)
  246.  *
  247.  * @retval MFD_SUCCESS : success
  248.  * @retval MFD_ERROR   : error
  249.  */
  250. int
  251. ${context}_undo_cleanup( ${context}_rowreq_ctx *rowreq_ctx)
  252. {
  253.     int rc = MFD_SUCCESS;
  254.  
  255.     DEBUGMSGTL(("verbose:${context}:${context}_undo_cleanup","called\n"));
  256.  
  257.     /** we should have a non-NULL pointer */
  258.     netsnmp_assert( NULL != rowreq_ctx );
  259.  
  260.     /*
  261.      * TODO:452:M: |-> Cleanup $context undo.
  262.      */
  263.  
  264.     return rc;
  265. } /* ${context}_undo_cleanup */
  266.  
  267. ##----------------------------------------------------------------------
  268. /**
  269.  * commit new values.
  270.  *
  271.  * At this point, you should have done everything you can to ensure that
  272.  * this commit will not fail.
  273.  *
  274.  * Should you need different behavior depending on which columns were
  275.  * set, rowreq_ctx->column_set_flags will indicate which writeable columns were
  276.  * set. The definitions for the FLAG_* bits can be found in
  277. @if $m2c_create_fewer_files != 1@
  278.  * ${context}_oids.h.
  279. @else@
  280.  * ${context}.h.
  281. @end@
  282.  * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags.
  283.  *
  284.  * @param ${context}_rowreq_ctx
  285.  *        Pointer to the users context.
  286.  *
  287.  * @retval MFD_SUCCESS : success
  288.  * @retval MFD_ERROR   : error
  289.  */
  290. int
  291. ${context}_commit( ${context}_rowreq_ctx *rowreq_ctx)
  292. {
  293.     int rc = MFD_SUCCESS;
  294.     int             save_flags;
  295.  
  296.     DEBUGMSGTL(("verbose:${context}:${context}_commit","called\n"));
  297.  
  298.     /** we should have a non-NULL pointer */
  299.     netsnmp_assert( NULL != rowreq_ctx );
  300.  
  301.     /*
  302.      * save flags, then clear until we actually do something
  303.      */
  304.     save_flags = rowreq_ctx->column_set_flags;
  305.     rowreq_ctx->column_set_flags = 0;
  306.  
  307.     /*
  308.      * commit $context data
  309.      * 1) check the column's flag in save_flags to see if it was set.
  310.      * 2) clear the flag when you handle that column
  311.      * 3) set the column's flag in column_set_flags if it needs undo
  312.      *    processing in case of a failure.
  313.      */
  314. ##$example_start
  315. @   foreach $node nonindex@
  316. @      include m2c_setup_node.m2i@
  317. @      if $node.settable == 0@
  318. @          next@
  319. @      end@
  320.     if (save_flags & FLAG_$node.uc) {
  321.        save_flags &= ~FLAG_$node.uc; /* clear $node */
  322.        /*
  323.         * TODO:482:o: |-> commit column $node.
  324.         */
  325.        rc = -1;
  326.        if(-1 == rc) {
  327.            snmp_log(LOG_ERR,"$context column $node commit failed\n");
  328.        }
  329.        else {
  330.             /*
  331.              * set flag, in case we need to undo $node
  332.              */
  333.             rowreq_ctx->column_set_flags |= FLAG_$node.uc;
  334.        }
  335.     }
  336.  
  337. @   end@ # foreach $node
  338.     if (save_flags) {
  339.        snmp_log(LOG_ERR, "unhandled columns (0x%x) in commit\n", save_flags);
  340.        return MFD_ERROR;
  341.     }
  342. ##$example_end
  343.  
  344.     return rc;
  345. } /* ${context}_commit */
  346.  
  347. /**
  348.  * undo commit new values.
  349.  *
  350.  * Should you need different behavior depending on which columns were
  351.  * set, rowreq_ctx->column_set_flags will indicate which writeable columns were
  352.  * set. The definitions for the FLAG_* bits can be found in
  353. @if $m2c_create_fewer_files != 1@
  354.  * ${context}_oids.h.
  355. @else@
  356.  * ${context}.h.
  357. @end@
  358.  * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags.
  359.  *
  360.  * @param ${context}_rowreq_ctx
  361.  *        Pointer to the users context.
  362.  *
  363.  * @retval MFD_SUCCESS : success
  364.  * @retval MFD_ERROR   : error
  365.  */
  366. int
  367. ${context}_undo_commit( ${context}_rowreq_ctx *rowreq_ctx)
  368. {
  369.     int rc = MFD_SUCCESS;
  370.  
  371.     DEBUGMSGTL(("verbose:${context}:${context}_undo_commit","called\n"));
  372.  
  373.     /** we should have a non-NULL pointer */
  374.     netsnmp_assert( NULL != rowreq_ctx );
  375.  
  376.     /*
  377.      * TODO:485:M: |-> Undo $context commit.
  378.      * check the column's flag in rowreq_ctx->column_set_flags to see
  379.      * if it was set during commit, then undo it.
  380.      *
  381.      * eg: if (rowreq_ctx->column_set_flags & FLAG_$node.uc) {}
  382.      */
  383. ##$example_start
  384. ##$example_end
  385.  
  386.     return rc;
  387. } /* ${context}_undo_commit */
  388.  
  389. @if $m2c_irreversible_commit == 1@
  390. ##----------------------------------------------------------------------
  391. /**
  392.  * perform commit actions that are not reversible
  393.  *
  394.  * THERE IS NO ATTEMPT AT RECOVERY FOR ERRORS FROM THIS STATE!
  395.  *
  396.  * @param ${context}_rowreq_ctx
  397.  *        Pointer to the users context.
  398.  *
  399.  * @retval MFD_SUCCESS : success
  400.  * @retval MFD_ERROR   : other error
  401.  */
  402. int
  403. ${context}_irreversible_commit( ${context}_rowreq_ctx *rowreq_ctx)
  404. {
  405.     int rc;
  406.  
  407.     DEBUGMSGTL(("verbose:${context}:${context}_irreversible_commit","called\n"));
  408.  
  409.     /** we should have a non-NULL pointer */
  410.     netsnmp_assert( NULL != rowreq_ctx );
  411.  
  412.     /*
  413.      * TODO:495:o: Irreversible $context commit.
  414.      */
  415. ##$example_start
  416. ##$example_end
  417.  
  418.     return MFD_SUCCESS;
  419. } /* ${context}_irreversible_commit */
  420.  
  421. @end@ // irreversable commit
  422. ##
  423. ########################################################################
  424. @end@ // m2c_processing_type eq 'c'
  425. ########################################################################
  426. @if $m2c_mark_boundary == 1@
  427. /** END code generated by $RCSfile: parent-set.m2i,v $ $Revision: 1.24.2.2 $ */
  428. @end@
  429.