Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

System Trap

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
manjucee
Asked:
manjucee
  • 2
1 Solution
 
braveheartCommented:
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
 
alexoCommented:
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
 
manjuceeAuthor Commented:
Hi Braveheart
                     It would be better if you give more information .
0
 
braveheartCommented:
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

Technology Partners: 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!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now