FreeBSD/usr.sbin/ctm/ctm/ctm_input.c
/*---------------------------------------------------------------------------*/
/* get next field, check that the terminating whitespace is what we expect */
get next field, check that the terminating whitespace is what we expect
get next field check that the terminating whitespace is what we expect
u_char *
Ffield(FILE *fd, MD5_CTX *ctx,u_char term)
{
    static u_char buf[BUFSIZ];
    int i,l;
    for(l=0;;) {
	if((i=getc(fd)) == EOF) {
	    Fatal("Truncated patch.");
	    return 0;
	}
	buf[l++] = i;
	if(isspace(i))
	    break;
	if(l >= sizeof buf) {
	    Fatal("Corrupt patch.");
	    printf("Token is too long.\n");
	    return 0;
	}
    }
    buf[l] = '\0';
    MD5Update(ctx,buf,l);
    if(buf[l-1] != term) {
        Fatal("Corrupt patch.");
	fprintf(stderr,"Expected \"%s\" but didn't find it {%02x}.\n",
	    term == '\n' ? "\\n" : " ",buf[l-1]);
	if(Verbose > 4)
	    fprintf(stderr,"{%s}\n",buf);
	return 0;
    }
    buf[--l] = '\0';
    if(Verbose > 4)
        fprintf(stderr,"<%s>\n",buf);
    return buf;
}
u_char * Ffield ( FILE * fd , MD5_CTX * ctx , u_char term ) { static u_char buf [ BUFSIZ ] ; int i , l ; for ( l = 0 ; ; ) { if ( ( i = getc ( fd ) ) == EOF ) { Fatal ( " " ) ; return 0 ; } buf [ l ++ ] = i ; if ( isspace ( i ) ) break ; if ( l >= sizeof buf ) { Fatal ( " " ) ; printf ( " \n " ) ; return 0 ; } } buf [ l ] = ' \0 ' ; MD5Update ( ctx , buf , l ) ; if ( buf [ l - 1 ] != term ) { Fatal ( " " ) ; fprintf ( stderr , " \" \" \n " , term == ' \n ' ? " \\ " : " " , buf [ l - 1 ] ) ; if ( Verbose > 4 ) fprintf ( stderr , " \n " , buf ) ; return 0 ; } buf [ -- l ] = ' \0 ' ; if ( Verbose > 4 ) fprintf ( stderr , " \n " , buf ) ; return buf ; }
get next field, check that the terminating whitespace is what we expect
get next field check that the terminating whitespace is what we expect