1 /* -*- c-basic-offset: 8 -*- 2 rdesktop: A Remote Desktop Protocol client. 3 4 Copyright 2017-2019 Henrik Andersson <hean01@cendio.se> for Cendio AB 5 6 This program is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef _utils_h 21 #define _utils_h 22 23 #include <gnutls/gnutls.h> 24 #include <gnutls/x509.h> 25 26 #include "types.h" 27 28 uint32 utils_djb2_hash(const char *str); 29 char *utils_string_escape(const char *str); 30 char *utils_string_unescape(const char *str); 31 int utils_locale_to_utf8(const char *src, size_t is, char *dest, size_t os); 32 int utils_mkdir_safe(const char *path, int mask); 33 int utils_mkdir_p(const char *path, int mask); 34 void utils_calculate_dpi_scale_factors(uint32 width, uint32 height, uint32 dpi, 35 uint32 * physwidth, uint32 * physheight, 36 uint32 * desktopscale, uint32 * devicescale); 37 void utils_apply_session_size_limitations(uint32 * width, uint32 * height); 38 39 const char* util_dialog_choice(const char *message, ...); 40 41 int utils_cert_handle_exception(gnutls_session_t session, unsigned int status, 42 RD_BOOL hostname_mismatch, const char *hostname); 43 44 typedef enum log_level_t 45 { 46 Debug = 0, 47 Verbose, 48 Warning, 49 Error, 50 Notice /* special message level for end user messages with prefix */ 51 } log_level_t; 52 53 typedef enum log_subject_t 54 { 55 GUI = 0, 56 Keyboard, 57 Clipboard, 58 Sound, 59 Protocol, 60 Graphics, 61 Core, 62 SmartCard, 63 Disk 64 } log_subject_t; 65 66 void logger(log_subject_t c, log_level_t lvl, char *format, ...); 67 void logger_set_verbose(int verbose); 68 void logger_set_subjects(char *subjects); 69 70 #endif /* _utils_h */ 71