| 591 | } /* OpenConfFile */ |
| 592 | |
| 593 | int pm_process( char *FileName, |
| 594 | BOOL (*sfunc)(char *), |
| 595 | BOOL (*pfunc)(char *, char *) ) |
| 596 | /* ------------------------------------------------------------------------ ** |
| 597 | * Process the named parameter file. |
| 598 | * |
| 599 | * Input: FileName - The pathname of the parameter file to be opened. |
| 600 | * sfunc - A pointer to a function that will be called when |
| 601 | * a section name is discovered. |
| 602 | * pfunc - A pointer to a function that will be called when |
| 603 | * a parameter name and value are discovered. |
| 604 | * |
| 605 | * Output: 1 if the file was successfully parsed, 2 if parsing ended at a |
| 606 | * section header w/o a section function, else 0. |
| 607 | * |
| 608 | * ------------------------------------------------------------------------ ** |
| 609 | */ |
| 610 | { |
| 611 | int result; |
| 612 | FILE *InFile; |
| 613 | char *func = "params.c:pm_process() -"; |
| 614 | |
| 615 | InFile = OpenConfFile( FileName ); /* Open the config file. */ |
| 616 | if( NULL == InFile ) |
| 617 | return( False ); |
| 618 | |
| 619 | if( NULL != bufr ) /* If we already have a buffer */ |
| 620 | result = Parse( InFile, sfunc, pfunc ); /* (recursive call), then just */ |
| 621 | /* use it. */ |
| 622 | |
| 623 | else /* If we don't have a buffer */ |
| 624 | { /* allocate one, then parse, */ |
| 625 | bSize = BUFR_INC; /* then free. */ |
| 626 | bufr = new_array( char, bSize ); |
| 627 | result = Parse( InFile, sfunc, pfunc ); |
| 628 | free( bufr ); |
| 629 | bufr = NULL; |
| 630 | bSize = 0; |
| 631 | } |
| 632 | |
| 633 | fclose(InFile); |
| 634 | |
| 635 | if( !result ) /* Generic failure. */ |
| 636 | { |
| 637 | rprintf(FLOG, "%s Failed. Error returned from params.c:parse().\n", func); |
| 638 | return 0; |
| 639 | } |
| 640 | |
| 641 | return result; |
| 642 | } /* pm_process */ |
| 643 | |
| 644 | /* -------------------------------------------------------------------------- */ |
| 645 |
no test coverage detected