From 06632fb7f9f91d5147eadee23a48a451289e6b9a Mon Sep 17 00:00:00 2001 From: Chuck Miller Date: Mon, 25 May 2009 15:22:39 -0400 Subject: Adds -s option to itemsearch tool, for searching storages files --- src/tool/itemsearch.cpp | 60 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/src/tool/itemsearch.cpp b/src/tool/itemsearch.cpp index cf399e5..986e9b5 100644 --- a/src/tool/itemsearch.cpp +++ b/src/tool/itemsearch.cpp @@ -7,6 +7,7 @@ using namespace std; +bool useStorage; int itemID; int itemCount(string itemData) @@ -57,24 +58,38 @@ void parseLine(string &line) do { - if (counter == 1 || counter == 2 || counter == 15) + if (!useStorage) { - - int ending = line.find('\t', pointer + 1); - if (ending == string::npos) - ending = line.size(); - switch (counter) - { - case 1: - AccountId = line.substr(pointer,ending - pointer); - break; - case 2: - Name = line.substr(pointer, ending - pointer); - break; - case 15: - Items = line.substr(pointer, ending - pointer); - } + if (counter == 1 || counter == 2 || counter == 15) + { + int ending = line.find('\t', pointer + 1); + if (ending == string::npos) + ending = line.size(); + switch (counter) + { + case 1: + AccountId = line.substr(pointer,ending - pointer); + break; + case 2: + Name = line.substr(pointer, ending - pointer); + break; + case 15: + Items = line.substr(pointer, ending - pointer); + } + } } + else if (useStorage) + { + int ending = line.find('\t', pointer + 1); + if (ending == string::npos) + ending = line.size(); + + if (counter == 0) + AccountId = line.substr(pointer,ending - pointer); + else if (counter == 1) + Items = line.substr(pointer,ending - pointer); + } + counter++; } while ((pointer = line.find('\t',pointer) + 1) != string::npos + 1 && counter < 16); @@ -96,11 +111,22 @@ int main(int argc,char *argv[]) if(argc < 2) { printf("Usage: %s \n", argv[0]); + printf("Usage2: %s -s \n", argv[0]); printf("e.g., %s 701\n", argv[0]); printf("Will return all users who own that item\n"); + printf("Option \"-s\" will expect storage files\n"); exit(0); } - itemID = atoi(argv[1]); + if (strcmp(argv[1],"-s") == 0) + { + useStorage = true; + itemID = atoi(argv[2]); + } + else + { + useStorage = false; + itemID = atoi(argv[1]); + } parseInput(); return 0; -- cgit v1.2.3-70-g09d2