test_ole2.c (16513B)
1 /* 2 This file is part of libextractor. 3 Copyright (C) 2012 Vidyut Samanta and Christian Grothoff 4 5 libextractor is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published 7 by the Free Software Foundation; either version 3, or (at your 8 option) any later version. 9 10 libextractor is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with libextractor; see the file COPYING. If not, write to the 17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, USA. 19 */ 20 /** 21 * @file plugins/test_ole2.c 22 * @brief testcase for ole2 plugin 23 * @author Christian Grothoff 24 */ 25 #include "platform.h" 26 #include "test_lib.h" 27 28 29 /** 30 * Main function for the OLE2 testcase. 31 * 32 * @param argc number of arguments (ignored) 33 * @param argv arguments (ignored) 34 * @return 0 on success 35 */ 36 int 37 main (int argc, char *argv[]) 38 { 39 struct SolutionData ole2_msword_sol[] = { 40 { 41 EXTRACTOR_METATYPE_CREATOR, 42 EXTRACTOR_METAFORMAT_UTF8, 43 "text/plain", 44 "Nils Durner", 45 strlen ("Nils Durner") + 1, 46 0 47 }, 48 { 49 EXTRACTOR_METATYPE_UNKNOWN_DATE, 50 EXTRACTOR_METAFORMAT_UTF8, 51 "text/plain", 52 "2005-03-21T06:11:12Z", 53 strlen ("2005-03-21T06:11:12Z") + 1, 54 0 55 }, 56 { 57 EXTRACTOR_METATYPE_DESCRIPTION, 58 EXTRACTOR_METAFORMAT_UTF8, 59 "text/plain", 60 "This is a small document to test meta data extraction by GNU libextractor.", 61 strlen ( 62 "This is a small document to test meta data extraction by GNU libextractor.") 63 + 1, 64 0 65 }, 66 { 67 EXTRACTOR_METATYPE_KEYWORDS, 68 EXTRACTOR_METAFORMAT_UTF8, 69 "text/plain", 70 "ole ole2 eole2extractor", 71 strlen ("ole ole2 eole2extractor") + 1, 72 0 73 }, 74 { 75 EXTRACTOR_METATYPE_SUBJECT, 76 EXTRACTOR_METAFORMAT_UTF8, 77 "text/plain", 78 "GNU libextractor", 79 strlen ("GNU libextractor") + 1, 80 0 81 }, 82 { 83 EXTRACTOR_METATYPE_TITLE, 84 EXTRACTOR_METAFORMAT_UTF8, 85 "text/plain", 86 "Testcase for the ole2 extractor", 87 strlen ("Testcase for the ole2 extractor") + 1, 88 0 89 }, 90 { 91 EXTRACTOR_METATYPE_LAST_SAVED_BY, 92 EXTRACTOR_METAFORMAT_UTF8, 93 "text/plain", 94 "Nils Durner", 95 strlen ("Nils Durner") + 1, 96 0 97 }, 98 { 99 EXTRACTOR_METATYPE_CREATION_DATE, 100 EXTRACTOR_METAFORMAT_UTF8, 101 "text/plain", 102 "2005-03-21T06:10:19Z", 103 strlen ("2005-03-21T06:10:19Z") + 1, 104 0 105 }, 106 { 107 EXTRACTOR_METATYPE_EDITING_CYCLES, 108 EXTRACTOR_METAFORMAT_UTF8, 109 "text/plain", 110 "2", 111 strlen ("2") + 1, 112 0 113 }, 114 { 115 EXTRACTOR_METATYPE_AUTHORING_OS, 116 EXTRACTOR_METAFORMAT_UTF8, 117 "text/plain", 118 "Windows 1.0", 119 strlen ("Windows 1.0") + 1, 120 0 121 }, 122 { 0, 0, NULL, NULL, 0, -1 } 123 }; 124 125 struct SolutionData ole2_starwriter_sol[] = { 126 { 127 EXTRACTOR_METATYPE_CREATOR, 128 EXTRACTOR_METAFORMAT_UTF8, 129 "text/plain", 130 "Christian Grothoff", 131 strlen ("Christian Grothoff") + 1, 132 0 133 }, 134 { 135 EXTRACTOR_METATYPE_UNKNOWN_DATE, 136 EXTRACTOR_METAFORMAT_UTF8, 137 "text/plain", 138 "2004-09-24T02:54:31Z", 139 strlen ("2004-09-24T02:54:31Z") + 1, 140 0 141 }, 142 { 143 EXTRACTOR_METATYPE_DESCRIPTION, 144 EXTRACTOR_METAFORMAT_UTF8, 145 "text/plain", 146 "The comments", 147 strlen ("The comments") + 1, 148 0 149 }, 150 { 151 EXTRACTOR_METATYPE_KEYWORDS, 152 EXTRACTOR_METAFORMAT_UTF8, 153 "text/plain", 154 "The Keywords", 155 strlen ("The Keywords") + 1, 156 0 157 }, 158 { 159 EXTRACTOR_METATYPE_SUBJECT, 160 EXTRACTOR_METAFORMAT_UTF8, 161 "text/plain", 162 "The Subject", 163 strlen ("The Subject") + 1, 164 0 165 }, 166 { 167 EXTRACTOR_METATYPE_TITLE, 168 EXTRACTOR_METAFORMAT_UTF8, 169 "text/plain", 170 "The Title", 171 strlen ("The Title") + 1, 172 0 173 }, 174 { 175 EXTRACTOR_METATYPE_LAST_SAVED_BY, 176 EXTRACTOR_METAFORMAT_UTF8, 177 "text/plain", 178 "Christian Grothoff", 179 strlen ("Christian Grothoff") + 1, 180 0 181 }, 182 { 183 EXTRACTOR_METATYPE_CREATION_DATE, 184 EXTRACTOR_METAFORMAT_UTF8, 185 "text/plain", 186 "2004-09-24T02:53:15Z", 187 strlen ("2004-09-24T02:53:15Z") + 1, 188 0 189 }, 190 { 191 EXTRACTOR_METATYPE_EDITING_CYCLES, 192 EXTRACTOR_METAFORMAT_UTF8, 193 "text/plain", 194 "4", 195 strlen ("4") + 1, 196 0 197 }, 198 { 199 EXTRACTOR_METATYPE_TITLE, 200 EXTRACTOR_METAFORMAT_UTF8, 201 "text/plain", 202 "The Title", 203 strlen ("The Title") + 1, 204 0 205 }, 206 { 207 EXTRACTOR_METATYPE_SUBJECT, 208 EXTRACTOR_METAFORMAT_UTF8, 209 "text/plain", 210 "The Subject", 211 strlen ("The Subject") + 1, 212 0 213 }, 214 { 215 EXTRACTOR_METATYPE_COMMENT, 216 EXTRACTOR_METAFORMAT_UTF8, 217 "text/plain", 218 "The comments", 219 strlen ("The comments") + 1, 220 0 221 }, 222 { 223 EXTRACTOR_METATYPE_KEYWORDS, 224 EXTRACTOR_METAFORMAT_UTF8, 225 "text/plain", 226 "The Keywords", 227 strlen ("The Keywords") + 1, 228 0 229 }, 230 { 231 EXTRACTOR_METATYPE_AUTHORING_OS, 232 EXTRACTOR_METAFORMAT_UTF8, 233 "text/plain", 234 "Windows (16 bit) 1.0", 235 strlen ("Windows (16 bit) 1.0") + 1, 236 0 237 }, 238 { 0, 0, NULL, NULL, 0, -1 } 239 }; 240 #if HAVE_ICONV 241 struct SolutionData ole2_blair_sol[] = { 242 { 243 EXTRACTOR_METATYPE_LANGUAGE, 244 EXTRACTOR_METAFORMAT_UTF8, 245 "text/plain", 246 "U.S. English", 247 strlen ("U.S. English") + 1, 248 0 249 }, 250 { 251 EXTRACTOR_METATYPE_CREATOR, 252 EXTRACTOR_METAFORMAT_UTF8, 253 "text/plain", 254 "default", 255 strlen ("default") + 1, 256 0 257 }, 258 { 259 EXTRACTOR_METATYPE_UNKNOWN_DATE, 260 EXTRACTOR_METAFORMAT_UTF8, 261 "text/plain", 262 "2003-02-03T11:18:00Z", 263 strlen ("2003-02-03T11:18:00Z") + 1, 264 0 265 }, 266 { 267 EXTRACTOR_METATYPE_TITLE, 268 EXTRACTOR_METAFORMAT_UTF8, 269 "text/plain", 270 "Iraq- ITS INFRASTRUCTURE OF CONCEALMENT, DECEPTION AND INTIMIDATION", 271 strlen ( 272 "Iraq- ITS INFRASTRUCTURE OF CONCEALMENT, DECEPTION AND INTIMIDATION") 273 + 1, 274 0 275 }, 276 { 277 EXTRACTOR_METATYPE_CHARACTER_COUNT, 278 EXTRACTOR_METAFORMAT_UTF8, 279 "text/plain", 280 "22090", 281 strlen ("22090") + 1, 282 0 283 }, 284 { 285 EXTRACTOR_METATYPE_LAST_SAVED_BY, 286 EXTRACTOR_METAFORMAT_UTF8, 287 "text/plain", 288 "MKhan", 289 strlen ("MKhan") + 1, 290 0 291 }, 292 { 293 EXTRACTOR_METATYPE_PAGE_COUNT, 294 EXTRACTOR_METAFORMAT_UTF8, 295 "text/plain", 296 "1", 297 strlen ("1") + 1, 298 0 299 }, 300 { 301 EXTRACTOR_METATYPE_WORD_COUNT, 302 EXTRACTOR_METAFORMAT_UTF8, 303 "text/plain", 304 "3875", 305 strlen ("3875") + 1, 306 0 307 }, 308 { 309 EXTRACTOR_METATYPE_CREATION_DATE, 310 EXTRACTOR_METAFORMAT_UTF8, 311 "text/plain", 312 "2003-02-03T09:31:00Z", 313 strlen ("2003-02-03T09:31:00Z") + 1, 314 0 315 }, 316 { 317 EXTRACTOR_METATYPE_EDITING_CYCLES, 318 EXTRACTOR_METAFORMAT_UTF8, 319 "text/plain", 320 "4", 321 strlen ("4") + 1, 322 0 323 }, 324 { 325 EXTRACTOR_METATYPE_MIMETYPE, 326 EXTRACTOR_METAFORMAT_UTF8, 327 "text/plain", 328 "application/vnd.ms-files", 329 strlen ("application/vnd.ms-files") + 1, 330 0 331 }, 332 { 333 EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, 334 EXTRACTOR_METAFORMAT_UTF8, 335 "text/plain", 336 "Microsoft Word 8.0", 337 strlen ("Microsoft Word 8.0") + 1, 338 0 339 }, 340 { 341 EXTRACTOR_METATYPE_TEMPLATE, 342 EXTRACTOR_METAFORMAT_UTF8, 343 "text/plain", 344 "Normal.dot", 345 strlen ("Normal.dot") + 1, 346 0 347 }, 348 { 349 EXTRACTOR_METATYPE_LINE_COUNT, 350 EXTRACTOR_METAFORMAT_UTF8, 351 "text/plain", 352 "184", 353 strlen ("184") + 1, 354 0 355 }, 356 { 357 EXTRACTOR_METATYPE_PARAGRAPH_COUNT, 358 EXTRACTOR_METAFORMAT_UTF8, 359 "text/plain", 360 "44", 361 strlen ("44") + 1, 362 0 363 }, 364 { 365 EXTRACTOR_METATYPE_REVISION_HISTORY, 366 EXTRACTOR_METAFORMAT_UTF8, 367 "text/plain", 368 "Revision #0: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'", 369 strlen ( 370 "Revision #0: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'") 371 + 1, 372 0 373 }, 374 { 375 EXTRACTOR_METATYPE_REVISION_HISTORY, 376 EXTRACTOR_METAFORMAT_UTF8, 377 "text/plain", 378 "Revision #1: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'", 379 strlen ( 380 "Revision #1: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'") 381 + 1, 382 0 383 }, 384 { 385 EXTRACTOR_METATYPE_REVISION_HISTORY, 386 EXTRACTOR_METAFORMAT_UTF8, 387 "text/plain", 388 "Revision #2: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'", 389 strlen ( 390 "Revision #2: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'") 391 + 1, 392 0 393 }, 394 { 395 EXTRACTOR_METATYPE_REVISION_HISTORY, 396 EXTRACTOR_METAFORMAT_UTF8, 397 "text/plain", 398 "Revision #3: Author `JPratt' worked on `C:\\TEMP\\Iraq - security.doc'", 399 strlen ( 400 "Revision #3: Author `JPratt' worked on `C:\\TEMP\\Iraq - security.doc'") 401 + 1, 402 0 403 }, 404 { 405 EXTRACTOR_METATYPE_REVISION_HISTORY, 406 EXTRACTOR_METAFORMAT_UTF8, 407 "text/plain", 408 "Revision #4: Author `JPratt' worked on `A:\\Iraq - security.doc'", 409 strlen ( 410 "Revision #4: Author `JPratt' worked on `A:\\Iraq - security.doc'") + 1, 411 0 412 }, 413 { 414 EXTRACTOR_METATYPE_REVISION_HISTORY, 415 EXTRACTOR_METAFORMAT_UTF8, 416 "text/plain", 417 "Revision #5: Author `ablackshaw' worked on `C:\\ABlackshaw\\Iraq - security.doc'", 418 strlen ( 419 "Revision #5: Author `ablackshaw' worked on `C:\\ABlackshaw\\Iraq - security.doc'") 420 + 1, 421 0 422 }, 423 { 424 EXTRACTOR_METATYPE_REVISION_HISTORY, 425 EXTRACTOR_METAFORMAT_UTF8, 426 "text/plain", 427 "Revision #6: Author `ablackshaw' worked on `C:\\ABlackshaw\\A;Iraq - security.doc'", 428 strlen ( 429 "Revision #6: Author `ablackshaw' worked on `C:\\ABlackshaw\\A;Iraq - security.doc'") 430 + 1, 431 0 432 }, 433 { 434 EXTRACTOR_METATYPE_REVISION_HISTORY, 435 EXTRACTOR_METAFORMAT_UTF8, 436 "text/plain", 437 "Revision #7: Author `ablackshaw' worked on `A:\\Iraq - security.doc'", 438 strlen ( 439 "Revision #7: Author `ablackshaw' worked on `A:\\Iraq - security.doc'") 440 + 1, 441 0 442 }, 443 { 444 EXTRACTOR_METATYPE_REVISION_HISTORY, 445 EXTRACTOR_METAFORMAT_UTF8, 446 "text/plain", 447 "Revision #8: Author `MKhan' worked on `C:\\TEMP\\Iraq - security.doc'", 448 strlen ( 449 "Revision #8: Author `MKhan' worked on `C:\\TEMP\\Iraq - security.doc'") 450 + 1, 451 0 452 }, 453 { 454 EXTRACTOR_METATYPE_REVISION_HISTORY, 455 EXTRACTOR_METAFORMAT_UTF8, 456 "text/plain", 457 "Revision #9: Author `MKhan' worked on `C:\\WINNT\\Profiles\\mkhan\\Desktop\\Iraq.doc'", 458 strlen ( 459 "Revision #9: Author `MKhan' worked on `C:\\WINNT\\Profiles\\mkhan\\Desktop\\Iraq.doc'") 460 + 1, 461 0 462 }, 463 { 464 EXTRACTOR_METATYPE_AUTHORING_OS, 465 EXTRACTOR_METAFORMAT_UTF8, 466 "text/plain", 467 "Windows 4.0", 468 strlen ("Windows 4.0") + 1, 469 0 470 }, 471 { 0, 0, NULL, NULL, 0, -1 } 472 }; 473 #endif 474 struct SolutionData ole2_excel_sol[] = { 475 { 476 EXTRACTOR_METATYPE_CREATOR, 477 EXTRACTOR_METAFORMAT_UTF8, 478 "text/plain", 479 "JV", 480 strlen ("JV") + 1, 481 0 482 }, 483 { 484 EXTRACTOR_METATYPE_LAST_SAVED_BY, 485 EXTRACTOR_METAFORMAT_UTF8, 486 "text/plain", 487 "JV", 488 strlen ("JV") + 1, 489 0 490 }, 491 { 492 EXTRACTOR_METATYPE_CREATION_DATE, 493 EXTRACTOR_METAFORMAT_UTF8, 494 "text/plain", 495 "2002-03-20T21:26:28Z", 496 strlen ("2002-03-20T21:26:28Z") + 1, 497 0 498 }, 499 { 500 EXTRACTOR_METATYPE_MIMETYPE, 501 EXTRACTOR_METAFORMAT_UTF8, 502 "text/plain", 503 "application/vnd.ms-files", 504 strlen ("application/vnd.ms-files") + 1, 505 0 506 }, 507 { 508 EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, 509 EXTRACTOR_METAFORMAT_UTF8, 510 "text/plain", 511 "Microsoft Excel", 512 strlen ("Microsoft Excel") + 1, 513 0 514 }, 515 { 516 EXTRACTOR_METATYPE_AUTHORING_OS, 517 EXTRACTOR_METAFORMAT_UTF8, 518 "text/plain", 519 "Macintosh 3.10", 520 strlen ("Macintosh 3.10") + 1, 521 0 522 }, 523 /* The WRITEACCESS record of the File Protection Block names the 524 user that saved the file independently of the summary 525 information; here both agree, but they often do not. */ 526 { 527 EXTRACTOR_METATYPE_LAST_SAVED_BY, 528 EXTRACTOR_METAFORMAT_UTF8, 529 "text/plain", 530 "JV", 531 strlen ("JV") + 1, 532 0 533 }, 534 { 0, 0, NULL, NULL, 0, -1 } 535 }; 536 537 /* A PowerPoint presentation. The `Current User' stream records who 538 last opened the file for editing; note that it disagrees with both 539 the author and the last-saved-by of the summary information. */ 540 struct SolutionData ole2_powerpoint_sol[] = { 541 { 542 EXTRACTOR_METATYPE_LAST_SAVED_BY, 543 EXTRACTOR_METAFORMAT_UTF8, 544 "text/plain", 545 "FDA.CDER", 546 strlen ("FDA.CDER") + 1, 547 0 548 }, 549 { 550 EXTRACTOR_METATYPE_LAST_SAVED_BY, 551 EXTRACTOR_METAFORMAT_UTF8, 552 "text/plain", 553 "CDER USER", 554 strlen ("CDER USER") + 1, 555 0 556 }, 557 { 558 EXTRACTOR_METATYPE_CREATOR, 559 EXTRACTOR_METAFORMAT_UTF8, 560 "text/plain", 561 "CDER.USER", 562 strlen ("CDER.USER") + 1, 563 0 564 }, 565 { 566 EXTRACTOR_METATYPE_AUTHORING_OS, 567 EXTRACTOR_METAFORMAT_UTF8, 568 "text/plain", 569 "Windows 5.0", 570 strlen ("Windows 5.0") + 1, 571 0 572 }, 573 { 574 EXTRACTOR_METATYPE_TITLE, 575 EXTRACTOR_METAFORMAT_UTF8, 576 "text/plain", 577 " Topical Dosage Forms Classification/Nomenclature Introduction", 578 strlen (" Topical Dosage Forms Classification/Nomenclature Introduction") 579 + 1, 580 0 581 }, 582 { 583 EXTRACTOR_METATYPE_UNKNOWN_DATE, 584 EXTRACTOR_METAFORMAT_UTF8, 585 "text/plain", 586 "2003-03-07T16:12:40Z", 587 strlen ("2003-03-07T16:12:40Z") + 1, 588 0 589 }, 590 { 591 EXTRACTOR_METATYPE_CREATION_DATE, 592 EXTRACTOR_METAFORMAT_UTF8, 593 "text/plain", 594 "2003-02-19T00:20:15Z", 595 strlen ("2003-02-19T00:20:15Z") + 1, 596 0 597 }, 598 { 599 EXTRACTOR_METATYPE_EDITING_CYCLES, 600 EXTRACTOR_METAFORMAT_UTF8, 601 "text/plain", 602 "5", 603 strlen ("5") + 1, 604 0 605 }, 606 { 607 EXTRACTOR_METATYPE_WORD_COUNT, 608 EXTRACTOR_METAFORMAT_UTF8, 609 "text/plain", 610 "228", 611 strlen ("228") + 1, 612 0 613 }, 614 { 615 EXTRACTOR_METATYPE_PARAGRAPH_COUNT, 616 EXTRACTOR_METAFORMAT_UTF8, 617 "text/plain", 618 "36", 619 strlen ("36") + 1, 620 0 621 }, 622 { 623 EXTRACTOR_METATYPE_MIMETYPE, 624 EXTRACTOR_METAFORMAT_UTF8, 625 "text/plain", 626 "application/vnd.ms-files", 627 strlen ("application/vnd.ms-files") + 1, 628 0 629 }, 630 { 631 EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, 632 EXTRACTOR_METAFORMAT_UTF8, 633 "text/plain", 634 "Microsoft PowerPoint", 635 strlen ("Microsoft PowerPoint") + 1, 636 0 637 }, 638 { 639 EXTRACTOR_METATYPE_TEMPLATE, 640 EXTRACTOR_METAFORMAT_UTF8, 641 "text/plain", 642 "C:\\Program Files\\Microsoft Office\\Templates\\Blank Presentation.pot", 643 strlen ( 644 "C:\\Program Files\\Microsoft Office\\Templates\\Blank Presentation.pot") 645 + 1, 646 0 647 }, 648 { 0, 0, NULL, NULL, 0, -1 } 649 }; 650 651 struct ProblemSet ps[] = { 652 { "testdata/ole2_msword.doc", 653 ole2_msword_sol }, 654 { "testdata/ole2_starwriter40.sdw", 655 ole2_starwriter_sol }, 656 #if HAVE_ICONV 657 { "testdata/ole2_blair.doc", 658 ole2_blair_sol }, 659 #endif 660 { "testdata/ole2_excel.xls", 661 ole2_excel_sol }, 662 { "testdata/ole2_powerpoint.ppt", 663 ole2_powerpoint_sol }, 664 { NULL, NULL } 665 }; 666 return ET_main ("ole2", ps); 667 } 668 669 670 /* end of test_ole2.c */