… | |
… | |
679 | ///////////////////////////////////////////////////////////////////////////// |
679 | ///////////////////////////////////////////////////////////////////////////// |
680 | // C API |
680 | // C API |
681 | |
681 | |
682 | #ifndef PTYTTY_NO_C_API |
682 | #ifndef PTYTTY_NO_C_API |
683 | |
683 | |
|
|
684 | typedef void *PTYTTY; |
|
|
685 | |
684 | #define DEFINE_METHOD(retval, name, args1, args2) \ |
686 | #define DEFINE_METHOD(retval, name, args1, args2) \ |
685 | extern "C" retval ptytty_ ## name args1 \ |
687 | extern "C" retval ptytty_ ## name args1 \ |
686 | { return ((struct ptytty *)ptytty)->name args2; } |
688 | { return ((struct ptytty *)ptytty)->name args2; } |
687 | |
689 | |
688 | DEFINE_METHOD(int,pty,(void *ptytty),) |
690 | DEFINE_METHOD(int,pty,(PTYTTY ptytty),) |
689 | DEFINE_METHOD(int,tty,(void *ptytty),) |
691 | DEFINE_METHOD(int,tty,(PTYTTY ptytty),) |
690 | DEFINE_METHOD(int,get,(void *ptytty),()) |
692 | DEFINE_METHOD(int,get,(PTYTTY ptytty),()) |
691 | DEFINE_METHOD(void,login,(void *ptytty, int cmd_pid, bool login_shell, const char *hostname),(cmd_pid,login_shell,hostname)) |
693 | DEFINE_METHOD(void,login,(PTYTTY ptytty, int cmd_pid, bool login_shell, const char *hostname),(cmd_pid,login_shell,hostname)) |
692 | |
694 | |
693 | DEFINE_METHOD(void,close_tty,(void *ptytty),()) |
695 | DEFINE_METHOD(void,close_tty,(PTYTTY ptytty),()) |
694 | DEFINE_METHOD(int,make_controlling_tty,(void *ptytty),()) |
696 | DEFINE_METHOD(int,make_controlling_tty,(PTYTTY ptytty),()) |
695 | DEFINE_METHOD(void,set_utf8_mode,(void *ptytty, int on),(on)) |
697 | DEFINE_METHOD(void,set_utf8_mode,(PTYTTY ptytty, int on),(on)) |
696 | |
698 | |
697 | #define DEFINE_STATIC(retval, name, args) \ |
699 | #define DEFINE_STATIC(retval, name, args) \ |
698 | extern "C" retval ptytty_ ## name args \ |
700 | extern "C" retval ptytty_ ## name args \ |
699 | { return ptytty::name args; } |
701 | { return ptytty::name args; } |
700 | |
702 | |
701 | DEFINE_STATIC(void,drop_privileges,()) |
703 | DEFINE_STATIC(void,drop_privileges,()) |
702 | DEFINE_STATIC(void,use_helper,()) |
704 | DEFINE_STATIC(void,use_helper,()) |
703 | DEFINE_STATIC(void,init,()) |
705 | DEFINE_STATIC(void,init,()) |
704 | |
706 | |
705 | DEFINE_STATIC(void *,create,()) |
707 | DEFINE_STATIC(PTYTTY ,create,()) |
706 | |
708 | |
707 | void ptytty_delete (void *ptytty) |
709 | void ptytty_delete (PTYTTY ptytty) |
708 | { |
710 | { |
709 | delete (struct ptytty *)ptytty; |
711 | delete (struct ptytty *)ptytty; |
710 | } |
712 | } |
711 | |
713 | |
712 | // send_fd, recv_fd not exposed |
714 | // send_fd, recv_fd not exposed |