2012-03-23 10:11:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011-2012 Ryan Prichard
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2012-03-25 09:29:37 +00:00
|
|
|
#ifndef WINPTY_H
|
|
|
|
#define WINPTY_H
|
2012-01-09 08:56:55 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
2012-02-10 10:09:38 +00:00
|
|
|
#include <windows.h>
|
2012-01-09 08:56:55 +00:00
|
|
|
|
2012-03-25 09:29:37 +00:00
|
|
|
#ifdef WINPTY
|
|
|
|
#define WINPTY_API __declspec(dllexport)
|
2012-01-09 08:56:55 +00:00
|
|
|
#else
|
2012-03-25 09:29:37 +00:00
|
|
|
#define WINPTY_API __declspec(dllimport)
|
2012-01-09 08:56:55 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-03-25 09:29:37 +00:00
|
|
|
typedef struct winpty_s winpty_t;
|
2012-01-09 08:56:55 +00:00
|
|
|
|
2012-01-27 17:05:34 +00:00
|
|
|
/*
|
2012-03-25 09:29:37 +00:00
|
|
|
* winpty API.
|
2012-01-27 17:05:34 +00:00
|
|
|
*/
|
2012-01-09 08:56:55 +00:00
|
|
|
|
2012-01-27 17:05:34 +00:00
|
|
|
/*
|
2012-03-25 09:29:37 +00:00
|
|
|
* Starts a new winpty instance with the given size.
|
2012-03-25 00:17:23 +00:00
|
|
|
*
|
|
|
|
* This function creates a new agent process and connects to it.
|
2012-01-27 17:05:34 +00:00
|
|
|
*/
|
2012-03-25 09:29:37 +00:00
|
|
|
WINPTY_API winpty_t *winpty_open(int cols, int rows);
|
2012-01-09 08:56:55 +00:00
|
|
|
|
2012-01-27 17:05:34 +00:00
|
|
|
/*
|
2012-02-20 09:23:46 +00:00
|
|
|
* Start a child process. Either (but not both) of appname and cmdline may
|
|
|
|
* be NULL. cwd and env may be NULL. env is a pointer to an environment
|
|
|
|
* block like that passed to CreateProcess.
|
2012-01-27 17:05:34 +00:00
|
|
|
*
|
|
|
|
* This function never modifies the cmdline, unlike CreateProcess.
|
|
|
|
*
|
|
|
|
* Only one child process may be started. After the child process exits, the
|
2012-03-25 00:17:23 +00:00
|
|
|
* agent will scrape the console output one last time, then close the data pipe
|
|
|
|
* once all remaining data has been sent.
|
|
|
|
*
|
|
|
|
* Returns 0 on success or a Win32 error code on failure.
|
2012-01-27 17:05:34 +00:00
|
|
|
*/
|
2012-03-25 09:29:37 +00:00
|
|
|
WINPTY_API int winpty_start_process(winpty_t *pc,
|
2012-04-01 08:40:15 +00:00
|
|
|
const wchar_t *appname,
|
|
|
|
const wchar_t *cmdline,
|
|
|
|
const wchar_t *cwd,
|
|
|
|
const wchar_t *env);
|
2012-01-09 08:56:55 +00:00
|
|
|
|
2012-03-25 00:17:23 +00:00
|
|
|
/*
|
2012-03-25 09:29:37 +00:00
|
|
|
* Returns the exit code of the process started with winpty_start_process,
|
2012-03-25 00:17:23 +00:00
|
|
|
* or -1 none is available.
|
|
|
|
*/
|
2012-03-25 09:29:37 +00:00
|
|
|
WINPTY_API int winpty_get_exit_code(winpty_t *pc);
|
2012-01-27 17:05:34 +00:00
|
|
|
|
2013-09-24 08:09:01 +00:00
|
|
|
/*
|
|
|
|
* Returns the process id of the process started with winpty_start_process,
|
|
|
|
* or -1 none is available.
|
|
|
|
*/
|
|
|
|
WINPTY_API int winpty_get_process_id(winpty_t *pc);
|
|
|
|
|
2012-01-27 17:05:34 +00:00
|
|
|
/*
|
2012-02-10 10:09:38 +00:00
|
|
|
* Returns an overlapped-mode pipe handle that can be read and written
|
|
|
|
* like a Unix terminal.
|
2012-01-27 17:05:34 +00:00
|
|
|
*/
|
2012-03-25 09:29:37 +00:00
|
|
|
WINPTY_API HANDLE winpty_get_data_pipe(winpty_t *pc);
|
2012-01-27 17:05:34 +00:00
|
|
|
|
|
|
|
/*
|
2012-02-10 10:09:38 +00:00
|
|
|
* Change the size of the Windows console.
|
2012-01-27 17:05:34 +00:00
|
|
|
*/
|
2012-03-25 09:29:37 +00:00
|
|
|
WINPTY_API int winpty_set_size(winpty_t *pc, int cols, int rows);
|
2012-01-27 17:05:34 +00:00
|
|
|
|
2013-12-06 14:32:23 +00:00
|
|
|
/*
|
|
|
|
* Toggle the console mode. If in console mode, no terminal escape sequences are send.
|
|
|
|
*/
|
|
|
|
WINPTY_API int winpty_set_console_mode(winpty_t *pc, int mode);
|
|
|
|
|
2012-01-27 17:05:34 +00:00
|
|
|
/*
|
2012-03-25 09:29:37 +00:00
|
|
|
* Closes the winpty.
|
2012-01-27 17:05:34 +00:00
|
|
|
*/
|
2012-03-25 09:29:37 +00:00
|
|
|
WINPTY_API void winpty_close(winpty_t *pc);
|
2012-01-09 08:56:55 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-03-25 09:29:37 +00:00
|
|
|
#endif /* WINPTY_H */
|