openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/shadow/4.6-r0/shadow-4.6/lib/fields.c
void change_field(char* buf, size_t maxsize, const char* prompt)
{
    char newf[200];
    char* cp;

    if (maxsize > sizeof(newf))
    {
        maxsize = sizeof(newf);
    }

    printf("\t%s [%s]: ", prompt, buf);
    (void)fflush(stdout);
    if (fgets(newf, (int)maxsize, stdin) != newf)
    {
        return;
    }

    cp = strchr(newf, '\n');
    if (NULL == cp)
    {
        return;
    }
    *cp = '\0';

    if ('\0' != newf[0])
    {
        /*
         * Remove leading and trailing whitespace.  This also
         * makes it possible to change the field to empty, by
         * entering a space.  --marekm
         */

        while (--cp >= newf && isspace(*cp))
            ;
        cp++;
        *cp = '\0';

        cp = newf;
        while (('\0' != *cp) && isspace(*cp))
        {
            cp++;
        }

        strncpy(buf, cp, maxsize - 1);
        buf[maxsize - 1] = '\0';
    }
}
/*
 * change_field - change a single field if a new value is given.
 *
 * prompt the user with the name of the field being changed and the
 * current value.
 */
change a single field if a new value is given.
prompt the user with the name of the field being changed and the
current value.
change a single field if a new value is given . prompt the user with the name of the field being changed and the current value .
void change_field(char* buf, size_t maxsize, const char* prompt)
{
    char newf[200];
    char* cp;
    if (maxsize > sizeof(newf))
    {
        maxsize = sizeof(newf);
    }
    printf("\t%s [%s]: ", prompt, buf);
    (void)fflush(stdout);
    if (fgets(newf, (int)maxsize, stdin) != newf)
    {
        return;
    }
    cp = strchr(newf, '\n');
    if (NULL == cp)
    {
        return;
    }
    *cp = '\0';
    if ('\0' != newf[0])
    {
        while (--cp >= newf && isspace(*cp))
            ;
        cp++;
        *cp = '\0';
        cp = newf;
        while (('\0' != *cp) && isspace(*cp))
        {
            cp++;
        }
        strncpy(buf, cp, maxsize - 1);
        buf[maxsize - 1] = '\0';
    }
}
void change_field ( char * buf , size_t maxsize , const char * prompt ) { char newf [ 200 ] ; char * cp ; if ( maxsize > sizeof ( newf ) ) { maxsize = sizeof ( newf ) ; } printf ( " \t " , prompt , buf ) ; ( void ) fflush ( stdout ) ; if ( fgets ( newf , ( int ) maxsize , stdin ) != newf ) { return ; } cp = strchr ( newf , ' \n ' ) ; if ( NULL == cp ) { return ; } * cp = ' \0 ' ; if ( ' \0 ' != newf [ 0 ] ) { while ( -- cp >= newf && isspace ( * cp ) ) ; cp ++ ; * cp = ' \0 ' ; cp = newf ; while ( ( ' \0 ' != * cp ) && isspace ( * cp ) ) { cp ++ ; } strncpy ( buf , cp , maxsize - 1 ) ; buf [ maxsize - 1 ] = ' \0 ' ; } }
change_field - change a single field if a new value is given.
change_field - change a single field if a new value is given .
/*
         * Remove leading and trailing whitespace.  This also
         * makes it possible to change the field to empty, by
         * entering a space.  --marekm
         */