75 lines
2.2 KiB
C
75 lines
2.2 KiB
C
/*
|
|
* 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.
|
|
*/
|
|
|
|
|
|
#ifndef _GUAC_TERMINAL_COMMON_H
|
|
#define _GUAC_TERMINAL_COMMON_H
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdbool.h>
|
|
|
|
/**
|
|
* Returns the closest value to the value given that is also
|
|
* within the given range.
|
|
*/
|
|
int guac_terminal_fit_to_range(int value, int min, int max);
|
|
|
|
/**
|
|
* Encodes the given codepoint as UTF-8, storing the result within the
|
|
* provided buffer, and returning the number of bytes stored.
|
|
*/
|
|
int guac_terminal_encode_utf8(int codepoint, char* utf8);
|
|
|
|
/**
|
|
* Returns whether a codepoint has a corresponding glyph, or is rendered
|
|
* as a blank space.
|
|
*/
|
|
bool guac_terminal_has_glyph(int codepoint);
|
|
|
|
/**
|
|
* Similar to write, but automatically retries the write operation until
|
|
* an error occurs.
|
|
*/
|
|
int guac_terminal_write_all(int fd, const char* buffer, int size);
|
|
|
|
/**
|
|
* Similar to read, but automatically retries the read until an error occurs,
|
|
* filling all available space within the buffer. Unless it is known that the
|
|
* given amount of space is available on the file descriptor, there is a good
|
|
* chance this function will block.
|
|
*
|
|
* @param fd
|
|
* The file descriptor to read data from.
|
|
*
|
|
* @param buffer
|
|
* The buffer to store data within.
|
|
*
|
|
* @param size
|
|
* The number of bytes available within the buffer.
|
|
*
|
|
* @return
|
|
* The number of bytes read if successful, or a negative value if an error
|
|
* occurs.
|
|
*/
|
|
int guac_terminal_fill_buffer(int fd, char* buffer, int size);
|
|
|
|
#endif
|
|
|