C code example for the RtreeInfo support function

You can use the following sample C code to help write your own RtreeInfo function.
/**************************************************************************
* Description: Example of new support function used to return             *
*              requested Information to R-tree.                           *
*                                                                         *
* Arguments:                                                              *
*                                                                         *
* dummy_obj - (is NULL)                                                   *
*                                                                         *
* operation_ptr - ptr to string that represents the operation.            *
*                                                                         *
* opclass_ptr - ptr to string that represents the opclass name.           *
*                                                                         *
* answer_ptr - pointer to the pointer to the structure used to            *
*               return information to R-tree.                             *
*               answer_ptr is a "pointer to a pointer" to make            *
*               the interface generic to support later                    *
*               operations to implement which the blade might             *
*               need to allocate memory and return its address            *
*               to R-tree. For the operation                              *
*               "strat_func_substitutions", memory is allocated           *
*                  by R-tree.                                             *
*                                                                         *
*                                                                         *
* Support function slot no: 8                                             *
*                                                                         *
* Return values: MI_OK - Success, operation supported.                    *
*                MI_ERROR - Error.                                        *
*                RLT_OP_UNSUPPORTED - operation not supported.            *
*                                                                         *
***************************************************************************
*/

     #define RLT_OP_UNSUPPORTED 1
     mi_integer
     rtreeInfo (mi_lvarchar *dummy_obj, mi_lvarchar *operation_ptr,
                   mi_lvarchar *opclass_ptr, mi_lvarchar *answer_ptr)
     {
     mi_integer status = MI_OK;
     mi_string *operation = NULL, *opclassname = NULL;
                  /* opclassname may be used if required */

         operation = mi_lvarchar_to_string(operation_ptr);
         if (operation == NULL)
             {
             status = MI_ERROR;
             goto bad;
             }

         opclassname = mi_lvarchar_to_string(opclass_ptr);
         if (opclassname == NULL)
             {
             status = MI_ERROR;
             goto bad;
             }

         if (!strcmp(operation,"strat_func_substitutions"))
             {
             mi_integer *answer = NULL;

             if (answer_ptr == NULL)
                 {
                 status = MI_OK;
                 goto done;
                 }/* Option is supported */

             /* For operation "strat_func_substitutions" memory
              * for 64 slots is allocated by R-tree. For later
              * operations, we might need to allocate the return
              * structure and set its address.
              */
              answer =(mi_integer*) 
                         mi_get_vardata((mi_lvarchar*)
                             (mi_get_vardata(answer_ptr)));

             if (answer == NULL)
                 {
                 status = MI_ERROR;
                 goto bad;
                 }

             /* Provide mapping for strategy functions to be used at 
              * internal nodes.
              * If the mapping changes for the opclasses I support,
              * use the opclassname
              */
             if (!strcmp(opclass,"my_opclass1")) 
                 {
                 answer[0] = 0;
                 answer[1] = 2;
                 answer[2] = 2;
                 answer[3] = 0;
                 answer[4] = 4;
                 answer[5] = 4;
                      /* as many slots as strategy functions. max is 64 */
                 }
              else if (!strcmp(opclass,"my_opclass2")) {
                 answer[0] = 0;
                 answer[1] = 2;
                 answer[2] = 2;
                 answer[3] = 0;
                 answer[4] = 4;
                 }
              else /* for all other opclasses that I support */
                 {
                 answer[0] = 0;
                 answer[1] = 2;
                 answer[2] = 2;
                 answer[3] = 0;
                 }

             status = MI_OK;
             }
         else
             status = RLT_OP_UNSUPPORTED; 
              /* Only "strat_func_substitutions" is
               * supported, as yet. */

     done:
     bad:
         if (opclassname)
             mi_free(opclassname);
         if (operation)
             mi_free(operation);
         return status;
     }