ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libptytty/src/c-api.C
Revision: 1.7
Committed: Mon May 24 13:53:53 2021 UTC (5 years, 3 months ago) by sf-exg
Content type: text/plain
Branch: MAIN
Changes since 1.6: +1 -1 lines
Log Message:
Rename and document the macro to disable the C api

File Contents

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