Code:
table=get_result("SELECT serialno,cas,Mode,FLC,TLC,location,CompName,CompCode,FG,FC,DispNo,TruckNo,LWbill,RRGPN,INVNO,DCN,RQTY,DQTY,SQTY,DDATE,RDATE,SDATE,TTIME FROM Drafts");
if(table.rows>1)
{//draft table opened
printf("\n Data in Drafts table...\n");
for(i=0;i<table.rows;i++)
{//outer loop
printf( " \t");
for(j=0;j<table.cols;j++)
{//inner loop
printf("\n%d:%s",j,table.recordset[i][j]);
}//inner loop ends..
choice=atoi(table.recordset[i][1]);//case
printf(" the choice is %d",choice);
switch(choice)
{//Switch starts
case 1:
sprintf(url,"http://%s:%s/FCMSBihar/Device/ReadData.aspx?Mode=%s&FLF=%s&FLC=%s&CC=%s&PPC=0&FG=%s&RRGPN=%s&LBillNo=%s&RQTY=%s&RDATE=%s%s&DDATE=%s",ipaddr,Port,table.recordset[i][2],table.recordset[i][5], table.recordset[i][3],table.recordset[i][7],table.recordset[i][9], table.recordset[i][10],table.recordset[i][13],table.recordset[i][16], table.recordset[i][20],table.recordset[i][22],table.recordset[i][19]);
printf("\nThe URL is %s",url);
GET_file_clear(url,"/mnt/jffs2/RP_rcpt.txt");//Launch the url to get the response.
fp=fopen("/mnt/jffs2/RP_rcpt.txt","r");//Read response
printf("\nthe file Contents are:");
printf("Opening the file\n");
while(fgets(buff_response,100,fp)) //buffer by buffer reading
{
printf("Reading the file\n");
}
fclose(fp);
printf("\nthe response is: %s",buff_response);
if(strstr(buff_response,"Successfull"))//checking the response.
{//if successful clear the record from Drafts.
execute("DELETE FROM Drafts WHERE location ='%s'AND serialno='%s'AND Mode='%s';",table.recordset[i][5],table.recordset[i][0],table.recordset[i][2]);
sucess_count++;//increaments the success counter
}
else
{//if fails
fail_count++;//increaments the fail counter
}
memset(url,'\0',sizeof(url));
break;
sprintf(str_sucess_report,"Record send is : %d",sucess_count);
sprintf(str_fail_report,"Record fail is : %d",fail_count);
printf("\n Records send is : %d ",sucess_count);//total successful transactions
printf("\n Records fail is : %d ",fail_count);//total failed transactions
getchar();
free_result(table);
return 0;