Implementation

R

Ravi Uday

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
 
E

Ed Morton

Ravi Uday wrote:

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.
 
R

Ravi Uday

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
 
D

dis

Ravi Uday said:
(e-mail address removed) (Ravi Uday) wrote in message

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?
 
R

Ravi Uday

dis said:
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

Yes all have 'void' type.

Thx
- Ravi
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top