MCPcopy Create free account
hub / github.com/OpenPrinting/cups / httpEncode64_2

Function httpEncode64_2

cups/http-support.c:690–774  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

688 */
689
690char * /* O - Encoded string */
691httpEncode64_2(char *out, /* I - String to write to */
692 int outlen, /* I - Maximum size of output string */
693 const char *in, /* I - String to read from */
694 int inlen) /* I - Size of input string */
695{
696 char *outptr, /* Output pointer */
697 *outend; /* End of output buffer */
698 static const char base64[] = /* Base64 characters... */
699 {
700 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
701 "abcdefghijklmnopqrstuvwxyz"
702 "0123456789"
703 "+/"
704 };
705
706
707 /*
708 * Range check input...
709 */
710
711 if (!out || outlen < 1 || !in)
712 return (NULL);
713
714 /*
715 * Convert bytes to base-64...
716 */
717
718 for (outptr = out, outend = out + outlen - 1; inlen > 0; in ++, inlen --)
719 {
720 /*
721 * Encode the up to 3 characters as 4 Base64 numbers...
722 */
723
724 if (outptr < outend)
725 *outptr ++ = base64[(in[0] & 255) >> 2];
726
727 if (outptr < outend)
728 {
729 if (inlen > 1)
730 *outptr ++ = base64[(((in[0] & 255) << 4) | ((in[1] & 255) >> 4)) & 63];
731 else
732 *outptr ++ = base64[(in[0] << 4) & 63];
733 }
734
735 in ++;
736 inlen --;
737 if (inlen <= 0)
738 {
739 if (outptr < outend)
740 *outptr ++ = '=';
741 if (outptr < outend)
742 *outptr ++ = '=';
743 break;
744 }
745
746 if (outptr < outend)
747 {

Callers 11

print_attrFunction · 0.85
cupsd_start_notifierFunction · 0.85
save_auth_infoFunction · 0.85
ppdxWriteDataFunction · 0.85
httpSaveCredentialsFunction · 0.85
mainFunction · 0.85
cupsDoAuthenticationFunction · 0.85
ifFunction · 0.85
cups_local_authFunction · 0.85
httpSaveCredentialsFunction · 0.85
httpEncode64Function · 0.85

Calls

no outgoing calls

Tested by 1

mainFunction · 0.68