1097 {
1099 "Reading Compression Table from File is not supported anymore!");
1100
1101 return StatusCode::FAILURE;
1102
1103#ifdef TRT_READCOMPTABLE_FILE
1104
1106
1107 ATH_MSG_INFO(
"Reading Compress Table File: " << TableFilename);
1108
1111
1113 ATH_MSG_FATAL(
"Could not open Compression Table File " << TableFilename);
1114 return StatusCode::FAILURE;
1115 }
1116
1117#define MAXLINE 1024
1118
1120 char* tok;
1121
1122 int* lengths = 0;
1123 int* codewords = 0;
1124
1125 Ctable->m_Nsymbols = 0;
1126
1128 inFile.getline(line, MAXLINE);
1129
1130 tok = strtok(line, " \t\n<");
1131 if (!tok)
1132 continue;
1133
1134
1135 if (!strncmp(tok, "Version", 7)) {
1136 tok = strtok(NULL, " \t\n");
1137 Ctable->m_TableVersion =
atoi(tok);
1138
1139 ATH_MSG_DEBUG(
"Table Version = " << Ctable->m_TableVersion);
1140
1141 tok = strtok(NULL, " \t\n");
1142 if (!tok) {
1143 inFile.getline(line, MAXLINE);
1144
1145 tok = strtok(line, " \t\n");
1146 }
1147
1148 if (strncmp(tok, ">", 1)) {
1151
1152 if (lengths)
1153 delete[] lengths;
1154
1155 if (codewords)
1156 delete[] codewords;
1157
1158 return StatusCode::FAILURE;
1159 }
1160
1161 Ctable->m_syms = std::make_unique<unsigned int[]>(Ctable->m_Nsymbols);
1162
1163 if (lengths)
1164 delete[] lengths;
1165 lengths = new int[Ctable->m_Nsymbols];
1166
1167 if (codewords)
1168 delete[] codewords;
1169 codewords = new int[Ctable->m_Nsymbols];
1170 }
1171
1172
1173 if (!strncmp(tok, "Nsymbols", 8)) {
1174 tok = strtok(NULL, " \t\n");
1175 Ctable->m_Nsymbols =
atoi(tok);
1176
1178
1179 tok = strtok(NULL, " \t\n");
1180 if (!tok) {
1181 inFile.getline(line, MAXLINE);
1182
1183 tok = strtok(line, " \t\n");
1184 }
1185
1186 if (strncmp(tok, ">", 1)) {
1189
1190 if (lengths)
1191 delete[] lengths;
1192
1193 if (codewords)
1194 delete[] codewords;
1195
1196 return StatusCode::FAILURE;
1197 }
1198
1199 Ctable->m_syms = std::make_unique<unsigned int[]>(Ctable->m_Nsymbols);
1200
1201 if (lengths)
1202 delete[] lengths;
1203 lengths = new int[Ctable->m_Nsymbols];
1204
1205 if (codewords)
1206 delete[] codewords;
1207 codewords = new int[Ctable->m_Nsymbols];
1208 }
1209
1210
1211 if (!strncmp(tok, "syms", 4)) {
1212
1213 if (!Ctable->m_syms) {
1216
1217 if (lengths)
1218 delete[] lengths;
1219
1220 if (codewords)
1221 delete[] codewords;
1222
1223 return StatusCode::FAILURE;
1224 }
1225
1227
1228 tok = strtok(NULL, " \t\n");
1229 while (i < Ctable->m_Nsymbols) {
1230 while ((tok) && (i < Ctable->m_Nsymbols)) {
1231 Ctable->m_syms[
i++] =
atoi(tok);
1232 tok = strtok(NULL, " \t\n");
1233 }
1234
1235 if (!tok) {
1236 inFile.getline(line, MAXLINE);
1237 tok = strtok(line, " \t\n");
1238 }
1239 }
1240
1241 if (strncmp(tok, ">", 1)) {
1244
1245 if (lengths)
1246 delete[] lengths;
1247
1248 if (codewords)
1249 delete[] codewords;
1250
1251 return StatusCode::FAILURE;
1252 }
1253 }
1254
1255
1256 if (!strncmp(tok, "codewords", 9)) {
1257 if (!codewords) {
1260
1261 if (lengths)
1262 delete[] lengths;
1263
1264 return StatusCode::FAILURE;
1265 }
1266
1268
1269 tok = strtok(NULL, " \t\n");
1270 while (i < Ctable->m_Nsymbols) {
1271 while ((tok) && (i < Ctable->m_Nsymbols)) {
1272 codewords[
i++] =
atoi(tok);
1273 tok = strtok(NULL, " \t\n");
1274 }
1275
1276 if (!tok) {
1277 inFile.getline(line, MAXLINE);
1278 tok = strtok(line, " \t\n");
1279 }
1280 }
1281
1282 if (strncmp(tok, ">", 1)) {
1285
1286 if (lengths)
1287 delete[] lengths;
1288
1289 if (codewords)
1290 delete[] codewords;
1291
1292 return StatusCode::FAILURE;
1293 }
1294 }
1295
1296
1297 if (!strncmp(tok, "firstcode", 9)) {
1299
1300 tok = strtok(NULL, " \t\n");
1301 while (i < 33) {
1302 while ((tok) && (i < 33)) {
1303 Ctable->m_firstcode[
i++] =
atoi(tok);
1304 tok = strtok(NULL, " \t\n");
1305 }
1306
1307 if (!tok) {
1308 inFile.getline(line, MAXLINE);
1309 tok = strtok(line, " \t\n");
1310 }
1311 }
1312
1313 if (strncmp(tok, ">", 1)) {
1316
1317 if (lengths)
1318 delete[] lengths;
1319
1320 if (codewords)
1321 delete[] codewords;
1322
1323 return StatusCode::FAILURE;
1324 }
1325 }
1326
1327
1328 if (!strncmp(tok, "lengths_integral", 16)) {
1330
1331 tok = strtok(NULL, " \t\n");
1332 while (i < 33) {
1333 while ((tok) && (i < 33)) {
1334 Ctable->m_lengths_integral[
i++] =
atoi(tok);
1335 tok = strtok(NULL, " \t\n");
1336 }
1337
1338 if (!tok) {
1339 inFile.getline(line, MAXLINE);
1340 tok = strtok(line, " \t\n");
1341 }
1342 }
1343
1344 if (strncmp(tok, ">", 1)) {
1347
1348 if (lengths)
1349 delete[] lengths;
1350
1351 if (codewords)
1352 delete[] codewords;
1353
1354 return StatusCode::FAILURE;
1355 }
1356 }
1357
1358
1359 if (!strncmp(tok, "lengths", 7)) {
1360 if (!lengths) {
1363
1364 if (codewords)
1365 delete[] codewords;
1366
1367 return StatusCode::FAILURE;
1368 }
1369
1371
1372 tok = strtok(NULL, " \t\n");
1373 while (i < Ctable->m_Nsymbols) {
1374 while ((tok) && (i < Ctable->m_Nsymbols)) {
1375 lengths[
i++] =
atoi(tok);
1376 tok = strtok(NULL, " \t\n");
1377 }
1378
1379 if (!tok) {
1380 inFile.getline(line, MAXLINE);
1381 tok = strtok(line, " \t\n");
1382 }
1383 }
1384
1385 if (strncmp(tok, ">", 1)) {
1388
1389 if (lengths)
1390 delete[] lengths;
1391
1392 if (codewords)
1393 delete[] codewords;
1394
1395 return StatusCode::FAILURE;
1396 }
1397 }
1398 }
1399
1401
1402 if (!codewords || !lengths) {
1404
1405 if (lengths)
1406 delete[] lengths;
1407
1408 if (codewords)
1409 delete[] codewords;
1410
1411 return StatusCode::FAILURE;
1412 }
1413
1414
1415
1416
1417 int i = Ctable->m_Nsymbols - 1;
1418 int escape_length = 0;
1419
1420
1423
1424 if (i < 0) {
1426
1427 if (lengths)
1428 delete[] lengths;
1429
1430 if (codewords)
1431 delete[] codewords;
1432
1433 return StatusCode::FAILURE;
1434 } else {
1435
1436 escape_length = lengths[
i];
1437
1438 if (escape_length != 5)
1440 << " rather than 5!");
1441 }
1442
1443#ifdef PRINT_TABLE
1444 for (int j = 0; j < Ctable->m_Nsymbols; j++) {
1445 ATH_MSG_INFO(
"Table: " << j <<
" " << lengths[j] <<
" " << MSG::hex
1446 << codewords[j] << " " << Ctable->m_syms[j]
1447 << std::dec);
1448 }
1449#endif
1450
1451 if (lengths)
1452 delete[] lengths;
1453
1454 if (codewords)
1455 delete[] codewords;
1456
1459 "Invalid Compression Table Version: " << Ctable->m_TableVersion);
1460
1461 return StatusCode::FAILURE;
1462 }
1463
1466 << " already loaded! Not overwriting");
1467 } else {
1468 ATH_MSG_INFO(
"Loaded Compress Table Version: " << Ctable->m_TableVersion);
1470 }
1471
1472 return StatusCode::SUCCESS;
1473
1474#endif
1475}
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...