----------------------------------------------------- //
| 342 | |
| 343 | // ----------------------------------------------------- // |
| 344 | void bDNA::init(char *data, int len, bool swap) |
| 345 | { |
| 346 | int *intPtr = 0; |
| 347 | short *shtPtr = 0; |
| 348 | char *cp = 0; |
| 349 | int dataLen = 0; |
| 350 | //long nr=0; |
| 351 | intPtr = (int *)data; |
| 352 | |
| 353 | /* |
| 354 | SDNA (4 bytes) (magic number) |
| 355 | NAME (4 bytes) |
| 356 | <nr> (4 bytes) amount of names (int) |
| 357 | <string> |
| 358 | <string> |
| 359 | */ |
| 360 | |
| 361 | if (strncmp(data, "SDNA", 4) == 0) |
| 362 | { |
| 363 | // skip ++ NAME |
| 364 | intPtr++; |
| 365 | intPtr++; |
| 366 | } |
| 367 | |
| 368 | // Parse names |
| 369 | if (swap) |
| 370 | { |
| 371 | *intPtr = ChunkUtils::swapInt(*intPtr); |
| 372 | } |
| 373 | dataLen = *intPtr; |
| 374 | intPtr++; |
| 375 | |
| 376 | cp = (char *)intPtr; |
| 377 | int i; |
| 378 | for (i = 0; i < dataLen; i++) |
| 379 | { |
| 380 | bNameInfo info; |
| 381 | info.m_name = cp; |
| 382 | info.m_isPointer = (info.m_name[0] == '*') || (info.m_name[1] == '*'); |
| 383 | name_is_array(info.m_name, &info.m_dim0, &info.m_dim1); |
| 384 | m_Names.push_back(info); |
| 385 | while (*cp) cp++; |
| 386 | cp++; |
| 387 | } |
| 388 | |
| 389 | cp = b3AlignPointer(cp, 4); |
| 390 | |
| 391 | /* |
| 392 | TYPE (4 bytes) |
| 393 | <nr> amount of types (int) |
| 394 | <string> |
| 395 | <string> |
| 396 | */ |
| 397 | |
| 398 | intPtr = (int *)cp; |
| 399 | assert(strncmp(cp, "TYPE", 4) == 0); |
| 400 | intPtr++; |
| 401 |
no test coverage detected