This is what I have so far, *fp1 == File reading from. *fp2 == file writing to, the printf is just a test to make sure I'm reading the information correctly. This is the data I'm reading out of the file:
Date,Time,Call Leg Setup Time,Gateway Identifier,Connection Id,Call Leg Direction,Call Leg Type,Call Leg Connect Time,Call Leg Disconnect Time,Call Leg Disconnect Cause,Remote Gateway IP Address,Calling-Station-Id,Called-Station-Id,Acct-Status-Type,Description
03/25/2001,00:00:00,04:57:10.775 UTC Sun Mar 25 2001,netnyc36.113.,B4C20D3A 300301CF 0 776EEA8,answer,Telephony,,,,,,,Start,
03/25/2001,00:00:01,04:56:58.747 UTC Sun Mar 25 2001,netnyc36.113.,B4C20D3A 300301AB 0 7768AE0,originate,VoIP,04:57:11.827 UTC Sun Mar 25 2001,04:57:11.827 UTC Sun Mar 25 2001,10,203.91.128.86,,01188031721576,Stop,
Here's the code I'm using. I'm curious if this is the best way to do it or not. I haven't been able to get past the host name (Which is netnyc36.113 in the first example) and I get stuck reading in B4C20D3A 300301AB 0 7768AE0 as you can see everything is seperated by comas, I was thinking about reading everything in one thing at a time, but as you can see its a mess of numbers and characters combined together...
int convert(FILE *fp1, FILE *fp2) {
int i;
int date[3];
float time[3];
float callsetuptime[4];
char datetime1[10], datetime2[5], datetime3[5];
int day, year;
char hostname[50];
char connectID[10], connectID2[10], connectID3[5], connectID4[10];
char CLdir[20];
char CLtype[20];
float CLconnecttime[4];
float CLdisconnectime[4];
int CLDiscause;
int ip[4];
unsigned long CSid;
unsigned long CSDid;
char AStype[10];
fscanf(fp2, "%d/%d/%d,%f:%f:%f,%f:%f:%f %c%c%c %c%c%c %c%c%c %d %d,%13s.,%8s %7s %1s %7s,%c%c%c%c%c%c%c,%s,%f:%f:%f.%f %s,%f:%f:%f.%f %s,%d,%d.%d.%d.%d,%lu,%lu,%s",
&date[0], &date[1], &date[2],
&time[0], &time[1], &time[2],
&callsetuptime[0], &callsetuptime[1], &callsetuptime[2],
&datetime1[0], &datetime1[1], &datetime1[2],
&datetime2[0], &datetime2[1], &datetime2[2],
&datetime3[0], &datetime3[1], &datetime3[2], &day, &year,
&hostname,
&connectID, &connectID2, &connectID3, &connectID4,
&CLdir[0], &CLdir[1],&CLdir[2],&CLdir[3],&CLdir[4],&CLdir[5],&CLdir[6], &CLtype,
&CLconnecttime[0], &CLconnecttime[1], &CLconnecttime[2], &CLconnecttime[3],
&CLdisconnectime[0], &CLdisconnectime[1], &CLdisconnectime[2], &CLdisconnectime[3],
&CLDiscause,
&ip[0], &ip[1], &ip[2], &ip[3],
&CSid, &CSDid, &AStype);
printf("
Date: %d/%d/%d
Time: %.0f:%.0f:%.2f
Call Setup Time: %.0f:%.0f:%.0f %c%c%c %c%c%c %c%c%c %d %d
Host Name: %s
Connect ID: %s %s %s %s
Call Leg Direction: %c%c%c%c%c%c%c
Call Leg Type: %s
Call Leg Connect Time: %f:%f:%f.%f %s
Call Leg Disconnect Time: %f:%f:%f.%f %s
Call Leg Disconnect Cause: %d
Remote Gateway IP: %d.%d.%d.%d
Calling Station ID: %lu
Called Station ID: %lu
Account Status Type: %s\n",
date[0], date[1], date[2],
time[0], time[1], time[2],
callsetuptime[0], callsetuptime[1], callsetuptime[2],
datetime1[0], datetime1[1], datetime1[2],
datetime2[0], datetime2[1], datetime2[2],
datetime3[0], datetime3[1], datetime3[2], day, year,
hostname,
connectID, connectID2, connectID3, connectID4,
CLdir[0], CLdir[1],CLdir[2],CLdir[3],CLdir[4],CLdir[5],CLdir[6], CLtype,
CLconnecttime[0], CLconnecttime[1], CLconnecttime[2], CLconnecttime[3],
CLdisconnectime[0], CLdisconnectime[1], CLdisconnectime[2], CLdisconnectime[3],
CLDiscause,
ip[0], ip[1], ip[2], ip[3],
CSid, CSDid, AStype);
Any help is much appreciated...
Rhoon