visualtest/include/SDL_visualtest_process.h
author David Ludwig <dludwig@pobox.com>
Wed, 25 Dec 2013 21:39:48 -0500
changeset 8563 c0e68f3b6bbb
parent 7924 fcb86d323770
child 11382 2c50e79b19e0
permissions -rw-r--r--
WinRT: compiled the d3d11 renderer's shaders into SDL itself

Previously, the shaders would get compiled separately, the output of which would need to be packaged into the app. This change should make SDL's dll be the only binary needed to include SDL in a WinRT app.
icculus@7924
     1
/* See COPYING.txt for the full license governing this code. */
icculus@7924
     2
/**
icculus@7924
     3
 * \file SDL_visualtest_process.h
icculus@7924
     4
 *
icculus@7924
     5
 * Provides cross-platfrom process launching and termination functionality.
icculus@7924
     6
 */
icculus@7924
     7
icculus@7924
     8
#include <SDL_platform.h>
icculus@7924
     9
icculus@7924
    10
#if defined(__WIN32__)
icculus@7924
    11
#include <Windows.h>
icculus@7924
    12
#include <Shlwapi.h>
icculus@7924
    13
#elif defined(__LINUX__)
icculus@7924
    14
#include <unistd.h>
icculus@7924
    15
#else
icculus@7924
    16
#error "Unsupported platform."
icculus@7924
    17
#endif
icculus@7924
    18
icculus@7924
    19
#ifndef _SDL_visualtest_process_h
icculus@7924
    20
#define _SDL_visualtest_process_h
icculus@7924
    21
icculus@7924
    22
/* Set up for C function definitions, even when using C++ */
icculus@7924
    23
#ifdef __cplusplus
icculus@7924
    24
extern "C" {
icculus@7924
    25
#endif
icculus@7924
    26
icculus@7924
    27
/**
icculus@7924
    28
 * Struct to store a platform specific handle to a process.
icculus@7924
    29
 */
icculus@7924
    30
typedef struct SDL_ProcessInfo
icculus@7924
    31
{
icculus@7924
    32
//#if defined(_WIN32) || defined(__WIN32__)
icculus@7924
    33
#if defined(__WIN32__)
icculus@7924
    34
    PROCESS_INFORMATION pi;
icculus@7924
    35
//#elif defined(__linux__)
icculus@7924
    36
#elif defined(__LINUX__)
icculus@7924
    37
    int pid;
icculus@7924
    38
#endif
icculus@7924
    39
} SDL_ProcessInfo;
icculus@7924
    40
icculus@7924
    41
/**
icculus@7924
    42
 * This structure stores the exit status (value returned by main()) and
icculus@7924
    43
 * whether the process exited sucessfully or not.
icculus@7924
    44
 */
icculus@7924
    45
typedef struct SDL_ProcessExitStatus
icculus@7924
    46
{
icculus@7924
    47
    int exit_success;   /*!< Zero if the process exited successfully */
icculus@7924
    48
    int exit_status;    /*!< The exit status of the process. 8-bit value. */
icculus@7924
    49
} SDL_ProcessExitStatus;
icculus@7924
    50
icculus@7924
    51
/**
icculus@7924
    52
 * Launches a process with the given commandline arguments.
icculus@7924
    53
 *
icculus@7924
    54
 * \param file  The path to the executable to be launched.
icculus@7924
    55
 * \param args  The command line arguments to be passed to the process.
icculus@7924
    56
 * \param pinfo Pointer to an SDL_ProcessInfo object to be populated with
icculus@7924
    57
 *              platform specific information about the launched process.
icculus@7924
    58
 *
icculus@7924
    59
 * \return Non-zero on success, zero on failure.
icculus@7924
    60
 */
icculus@7924
    61
int SDL_LaunchProcess(char* file, char* args, SDL_ProcessInfo* pinfo);
icculus@7924
    62
icculus@7924
    63
/**
icculus@7924
    64
 * Checks if a process is running or not.
icculus@7924
    65
 *
icculus@7924
    66
 * \param pinfo Pointer to SDL_ProcessInfo object of the process that needs to be
icculus@7924
    67
 *              checked.
icculus@7924
    68
 *
icculus@7924
    69
 * \return 1 if the process is still running; zero if it is not and -1 if the
icculus@7924
    70
 *         status could not be retrieved.
icculus@7924
    71
 */
icculus@7924
    72
int SDL_IsProcessRunning(SDL_ProcessInfo* pinfo);
icculus@7924
    73
icculus@7924
    74
/**
icculus@7924
    75
 * Kills a currently running process.
icculus@7924
    76
 *
icculus@7924
    77
 * \param pinfo Pointer to a SDL_ProcessInfo object of the process to be terminated.
icculus@7924
    78
 * \param ps Pointer to a SDL_ProcessExitStatus object which will be populated
icculus@7924
    79
 *           with the exit status.
icculus@7924
    80
 *
icculus@7924
    81
 * \return 1 on success, 0 on failure.
icculus@7924
    82
 */
icculus@7924
    83
int SDL_KillProcess(SDL_ProcessInfo* pinfo, SDL_ProcessExitStatus* ps);
icculus@7924
    84
icculus@7924
    85
/**
icculus@7924
    86
 * Cleanly exits the process represented by \c pinfo and stores the exit status
icculus@7924
    87
 * in the exit status object pointed to by \c ps.
icculus@7924
    88
 *
icculus@7924
    89
 * \return 1 on success, 0 on failure.
icculus@7924
    90
 */
icculus@7924
    91
int SDL_QuitProcess(SDL_ProcessInfo* pinfo, SDL_ProcessExitStatus* ps);
icculus@7924
    92
icculus@7924
    93
/**
icculus@7924
    94
 * Gets the exit status of a process. If the exit status is -1, the process is
icculus@7924
    95
 * still running.
icculus@7924
    96
 *
icculus@7924
    97
 * \param pinfo Pointer to a SDL_ProcessInfo object of the process to be checked.
icculus@7924
    98
 * \param ps Pointer to a SDL_ProcessExitStatus object which will be populated
icculus@7924
    99
 *           with the exit status.
icculus@7924
   100
 *
icculus@7924
   101
 * \return 1 on success, 0 on failure.
icculus@7924
   102
 */
icculus@7924
   103
int SDL_GetProcessExitStatus(SDL_ProcessInfo* pinfo, SDL_ProcessExitStatus* ps);
icculus@7924
   104
icculus@7924
   105
/* Ends C function definitions when using C++ */
icculus@7924
   106
#ifdef __cplusplus
icculus@7924
   107
}
icculus@7924
   108
#endif
icculus@7924
   109
icculus@7924
   110
#endif /* _SDL_visualtest_process_h */
icculus@7924
   111