/*************************************************************************** copyright : (C) 1996, 2004 by Ramón Díaz-Uriarte email : rdiaz@ligarto.org ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,USA * * * **************************************************************************/ #include #include #include "antipb.h" char caca[101], temporal [50],s1[15],s2[15]; int indicador; void read_init_stuff(ifstream &d1, All_Antipr &ALA ); void getinit(ifstream &d1,char *variable); double hora_dec(const double &num); void heading0(ostream &out); void heading3(ostream &out); void antip_data_in(ifstream &d1, All_Antipr &AAP); void read_cont_event(ifstream &d1, cont_event &event_struct, Antipred_CE_Stuff &Adat); void dataout(ofstream &out,All_Antipr &AAP, Antipred_CE_Stuff &Adat); main (int argc, char *argv[]) { // Command line arguments and error handling of files. if(argc!=3) {cout <<"antip2 input output"; return 1;} ifstream d1(argv[1], ios::in | ios::binary); if(!d1) {cout << "Cannot open input file"; return 1;} ofstream out(argv[2]); if(!out) {cout <<"Cannot open output file"; return 1;} /* if(argc!=4) {cout <<"antip2 input output1 output2"; return 1;} ifstream d1(argv[1], ios::in | ios::binary); if(!d1) {cout << "Cannot open input file"; return 1;} ofstream out(argv[2]); if(!out) {cout <<"Cannot open output file"; return 1;} ofstream error_file(argv[3]); if(!error_file) {cout <<"Cannot open error file"; return 1;} */ // Create the heading for the output file. Each file handles different parts. heading0(out); heading3(out); indicador =0; int next_char; // to end main loop. int j; //a loop counter. //This is the main loop do { j = 0; //cont_event eventarray[SIZE_EVENTARRAY]; cont_event *eventptr; eventptr = new cont_event [300]; if(!eventptr) { cout <<"allocation failure\n"; exit(1);} /* To be able to work with very large files, I use a array of pointers, instead of the array of the structure directly. */ /* As I am still unsure of this, recheck the program, without the pointer. Comment out the pointer lines, and uncomment the cont_evetn eventarray line. Then, replace all "eventptr" for "eventarray". */ Antipred_CE_Stuff Adat; All_Antipr ANTP; //First, get the initial information. read_init_stuff(d1,ANTP); //ID, temp, weather, etc. do { read_cont_event(d1,eventptr[j],Adat); //Reads continuous event data, //and compute time in seconds since 00:00. Adat.Time_to_Attack(eventptr[j].behav, eventptr[j].hora_std); Adat.Time_Reemergence(eventptr[j].behav, eventptr[j].hora_std); Adat.Duration_Approach(eventptr[j].behav,eventptr[j].hora_std); j+=1; if(j>300) { cout<<"Fatal error: exceeded size of structure. Behav "<