include/SDL_clipboard.h
author Ryan C. Gordon <icculus@icculus.org>
Thu, 28 May 2015 01:54:52 -0400
changeset 9671 0e1f57b051f4
parent 9619 b94b6d0bff0f
child 9998 f67cf37e9cd4
permissions -rw-r--r--
Windows GetBasePath should use GetModuleFileNameExW() and check for overflows.

Apparently you might get strange paths from GetModuleFileName(), such as
short path names or UNC filenames, so this avoids that problem. Since you have
to tapdance with linking different libraries and defining macros depending on
what Windows you plan to target, we dynamically load the API we need, which
works on all versions of Windows (on Win7, it'll load a compatibility wrapper
for the newer API location).

What a mess.

This also now does the right thing if there isn't enough space to store the
path, looping with a larger allocated buffer each try.

Fixes Bugzilla #2435.
slouken@4493
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@9619
     3
  Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
slouken@4493
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@4493
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@4493
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@4493
    20
*/
slouken@4493
    21
slouken@4493
    22
/**
slouken@4493
    23
 * \file SDL_clipboard.h
slouken@4493
    24
 *
slouken@4493
    25
 * Include file for SDL clipboard handling
slouken@4493
    26
 */
slouken@4493
    27
slouken@4493
    28
#ifndef _SDL_clipboard_h
slouken@4493
    29
#define _SDL_clipboard_h
slouken@4493
    30
slouken@4493
    31
#include "SDL_stdinc.h"
slouken@4493
    32
slouken@4493
    33
#include "begin_code.h"
slouken@4493
    34
/* Set up for C function definitions, even when using C++ */
slouken@4493
    35
#ifdef __cplusplus
slouken@4493
    36
extern "C" {
slouken@4493
    37
#endif
slouken@4493
    38
slouken@4493
    39
/* Function prototypes */
slouken@4493
    40
slouken@4493
    41
/**
slouken@4495
    42
 * \brief Put UTF-8 text into the clipboard
slouken@4493
    43
 *
slouken@4493
    44
 * \sa SDL_GetClipboardText()
slouken@4493
    45
 */
slouken@4493
    46
extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text);
slouken@4493
    47
slouken@4493
    48
/**
slouken@4495
    49
 * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free()
slouken@4493
    50
 *
slouken@4493
    51
 * \sa SDL_SetClipboardText()
slouken@4493
    52
 */
slouken@4506
    53
extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void);
slouken@4493
    54
slouken@4493
    55
/**
slouken@6120
    56
 * \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty
slouken@4493
    57
 *
slouken@4493
    58
 * \sa SDL_GetClipboardText()
slouken@4493
    59
 */
slouken@4506
    60
extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void);
slouken@4493
    61
slouken@4493
    62
slouken@4493
    63
/* Ends C function definitions when using C++ */
slouken@4493
    64
#ifdef __cplusplus
slouken@4493
    65
}
slouken@4493
    66
#endif
slouken@4493
    67
#include "close_code.h"
slouken@4493
    68
slouken@4493
    69
#endif /* _SDL_clipboard_h */
slouken@4493
    70
slouken@4493
    71
/* vi: set ts=4 sw=4 expandtab: */