00001 #define USELIBRARY 00002 00003 #include <fstream> 00004 #include <cstdlib> 00005 00006 #include "../primUtils.h" 00007 00008 using namespace std; 00009 00010 struct { 00011 int reply; 00012 } globalConf; 00013 00014 static void usage(); 00015 static void parseArgs(int argc, char **argv); 00016 00017 int main(int argc, char **argv) { 00018 globalConf.reply = 0; 00019 parseArgs(argc, argv); 00020 00021 string fileName = argv[argc-1]; 00022 00023 ifstream fin(fileName.c_str(), ios::binary); 00024 00025 cout << "Reading " << fileName << endl; 00026 00027 if(fin.is_open()) { 00028 fin.seekg(0, std::ios::end); 00029 int fileSize = fin.tellg(); 00030 fin.seekg(0, std::ios::beg); 00031 00032 cout << "Filesize " << fileSize << endl; 00033 00034 unsigned long *buffer = new unsigned long[fileSize / 4]; 00035 00036 fin.read((char*)&buffer[0], fileSize); 00037 00038 SctApi::printOutList(buffer, fileSize/4, !globalConf.reply, 0, cout, false, false); 00039 } else { 00040 cout << "Couldn't open file " << fileName << "\n"; 00041 } 00042 } 00043 00044 void parseArgs(int argc, char **argv) { 00045 if(argc < 2) { 00046 usage(); 00047 exit(1); 00048 } else { 00049 for(int i=1; i<argc-1; i++) { 00050 if(argv[i][0] == '-') { 00051 switch(argv[i][1]) { 00052 case 'r': 00053 globalConf.reply = 1; 00054 break; 00055 case 'h': 00056 usage(); 00057 exit(1); 00058 break; 00059 } 00060 } 00061 } 00062 } 00063 } 00064 00065 void usage() { 00066 cout << "usage: PrimList [opts] Filename\n"; 00067 cout << " where filename is a file containing a raw primitive list\n"; 00068 cout << "\t-r This is a reply list\n"; 00069 }