Merge pull request #364 from unxed/master

replaced unneeded copy-paste with proper base64 encode function usage
This commit is contained in:
Cyd
2022-01-30 16:37:18 +01:00
committed by GitHub
2 changed files with 2 additions and 39 deletions
+1 -20
View File
@@ -3726,30 +3726,11 @@ static void do_osc(Terminal *term)
// ok, let us try to answer something
// base64-encode
// result in null-terminated char* out
base64_encodestate _state;
base64_init_encodestate(&_state);
char* out = malloc(reply_size*2);
int count = base64_encode_block((char*)reply, reply_size, out, &_state);
// finishing '=' characters
char* next_char = out + count;
switch (_state.step)
{
case step_B:
*next_char++ = base64_encode_value(_state.result);
*next_char++ = '=';
*next_char++ = '=';
break;
case step_C:
*next_char++ = base64_encode_value(_state.result);
*next_char++ = '=';
break;
case step_A:
break;
}
count = next_char - out;
out[count] = 0;
count += base64_encode_blockend(out + count, &_state);
// send escape seq
+1 -19
View File
@@ -5696,29 +5696,11 @@ if( (GetKeyState(VK_MENU)&0x8000) && (wParam==VK_SPACE) ) {
memcpy(kev + 14, &type, sizeof(type));
// base64-encode kev
// result in null-terminated char* out
base64_encodestate _state;
base64_init_encodestate(&_state);
char* out = malloc(15*2);
int count = base64_encode_block(kev, 15, out, &_state);
// finishing '=' characters
char* next_char = out + count;
switch (_state.step)
{
case step_B:
*next_char++ = base64_encode_value(_state.result);
*next_char++ = '=';
*next_char++ = '=';
break;
case step_C:
*next_char++ = base64_encode_value(_state.result);
*next_char++ = '=';
break;
case step_A:
break;
}
count = next_char - out;
out[count] = 0;
count += base64_encode_blockend(out + count, &_state);
// send escape seq