openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/text-utils/more.c
static FILE* checkf(struct more_control* ctl, char* fs, int* clearfirst)
{
    struct stat st;
    FILE* f;
    int c;

    if (stat(fs, &st) == -1)
    {
        fflush(stdout);
        if (ctl->clear_line_ends)
            putp(ctl->erase_line);
        warn(_("stat of %s failed"), fs);
        return NULL;
    }
    if ((st.st_mode & S_IFMT) == S_IFDIR)
    {
        printf(_("\n*** %s: directory ***\n\n"), fs);
        return NULL;
    }
    ctl->current_line = 0;
    ctl->file_position = 0;
    if ((f = fopen(fs, "r")) == NULL)
    {
        fflush(stdout);
        warn(_("cannot open %s"), fs);
        return NULL;
    }
    if (check_magic(f, fs))
    {
        fclose(f);
        return NULL;
    }
    fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
    c = more_getc(ctl, f);
    *clearfirst = (c == '\f');
    more_ungetc(ctl, c, f);
    if ((ctl->file_size = st.st_size) == 0)
        ctl->file_size = LONG_MAX;
    return f;
}
/* Check whether the file named by fs is an ASCII file which the user may
 * access.  If it is, return the opened file.  Otherwise return NULL. */
Check whether the file named by fs is an ASCII file which the user may
access.  If it is, return the opened file.  Otherwise return NULL.
Check whether the file named by fs is an ASCII file which the user may access . If it is return the opened file . Otherwise return NULL .
static FILE* checkf(struct more_control* ctl, char* fs, int* clearfirst)
{
    struct stat st;
    FILE* f;
    int c;
    if (stat(fs, &st) == -1)
    {
        fflush(stdout);
        if (ctl->clear_line_ends)
            putp(ctl->erase_line);
        warn(_("stat of %s failed"), fs);
        return NULL;
    }
    if ((st.st_mode & S_IFMT) == S_IFDIR)
    {
        printf(_("\n*** %s: directory ***\n\n"), fs);
        return NULL;
    }
    ctl->current_line = 0;
    ctl->file_position = 0;
    if ((f = fopen(fs, "r")) == NULL)
    {
        fflush(stdout);
        warn(_("cannot open %s"), fs);
        return NULL;
    }
    if (check_magic(f, fs))
    {
        fclose(f);
        return NULL;
    }
    fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
    c = more_getc(ctl, f);
    *clearfirst = (c == '\f');
    more_ungetc(ctl, c, f);
    if ((ctl->file_size = st.st_size) == 0)
        ctl->file_size = LONG_MAX;
    return f;
}
static FILE * checkf ( struct more_control * ctl , char * fs , int * clearfirst ) { struct stat st ; FILE * f ; int c ; if ( stat ( fs , & st ) == -1 ) { fflush ( stdout ) ; if ( ctl -> clear_line_ends ) putp ( ctl -> erase_line ) ; warn ( _ ( " " ) , fs ) ; return NULL ; } if ( ( st . st_mode & S_IFMT ) == S_IFDIR ) { printf ( _ ( " \n \n \n " ) , fs ) ; return NULL ; } ctl -> current_line = 0 ; ctl -> file_position = 0 ; if ( ( f = fopen ( fs , " " ) ) == NULL ) { fflush ( stdout ) ; warn ( _ ( " " ) , fs ) ; return NULL ; } if ( check_magic ( f , fs ) ) { fclose ( f ) ; return NULL ; } fcntl ( fileno ( f ) , F_SETFD , FD_CLOEXEC ) ; c = more_getc ( ctl , f ) ; * clearfirst = ( c == ' \f ' ) ; more_ungetc ( ctl , c , f ) ; if ( ( ctl -> file_size = st . st_size ) == 0 ) ctl -> file_size = LONG_MAX ; return f ; }
Check whether the file named by fs is an ASCII file which the user may
 access.
Check whether the file named by fs is an ASCII file which the user may access .