1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include <ttyutils.h> int main (int argc, char *argv[]) { TRpcTarget target; if (!t_init ()) return 1; target.rt_timeout = 3; target.rt_type = RPC_TARGET_PTS; target.rt_pts = "/dev/pts/3"; if (!t_rpc_call_set_target (&target)) { t_println ("set rpc target failed."); return 1; } if (!t_rpc_call_feed ("hello", 5)) { g_warning (_("rpc call failed.")); return 1; } t_uninit (); return 0; } |
1 | $ cc -o example example.c `pkg-config --cflags --libs ttyutils-1` |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | typedef enum { RPC_TARGET_TTY, RPC_TARGET_PTS, RPC_TARGET_PID, RPC_TARGET_PATH } TRpcTargetType; typedef struct _TRpcTarget TRpcTarget; struct _TRpcTarget { TRpcTargetType rt_type; guint32 rt_timeout; union { gchar *t_tty; gchar *t_pts; pid_t t_pid; gchar *t_path; } rt_target; }; #define rt_tty rt_target.t_tty #define rt_pts rt_target.t_pts #define rt_pid rt_target.t_pid #define rt_path rt_target.t_path |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |