?
Solved

System Trap

Posted on 1998-09-21
4
Medium Priority
?
258 Views
Last Modified: 2010-04-15
Hi,
   I am currently involved in the developing a Y2K tool .The one of important feature of this tool is it wont use any of the source code. It will use the data to give remedation and aging in runtime. So I would like to know whether we can trap a system calls like if(date1 > date2) or reading from a database in C. if yes please with example
0
Comment
Question by:manjucee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
braveheart earned 200 total points
ID: 1252954
If you can relink your program, you could write a library which mimics all system calls using times and dates so that your new function is called instead of the system function.  That way you don't alter the source code of the original program.

Using shared libraries it is possible that your mimic functions can then call system functions of the same name but in a system library, although I don't remember the details.

0
 
LVL 11

Expert Comment

by:alexo
ID: 1252955
Unfortunately, no.
You see, you can trap a system (API) call at runtime but "if(date1 > date2)" and similar are implemented using inline code and not function calls.  Reading a DB is too general.  How would you know what constitutes a DB read?  There are hundreds of DB systems, each with it's oun I/O routines.
0
 

Author Comment

by:manjucee
ID: 1252956
Hi Braveheart
                     It would be better if you give more information .
0
 
LVL 3

Expert Comment

by:braveheart
ID: 1252957
Say you are using a DB routine called db_getdate(). You could write your own version of db_getdate() which would call the original routine but would adjust the year appropriately.

Assuming that the data in your database never refers to a date prior to 1960, say, then your version of db_getdate would add
100 to any year less than 60 but returns the original value if the year was greater than or equal to 60.

This approach assumes that you treat the year as an integer rather than a two character string internally. If you use the string approach then the only way you can do a conversion is if all date manipulations are performed by functions which you can over-ride in the same way as the above example. It's an aspect of object oriented programming ;-).

This technique puts off the evil day when you need to rewrite your application and the contents of your database for another 60 years.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question