Solved

System Trap

Posted on 1998-09-21
4
227 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
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
braveheart earned 100 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use pointers 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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now