MCPcopy Create free account
hub / github.com/RsyncProject/rsync / Parse

Function Parse

params.c:489–560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

487}
488
489static int Parse( FILE *InFile,
490 BOOL (*sfunc)(char *),
491 BOOL (*pfunc)(char *, char *) )
492 /* ------------------------------------------------------------------------ **
493 * Scan & parse the input.
494 *
495 * Input: InFile - Input source.
496 * sfunc - Function to be called when a section name is scanned.
497 * See Section().
498 * pfunc - Function to be called when a parameter is scanned.
499 * See Parameter().
500 *
501 * Output: 1 if the file was successfully scanned, 2 if the file was
502 * scanned until a section header with no section function, else 0.
503 *
504 * Notes: The input can be viewed in terms of 'lines'. There are four
505 * types of lines:
506 * Blank - May contain whitespace, otherwise empty.
507 * Comment - First non-whitespace character is a ';' or '#'.
508 * The remainder of the line is ignored.
509 * Section - First non-whitespace character is a '['.
510 * Parameter - The default case.
511 *
512 * ------------------------------------------------------------------------ **
513 */
514 {
515 int c;
516
517 c = EatWhitespace( InFile );
518 while( (EOF != c) && (c > 0) )
519 {
520 switch( c )
521 {
522 case '\n': /* Blank line. */
523 c = EatWhitespace( InFile );
524 break;
525
526 case ';': /* Comment line. */
527 case '#':
528 c = EatComment( InFile );
529 break;
530
531 case '[': /* Section Header. */
532 if (!sfunc)
533 return 2;
534 if( !Section( InFile, sfunc ) )
535 return 0;
536 c = EatWhitespace( InFile );
537 break;
538
539 case '\\': /* Bogus backslash. */
540 c = EatWhitespace( InFile );
541 break;
542
543 case '&': /* Handle directives */
544 the_sfunc = sfunc;
545 the_pfunc = pfunc;
546 c = Parameter( InFile, parse_directives, c );

Callers 1

pm_processFunction · 0.85

Calls 4

EatWhitespaceFunction · 0.85
EatCommentFunction · 0.85
SectionFunction · 0.85
ParameterFunction · 0.85

Tested by

no test coverage detected