void PacketCallback(u_char *user, const struct pcap_pkthdr *h, const u_char *p) { unsigned int Counter; unsigned short SkipSrc = 0; unsigned short SkipDst = 0; u_int caplen = h->caplen; struct ether_header *eptr; struct VlanHeader *vlanhdr; const struct ip *ip; uint32_t srcip; uint32_t dstip; struct IPData *ptrIPData; int AlreadyTotaled = FALSE; PacketCallbackLock = TRUE; eptr = (struct ether_header *) p; vlanhdr = (struct vlanhdr *) p; if (eptr->ether_type == htons(1537)) ParseBroadcast(p); if (vlanhdr->ether_type[0]==0x81 && vlanhdr->ether_type[1]==0x00) //Two byte-wise checks instead of 1 word-wise check to avoid word boundary issues on some intel processors p+=4; caplen -= IP_Offset; // We're only measuring ip size, so pull off the ethernet header p += IP_Offset; // Move the pointer past the datalink header ip = (const struct ip *)p; // Point ip at the ip header if (ip->ip_v != 4) // then not an ip packet so skip it return; srcip = ntohl(*(uint32_t *) (&ip->ip_src)); dstip = ntohl(*(uint32_t *) (&ip->ip_dst)); for (Counter = 0; Counter < NotSubnetCount; Counter++) { if (NotSubnetTable[Counter].ip == (srcip & NotSubnetTable[Counter].mask)) //In the list of subnets we're ignoring. { SkipSrc=1; } if (NotSubnetTable[Counter].ip == (dstip & NotSubnetTable[Counter].mask)) //In the list of subnets we're ignoring. { SkipDst=1; } } for (Counter = 0; Counter < SubnetCount; Counter++) { // Packets from a monitored subnet to a monitored subnet will be // credited to both ip's // Totals are checked for first to speed up FindIp in the total case // That way the 0 entry is always first in the FindIp table if ((SubnetTable[Counter].ip == (srcip & SubnetTable[Counter].mask)) && !SkipSrc) { if (!AlreadyTotaled) { Credit(&(IpTable[0].Send), ip); AlreadyTotaled = TRUE; } ptrIPData = FindIp(srcip); // Return or create this ip's data structure if (ptrIPData) Credit(&(ptrIPData->Send), ip); } if ((SubnetTable[Counter].ip == (dstip & SubnetTable[Counter].mask)) && !SkipDst) { if (!AlreadyTotaled) { Credit(&(IpTable[0].Receive), ip); AlreadyTotaled = TRUE; } ptrIPData = FindIp(dstip); if (ptrIPData) Credit(&(ptrIPData->Receive), ip); } } PacketCallbackLock = FALSE; }
//Begin excution of function main int main() { Menu *menuPtr[5]; //declare an array of pointer of class type Menu Menu menu; //declare an object of the class type Menu Insurpolicy *Bpolicy; //declare a pointer to the base class Homeinsurpolicy HCpolicy; //declare an object of the class type Homeinsurpolicy Homeinsurpolicy blankHCpolicy; //declare an object of the class type Homeinsurpolicy for initializing objects of its type to blank fstream HomeFile ("HomeFile.txt", ios::in | ios::out | ios::binary); //create a file for storing home insurance Lifeinsurpolicy LCpolicy; //declare an object of the class type Lifeinsurpolicy Lifeinsurpolicy blankLCpolicy; //declare an object of the class type Lifeinsurpolicy for initializing objects of its type to blank fstream LifeFile("LifeFile.txt", ios::in | ios::out | ios::binary); //create a file for storing life insurance MVinsurpolicy MVCpolicy; //declare an object of the class type MVinsurpolicy MVinsurpolicy blankMVCpolicy; //declare an object of the class type MVinsurpolicy for initializing objects of its type to blank fstream MVFile ("MVFile.txt", ios::in | ios::out | ios::binary); //create a file for storing motor vehicle insurance int Option; //Menu selection/option int Polopt; //policy selection/option Startup( ); //call a function to display boot up screen //exit program if fstream cannot open file if (!HomeFile) { cerr << "HomeFile File could not be opened."<<endl; //display error exit (1); }// end if //exit program if fstream cannot open file if (!LifeFile) { cerr << "LifeFile File could not be opened."<<endl; //display error exit (1); }// end if //exit program if fstream cannot open file if (!MVFile) { cerr << "MVFile File could not be opened."<<endl; //display error exit (1); }//end if system("title True Value Insurance Company Ltd."); //programme title Option = menu.Popumenu(menuPtr); //call function to get user option //while the option is not 5, do the following while (Option != 5) { //do a case on the option switch (Option) { case 1: //Add policy // call a function to get the policy option that the user wants and set it to Polopt Polopt = Poloption(); //do a case on the Polopt switch(Polopt) { case 1: //if 1 add home policy HCpolicy.AddHomeDisplayScreen( ); //Create display screen HCpolicy.addPolicy(HomeFile); //call object method to add policy and send the home file to it HCpolicy = blankHCpolicy; //then initialize the object to be blank break; case 2: //if 2 add life policy LCpolicy.AddLifeDisplayScreen( ); //Create display screen LCpolicy.addPolicy(LifeFile); //call object method to add policy and send the life file to it LCpolicy = blankLCpolicy; //then initialize the object to be blank break; case 3: //if 3 add motor vehicle policy MVCpolicy.AddMotovDisplayScreen( ); //Create display screen MVCpolicy.addPolicy(MVFile); //call object method to add policy and send the motor vehicle file to it MVCpolicy = blankMVCpolicy; //then initialize the object to be blank break; }// end switch break; case 2: //Delete policy // call a function to get the policy option that the user wants and set it to Polopt Polopt = Poloption(); //do a case on the Polopt switch(Polopt) { case 1: //if 1 delete home policy HCpolicy.DeleteHome(HomeFile); //call object method to delete policy and send the home file to it HCpolicy = blankHCpolicy; //then initialize the object to be blank break; case 2: //if 2 delete life policy LCpolicy.DeleteLife(LifeFile); //call object method to delete policy and send the life file to it LCpolicy = blankLCpolicy; //then initialize the object to be blank break; case 3: //if 3 delete a motor vehicle policy MVCpolicy.DeleteMotov(MVFile); //call object method to delete policy and send the motor vehicle file to it MVCpolicy = blankMVCpolicy; //then initialize the object to be blank break; }// end switch break; case 3: //Edit policy // call a function to get the policy option that the user wants and set it to Polopt Polopt = Poloption(); //do a case on the Polopt switch(Polopt) { case 1: //if 1 edit home policy HCpolicy.EditPolicy( HomeFile ); //call object method to edit policy and send the home file to it break; case 2: //if 2 edit life policy LCpolicy.EditPolicy( LifeFile ); //call object method to edit policy and send the life file to it break; case 3: //if 3 edit motor vehicle policy MVCpolicy.EditPolicy( MVFile ); //call object method to edit policy and send the motor vehicle file to it break; }// end switch break; case 4: //View policy // call a function to get the policy option that the user wants and set it to Polopt Polopt = Poloption(); //do a case on the Polopt switch(Polopt) { case 1: //if 1 view home policy Bpolicy = &HCpolicy; //point the base class to the child class home /*call the view method inside the child object to get policy to view if it return a zero then dont enter the if statment */ if ( HCpolicy.ViewHome(HomeFile) != 0 ){ //if not equal to 0 ThemeStyle1( ); //create screen theme Bpolicy->Insurpolicy::Display( ); //display the base class data Bpolicy->Display( ); //display the child class data }//end if gotoxy( 25, 22); system("PAUSE"); break; case 2: //if 2 view life policy Bpolicy = &LCpolicy; //point the base class to the child class life /*call the view method inside the child object to get policy to view if it return a zero then dont enter the if statment */ if ( LCpolicy.ViewLife(LifeFile) != 0 ){ //if not equal to 0 ThemeStyle1( ); //create screen theme Bpolicy->Insurpolicy::Display( ); //display the base class data Bpolicy->Display( ); //display the child class data }//end if gotoxy( 25, 22); system("PAUSE"); break; case 3: //if 3 view motor vehicle policy Bpolicy = &MVCpolicy; //point the base class to the child class motor vehicle /*call the view method inside the child object to get policy to view if it return a zero then dont enter the if statment */ if ( MVCpolicy.ViewMotov(MVFile) != 0 ){ //if not equal to 0 ThemeStyle1( ); //create screen theme Bpolicy->Insurpolicy::Display( ); //display the base class data Bpolicy->Display( ); //display the child class data } //end if gotoxy( 25, 24); system("PAUSE"); break; }// end switch break; case 6: helpFile(); //function calls the help break; case 7: AboutUs(); //function tell about the program break; case 8: Credit(); //function gives credit to the programmers break; default : cout<<"\a\a\a"; //sound the system alarm to notify wrong input }//end switch Option = menu.Popumenu(menuPtr); //call function to get user option }//end while Shutdown( ); //display a shutdown screen return 0; //the function has run successfully }//end function main
void Parameter::PrintCredit() { vector<Credit> everyone; srand ( time(NULL) ); everyone.push_back(Credit("Nicola Bertoldi" , "911" , "" , "scripts & other stuff")); everyone.push_back(Credit("Ondrej Bojar" , "" , "czech this out!" , "")); everyone.push_back(Credit("Chris Callison-Burch" , "anytime, anywhere" , "international playboy" , "")); everyone.push_back(Credit("Alexandra Constantin" , "" , "eu sunt varza" , "")); everyone.push_back(Credit("Brooke Cowan" , "*****@*****.**" , "if you're going to san francisco, be sure to wear a flower in your hair" , "")); everyone.push_back(Credit("Chris Dyer" , "can't. i'll be out driving my mustang" , "driving my mustang" , "")); everyone.push_back(Credit("Marcello Federico" , "federico at itc at it" , "Researcher at ITC-irst, Trento, Italy" , "IRST language model")); everyone.push_back(Credit("Evan Herbst" , "Small college in upstate New York" , "" , "")); everyone.push_back(Credit("Philipp Koehn" , "only between 2 and 4am" , "" , "Nothing fazes this dude")); everyone.push_back(Credit("Christine Moran" , "weird building at MIT" , "" , "")); everyone.push_back(Credit("Wade Shen" , "via morse code" , "buying another laptop" , "")); everyone.push_back(Credit("Richard Zens" , "richard at aachen dot de" , "" , "ambiguous source input, confusion networks, confusing source code")); everyone.push_back(Credit("Hieu Hoang", "http://www.hoang.co.uk/hieu/" , "phd student at Edinburgh Uni. Original Moses developer" , "general queries/ flames on Moses.")); sort(everyone.begin(), everyone.end()); cerr << "Moses - A beam search decoder for phrase-based statistical machine translation models" << endl << "Copyright (C) 2006 University of Edinburgh" << endl << endl << "This library is free software; you can redistribute it and/or" << endl << "modify it under the terms of the GNU Lesser General Public" << endl << "License as published by the Free Software Foundation; either" << endl << "version 2.1 of the License, or (at your option) any later version." << endl << endl << "This library is distributed in the hope that it will be useful," << endl << "but WITHOUT ANY WARRANTY; without even the implied warranty of" << endl << "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU" << endl << "Lesser General Public License for more details." << endl << endl << "You should have received a copy of the GNU Lesser General Public" << endl << "License along with this library; if not, write to the Free Software" << endl << "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA" << endl << endl << "***********************************************************************" << endl << endl << "Built on " << __DATE__ << " at " __TIME__ << endl << endl << "WHO'S FAULT IS THIS GODDAM SOFTWARE:" << endl; ostream_iterator<Credit> out(cerr, "\n"); copy(everyone.begin(), everyone.end(), out); cerr << endl << endl; }
void Player::PassGo() { cout << name << " passed go and collected " << POUND << "200." << endl; Credit(200); }