| 477 | // |
| 478 | |
| 479 | act* PAR_database(bool sql, const TEXT* base_directory) |
| 480 | { |
| 481 | if (gpreGlob.token_global.tok_length >= NAME_SIZE) |
| 482 | PAR_error("Database alias too long"); |
| 483 | |
| 484 | TEXT s[MAXPATHLEN << 1]; |
| 485 | |
| 486 | act* action = MSC_action(0, ACT_database); |
| 487 | gpre_dbb* db = (gpre_dbb*) MSC_alloc(DBB_LEN); |
| 488 | |
| 489 | // Get handle name token, make symbol for handle, and |
| 490 | // insert symbol into hash table |
| 491 | |
| 492 | gpre_sym* symbol = PAR_symbol(SYM_dummy); |
| 493 | db->dbb_name = symbol; |
| 494 | symbol->sym_type = SYM_database; |
| 495 | symbol->sym_object = (gpre_ctx*) db; |
| 496 | |
| 497 | if (!MSC_match(KW_EQUALS)) |
| 498 | CPR_s_error("\"=\" in database declaration"); |
| 499 | |
| 500 | if (MSC_match(KW_STATIC)) |
| 501 | db->dbb_scope = DBB_STATIC; |
| 502 | else if (MSC_match(KW_EXTERN)) |
| 503 | db->dbb_scope = DBB_EXTERN; |
| 504 | |
| 505 | MSC_match(KW_COMPILETIME); |
| 506 | |
| 507 | // parse the compiletime options |
| 508 | TEXT* string; |
| 509 | |
| 510 | for (;;) |
| 511 | { |
| 512 | if (MSC_match(KW_FILENAME) && !isQuoted(gpreGlob.token_global.tok_type)) |
| 513 | CPR_s_error("quoted file name"); |
| 514 | |
| 515 | tok& token = gpreGlob.token_global; |
| 516 | |
| 517 | if (isQuoted(token.tok_type)) |
| 518 | { |
| 519 | if (base_directory) |
| 520 | { |
| 521 | db->dbb_filename = string = |
| 522 | (TEXT*) MSC_alloc(token.tok_length + static_cast<int>(strlen(base_directory)) + 1); |
| 523 | MSC_copy_cat(base_directory, static_cast<int>(strlen(base_directory)), |
| 524 | token.tok_string, token.tok_length, string); |
| 525 | } |
| 526 | else |
| 527 | { |
| 528 | db->dbb_filename = string = (TEXT *) MSC_alloc(token.tok_length + 1); |
| 529 | MSC_copy(token.tok_string, token.tok_length, string); |
| 530 | } |
| 531 | token.tok_length += 2; |
| 532 | } |
| 533 | else if (MSC_match(KW_PASSWORD)) |
| 534 | { |
| 535 | if (!isQuoted(token.tok_type)) |
| 536 | CPR_s_error("quoted password"); |
no test coverage detected