Implementation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ravi Uday

    Implementation

    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
  • Ed Morton

    #2
    Re: Implementation



    Ravi Uday wrote:

    <snip>[color=blue]
    > 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[/color]

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

    Ed.

    Comment

    • Ravi Uday

      #3
      Re: Implementation

      ravi368@yahoo.c om (Ravi Uday) wrote in message news:<ecca3ca6. 0310150056.7954 5fd0@posting.go ogle.com>...[color=blue]
      > 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[/color]

      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

      Comment

      • dis

        #4
        Re: Implementation

        "Ravi Uday" <ravi368@yahoo. com> wrote in message
        news:ecca3ca6.0 310160052.200a1 071@posting.goo gle.com...[color=blue]
        > ravi368@yahoo.c om (Ravi Uday) wrote in message[/color]
        news:<ecca3ca6. 0310150056.7954 5fd0@posting.go ogle.com>...[color=blue][color=green]
        > > 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[/color]
        >
        > 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[/color]

        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?


        Comment

        • Ravi Uday

          #5
          Re: Implementation

          "dis" <dis@hotmail.co m> wrote in message news:<bmlrjj$sh a$1@news4.tilbu 1.nb.home.nl>.. .[color=blue]
          > "Ravi Uday" <ravi368@yahoo. com> wrote in message
          > news:ecca3ca6.0 310160052.200a1 071@posting.goo gle.com...[color=green]
          > > ravi368@yahoo.c om (Ravi Uday) wrote in message[/color]
          > news:<ecca3ca6. 0310150056.7954 5fd0@posting.go ogle.com>...[color=green][color=darkred]
          > > > 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[/color]
          > >
          > > 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[/color]
          >
          > 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.[/color]
          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[color=blue]
          > function from which CleanUpScript was called from within CleanUpScript?[/color]

          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[color=blue]
          > type?[/color]

          Yes all have 'void' type.

          Thx
          - Ravi

          Comment

          Working...