~ubuntu-branches/ubuntu/hardy/gnupg/hardy-updates

« back to all changes in this revision

Viewing changes to util/miscutil.c

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2006-12-12 15:56:56 UTC
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20061212155656-kk00wp4x0uq4tm1y
Tags: upstream-1.4.6
ImportĀ upstreamĀ versionĀ 1.4.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
453
453
 
454
454
  return 0;
455
455
}
456
 
 
457
 
int
458
 
hextobyte( const char *s )
459
 
{
460
 
    int c;
461
 
 
462
 
    if( *s >= '0' && *s <= '9' )
463
 
        c = 16 * (*s - '0');
464
 
    else if( *s >= 'A' && *s <= 'F' )
465
 
        c = 16 * (10 + *s - 'A');
466
 
    else if( *s >= 'a' && *s <= 'f' )
467
 
        c = 16 * (10 + *s - 'a');
468
 
    else
469
 
        return -1;
470
 
    s++;
471
 
    if( *s >= '0' && *s <= '9' )
472
 
        c += *s - '0';
473
 
    else if( *s >= 'A' && *s <= 'F' )
474
 
        c += 10 + *s - 'A';
475
 
    else if( *s >= 'a' && *s <= 'f' )
476
 
        c += 10 + *s - 'a';
477
 
    else
478
 
        return -1;
479
 
    return c;
480
 
}