Implementation

Discussion in 'C Programming' started by Ravi Uday, Oct 15, 2003.

  1. Ravi Uday

    Ravi Uday Guest

    Hi,

    I have a strange problem. I would appreciate if someone can give me a
    way to implement/solve my problem.
    I am using a third party tool which has C-implementation defined but
    to a minimum. It uses some kind of a 'interpreter' thing so features
    like - vsprintf, variadic functions, 'function pointers' are NOT
    supported by it.

    I have a function/script which is called when a system 'crash' is
    occured. It is called CleanUpScript(). It can be called from any
    function.

    void main_function ()
    {
    ...
    ...
    if ( crash )
    CleanUpScript ();
    }

    void another_fn()
    {
    ...
    ...
    if ( crash )
    CleanUpScript ();
    }

    void CleanUpScript()
    {
    .../* free resources..etc..*/
    ...
    main_function ();/* call the function which triggerd CleanUpScript
    function*/
    }

    At the end of CleanUpScript() i need to call the function from which
    CleanUpScript was called. It can be any function. How do i do that ?
    One way to implement was using 'Function Pointers' or by using
    LookUpTable, but since function pointers itself are *not* supported
    here, is there any other way to do this.
    Please help.

    - Ravi
     
    Ravi Uday, Oct 15, 2003
    #1
    1. Advertising

  2. Ravi Uday

    Ed Morton Guest

    Ravi Uday wrote:

    <snip>
    > At the end of CleanUpScript() i need to call the function from which
    > CleanUpScript was called. It can be any function. How do i do that ?
    > One way to implement was using 'Function Pointers' or by using
    > LookUpTable, but since function pointers itself are *not* supported
    > here, is there any other way to do this.
    > Please help.
    >
    > - Ravi


    You could take a look at setjmp() and longjmp(). See
    http://www-ccs.ucsd.edu/c/setjmp.html for details.

    Ed.
     
    Ed Morton, Oct 15, 2003
    #2
    1. Advertising

  3. Ravi Uday

    Ravi Uday Guest

    (Ravi Uday) wrote in message news:<>...
    > Hi,
    >
    > I have a strange problem. I would appreciate if someone can give me a
    > way to implement/solve my problem.
    > I am using a third party tool which has C-implementation defined but
    > to a minimum. It uses some kind of a 'interpreter' thing so features
    > like - vsprintf, variadic functions, 'function pointers' are NOT
    > supported by it.
    >
    > I have a function/script which is called when a system 'crash' is
    > occured. It is called CleanUpScript(). It can be called from any
    > function.
    >
    > void main_function ()
    > {
    > ...
    > ...
    > if ( crash )
    > CleanUpScript ();
    > }
    >
    > void another_fn()
    > {
    > ...
    > ...
    > if ( crash )
    > CleanUpScript ();
    > }
    >
    > void CleanUpScript()
    > {
    > ../* free resources..etc..*/
    > ..
    > main_function ();/* call the function which triggerd CleanUpScript
    > function*/
    > }
    >
    > At the end of CleanUpScript() i need to call the function from which
    > CleanUpScript was called. It can be any function. How do i do that ?
    > One way to implement was using 'Function Pointers' or by using
    > LookUpTable, but since function pointers itself are *not* supported
    > here, is there any other way to do this.
    > Please help.
    >
    > - Ravi


    Also I dont think setjmp() is supported by this as Morton suggested !!
    Are there really no way i can do this. How about using switch cases in
    the CleanUpScript(). Is there an efficient solution to this

    Thx
    Ravi
     
    Ravi Uday, Oct 16, 2003
    #3
  4. Ravi Uday

    dis Guest

    "Ravi Uday" <> wrote in message
    news:...
    > (Ravi Uday) wrote in message

    news:<>...
    > > Hi,
    > >
    > > I have a strange problem. I would appreciate if someone can give me a
    > > way to implement/solve my problem.
    > > I am using a third party tool which has C-implementation defined but
    > > to a minimum. It uses some kind of a 'interpreter' thing so features
    > > like - vsprintf, variadic functions, 'function pointers' are NOT
    > > supported by it.
    > >
    > > I have a function/script which is called when a system 'crash' is
    > > occured. It is called CleanUpScript(). It can be called from any
    > > function.
    > >
    > > void main_function ()
    > > {
    > > ...
    > > ...
    > > if ( crash )
    > > CleanUpScript ();
    > > }
    > >
    > > void another_fn()
    > > {
    > > ...
    > > ...
    > > if ( crash )
    > > CleanUpScript ();
    > > }
    > >
    > > void CleanUpScript()
    > > {
    > > ../* free resources..etc..*/
    > > ..
    > > main_function ();/* call the function which triggerd CleanUpScript
    > > function*/
    > > }
    > >
    > > At the end of CleanUpScript() i need to call the function from which
    > > CleanUpScript was called. It can be any function. How do i do that ?
    > > One way to implement was using 'Function Pointers' or by using
    > > LookUpTable, but since function pointers itself are *not* supported
    > > here, is there any other way to do this.
    > > Please help.
    > >
    > > - Ravi

    >
    > Also I dont think setjmp() is supported by this as Morton suggested !!
    > Are there really no way i can do this. How about using switch cases in
    > the CleanUpScript(). Is there an efficient solution to this


    What are you trying to achieve? There might be a better way to achieve what
    you want. Is it really necessary to call the function from which
    CleanUpScript was called from within CleanUpScript right before it returns?
    Or would it be ok to call the function from which CleanUpScript was called
    from directly after CleanUpScript returned. Why is it necessary to call the
    function from which CleanUpScript was called from within CleanUpScript? Do
    all functions from which CleanUpScript might be called from have the same
    type?
     
    dis, Oct 16, 2003
    #4
  5. Ravi Uday

    Ravi Uday Guest

    "dis" <> wrote in message news:<bmlrjj$sha$1.nb.home.nl>...
    > "Ravi Uday" <> wrote in message
    > news:...
    > > (Ravi Uday) wrote in message

    > news:<>...
    > > > Hi,
    > > >
    > > > I have a strange problem. I would appreciate if someone can give me a
    > > > way to implement/solve my problem.
    > > > I am using a third party tool which has C-implementation defined but
    > > > to a minimum. It uses some kind of a 'interpreter' thing so features
    > > > like - vsprintf, variadic functions, 'function pointers' are NOT
    > > > supported by it.
    > > >
    > > > I have a function/script which is called when a system 'crash' is
    > > > occured. It is called CleanUpScript(). It can be called from any
    > > > function.
    > > >
    > > > void main_function ()
    > > > {
    > > > ...
    > > > ...
    > > > if ( crash )
    > > > CleanUpScript ();
    > > > }
    > > >
    > > > void another_fn()
    > > > {
    > > > ...
    > > > ...
    > > > if ( crash )
    > > > CleanUpScript ();
    > > > }
    > > >
    > > > void CleanUpScript()
    > > > {
    > > > ../* free resources..etc..*/
    > > > ..
    > > > main_function ();/* call the function which triggerd CleanUpScript
    > > > function*/
    > > > }
    > > >
    > > > At the end of CleanUpScript() i need to call the function from which
    > > > CleanUpScript was called. It can be any function. How do i do that ?
    > > > One way to implement was using 'Function Pointers' or by using
    > > > LookUpTable, but since function pointers itself are *not* supported
    > > > here, is there any other way to do this.
    > > > Please help.
    > > >
    > > > - Ravi

    > >
    > > Also I dont think setjmp() is supported by this as Morton suggested !!
    > > Are there really no way i can do this. How about using switch cases in
    > > the CleanUpScript(). Is there an efficient solution to this

    >
    > What are you trying to achieve? There might be a better way to achieve what
    > you want. Is it really necessary to call the function from which
    > CleanUpScript was called from within CleanUpScript right before it returns?
    > Or would it be ok to call the function from which CleanUpScript was called
    > from directly after CleanUpScript returned.

    Cant do that because the tool doesnt provide the option to return to the
    place where the crash happened. It just calls this CleanUpScript and program
    finishes.

    Why is it necessary to call the
    > function from which CleanUpScript was called from within CleanUpScript?


    It would help to reproduce the crashing sequence. Its one of the requirement.

    Do all functions from which CleanUpScript might be called from have the same
    > type?


    Yes all have 'void' type.

    Thx
    - Ravi
     
    Ravi Uday, Oct 17, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VBDotNETCoder

    Need MSF Implementation Plan

    VBDotNETCoder, Nov 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    706
    richlm
    Nov 18, 2004
  2. Anand P Paralkar

    UART Implementation

    Anand P Paralkar, Jun 26, 2003, in forum: VHDL
    Replies:
    2
    Views:
    12,949
    Rudolf Usselmann
    Jul 7, 2003
  3. Michael Tsang
    Replies:
    32
    Views:
    1,127
    Richard Bos
    Mar 1, 2010
  4. Michael Tsang
    Replies:
    54
    Views:
    1,208
    Phil Carmody
    Mar 30, 2010
  5. sanket
    Replies:
    7
    Views:
    1,023
    Tsung
    Nov 3, 2011
Loading...

Share This Page