| 77 | // |
| 78 | |
| 79 | const char * // O - Formatted string |
| 80 | cupsHashString( |
| 81 | const unsigned char *hash, // I - Hash |
| 82 | size_t hashsize, // I - Size of hash |
| 83 | char *buffer, // I - String buffer |
| 84 | size_t bufsize) // I - Size of string buffer |
| 85 | { |
| 86 | char *bufptr = buffer; // Pointer into buffer |
| 87 | static const char *hex = "0123456789abcdef"; |
| 88 | // Hex characters (lowercase!) |
| 89 | |
| 90 | |
| 91 | // Range check input... |
| 92 | if (!hash || hashsize < 1 || !buffer || bufsize < (2 * hashsize + 1)) |
| 93 | { |
| 94 | if (buffer) |
| 95 | *buffer = '\0'; |
| 96 | return (NULL); |
| 97 | } |
| 98 | |
| 99 | // Loop until we've converted the whole hash... |
| 100 | while (hashsize > 0) |
| 101 | { |
| 102 | *bufptr++ = hex[*hash >> 4]; |
| 103 | *bufptr++ = hex[*hash & 15]; |
| 104 | |
| 105 | hash ++; |
| 106 | hashsize --; |
| 107 | } |
| 108 | |
| 109 | *bufptr = '\0'; |
| 110 | |
| 111 | return (buffer); |
| 112 | } |
| 113 | |
| 114 | |
| 115 | // |
no outgoing calls
no test coverage detected