HP3000-L Archives

March 1999, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Stan Sieler <[log in to unmask]>
Reply To:
Stan Sieler <[log in to unmask]>
Date:
Thu, 18 Mar 1999 11:08:02 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (63 lines)
Re:

> The approach I have taken is to have 1 main program where 99%
> of the code resides, and a small executable library (XL) for each
> client.  The XL will have 1 function - Custom() containing all
> of the client specific code.
...
> This is working, but now my problem:
> Once I am inside the Custom() function in the XL I would like to be
> able to call functions back in the mainprog.

An alternative solution would be to invert things, so that the
main() and custom() are in the main program, and the XL contains the
99% of the code ... but this means the XL needs to be able to "find"
the custom() routine.  This can be done as follows:

The (big) XL contains one new typedef, one new "global" variable,
and one new routine:

    typedef int (*custom_function_ptr_type) (int32 xxx);
    ...
    custom_function_ptr_type custom_function;
    ...
    void register_custom_function (custom_function_ptr_type new_func)
       {
       custom_function = new_func;
       }
    ...

and calls to "custom (xxx)" are replaced with:

    (*custom_function) (xxx);

and the old "main()" in the XL is changed to "real_main ()".

and, in the new main program do:

   ...
   ...include extern declarations for functions in XL that custom() wants
   ...to call...
   ...

   typedef int (*custom_function_ptr_type) (int32 xxx);
   void register_custom_function (custom_function_ptr_type new_func);

   void custom (int32 xxx)
      {
      ...
      }

   main ()
      {
      register_custom_function (&custom);

      real_main ();
      }

Hope this helps.

--
Stan Sieler                                          [log in to unmask]
                                     http://www.allegro.com/sieler.html

ATOM RSS1 RSS2