2018-02-23 00:56:05 +00:00
|
|
|
/*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
|
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
|
|
* to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "ttymode.h"
|
|
|
|
|
2018-03-08 14:32:19 +00:00
|
|
|
#include <stdarg.h>
|
2018-04-02 13:10:11 +00:00
|
|
|
#include <stdbool.h>
|
2018-02-25 13:41:14 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2018-04-02 13:22:51 +00:00
|
|
|
int guac_ssh_ttymodes_init(char opcode_array[], ...) {
|
2018-02-25 13:41:14 +00:00
|
|
|
|
2018-03-08 14:32:19 +00:00
|
|
|
/* Initialize the variable argument list. */
|
|
|
|
va_list args;
|
2018-04-02 13:22:51 +00:00
|
|
|
va_start(args, opcode_array);
|
2018-02-25 13:41:14 +00:00
|
|
|
|
2018-04-02 13:10:11 +00:00
|
|
|
/* Initialize array pointer and byte counter. */
|
2018-03-24 19:50:11 +00:00
|
|
|
char *current = opcode_array;
|
2018-04-02 13:10:11 +00:00
|
|
|
|
|
|
|
/* Loop through variable argument list. */
|
|
|
|
while (true) {
|
|
|
|
|
|
|
|
/* Next argument should be an opcode. */
|
|
|
|
char opcode = (char)va_arg(args, int);
|
|
|
|
*(current++) = opcode;
|
2018-02-25 13:41:14 +00:00
|
|
|
|
2018-04-02 13:10:11 +00:00
|
|
|
/* If it's the end opcode, we're done. */
|
|
|
|
if (opcode == GUAC_SSH_TTY_OP_END)
|
|
|
|
break;
|
2018-02-25 13:41:14 +00:00
|
|
|
|
2018-04-02 13:10:11 +00:00
|
|
|
/* Next argument should be 4-byte value. */
|
|
|
|
uint32_t value = va_arg(args, uint32_t);
|
|
|
|
*(current++) = (value >> 24) & 0xFF;
|
|
|
|
*(current++) = (value >> 16) & 0xFF;
|
|
|
|
*(current++) = (value >> 8) & 0xFF;
|
|
|
|
*(current++) = value & 0xFF;
|
2018-03-08 14:32:19 +00:00
|
|
|
}
|
2018-02-27 14:13:01 +00:00
|
|
|
|
2018-04-02 13:10:11 +00:00
|
|
|
/* We're done processing arguments. */
|
|
|
|
va_end(args);
|
2018-02-25 13:41:14 +00:00
|
|
|
|
2018-04-02 19:04:03 +00:00
|
|
|
return current - opcode_array;
|
2018-02-25 13:41:14 +00:00
|
|
|
|
|
|
|
}
|