I have a Korn shell script that needs to call a Pro C program that passes in a filename. This file is created in the Korn shell script and it containes lines with pipe delimited data:
Each line is formatted to look like this:
1234|Pat|Smith|567 Main St Chicago, IL 60601| <blank space> |firstname.lastname@example.org
This line was populated using PL/SQL. Every time the Korn shell script is called, the file is populated with a variable number of lines each time so I'll number of lines will always change but have the same format as above.
Within the Pro C program, I need to query a table "customer" to get the phone number based on the first field in the pipe delimited line which is custID. The phone number is stored like this 2125551234 in the table. THEN, I need to call another Pro C program (which I have) to format the phone number to look like this (212) 555-1234.
After I get the phone number with the correct format, I need to replace it with the <blank space> in each line of the file and then save that file.
There's alot going on here. I need help with the design of this C program. I have written some of it but I am concerned with my approach. I am storing the information from the file in an array of custIDs. The problem is I dont know how big this custID array will get since I never know what the number of lines in a file will be. Also, my other concern is figuring out how to write to the same file I'm reading. I dont think this is possible so I'm thinking of creating a temporary file to store this information.
Any design input would be GREATLY appreciated.