Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Implementation (http://www.velocityreviews.com/forums/t315780-implementation.html)

Ravi Uday 10-15-2003 08:56 AM

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 10-15-2003 09:57 AM

Re: Implementation
 


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.


Ravi Uday 10-16-2003 08:52 AM

Re: Implementation
 
ravi368@yahoo.com (Ravi Uday) wrote in message news:<ecca3ca6.0310150056.79545fd0@posting.google. com>...
> 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

dis 10-16-2003 10:24 AM

Re: Implementation
 
"Ravi Uday" <ravi368@yahoo.com> wrote in message
news:ecca3ca6.0310160052.200a1071@posting.google.c om...
> ravi368@yahoo.com (Ravi Uday) wrote in message

news:<ecca3ca6.0310150056.79545fd0@posting.google. com>...
> > 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?



Ravi Uday 10-17-2003 11:28 AM

Re: Implementation
 
"dis" <dis@hotmail.com> wrote in message news:<bmlrjj$sha$1@news4.tilbu1.nb.home.nl>...
> "Ravi Uday" <ravi368@yahoo.com> wrote in message
> news:ecca3ca6.0310160052.200a1071@posting.google.c om...
> > ravi368@yahoo.com (Ravi Uday) wrote in message

> news:<ecca3ca6.0310150056.79545fd0@posting.google. com>...
> > > 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


All times are GMT. The time now is 09:07 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.