Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit43e9490

Browse files
committed
Rename base64 routines to avoid conflict with Solaris built-in functions.
Solaris 11.4 has built-in functions named b64_encode and b64_decode.Rename ours to something else to avoid the conflict (fortunately,ours are static so the impact is limited).One could wish for less duplication of code in this area, but thatwould be a larger patch and not very suitable for back-patching.Since this is a portability fix, we want to put it into all supportedbranches.Report and initial patch by Rainer Orth, reviewed and adjusted a bitby Michael PaquierDiscussion:https://postgr.es/m/ydd372wk28h.fsf@CeBiTec.Uni-Bielefeld.DE
1 parent38a1144 commit43e9490

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

‎contrib/pgcrypto/pgp-armor.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static const unsigned char _base64[] =
4242
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
4343

4444
staticint
45-
b64_encode(constuint8*src,unsignedlen,uint8*dst)
45+
pg_base64_encode(constuint8*src,unsignedlen,uint8*dst)
4646
{
4747
uint8*p,
4848
*lend=dst+76;
@@ -92,7 +92,7 @@ b64_encode(const uint8 *src, unsigned len, uint8 *dst)
9292

9393
/* probably should use lookup table */
9494
staticint
95-
b64_decode(constuint8*src,unsignedlen,uint8*dst)
95+
pg_base64_decode(constuint8*src,unsignedlen,uint8*dst)
9696
{
9797
constuint8*srcend=src+len,
9898
*s=src;
@@ -160,7 +160,7 @@ b64_decode(const uint8 *src, unsigned len, uint8 *dst)
160160
}
161161

162162
staticunsigned
163-
b64_enc_len(unsignedsrclen)
163+
pg_base64_enc_len(unsignedsrclen)
164164
{
165165
/*
166166
* 3 bytes will be converted to 4, linefeed after 76 chars
@@ -169,7 +169,7 @@ b64_enc_len(unsigned srclen)
169169
}
170170

171171
staticunsigned
172-
b64_dec_len(unsignedsrclen)
172+
pg_base64_dec_len(unsignedsrclen)
173173
{
174174
return (srclen*3) >>2;
175175
}
@@ -218,11 +218,11 @@ pgp_armor_encode(const uint8 *src, unsigned len, StringInfo dst,
218218
appendStringInfo(dst,"%s: %s\n",keys[n],values[n]);
219219
appendStringInfoChar(dst,'\n');
220220

221-
/* make sure we have enough room tob64_encode() */
222-
b64len=b64_enc_len(len);
221+
/* make sure we have enough room topg_base64_encode() */
222+
b64len=pg_base64_enc_len(len);
223223
enlargeStringInfo(dst, (int)b64len);
224224

225-
res=b64_encode(src,len, (uint8*)dst->data+dst->len);
225+
res=pg_base64_encode(src,len, (uint8*)dst->data+dst->len);
226226
if (res>b64len)
227227
elog(FATAL,"overflow - encode estimate too small");
228228
dst->len+=res;
@@ -358,14 +358,14 @@ pgp_armor_decode(const uint8 *src, int len, StringInfo dst)
358358
gotoout;
359359

360360
/* decode crc */
361-
if (b64_decode(p+1,4,buf)!=3)
361+
if (pg_base64_decode(p+1,4,buf)!=3)
362362
gotoout;
363363
crc= (((long)buf[0]) <<16)+ (((long)buf[1]) <<8)+ (long)buf[2];
364364

365365
/* decode data */
366-
blen= (int)b64_dec_len(len);
366+
blen= (int)pg_base64_dec_len(len);
367367
enlargeStringInfo(dst,blen);
368-
res=b64_decode(base64_start,base64_end-base64_start, (uint8*)dst->data);
368+
res=pg_base64_decode(base64_start,base64_end-base64_start, (uint8*)dst->data);
369369
if (res>blen)
370370
elog(FATAL,"overflow - decode estimate too small");
371371
if (res >=0)

‎src/backend/utils/adt/encode.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static const int8 b64lookup[128] = {
215215
};
216216

217217
staticunsigned
218-
b64_encode(constchar*src,unsignedlen,char*dst)
218+
pg_base64_encode(constchar*src,unsignedlen,char*dst)
219219
{
220220
char*p,
221221
*lend=dst+76;
@@ -262,7 +262,7 @@ b64_encode(const char *src, unsigned len, char *dst)
262262
}
263263

264264
staticunsigned
265-
b64_decode(constchar*src,unsignedlen,char*dst)
265+
pg_base64_decode(constchar*src,unsignedlen,char*dst)
266266
{
267267
constchar*srcend=src+len,
268268
*s=src;
@@ -332,14 +332,14 @@ b64_decode(const char *src, unsigned len, char *dst)
332332

333333

334334
staticunsigned
335-
b64_enc_len(constchar*src,unsignedsrclen)
335+
pg_base64_enc_len(constchar*src,unsignedsrclen)
336336
{
337337
/* 3 bytes will be converted to 4, linefeed after 76 chars */
338338
return (srclen+2)*4 /3+srclen / (76*3 /4);
339339
}
340340

341341
staticunsigned
342-
b64_dec_len(constchar*src,unsignedsrclen)
342+
pg_base64_dec_len(constchar*src,unsignedsrclen)
343343
{
344344
return (srclen*3) >>2;
345345
}
@@ -532,7 +532,7 @@ static const struct
532532
{
533533
"base64",
534534
{
535-
b64_enc_len,b64_dec_len,b64_encode,b64_decode
535+
pg_base64_enc_len,pg_base64_dec_len,pg_base64_encode,pg_base64_decode
536536
}
537537
},
538538
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp