| 1 | /** |
| 2 | * WinPR: Windows Portable Runtime |
| 3 | * Clipboard Functions |
| 4 | * |
| 5 | * Copyright 2014 Marc-Andre Moreau <[email protected]> |
| 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | */ |
| 19 | |
| 20 | #include <winpr/config.h>cxx . . $ `<file>/build/winpr/include/winpr/config.h`/ |
| 21 | |
| 22 | #include <winpr/crt.h>cxx . . $ `<file>/winpr/include/winpr/crt.h`/ |
| 23 | #include <winpr/collections.h>cxx . . $ `<file>/winpr/include/winpr/collections.h`/ |
| 24 | #include <winpr/wlog.h>cxx . . $ `<file>/winpr/include/winpr/wlog.h`/ |
| 25 | |
| 26 | #include <winpr/clipboard.h>cxx . . $ `<file>/winpr/include/winpr/clipboard.h`/ |
| 27 | |
| 28 | #include "clipboard.h"cxx . . $ `<file>/winpr/libwinpr/clipboard/clipboard.h`/ |
| 29 | |
| 30 | #include "synthetic_file.h"cxx . . $ `<file>/winpr/libwinpr/clipboard/synthetic_file.h`/ |
| 31 | |
| 32 | #include "../log.h"cxx . . $ `<file>/winpr/libwinpr/log.h`/ |
| 33 | #define TAGcxx . . $ `winpr/libwinpr/clipboard/clipboard.c:33:9`! WINPR_TAGcxx . . $ `winpr/libwinpr/log.h:25:9`!("clipboard") |
| 34 | |
| 35 | const char* const mime_text_plaincxx . . $ mime_text_plain. = "text/plain"; |
| 36 | |
| 37 | /** |
| 38 | * Clipboard (Windows): |
| 39 | * msdn.microsoft.com/en-us/library/windows/desktop/ms648709/ |
| 40 | * |
| 41 | * W3C Clipboard API and events: |
| 42 | * http://www.w3.org/TR/clipboard-apis/ |
| 43 | */ |
| 44 | |
| 45 | static const char* CF_STANDARD_STRINGScxx . . $ CF_STANDARD_STRINGS.[] = { |
| 46 | "CF_RAW", /* 0 */ |
| 47 | "CF_TEXT", /* 1 */ |
| 48 | "CF_BITMAP", /* 2 */ |
| 49 | "CF_METAFILEPICT", /* 3 */ |
| 50 | "CF_SYLK", /* 4 */ |
| 51 | "CF_DIF", /* 5 */ |
| 52 | "CF_TIFF", /* 6 */ |
| 53 | "CF_OEMTEXT", /* 7 */ |
| 54 | "CF_DIB", /* 8 */ |
| 55 | "CF_PALETTE", /* 9 */ |
| 56 | "CF_PENDATA", /* 10 */ |
| 57 | "CF_RIFF", /* 11 */ |
| 58 | "CF_WAVE", /* 12 */ |
| 59 | "CF_UNICODETEXT", /* 13 */ |
| 60 | "CF_ENHMETAFILE", /* 14 */ |
| 61 | "CF_HDROP", /* 15 */ |
| 62 | "CF_LOCALE", /* 16 */ |
| 63 | "CF_DIBV5" /* 17 */ |
| 64 | }; |
| 65 | |
| 66 | const char* ClipboardGetFormatIdStringcxx . . $ ClipboardGetFormatIdString(81a3ae90da26a711).(UINT32cxx . . $ UINT32# formatId) |
| 67 | { |
| 68 | if (formatId < ARRAYSIZEcxx . . $ `winpr/include/winpr/spec.h:962:9`!(CF_STANDARD_STRINGS)) |
| 69 | return CF_STANDARD_STRINGScxx . . $ CF_STANDARD_STRINGS.[formatId]; |
| 70 | return "CF_REGISTERED_FORMAT"; |
| 71 | } |
| 72 | |
| 73 | static wClipboardFormatcxx . . $ wClipboardFormat#* ClipboardFindFormatcxx . . $ ClipboardFindFormat(bdf6b2ed66ff459d).(wClipboardcxx . . $ wClipboard#* clipboard, UINT32cxx . . $ UINT32# formatId, |
| 74 | const char* name) |
| 75 | { |
| 76 | wClipboardFormatcxx . . $ wClipboardFormat#* format = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 77 | |
| 78 | if (!clipboard) |
| 79 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 80 | |
| 81 | if (formatId) |
| 82 | { |
| 83 | for (UINT32cxx . . $ UINT32# index = 0; index < clipboard->numFormatscxx . . $ s_wClipboard#numFormats.; index++) |
| 84 | { |
| 85 | wClipboardFormatcxx . . $ wClipboardFormat#* cformat = &clipboard->formatscxx . . $ s_wClipboard#formats.[index]; |
| 86 | if (formatId == cformat->formatIdcxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatId.) |
| 87 | { |
| 88 | format = cformat; |
| 89 | break; |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | else if (name) |
| 94 | { |
| 95 | for (UINT32cxx . . $ UINT32# index = 0; index < clipboard->numFormatscxx . . $ s_wClipboard#numFormats.; index++) |
| 96 | { |
| 97 | wClipboardFormatcxx . . $ wClipboardFormat#* cformat = &clipboard->formatscxx . . $ s_wClipboard#formats.[index]; |
| 98 | if (!cformat->formatNamecxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatName.) |
| 99 | continue; |
| 100 | |
| 101 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(name, cformat->formatNamecxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatName.) == 0) |
| 102 | { |
| 103 | format = cformat; |
| 104 | break; |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | else |
| 109 | { |
| 110 | /* special "CF_RAW" case */ |
| 111 | if (clipboard->numFormatscxx . . $ s_wClipboard#numFormats. > 0) |
| 112 | { |
| 113 | format = &clipboard->formatscxx . . $ s_wClipboard#formats.[0]; |
| 114 | |
| 115 | if (format->formatIdcxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatId.) |
| 116 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 117 | |
| 118 | if (!format->formatNamecxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatName. || (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(format->formatNamecxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatName., CF_STANDARD_STRINGScxx . . $ CF_STANDARD_STRINGS.[0]) == 0)) |
| 119 | return format; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | return format; |
| 124 | } |
| 125 | |
| 126 | static wClipboardSynthesizercxx . . $ wClipboardSynthesizer#* ClipboardFindSynthesizercxx . . $ ClipboardFindSynthesizer(3c7674bbdfd9e811).(wClipboardFormatcxx . . $ wClipboardFormat#* format, UINT32cxx . . $ UINT32# formatId) |
| 127 | { |
| 128 | if (!format) |
| 129 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 130 | |
| 131 | for (UINT32cxx . . $ UINT32# index = 0; index < format->numSynthesizerscxx . . $ $anonymous_type_7749f03d27d6cf26_1#numSynthesizers.; index++) |
| 132 | { |
| 133 | wClipboardSynthesizercxx . . $ wClipboardSynthesizer#* synthesizer = &(format->synthesizerscxx . . $ $anonymous_type_7749f03d27d6cf26_1#synthesizers.[index]); |
| 134 | |
| 135 | if (formatId == synthesizer->syntheticIdcxx . . $ $anonymous_type_7749f03d27d6cf26_0#syntheticId.) |
| 136 | return synthesizer; |
| 137 | } |
| 138 | |
| 139 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 140 | } |
| 141 | |
| 142 | void ClipboardLockcxx . . $ ClipboardLock(33a3251873669989).(wClipboardcxx . . $ wClipboard#* clipboard) |
| 143 | { |
| 144 | if (!clipboard) |
| 145 | return; |
| 146 | |
| 147 | EnterCriticalSectioncxx . . $ EnterCriticalSection(648035eaeaf99ce5).(&(clipboard->lockcxx . . $ s_wClipboard#lock.)); |
| 148 | } |
| 149 | |
| 150 | void ClipboardUnlockcxx . . $ ClipboardUnlock(33a3251873669989).(wClipboardcxx . . $ wClipboard#* clipboard) |
| 151 | { |
| 152 | if (!clipboard) |
| 153 | return; |
| 154 | |
| 155 | LeaveCriticalSectioncxx . . $ LeaveCriticalSection(648035eaeaf99ce5).(&(clipboard->lockcxx . . $ s_wClipboard#lock.)); |
| 156 | } |
| 157 | |
| 158 | BOOLcxx . . $ BOOL# ClipboardEmptycxx . . $ ClipboardEmpty(8ba6547d1108b902).(wClipboardcxx . . $ wClipboard#* clipboard) |
| 159 | { |
| 160 | if (!clipboard) |
| 161 | return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!; |
| 162 | |
| 163 | if (clipboard->datacxx . . $ s_wClipboard#data.) |
| 164 | { |
| 165 | freecxx . . $ free(5d22bdacc48458e8).(clipboard->datacxx . . $ s_wClipboard#data.); |
| 166 | clipboard->datacxx . . $ s_wClipboard#data. = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 167 | } |
| 168 | |
| 169 | clipboard->sizecxx . . $ s_wClipboard#size. = 0; |
| 170 | clipboard->formatIdcxx . . $ s_wClipboard#formatId. = 0; |
| 171 | clipboard->sequenceNumbercxx . . $ s_wClipboard#sequenceNumber.++; |
| 172 | return TRUEcxx . . $ `winpr/include/winpr/wtypes.h:126:9`!; |
| 173 | } |
| 174 | |
| 175 | UINT32cxx . . $ UINT32# ClipboardCountRegisteredFormatscxx . . $ ClipboardCountRegisteredFormats(5f5d996d3e03a476).(wClipboardcxx . . $ wClipboard#* clipboard) |
| 176 | { |
| 177 | if (!clipboard) |
| 178 | return 0; |
| 179 | |
| 180 | return clipboard->numFormatscxx . . $ s_wClipboard#numFormats.; |
| 181 | } |
| 182 | |
| 183 | UINT32cxx . . $ UINT32# ClipboardGetRegisteredFormatIdscxx . . $ ClipboardGetRegisteredFormatIds(a69221f990b25543).(wClipboardcxx . . $ wClipboard#* clipboard, UINT32cxx . . $ UINT32#** ppFormatIds) |
| 184 | { |
| 185 | UINT32cxx . . $ UINT32#* pFormatIds = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 186 | wClipboardFormatcxx . . $ wClipboardFormat#* format = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 187 | |
| 188 | if (!clipboard) |
| 189 | return 0; |
| 190 | |
| 191 | if (!ppFormatIds) |
| 192 | return 0; |
| 193 | |
| 194 | pFormatIds = *ppFormatIds; |
| 195 | |
| 196 | if (!pFormatIds) |
| 197 | { |
| 198 | pFormatIds = calloccxx . . $ calloc(63a7bf2941bfcd7a).(clipboard->numFormatscxx . . $ s_wClipboard#numFormats., sizeof(UINT32cxx . . $ UINT32#)); |
| 199 | |
| 200 | if (!pFormatIds) |
| 201 | return 0; |
| 202 | |
| 203 | *ppFormatIds = pFormatIds; |
| 204 | } |
| 205 | |
| 206 | for (UINT32cxx . . $ UINT32# index = 0; index < clipboard->numFormatscxx . . $ s_wClipboard#numFormats.; index++) |
| 207 | { |
| 208 | format = &(clipboard->formatscxx . . $ s_wClipboard#formats.[index]); |
| 209 | pFormatIds[index] = format->formatIdcxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatId.; |
| 210 | } |
| 211 | |
| 212 | return clipboard->numFormatscxx . . $ s_wClipboard#numFormats.; |
| 213 | } |
| 214 | |
| 215 | UINT32cxx . . $ UINT32# ClipboardRegisterFormatcxx . . $ ClipboardRegisterFormat(107dc010d80825ea).(wClipboardcxx . . $ wClipboard#* clipboard, const char* name) |
| 216 | { |
| 217 | wClipboardFormatcxx . . $ wClipboardFormat#* format = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 218 | |
| 219 | if (!clipboard) |
| 220 | return 0; |
| 221 | |
| 222 | format = ClipboardFindFormatcxx . . $ ClipboardFindFormat(bdf6b2ed66ff459d).(clipboard, 0, name); |
| 223 | |
| 224 | if (format) |
| 225 | return format->formatIdcxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatId.; |
| 226 | |
| 227 | if ((clipboard->numFormatscxx . . $ s_wClipboard#numFormats. + 1) >= clipboard->maxFormatscxx . . $ s_wClipboard#maxFormats.) |
| 228 | { |
| 229 | UINT32cxx . . $ UINT32# numFormats = clipboard->maxFormatscxx . . $ s_wClipboard#maxFormats. * 2; |
| 230 | wClipboardFormatcxx . . $ wClipboardFormat#* tmpFormat = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 231 | tmpFormat = |
| 232 | (wClipboardFormatcxx . . $ wClipboardFormat#*)realloccxx . . $ realloc(417ab160f6baadc6).(clipboard->formatscxx . . $ s_wClipboard#formats., numFormats * sizeof(wClipboardFormatcxx . . $ wClipboardFormat#)); |
| 233 | |
| 234 | if (!tmpFormat) |
| 235 | return 0; |
| 236 | |
| 237 | clipboard->formatscxx . . $ s_wClipboard#formats. = tmpFormat; |
| 238 | clipboard->maxFormatscxx . . $ s_wClipboard#maxFormats. = numFormats; |
| 239 | } |
| 240 | |
| 241 | format = &(clipboard->formatscxx . . $ s_wClipboard#formats.[clipboard->numFormatscxx . . $ s_wClipboard#numFormats.]); |
| 242 | ZeroMemorycxx . . $ `winpr/include/winpr/crt.h:126:9`!(format, sizeof(wClipboardFormat)); |
| 243 | |
| 244 | if (name) |
| 245 | { |
| 246 | format->formatNamecxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatName. = _strdupcxx . . $ _strdup(a8b8e32347182212).(name); |
| 247 | |
| 248 | if (!format->formatNamecxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatName.) |
| 249 | return 0; |
| 250 | } |
| 251 | |
| 252 | format->formatIdcxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatId. = clipboard->nextFormatIdcxx . . $ s_wClipboard#nextFormatId.++; |
| 253 | clipboard->numFormatscxx . . $ s_wClipboard#numFormats.++; |
| 254 | return format->formatIdcxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatId.; |
| 255 | } |
| 256 | |
| 257 | BOOLcxx . . $ BOOL# ClipboardRegisterSynthesizercxx . . $ ClipboardRegisterSynthesizer(b52da92c4eca607f).(wClipboardcxx . . $ wClipboard#* clipboard, UINT32cxx . . $ UINT32# formatId, UINT32cxx . . $ UINT32# syntheticId, |
| 258 | CLIPBOARD_SYNTHESIZE_FNcxx . . $ CLIPBOARD_SYNTHESIZE_FN# pfnSynthesize) |
| 259 | { |
| 260 | UINT32cxx . . $ UINT32# index = 0; |
| 261 | wClipboardFormatcxx . . $ wClipboardFormat#* format = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 262 | wClipboardSynthesizercxx . . $ wClipboardSynthesizer#* synthesizer = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 263 | |
| 264 | if (!clipboard) |
| 265 | return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!; |
| 266 | |
| 267 | format = ClipboardFindFormatcxx . . $ ClipboardFindFormat(bdf6b2ed66ff459d).(clipboard, formatId, nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!); |
| 268 | |
| 269 | if (!format) |
| 270 | return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!; |
| 271 | |
| 272 | if (format->formatIdcxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatId. == syntheticId) |
| 273 | return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!; |
| 274 | |
| 275 | synthesizer = ClipboardFindSynthesizercxx . . $ ClipboardFindSynthesizer(3c7674bbdfd9e811).(format, formatId); |
| 276 | |
| 277 | if (!synthesizer) |
| 278 | { |
| 279 | wClipboardSynthesizercxx . . $ wClipboardSynthesizer#* tmpSynthesizer = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 280 | UINT32cxx . . $ UINT32# numSynthesizers = format->numSynthesizerscxx . . $ $anonymous_type_7749f03d27d6cf26_1#numSynthesizers. + 1; |
| 281 | tmpSynthesizer = (wClipboardSynthesizercxx . . $ wClipboardSynthesizer#*)realloccxx . . $ realloc(417ab160f6baadc6).( |
| 282 | format->synthesizerscxx . . $ $anonymous_type_7749f03d27d6cf26_1#synthesizers., numSynthesizers * sizeof(wClipboardSynthesizercxx . . $ wClipboardSynthesizer#)); |
| 283 | |
| 284 | if (!tmpSynthesizer) |
| 285 | return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!; |
| 286 | |
| 287 | format->synthesizerscxx . . $ $anonymous_type_7749f03d27d6cf26_1#synthesizers. = tmpSynthesizer; |
| 288 | format->numSynthesizerscxx . . $ $anonymous_type_7749f03d27d6cf26_1#numSynthesizers. = numSynthesizers; |
| 289 | index = numSynthesizers - 1; |
| 290 | synthesizer = &(format->synthesizerscxx . . $ $anonymous_type_7749f03d27d6cf26_1#synthesizers.[index]); |
| 291 | } |
| 292 | |
| 293 | synthesizer->syntheticIdcxx . . $ $anonymous_type_7749f03d27d6cf26_0#syntheticId. = syntheticId; |
| 294 | synthesizer->pfnSynthesizecxx . . $ $anonymous_type_7749f03d27d6cf26_0#pfnSynthesize. = pfnSynthesize; |
| 295 | return TRUEcxx . . $ `winpr/include/winpr/wtypes.h:126:9`!; |
| 296 | } |
| 297 | |
| 298 | UINT32cxx . . $ UINT32# ClipboardCountFormatscxx . . $ ClipboardCountFormats(5f5d996d3e03a476).(wClipboardcxx . . $ wClipboard#* clipboard) |
| 299 | { |
| 300 | UINT32cxx . . $ UINT32# count = 0; |
| 301 | wClipboardFormatcxx . . $ wClipboardFormat#* format = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 302 | |
| 303 | if (!clipboard) |
| 304 | return 0; |
| 305 | |
| 306 | format = ClipboardFindFormatcxx . . $ ClipboardFindFormat(bdf6b2ed66ff459d).(clipboard, clipboard->formatIdcxx . . $ s_wClipboard#formatId., nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!); |
| 307 | |
| 308 | if (!format) |
| 309 | return 0; |
| 310 | |
| 311 | count = 1 + format->numSynthesizerscxx . . $ $anonymous_type_7749f03d27d6cf26_1#numSynthesizers.; |
| 312 | return count; |
| 313 | } |
| 314 | |
| 315 | UINT32cxx . . $ UINT32# ClipboardGetFormatIdscxx . . $ ClipboardGetFormatIds(a69221f990b25543).(wClipboardcxx . . $ wClipboard#* clipboard, UINT32cxx . . $ UINT32#** ppFormatIds) |
| 316 | { |
| 317 | UINT32cxx . . $ UINT32# count = 0; |
| 318 | UINT32cxx . . $ UINT32#* pFormatIds = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 319 | wClipboardFormatcxx . . $ wClipboardFormat#* format = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 320 | wClipboardSynthesizercxx . . $ wClipboardSynthesizer#* synthesizer = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 321 | |
| 322 | if (!clipboard) |
| 323 | return 0; |
| 324 | |
| 325 | format = ClipboardFindFormatcxx . . $ ClipboardFindFormat(bdf6b2ed66ff459d).(clipboard, clipboard->formatIdcxx . . $ s_wClipboard#formatId., nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!); |
| 326 | |
| 327 | if (!format) |
| 328 | return 0; |
| 329 | |
| 330 | count = 1 + format->numSynthesizerscxx . . $ $anonymous_type_7749f03d27d6cf26_1#numSynthesizers.; |
| 331 | |
| 332 | if (!ppFormatIds) |
| 333 | return 0; |
| 334 | |
| 335 | pFormatIds = *ppFormatIds; |
| 336 | |
| 337 | if (!pFormatIds) |
| 338 | { |
| 339 | pFormatIds = calloccxx . . $ calloc(63a7bf2941bfcd7a).(count, sizeof(UINT32cxx . . $ UINT32#)); |
| 340 | |
| 341 | if (!pFormatIds) |
| 342 | return 0; |
| 343 | |
| 344 | *ppFormatIds = pFormatIds; |
| 345 | } |
| 346 | |
| 347 | pFormatIds[0] = format->formatIdcxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatId.; |
| 348 | |
| 349 | for (UINT32cxx . . $ UINT32# index = 1; index < count; index++) |
| 350 | { |
| 351 | synthesizer = &(format->synthesizerscxx . . $ $anonymous_type_7749f03d27d6cf26_1#synthesizers.[index - 1]); |
| 352 | pFormatIds[index] = synthesizer->syntheticIdcxx . . $ $anonymous_type_7749f03d27d6cf26_0#syntheticId.; |
| 353 | } |
| 354 | |
| 355 | return count; |
| 356 | } |
| 357 | |
| 358 | static void ClipboardUninitFormatscxx . . $ ClipboardUninitFormats(33a3251873669989).(wClipboardcxx . . $ wClipboard#* clipboard) |
| 359 | { |
| 360 | WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(clipboard); |
| 361 | for (UINT32cxx . . $ UINT32# formatId = 0; formatId < clipboard->numFormatscxx . . $ s_wClipboard#numFormats.; formatId++) |
| 362 | { |
| 363 | wClipboardFormatcxx . . $ wClipboardFormat#* format = &clipboard->formatscxx . . $ s_wClipboard#formats.[formatId]; |
| 364 | freecxx . . $ free(5d22bdacc48458e8).(format->formatNamecxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatName.); |
| 365 | freecxx . . $ free(5d22bdacc48458e8).(format->synthesizerscxx . . $ $anonymous_type_7749f03d27d6cf26_1#synthesizers.); |
| 366 | format->formatNamecxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatName. = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 367 | format->synthesizerscxx . . $ $anonymous_type_7749f03d27d6cf26_1#synthesizers. = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | static BOOLcxx . . $ BOOL# ClipboardInitFormatscxx . . $ ClipboardInitFormats(8ba6547d1108b902).(wClipboardcxx . . $ wClipboard#* clipboard) |
| 372 | { |
| 373 | UINT32cxx . . $ UINT32# formatId = 0; |
| 374 | wClipboardFormatcxx . . $ wClipboardFormat#* format = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 375 | |
| 376 | if (!clipboard) |
| 377 | return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!; |
| 378 | |
| 379 | for (formatId = 0; formatId < CF_MAXcxx . . $ `winpr/include/winpr/user.h:72:9`!; formatId++, clipboard->numFormatscxx . . $ s_wClipboard#numFormats.++) |
| 380 | { |
| 381 | format = &(clipboard->formatscxx . . $ s_wClipboard#formats.[clipboard->numFormatscxx . . $ s_wClipboard#numFormats.]); |
| 382 | ZeroMemorycxx . . $ `winpr/include/winpr/crt.h:126:9`!(format, sizeof(wClipboardFormat)); |
| 383 | format->formatIdcxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatId. = formatId; |
| 384 | format->formatNamecxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatName. = _strdupcxx . . $ _strdup(a8b8e32347182212).(CF_STANDARD_STRINGScxx . . $ CF_STANDARD_STRINGS.[formatId]); |
| 385 | |
| 386 | if (!format->formatNamecxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatName.) |
| 387 | goto error; |
| 388 | } |
| 389 | |
| 390 | if (!ClipboardInitSynthesizerscxx . . $ ClipboardInitSynthesizers(8ba6547d1108b902).(clipboard)) |
| 391 | goto error; |
| 392 | |
| 393 | return TRUEcxx . . $ `winpr/include/winpr/wtypes.h:126:9`!; |
| 394 | error: |
| 395 | |
| 396 | ClipboardUninitFormatscxx . . $ ClipboardUninitFormats(33a3251873669989).(clipboard); |
| 397 | return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!; |
| 398 | } |
| 399 | |
| 400 | UINT32cxx . . $ UINT32# ClipboardGetFormatIdcxx . . $ ClipboardGetFormatId(107dc010d80825ea).(wClipboardcxx . . $ wClipboard#* clipboard, const char* name) |
| 401 | { |
| 402 | wClipboardFormatcxx . . $ wClipboardFormat#* format = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 403 | |
| 404 | if (!clipboard) |
| 405 | return 0; |
| 406 | |
| 407 | format = ClipboardFindFormatcxx . . $ ClipboardFindFormat(bdf6b2ed66ff459d).(clipboard, 0, name); |
| 408 | |
| 409 | if (!format) |
| 410 | return 0; |
| 411 | |
| 412 | return format->formatIdcxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatId.; |
| 413 | } |
| 414 | |
| 415 | const char* ClipboardGetFormatNamecxx . . $ ClipboardGetFormatName(b0371392434d3fd6).(wClipboardcxx . . $ wClipboard#* clipboard, UINT32cxx . . $ UINT32# formatId) |
| 416 | { |
| 417 | wClipboardFormatcxx . . $ wClipboardFormat#* format = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 418 | |
| 419 | if (!clipboard) |
| 420 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 421 | |
| 422 | format = ClipboardFindFormatcxx . . $ ClipboardFindFormat(bdf6b2ed66ff459d).(clipboard, formatId, nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!); |
| 423 | |
| 424 | if (!format) |
| 425 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 426 | |
| 427 | return format->formatNamecxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatName.; |
| 428 | } |
| 429 | |
| 430 | void* ClipboardGetDatacxx . . $ ClipboardGetData(68884baa0697d4bf).(wClipboardcxx . . $ wClipboard#* clipboard, UINT32cxx . . $ UINT32# formatId, UINT32cxx . . $ UINT32#* pSize) |
| 431 | { |
| 432 | UINT32cxx . . $ UINT32# SrcSize = 0; |
| 433 | UINT32cxx . . $ UINT32# DstSize = 0; |
| 434 | void* pSrcData = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 435 | void* pDstData = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 436 | wClipboardFormatcxx . . $ wClipboardFormat#* format = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 437 | wClipboardSynthesizercxx . . $ wClipboardSynthesizer#* synthesizer = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 438 | |
| 439 | if (!clipboard || !pSize) |
| 440 | { |
| 441 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `winpr/libwinpr/clipboard/clipboard.c:33:9`!, "Invalid parameters clipboard=%p, pSize=%p", |
| 442 | WINPR_CXX_COMPAT_CASTcxx . . $ `winpr/include/winpr/cast.h:33:9`!(const void*, clipboard), |
| 443 | WINPR_CXX_COMPAT_CASTcxx . . $ `winpr/include/winpr/cast.h:33:9`!(const void*, pSize)); |
| 444 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 445 | } |
| 446 | |
| 447 | *pSize = 0; |
| 448 | format = ClipboardFindFormatcxx . . $ ClipboardFindFormat(bdf6b2ed66ff459d).(clipboard, clipboard->formatIdcxx . . $ s_wClipboard#formatId., nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!); |
| 449 | |
| 450 | if (!format) |
| 451 | { |
| 452 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `winpr/libwinpr/clipboard/clipboard.c:33:9`!, "Format [0x%08" PRIx32cxx . . $ `<external>/15933738808807975373/inttypes.h:125:10`! "] not found", clipboard->formatId); |
| 453 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 454 | } |
| 455 | |
| 456 | SrcSize = clipboard->sizecxx . . $ s_wClipboard#size.; |
| 457 | pSrcData = clipboard->datacxx . . $ s_wClipboard#data.; |
| 458 | |
| 459 | if (formatId == format->formatIdcxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatId.) |
| 460 | { |
| 461 | DstSize = SrcSize; |
| 462 | pDstData = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(DstSize); |
| 463 | |
| 464 | if (!pDstData) |
| 465 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 466 | |
| 467 | CopyMemorycxx . . $ `winpr/include/winpr/crt.h:123:9`!(pDstData, pSrcData, SrcSize); |
| 468 | *pSize = DstSize; |
| 469 | } |
| 470 | else |
| 471 | { |
| 472 | synthesizer = ClipboardFindSynthesizercxx . . $ ClipboardFindSynthesizer(3c7674bbdfd9e811).(format, formatId); |
| 473 | |
| 474 | if (!synthesizer || !synthesizer->pfnSynthesizecxx . . $ $anonymous_type_7749f03d27d6cf26_0#pfnSynthesize.) |
| 475 | { |
| 476 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `winpr/libwinpr/clipboard/clipboard.c:33:9`!, "No synthesizer for format %s [0x%08" PRIx32cxx . . $ `<external>/15933738808807975373/inttypes.h:125:10`! "] --> %s [0x%08" PRIx32cxx . . $ `<external>/15933738808807975373/inttypes.h:125:10`! "]", |
| 477 | ClipboardGetFormatName(clipboard, clipboard->formatId), clipboard->formatId, |
| 478 | ClipboardGetFormatName(clipboard, formatId), formatId); |
| 479 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 480 | } |
| 481 | |
| 482 | DstSize = SrcSize; |
| 483 | pDstData = synthesizer->pfnSynthesizecxx . . $ $anonymous_type_7749f03d27d6cf26_0#pfnSynthesize.(clipboard, format->formatIdcxx . . $ $anonymous_type_7749f03d27d6cf26_1#formatId., pSrcData, &DstSize); |
| 484 | if (pDstData) |
| 485 | *pSize = DstSize; |
| 486 | } |
| 487 | |
| 488 | WLog_DBGcxx . . $ `winpr/include/winpr/wlog.h:341:9`!(TAGcxx . . $ `winpr/libwinpr/clipboard/clipboard.c:33:9`!, "getting formatId=%s [0x%08" PRIx32cxx . . $ `<external>/15933738808807975373/inttypes.h:125:10`! "] data=%p, size=%" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`!, |
| 489 | ClipboardGetFormatName(clipboard, formatId), formatId, pDstData, *pSize); |
| 490 | return pDstData; |
| 491 | } |
| 492 | |
| 493 | BOOLcxx . . $ BOOL# ClipboardSetDatacxx . . $ ClipboardSetData(ea1fdeeee8f542d5).(wClipboardcxx . . $ wClipboard#* clipboard, UINT32cxx . . $ UINT32# formatId, const void* data, UINT32cxx . . $ UINT32# size) |
| 494 | { |
| 495 | wClipboardFormatcxx . . $ wClipboardFormat#* format = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 496 | |
| 497 | WLog_DBGcxx . . $ `winpr/include/winpr/wlog.h:341:9`!(TAGcxx . . $ `winpr/libwinpr/clipboard/clipboard.c:33:9`!, "setting formatId=%s [0x%08" PRIx32cxx . . $ `<external>/15933738808807975373/inttypes.h:125:10`! "], size=%" PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:109:10`!, |
| 498 | ClipboardGetFormatName(clipboard, formatId), formatId, size); |
| 499 | if (!clipboard) |
| 500 | return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!; |
| 501 | |
| 502 | format = ClipboardFindFormatcxx . . $ ClipboardFindFormat(bdf6b2ed66ff459d).(clipboard, formatId, nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!); |
| 503 | |
| 504 | if (!format) |
| 505 | return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!; |
| 506 | |
| 507 | freecxx . . $ free(5d22bdacc48458e8).(clipboard->datacxx . . $ s_wClipboard#data.); |
| 508 | |
| 509 | clipboard->datacxx . . $ s_wClipboard#data. = calloccxx . . $ calloc(63a7bf2941bfcd7a).(size + sizeof(WCHARcxx . . $ WCHAR#), sizeof(char)); |
| 510 | |
| 511 | if (!clipboard->datacxx . . $ s_wClipboard#data.) |
| 512 | return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!; |
| 513 | |
| 514 | memcpycxx . . $ memcpy(cc817cb175f282d).(clipboard->datacxx . . $ s_wClipboard#data., data, size); |
| 515 | |
| 516 | /* For string values we don´t know if they are '\0' terminated. |
| 517 | * so set the size to the full length in bytes (e.g. string length + 1) |
| 518 | */ |
| 519 | switch (formatId) |
| 520 | { |
| 521 | case CF_TEXTcxx . . $ `winpr/include/winpr/user.h:55:9`!: |
| 522 | case CF_OEMTEXTcxx . . $ `winpr/include/winpr/user.h:61:9`!: |
| 523 | clipboard->sizecxx . . $ s_wClipboard#size. = (UINT32cxx . . $ UINT32#)(strnlencxx . . $ strnlen(ac5a385650b4bde5).(clipboard->datacxx . . $ s_wClipboard#data., size) + 1UL); |
| 524 | break; |
| 525 | case CF_UNICODETEXTcxx . . $ `winpr/include/winpr/user.h:67:9`!: |
| 526 | clipboard->sizecxx . . $ s_wClipboard#size. = |
| 527 | (UINT32cxx . . $ UINT32#)((_wcsnlencxx . . $ _wcsnlen(878e7dc5509530f1).(clipboard->datacxx . . $ s_wClipboard#data., size / sizeof(WCHARcxx . . $ WCHAR#)) + 1UL) * sizeof(WCHARcxx . . $ WCHAR#)); |
| 528 | break; |
| 529 | default: |
| 530 | clipboard->sizecxx . . $ s_wClipboard#size. = size; |
| 531 | break; |
| 532 | } |
| 533 | |
| 534 | clipboard->formatIdcxx . . $ s_wClipboard#formatId. = formatId; |
| 535 | clipboard->sequenceNumbercxx . . $ s_wClipboard#sequenceNumber.++; |
| 536 | return TRUEcxx . . $ `winpr/include/winpr/wtypes.h:126:9`!; |
| 537 | } |
| 538 | |
| 539 | UINT64cxx . . $ UINT64# ClipboardGetOwnercxx . . $ ClipboardGetOwner(223cf2bc5c30bf37).(wClipboardcxx . . $ wClipboard#* clipboard) |
| 540 | { |
| 541 | if (!clipboard) |
| 542 | return 0; |
| 543 | |
| 544 | return clipboard->ownerIdcxx . . $ s_wClipboard#ownerId.; |
| 545 | } |
| 546 | |
| 547 | void ClipboardSetOwnercxx . . $ ClipboardSetOwner(64fca86b811117f2).(wClipboardcxx . . $ wClipboard#* clipboard, UINT64cxx . . $ UINT64# ownerId) |
| 548 | { |
| 549 | if (!clipboard) |
| 550 | return; |
| 551 | |
| 552 | clipboard->ownerIdcxx . . $ s_wClipboard#ownerId. = ownerId; |
| 553 | } |
| 554 | |
| 555 | wClipboardDelegatecxx . . $ wClipboardDelegate#* ClipboardGetDelegatecxx . . $ ClipboardGetDelegate(cbd5d3a817a05ef2).(wClipboardcxx . . $ wClipboard#* clipboard) |
| 556 | { |
| 557 | if (!clipboard) |
| 558 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 559 | |
| 560 | return &clipboard->delegatecxx . . $ s_wClipboard#delegate.; |
| 561 | } |
| 562 | |
| 563 | static void ClipboardInitLocalFileSubsystemcxx . . $ ClipboardInitLocalFileSubsystem(33a3251873669989).(wClipboardcxx . . $ wClipboard#* clipboard) |
| 564 | { |
| 565 | /* |
| 566 | * There can be only one local file subsystem active. |
| 567 | * Return as soon as initialization succeeds. |
| 568 | */ |
| 569 | if (ClipboardInitSyntheticFileSubsystemcxx . . $ ClipboardInitSyntheticFileSubsystem(8ba6547d1108b902).(clipboard)) |
| 570 | { |
| 571 | WLog_DBGcxx . . $ `winpr/include/winpr/wlog.h:341:9`!(TAGcxx . . $ `winpr/libwinpr/clipboard/clipboard.c:33:9`!, "initialized synthetic local file subsystem"); |
| 572 | return; |
| 573 | } |
| 574 | else |
| 575 | { |
| 576 | WLog_WARNcxx . . $ `winpr/include/winpr/wlog.h:345:9`!(TAGcxx . . $ `winpr/libwinpr/clipboard/clipboard.c:33:9`!, "failed to initialize synthetic local file subsystem"); |
| 577 | } |
| 578 | |
| 579 | WLog_INFOcxx . . $ `winpr/include/winpr/wlog.h:343:9`!(TAGcxx . . $ `winpr/libwinpr/clipboard/clipboard.c:33:9`!, "failed to initialize local file subsystem, file transfer not available"); |
| 580 | } |
| 581 | |
| 582 | wClipboardcxx . . $ wClipboard#* ClipboardCreatecxx . . $ ClipboardCreate(b7a7984ccfa2fe67).(void) |
| 583 | { |
| 584 | wClipboardcxx . . $ wClipboard#* clipboard = (wClipboardcxx . . $ wClipboard#*)calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(wClipboardcxx . . $ wClipboard#)); |
| 585 | |
| 586 | if (!clipboard) |
| 587 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 588 | |
| 589 | clipboard->nextFormatIdcxx . . $ s_wClipboard#nextFormatId. = 0xC000; |
| 590 | clipboard->sequenceNumbercxx . . $ s_wClipboard#sequenceNumber. = 0; |
| 591 | |
| 592 | if (!InitializeCriticalSectionAndSpinCountcxx . . $ InitializeCriticalSectionAndSpinCount(a0011235b16286ec).(&(clipboard->lockcxx . . $ s_wClipboard#lock.), 4000)) |
| 593 | goto fail; |
| 594 | |
| 595 | clipboard->numFormatscxx . . $ s_wClipboard#numFormats. = 0; |
| 596 | clipboard->maxFormatscxx . . $ s_wClipboard#maxFormats. = 64; |
| 597 | clipboard->formatscxx . . $ s_wClipboard#formats. = (wClipboardFormatcxx . . $ wClipboardFormat#*)calloccxx . . $ calloc(63a7bf2941bfcd7a).(clipboard->maxFormatscxx . . $ s_wClipboard#maxFormats., sizeof(wClipboardFormatcxx . . $ wClipboardFormat#)); |
| 598 | |
| 599 | if (!clipboard->formatscxx . . $ s_wClipboard#formats.) |
| 600 | goto fail; |
| 601 | |
| 602 | if (!ClipboardInitFormatscxx . . $ ClipboardInitFormats(8ba6547d1108b902).(clipboard)) |
| 603 | goto fail; |
| 604 | |
| 605 | clipboard->delegatecxx . . $ s_wClipboard#delegate..clipboardcxx . . $ s_wClipboardDelegate#clipboard. = clipboard; |
| 606 | ClipboardInitLocalFileSubsystemcxx . . $ ClipboardInitLocalFileSubsystem(33a3251873669989).(clipboard); |
| 607 | return clipboard; |
| 608 | fail: |
| 609 | ClipboardDestroycxx . . $ ClipboardDestroy(33a3251873669989).(clipboard); |
| 610 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 611 | } |
| 612 | |
| 613 | void ClipboardDestroycxx . . $ ClipboardDestroy(33a3251873669989).(wClipboardcxx . . $ wClipboard#* clipboard) |
| 614 | { |
| 615 | if (!clipboard) |
| 616 | return; |
| 617 | |
| 618 | ArrayList_Freecxx . . $ ArrayList_Free(ff3e3cd88f5bc6ab).(clipboard->localFilescxx . . $ s_wClipboard#localFiles.); |
| 619 | clipboard->localFilescxx . . $ s_wClipboard#localFiles. = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 620 | |
| 621 | ClipboardUninitFormatscxx . . $ ClipboardUninitFormats(33a3251873669989).(clipboard); |
| 622 | |
| 623 | freecxx . . $ free(5d22bdacc48458e8).(clipboard->datacxx . . $ s_wClipboard#data.); |
| 624 | clipboard->datacxx . . $ s_wClipboard#data. = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 625 | clipboard->sizecxx . . $ s_wClipboard#size. = 0; |
| 626 | clipboard->numFormatscxx . . $ s_wClipboard#numFormats. = 0; |
| 627 | freecxx . . $ free(5d22bdacc48458e8).(clipboard->formatscxx . . $ s_wClipboard#formats.); |
| 628 | DeleteCriticalSectioncxx . . $ DeleteCriticalSection(648035eaeaf99ce5).(&(clipboard->lockcxx . . $ s_wClipboard#lock.)); |
| 629 | freecxx . . $ free(5d22bdacc48458e8).(clipboard); |
| 630 | } |
| 631 | |
| 632 | static BOOLcxx . . $ BOOL# is_dos_drivecxx . . $ is_dos_drive(54dd70b47e85a2fc).(const char* path, size_t len) |
| 633 | { |
| 634 | if (len < 2) |
| 635 | return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!; |
| 636 | |
| 637 | WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(path); |
| 638 | if (path[1] == ':' || path[1] == '|') |
| 639 | { |
| 640 | if (((path[0] >= 'A') && (path[0] <= 'Z')) || ((path[0] >= 'a') && (path[0] <= 'z'))) |
| 641 | return TRUEcxx . . $ `winpr/include/winpr/wtypes.h:126:9`!; |
| 642 | } |
| 643 | return FALSEcxx . . $ `winpr/include/winpr/wtypes.h:122:9`!; |
| 644 | } |
| 645 | |
| 646 | char* parse_uri_to_local_filecxx . . $ parse_uri_to_local_file(eabdfdef77619b3d).(const char* uri, size_t uri_len) |
| 647 | { |
| 648 | // URI is specified by RFC 8089: https://datatracker.ietf.org/doc/html/rfc8089 |
| 649 | const char prefix[] = "file:"; |
| 650 | const char prefixTraditional[] = "file://"; |
| 651 | const char* localName = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 652 | size_t localLen = 0; |
| 653 | char* buffer = nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 654 | const size_t prefixLen = strnlencxx . . $ strnlen(ac5a385650b4bde5).(prefix, sizeof(prefix)); |
| 655 | const size_t prefixTraditionalLen = strnlencxx . . $ strnlen(ac5a385650b4bde5).(prefixTraditional, sizeof(prefixTraditional)); |
| 656 | |
| 657 | WINPR_ASSERTcxx . . $ `winpr/include/winpr/assert-api.h:76:9`!(uri || (uri_len == 0)); |
| 658 | |
| 659 | WLog_VRBcxx . . $ `winpr/include/winpr/wlog.h:339:9`!(TAGcxx . . $ `winpr/libwinpr/clipboard/clipboard.c:33:9`!, "processing URI: %.*s", WINPR_ASSERTING_INT_CASTcxx . . $ `winpr/include/winpr/cast.h:111:9`!(int, uri_len), uri); |
| 660 | |
| 661 | if ((uri_len <= prefixLen) || strncmpcxx . . $ strncmp(fd278af2f295fa2e).(uri, prefix, prefixLen) != 0) |
| 662 | { |
| 663 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `winpr/libwinpr/clipboard/clipboard.c:33:9`!, "non-'file:' URI schemes are not supported"); |
| 664 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 665 | } |
| 666 | |
| 667 | do |
| 668 | { |
| 669 | /* https://datatracker.ietf.org/doc/html/rfc8089#appendix-F |
| 670 | * - The minimal representation of a local file in a DOS- or Windows- |
| 671 | * based environment with no authority field and an absolute path |
| 672 | * that begins with a drive letter. |
| 673 | * |
| 674 | * "file:c:/path/to/file" |
| 675 | * |
| 676 | * - Regular DOS or Windows file URIs with vertical line characters in |
| 677 | * the drive letter construct. |
| 678 | * |
| 679 | * "file:c|/path/to/file" |
| 680 | * |
| 681 | */ |
| 682 | if (uri[prefixLen] != '/') |
| 683 | { |
| 684 | |
| 685 | if (is_dos_drivecxx . . $ is_dos_drive(54dd70b47e85a2fc).(&uri[prefixLen], uri_len - prefixLen)) |
| 686 | { |
| 687 | // Dos and Windows file URI |
| 688 | localName = &uri[prefixLen]; |
| 689 | localLen = uri_len - prefixLen; |
| 690 | break; |
| 691 | } |
| 692 | else |
| 693 | { |
| 694 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `winpr/libwinpr/clipboard/clipboard.c:33:9`!, "URI format are not supported: %s", uri); |
| 695 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | /* |
| 700 | * - The minimal representation of a local file with no authority field |
| 701 | * and an absolute path that begins with a slash "/". For example: |
| 702 | * |
| 703 | * "file:/path/to/file" |
| 704 | * |
| 705 | */ |
| 706 | else if ((uri_len > prefixLen + 1) && (uri[prefixLen + 1] != '/')) |
| 707 | { |
| 708 | if (is_dos_drivecxx . . $ is_dos_drive(54dd70b47e85a2fc).(&uri[prefixLen + 1], uri_len - prefixLen - 1)) |
| 709 | { |
| 710 | // Dos and Windows file URI |
| 711 | localName = (uri + prefixLen + 1); |
| 712 | localLen = uri_len - prefixLen - 1; |
| 713 | } |
| 714 | else |
| 715 | { |
| 716 | localName = &uri[prefixLen]; |
| 717 | localLen = uri_len - prefixLen; |
| 718 | } |
| 719 | break; |
| 720 | } |
| 721 | |
| 722 | /* |
| 723 | * - A traditional file URI for a local file with an empty authority. |
| 724 | * |
| 725 | * "file:///path/to/file" |
| 726 | */ |
| 727 | if ((uri_len < prefixTraditionalLen) || |
| 728 | strncmpcxx . . $ strncmp(fd278af2f295fa2e).(uri, prefixTraditional, prefixTraditionalLen) != 0) |
| 729 | { |
| 730 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `winpr/libwinpr/clipboard/clipboard.c:33:9`!, "non-'file:' URI schemes are not supported"); |
| 731 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 732 | } |
| 733 | |
| 734 | localName = &uri[prefixTraditionalLen]; |
| 735 | localLen = uri_len - prefixTraditionalLen; |
| 736 | |
| 737 | if (localLen < 1) |
| 738 | { |
| 739 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `winpr/libwinpr/clipboard/clipboard.c:33:9`!, "empty 'file:' URI schemes are not supported"); |
| 740 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 741 | } |
| 742 | |
| 743 | /* |
| 744 | * "file:///c:/path/to/file" |
| 745 | * "file:///c|/path/to/file" |
| 746 | */ |
| 747 | if (localName[0] != '/') |
| 748 | { |
| 749 | WLog_ERRcxx . . $ `winpr/include/winpr/wlog.h:347:9`!(TAGcxx . . $ `winpr/libwinpr/clipboard/clipboard.c:33:9`!, "URI format are not supported: %s", uri); |
| 750 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 751 | } |
| 752 | |
| 753 | if (is_dos_drivecxx . . $ is_dos_drive(54dd70b47e85a2fc).(&localName[1], localLen - 1)) |
| 754 | { |
| 755 | localName++; |
| 756 | localLen--; |
| 757 | } |
| 758 | |
| 759 | } while (0); |
| 760 | |
| 761 | buffer = winpr_str_url_decodecxx . . $ winpr_str_url_decode(eabdfdef77619b3d).(localName, localLen); |
| 762 | if (buffer) |
| 763 | { |
| 764 | if (buffer[1] == '|' && |
| 765 | ((buffer[0] >= 'A' && buffer[0] <= 'Z') || (buffer[0] >= 'a' && buffer[0] <= 'z'))) |
| 766 | buffer[1] = ':'; |
| 767 | return buffer; |
| 768 | } |
| 769 | |
| 770 | return nullptrcxx . . $ `winpr/include/winpr/platform.h:88:9`!; |
| 771 | } |