base64: Minor coding standard and style updates
This commit is contained in:
parent
0e16de870f
commit
5dc43b975b
18
lib/base64.c
18
lib/base64.c
@ -187,11 +187,11 @@ static CURLcode base64_encode(const char *table64,
|
|||||||
*outptr = NULL;
|
*outptr = NULL;
|
||||||
*outlen = 0;
|
*outlen = 0;
|
||||||
|
|
||||||
if(0 == insize)
|
if(!insize)
|
||||||
insize = strlen(indata);
|
insize = strlen(indata);
|
||||||
|
|
||||||
base64data = output = malloc(insize*4/3+4);
|
base64data = output = malloc(insize * 4 / 3 + 4);
|
||||||
if(NULL == output)
|
if(!output)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -233,12 +233,14 @@ static CURLcode base64_encode(const char *table64,
|
|||||||
table64[obuf[0]],
|
table64[obuf[0]],
|
||||||
table64[obuf[1]]);
|
table64[obuf[1]]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* two bytes read */
|
case 2: /* two bytes read */
|
||||||
snprintf(output, 5, "%c%c%c=",
|
snprintf(output, 5, "%c%c%c=",
|
||||||
table64[obuf[0]],
|
table64[obuf[0]],
|
||||||
table64[obuf[1]],
|
table64[obuf[1]],
|
||||||
table64[obuf[2]]);
|
table64[obuf[2]]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf(output, 5, "%c%c%c%c",
|
snprintf(output, 5, "%c%c%c%c",
|
||||||
table64[obuf[0]],
|
table64[obuf[0]],
|
||||||
@ -249,12 +251,17 @@ static CURLcode base64_encode(const char *table64,
|
|||||||
}
|
}
|
||||||
output += 4;
|
output += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Zero terminate */
|
||||||
*output = '\0';
|
*output = '\0';
|
||||||
*outptr = base64data; /* return pointer to new data, allocated memory */
|
|
||||||
|
/* Return the pointer to the new data (allocated memory) */
|
||||||
|
*outptr = base64data;
|
||||||
|
|
||||||
free(convbuf);
|
free(convbuf);
|
||||||
|
|
||||||
*outlen = strlen(base64data); /* return the length of the new data */
|
/* Return the length of the new data */
|
||||||
|
*outlen = strlen(base64data);
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
@ -306,4 +313,3 @@ CURLcode Curl_base64url_encode(struct SessionHandle *data,
|
|||||||
{
|
{
|
||||||
return base64_encode(base64url, data, inputbuff, insize, outptr, outlen);
|
return base64_encode(base64url, data, inputbuff, insize, outptr, outlen);
|
||||||
}
|
}
|
||||||
/* ---- End of Base64 Encoding ---- */
|
|
||||||
|
Loading…
Reference in New Issue
Block a user