2012-01-27 17:05:34 +00:00
|
|
|
#ifndef PCONSOLE_H
|
|
|
|
#define PCONSOLE_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-01-27 17:05:34 +00:00
|
|
|
#ifdef PCONSOLE
|
|
|
|
#define PCONSOLE_API __declspec(dllexport)
|
2012-01-09 08:56:55 +00:00
|
|
|
#else
|
2012-01-27 17:05:34 +00:00
|
|
|
#define PCONSOLE_API __declspec(dllimport)
|
2012-01-09 08:56:55 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-01-27 17:05:34 +00:00
|
|
|
typedef struct pconsole_s pconsole_t;
|
2012-01-09 08:56:55 +00:00
|
|
|
|
2012-01-27 17:05:34 +00:00
|
|
|
/*
|
|
|
|
* pconsole API.
|
|
|
|
*/
|
2012-01-09 08:56:55 +00:00
|
|
|
|
2012-01-27 17:05:34 +00:00
|
|
|
/*
|
|
|
|
* Starts a new pconsole instance with the given size.
|
|
|
|
*/
|
|
|
|
PCONSOLE_API pconsole_t *pconsole_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-02-10 10:09:38 +00:00
|
|
|
* agent will flush and close the data pipe.
|
2012-01-27 17:05:34 +00:00
|
|
|
*/
|
2012-02-10 10:09:38 +00:00
|
|
|
PCONSOLE_API int pconsole_start_process(pconsole_t *pc,
|
2012-02-20 09:23:46 +00:00
|
|
|
const wchar_t *appname,
|
2012-01-27 18:08:21 +00:00
|
|
|
const wchar_t *cmdline,
|
|
|
|
const wchar_t *cwd,
|
2012-02-20 09:23:46 +00:00
|
|
|
const wchar_t *env);
|
2012-01-09 08:56:55 +00:00
|
|
|
|
2012-02-10 10:09:38 +00:00
|
|
|
PCONSOLE_API int pconsole_get_exit_code(pconsole_t *pc);
|
2012-01-27 17:05:34 +00:00
|
|
|
|
2012-03-14 05:15:02 +00:00
|
|
|
/* TODO: Not implemented. Should it be? */
|
2012-02-10 10:09:38 +00:00
|
|
|
PCONSOLE_API int pconsole_flush_and_close(pconsole_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-02-10 10:09:38 +00:00
|
|
|
PCONSOLE_API HANDLE pconsole_get_data_pipe(pconsole_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-02-10 10:09:38 +00:00
|
|
|
PCONSOLE_API int pconsole_set_size(pconsole_t *pc, int cols, int rows);
|
2012-01-27 17:05:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Closes the pconsole.
|
|
|
|
*/
|
2012-02-10 10:09:38 +00:00
|
|
|
PCONSOLE_API void pconsole_close(pconsole_t *pc);
|
2012-01-09 08:56:55 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-01-27 17:05:34 +00:00
|
|
|
#endif /* PCONSOLE_H */
|