comparison sources/parser.cpp @ 6:9be05a31b7f9

Enqlave IRC Network => Vaygr IRC Network -Os optimizations by default temporary functions' arguments rename *char => NULL bool => true|false renamed some global vars, removed debug info
author Vlad Glagolev <enqlave@gmail.com>
date Sun, 27 Jan 2008 17:23:14 +0300
parents a7051ac7118b
children 8d54d9fdeca3
comparison
equal deleted inserted replaced
5:0faceb076254 6:9be05a31b7f9
32 strcpy(line, parsing.c_str()); 32 strcpy(line, parsing.c_str());
33 33
34 char *who = strtok(line, " "); 34 char *who = strtok(line, " ");
35 char *what = strtok(NULL, " "); 35 char *what = strtok(NULL, " ");
36 char *where = strtok(NULL, " "); 36 char *where = strtok(NULL, " ");
37 char *message = strtok(NULL, "\n"); 37 char *data = strtok(NULL, "\n");
38 38
39 if (strchr(who, '!')) { 39 if (strchr(who, '!')) {
40 alienID = strchr(who, '!'); 40 id = strchr(who, '!');
41 alienID = alienID.substr(1); 41 id = id.substr(1);
42 } 42 }
43 43
44 if (strtok(who, "!")) 44 if (strtok(who, "!"))
45 alien = strtok(who, "!"); 45 name = strtok(who, "!");
46 46
47 alienAction = what; 47 action = what;
48 48
49 if (*where == ':') 49 if (*where == ':')
50 alienLocation = ++where; 50 place = ++where;
51 else { 51 else {
52 alienLocation = where; 52 place = where;
53 53
54 if (message) { 54 if (data) {
55 if (alienLocation == S->nick) 55 if (place == S->nick)
56 alienLocation = alien; 56 place = name;
57 57
58 alienMessage = (*message == ':') ? ++message: message; 58 message = (*data == ':') ? ++data: data;
59 59
60 if (*message == CABAL->commander && ++message) { 60 if (*data == CABAL->commander && ++data) {
61 if (strchr(message, ' ')) { 61 if (strchr(data, ' ')) {
62 alienCommand = strtok(message, " "); 62 command = strtok(data, " ");
63 alienMessage = strtok(NULL, "\n"); 63 message = strtok(NULL, "\n");
64 } else 64 } else
65 alienCommand = message; 65 command = data;
66 } 66 }
67 } 67 }
68 } 68 }
69 69
70 delete[] line; 70 delete[] line;
71 71 }
72 /* DEBUG
73 cout
74 << "-----------------------------------\n" \
75 << "Alien: \t" << alien << endl \
76 << "Alien ID:\t" << alienID << endl \
77 << "Alien action:\t" << alienAction << endl \
78 << "Alien location:\t" << alienLocation << endl \
79 << "Alien command:\t" << alienCommand << endl \
80 << "Alien message:\t" << alienMessage << endl \
81 << "-----------------------------------\n";
82 */ }
83 } 72 }
84 73
85 void Parser::Parse(Connection *S) 74 void Parser::Parse(Connection *S)
86 { 75 {
87 if (alienCommand == "die" && alienID == "stealth@ru.raver") 76 if (command == "die" && id == "stealth@ru.raver")
88 shut("Requested shutdown"); 77 shut("Requested shutdown");
89 } 78 }