Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Implementation

Reply
Thread Tools

Implementation

 
 
Ravi Uday
Guest
Posts: n/a
 
      10-15-2003
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
 
Reply With Quote
 
 
 
 
Ed Morton
Guest
Posts: n/a
 
      10-15-2003


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.

 
Reply With Quote
 
 
 
 
Ravi Uday
Guest
Posts: n/a
 
      10-16-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (Ravi Uday) wrote in message news:<(E-Mail Removed). 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
 
Reply With Quote
 
dis
Guest
Posts: n/a
 
      10-16-2003
"Ravi Uday" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> (E-Mail Removed) (Ravi Uday) wrote in message

news:<(E-Mail Removed). 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?


 
Reply With Quote
 
Ravi Uday
Guest
Posts: n/a
 
      10-17-2003
"dis" <(E-Mail Removed)> wrote in message news:<bmlrjj$sha$(E-Mail Removed)1.nb.home.nl>...
> "Ravi Uday" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > (E-Mail Removed) (Ravi Uday) wrote in message

> news:<(E-Mail Removed). 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insertion Sort : C++ implementation 100 times slower than C implementation sanket C++ 7 11-03-2011 05:00 AM
Knowing the implementation, are all undefined behaviours become implementation-defined behaviours? Michael Tsang C Programming 54 03-30-2010 07:46 AM
Knowing the implementation, are all undefined behaviours become implementation-defined behaviours? Michael Tsang C++ 32 03-01-2010 09:15 PM
can anyone guide me in flight-mode implementation for Windows mobile 5.0? vivekanand holla Wireless Networking 1 11-10-2005 11:15 AM
transport protocol implementation in NDIS zenhwa Wireless Networking 0 09-14-2004 11:38 PM



Advertisments