openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libpam/1.3.1-r0/Linux-PAM-1.3.1/libpam/pam_handlers.c
static int _pam_assemble_line(FILE* f, char* buffer, int buf_len)
{
    char* p = buffer;
    char* endp = buffer + buf_len;
    char *s, *os;
    int used = 0;

    /* loop broken with a 'break' when a non-'\\n' ended line is read */

    D(("called."));
    for (;;)
    {
        if (p >= endp)
        {
            /* Overflow */
            D(("_pam_assemble_line: overflow"));
            return -1;
        }
        if (fgets(p, endp - p, f) == NULL)
        {
            if (used)
            {
                /* Incomplete read */
                return -1;
            }
            else
            {
                /* EOF */
                return 0;
            }
        }

        /* skip leading spaces --- line may be blank */

        s = p + strspn(p, " \n\t");
        if (*s && (*s != '#'))
        {
            os = s;

            /*
             * we are only interested in characters before the first '#'
             * character
             */

            while (*s && *s != '#')
                ++s;
            if (*s == '#')
            {
                *s = '\0';
                used += strlen(os);
                break; /* the line has been read */
            }

            s = os;

            /*
             * Check for backslash by scanning back from the end of
             * the entered line, the '\n' has been included since
             * normally a line is terminated with this
             * character. fgets() should only return one though!
             */

            s += strlen(s);
            while (s > os && ((*--s == ' ') || (*s == '\t') || (*s == '\n')))
                ;

            /* check if it ends with a backslash */
            if (*s == '\\')
            {
                *s++ = ' '; /* replace backslash with ' ' */
                *s = '\0';  /* truncate the line here */
                used += strlen(os);
                p = s; /* there is more ... */
            }
            else
            {
                /* End of the line! */
                used += strlen(os);
                break; /* this is the complete line */
            }
        }
        else
        {
            /* Nothing in this line */
            /* Don't move p         */
        }
    }

    return used;
}
/*
 * This is where we read a line of the PAM config file. The line may be
 * preceeded by lines of comments and also extended with "\\\n"
 */
This is where we read a line of the PAM config file. The line may be
preceeded by lines of comments and also extended with "\\\n"
This is where we read a line of the PAM config file . The line may be preceeded by lines of comments and also extended with " \\\ n "
static int _pam_assemble_line(FILE* f, char* buffer, int buf_len)
{
    char* p = buffer;
    char* endp = buffer + buf_len;
    char *s, *os;
    int used = 0;
    D(("called."));
    for (;;)
    {
        if (p >= endp)
        {
            D(("_pam_assemble_line: overflow"));
            return -1;
        }
        if (fgets(p, endp - p, f) == NULL)
        {
            if (used)
            {
                return -1;
            }
            else
            {
                return 0;
            }
        }
        s = p + strspn(p, " \n\t");
        if (*s && (*s != '#'))
        {
            os = s;
            while (*s && *s != '#')
                ++s;
            if (*s == '#')
            {
                *s = '\0';
                used += strlen(os);
                break; 
            }
            s = os;
            s += strlen(s);
            while (s > os && ((*--s == ' ') || (*s == '\t') || (*s == '\n')))
                ;
            if (*s == '\\')
            {
                *s++ = ' '; 
                *s = '\0';  
                used += strlen(os);
                p = s; 
            }
            else
            {
                used += strlen(os);
                break; 
            }
        }
        else
        {
        }
    }
    return used;
}
static int _pam_assemble_line ( FILE * f , char * buffer , int buf_len ) { char * p = buffer ; char * endp = buffer + buf_len ; char * s , * os ; int used = 0 ; D ( ( " " ) ) ; for ( ; ; ) { if ( p >= endp ) { D ( ( " " ) ) ; return -1 ; } if ( fgets ( p , endp - p , f ) == NULL ) { if ( used ) { return -1 ; } else { return 0 ; } } s = p + strspn ( p , " \n \t " ) ; if ( * s && ( * s != ' ' ) ) { os = s ; while ( * s && * s != ' ' ) ++ s ; if ( * s == ' ' ) { * s = ' \0 ' ; used += strlen ( os ) ; break ; } s = os ; s += strlen ( s ) ; while ( s > os && ( ( * -- s == ' ' ) || ( * s == ' \t ' ) || ( * s == ' \n ' ) ) ) ; if ( * s == ' \\ ' ) { * s ++ = ' ' ; * s = ' \0 ' ; used += strlen ( os ) ; p = s ; } else { used += strlen ( os ) ; break ; } } else { } } return used ; }
This is where we read a line of the PAM config file.
This is where we read a line of the PAM config file .
/* loop broken with a 'break' when a non-'\\n' ended line is read */ /* Overflow */ /* Incomplete read */ /* EOF */ /* skip leading spaces --- line may be blank */ /*
             * we are only interested in characters before the first '#'
             * character
             */ /* the line has been read */ /*
             * Check for backslash by scanning back from the end of
             * the entered line, the '\n' has been included since
             * normally a line is terminated with this
             * character. fgets() should only return one though!
             */ /* check if it ends with a backslash */ /* replace backslash with ' ' */ /* truncate the line here */ /* there is more ... */ /* End of the line! */ /* this is the complete line */ /* Nothing in this line */ /* Don't move p         */