* Simple program to decompress log files produced by the NanoLog System. * Note that this executable must be compiled with the same BufferStuffer.h * as the LogCompressor that generated the compressedLog for this to work. */
| 150 | * as the LogCompressor that generated the compressedLog for this to work. |
| 151 | */ |
| 152 | int main(int argc, char** argv) { |
| 153 | if (argc < 3) { |
| 154 | printHelp(argv[0]); |
| 155 | exit(1); |
| 156 | } |
| 157 | |
| 158 | const char *command = argv[1]; |
| 159 | const char *logFileName = argv[2]; |
| 160 | bool find = false; |
| 161 | bool sorted = false; |
| 162 | bool doRCDF = false; |
| 163 | FILE *outputFd = NULL; |
| 164 | int filterId = -1; |
| 165 | |
| 166 | if (strcmp(command, "decompress") == 0) { |
| 167 | outputFd = stdout; |
| 168 | sorted = true; |
| 169 | } else if (strcmp(command, "decompressUnordered") == 0) { |
| 170 | outputFd = stdout; |
| 171 | } else if (strcmp(command, "rcdfTime") == 0) { |
| 172 | doRCDF = true; |
| 173 | } else if (strcmp(command, "minMaxMean") == 0) { |
| 174 | if (argc < 4) { |
| 175 | printHelp(argv[0]); |
| 176 | exit(1); |
| 177 | } |
| 178 | |
| 179 | try { |
| 180 | filterId = std::stoi(argv[3]); |
| 181 | } catch (const std::invalid_argument& e) { |
| 182 | printf("Invalid logId, please enter a number: %s\r\n", argv[3]); |
| 183 | exit(-1); |
| 184 | } catch (const std::out_of_range& e) { |
| 185 | printf("The logId is too large: %s\r\n", argv[3]); |
| 186 | exit(-1); |
| 187 | } |
| 188 | |
| 189 | if (filterId < 0) { |
| 190 | printf("The logId must be positive: %s\r\n", argv[3]); |
| 191 | exit(-1); |
| 192 | } |
| 193 | } else if (strcmp(command, "find") == 0) { |
| 194 | if (argc < 4) { |
| 195 | printHelp(argv[0]); |
| 196 | exit(1); |
| 197 | } |
| 198 | |
| 199 | find = true; |
| 200 | } else { |
| 201 | printHelp(argv[0]); |
| 202 | exit(1); |
| 203 | } |
| 204 | |
| 205 | Decoder decoder; |
| 206 | if(!decoder.open(logFileName)) { |
| 207 | printf("Unable to open file %s\r\n", logFileName); |
| 208 | exit(1); |
| 209 | } |
nothing calls this directly
no test coverage detected