| 1 |
ayin |
1.1 |
// This file is part of libptytty. Do not make local modifications. |
| 2 |
|
|
// http://software.schmorp.de/pkg/libptytty |
| 3 |
|
|
|
| 4 |
|
|
/*----------------------------------------------------------------------* |
| 5 |
|
|
* File: c-api.C |
| 6 |
|
|
*----------------------------------------------------------------------* |
| 7 |
|
|
* |
| 8 |
|
|
* All portions of code are copyright by their respective author/s. |
| 9 |
|
|
* Copyright (c) 2005 Marc Lehmann <pcg@goof.com> |
| 10 |
|
|
* |
| 11 |
|
|
* This program is free software; you can redistribute it and/or modify |
| 12 |
|
|
* it under the terms of the GNU General Public License as published by |
| 13 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
| 14 |
|
|
* (at your option) any later version. |
| 15 |
|
|
* |
| 16 |
|
|
* This program is distributed in the hope that it will be useful, |
| 17 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
|
|
* GNU General Public License for more details. |
| 20 |
|
|
* |
| 21 |
|
|
* You should have received a copy of the GNU General Public License |
| 22 |
|
|
* along with this program; if not, write to the Free Software |
| 23 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 24 |
|
|
*---------------------------------------------------------------------*/ |
| 25 |
|
|
|
| 26 |
sf-exg |
1.2 |
#include "config.h" |
| 27 |
ayin |
1.1 |
|
| 28 |
|
|
#include "ptytty.h" |
| 29 |
|
|
|
| 30 |
|
|
///////////////////////////////////////////////////////////////////////////// |
| 31 |
|
|
// C API |
| 32 |
|
|
|
| 33 |
|
|
#ifndef PTYTTY_NO_C_API |
| 34 |
|
|
|
| 35 |
|
|
typedef void *PTYTTY; |
| 36 |
|
|
|
| 37 |
|
|
#define DEFINE_METHOD(retval, name, args1, args2) \ |
| 38 |
|
|
extern "C" retval ptytty_ ## name args1 \ |
| 39 |
|
|
{ return ((struct ptytty *)ptytty)->name args2; } |
| 40 |
|
|
|
| 41 |
|
|
DEFINE_METHOD(int,pty,(PTYTTY ptytty),) |
| 42 |
|
|
DEFINE_METHOD(int,tty,(PTYTTY ptytty),) |
| 43 |
|
|
DEFINE_METHOD(int,get,(PTYTTY ptytty),()) |
| 44 |
|
|
DEFINE_METHOD(void,login,(PTYTTY ptytty, int cmd_pid, int login_shell, const char *hostname),(cmd_pid,login_shell,hostname)) |
| 45 |
|
|
|
| 46 |
|
|
DEFINE_METHOD(void,close_tty,(PTYTTY ptytty),()) |
| 47 |
|
|
DEFINE_METHOD(int,make_controlling_tty,(PTYTTY ptytty),()) |
| 48 |
|
|
DEFINE_METHOD(void,set_utf8_mode,(PTYTTY ptytty, int on),(on)) |
| 49 |
|
|
|
| 50 |
|
|
#define DEFINE_STATIC(retval, name, args) \ |
| 51 |
|
|
extern "C" retval ptytty_ ## name args \ |
| 52 |
|
|
{ return ptytty::name args; } |
| 53 |
|
|
|
| 54 |
|
|
DEFINE_STATIC(void,drop_privileges,()) |
| 55 |
|
|
DEFINE_STATIC(void,use_helper,()) |
| 56 |
|
|
DEFINE_STATIC(void,sanitise_stdfd,()) |
| 57 |
|
|
DEFINE_STATIC(void,init,()) |
| 58 |
|
|
|
| 59 |
|
|
DEFINE_STATIC(PTYTTY,create,()) |
| 60 |
|
|
|
| 61 |
|
|
extern "C" void ptytty_delete (PTYTTY ptytty) |
| 62 |
|
|
{ |
| 63 |
|
|
delete (struct ptytty *)ptytty; |
| 64 |
|
|
} |
| 65 |
|
|
|
| 66 |
|
|
// send_fd, recv_fd not exposed |
| 67 |
|
|
|
| 68 |
|
|
#endif |
| 69 |
|
|
|