base32.c revision 917bf5a50ae184ad61d48442e7f256ca286f688a
// Base32 implementation
//
// Copyright 2010 Google Inc.
// Author: Markus Gutschke
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
int
{
int buffer = 0;
int bitsLeft = 0;
int count = 0;
continue;
buffer <<= 5;
// Deal with commonly mistyped characters
if (ch == '0')
ch = 'O';
else if (ch == '1')
ch = 'L';
else if (ch == '8')
ch = 'B';
// Look up one base32 digit
else
return -1;
bitsLeft += 5;
if (bitsLeft >= 8) {
bitsLeft -= 8;
}
}
return count;
}
int
{
int count = 0;
return -1;
if (length > 0) {
int next = 1;
int bitsLeft = 8;
if (bitsLeft < 5) {
buffer <<= 8;
bitsLeft += 8;
} else {
}
}
bitsLeft -= 5;
}
}
return count;
}