亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? enhance.c

?? BCAST Implementation for NS2
?? C
?? 第 1 頁 / 共 2 頁
字號:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <errno.h>#include <signal.h>#include <locale.h>#include <unistd.h>#include <termios.h>#include <fcntl.h>#include <sys/termios.h>#include <sys/time.h>#include <sys/types.h>#include <sys/wait.h>#include <dirent.h>#if HAVE_SYSV_PTY#include <stropts.h>    /* System-V stream I/O */char *ptsname(int fd);int grantpt(int fd);int unlockpt(int fd);#endif#include "libtecla.h"/* * Pseudo-terminal devices are found in the following directory. */#define PTY_DEV_DIR "/dev/"/* * Pseudo-terminal controller device file names start with the following * prefix. */#define PTY_CNTRL "pty"/* * Pseudo-terminal slave device file names start with the following * prefix. */#define PTY_SLAVE "tty"/* * Specify the maximum suffix length for the control and slave device * names. */#define PTY_MAX_SUFFIX 10/* * Set the maximum length of the master and slave terminal device filenames, * including space for a terminating '\0'. */#define PTY_MAX_NAME (sizeof(PTY_DEV_DIR)-1 + \		      (sizeof(PTY_SLAVE) > sizeof(PTY_CNTRL) ? \		       sizeof(PTY_SLAVE) : sizeof(PTY_CNTRL))-1 \		      + PTY_MAX_SUFFIX + 1)/* * Set the maximum length of an input line. */#define PTY_MAX_LINE 4096/* * Set the size of the buffer used for accumulating bytes written by the * user's terminal to its stdout. */#define PTY_MAX_READ 1000/* * Set the amount of memory used to record history. */#define PTY_HIST_SIZE 10000/* * Set the timeout delay used to check for quickly arriving * sequential output from the application. */#define PTY_READ_TIMEOUT 100000    /* micro-seconds */static int pty_open_master(const char *prog, int *cntrl, char *slave_name);static int pty_open_slave(const char *prog, char *slave_name);static int pty_child(const char *prog, int slave, char *argv[]);static int pty_parent(const char *prog, int cntrl);static int pty_stop_parent(int waserr, int cntrl, GetLine *gl, char *rbuff);static GL_FD_EVENT_FN(pty_read_from_program);static int pty_write_to_fd(int fd, const char *string, int n);static void pty_child_exited(int sig);static int pty_master_readable(int fd, long usec);/*....................................................................... * Run a program with enhanced terminal editing facilities. * * Usage: *  enhance program [args...] */int main(int argc, char *argv[]){  int cntrl = -1;  /* The fd of the pseudo-terminal controller device */  int slave = -1;  /* The fd of the pseudo-terminal slave device */  pid_t pid;       /* The return value of fork() */  int status;      /* The return statuses of the parent and child functions */  char slave_name[PTY_MAX_NAME]; /* The filename of the slave end of the */                                 /*  pseudo-terminal. */  char *prog;      /* The name of the program (ie. argv[0]) *//* * Check the arguments. */  if(argc < 2) {    fprintf(stderr, "Usage: %s <program> [arguments...]\n", argv[0]);    return 1;  };/* * Get the name of the program. */  prog = argv[0];/* * If the user has the LC_CTYPE or LC_ALL environment variables set, * enable display of characters corresponding to the specified locale. */  (void) setlocale(LC_CTYPE, "");/* * If the program is taking its input from a pipe or a file, or * sending its output to something other than a terminal, run the * program without tecla. */  if(!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO)) {    if(execvp(argv[1], argv + 1) < 0) {      fprintf(stderr, "%s: Unable to execute %s (%s).\n", prog, argv[1],	      strerror(errno));      fflush(stderr);      _exit(1);    };  };/* * Open the master side of a pseudo-terminal pair, and return * the corresponding file descriptor and the filename of the * slave end of the pseudo-terminal. */  if(pty_open_master(prog, &cntrl, slave_name))    return 1;/* * Set up a signal handler to watch for the child process exiting. */  signal(SIGCHLD, pty_child_exited);/* * The above signal handler sends the parent process a SIGINT signal. * This signal is caught by gl_get_line(), which resets the terminal * settings, and if the application signal handler for this signal * doesn't abort the process, gl_get_line() returns NULL with errno * set to EINTR. Arrange to ignore the signal, so that gl_get_line() * returns and we have a chance to cleanup. */  signal(SIGINT, SIG_IGN);/* * We will read user input in one process, and run the user's program * in a child process. */  pid = fork();  if(pid < 0) {    fprintf(stderr, "%s: Unable to fork child process (%s).\n", prog,	    strerror(errno));    return 1;  };/* * Are we the parent? */  if(pid!=0) {    status = pty_parent(prog, cntrl);    close(cntrl);  } else {    close(cntrl); /* The child doesn't use the slave device */    signal(SIGCHLD, pty_child_exited);    if((slave = pty_open_slave(prog, slave_name)) >= 0) {      status = pty_child(prog, slave, argv + 1);      close(slave);    } else {      status = 1;    };  };  return status;}/*....................................................................... * Open the master side of a pseudo-terminal pair, and return * the corresponding file descriptor and the filename of the * slave end of the pseudo-terminal. * * Input/Output: *  prog  const char *  The name of this program. *  cntrl        int *  The file descriptor of the pseudo-terminal *                      controller device will be assigned tp *cntrl. *  slave_name  char *  The file-name of the pseudo-terminal slave device *                      will be recorded in slave_name[], which must have *                      at least PTY_MAX_NAME elements. * Output: *  return       int    0 - OK. *                      1 - Error. */static int pty_open_master(const char *prog, int *cntrl, char *slave_name){  char master_name[PTY_MAX_NAME]; /* The filename of the master device */  DIR *dir;                       /* The directory iterator */  struct dirent *file;            /* A file in "/dev" *//* * Mark the controller device as not opened yet. */  *cntrl = -1;/* * On systems with the Sys-V pseudo-terminal interface, we don't * have to search for a free master terminal. We just open /dev/ptmx, * and if there is a free master terminal device, we are given a file * descriptor connected to it. */#if HAVE_SYSV_PTY  *cntrl = open("/dev/ptmx", O_RDWR);  if(*cntrl >= 0) {/* * Get the filename of the slave side of the pseudo-terminal. */    char *name = ptsname(*cntrl);    if(name) {      if(strlen(name)+1 > PTY_MAX_NAME) {	fprintf(stderr, "%s: Slave pty filename too long.\n", prog);	return 1;      };      strcpy(slave_name, name);/* * If unable to get the slave name, discard the controller file descriptor, * ready to try a search instead. */    } else {      close(*cntrl);      *cntrl = -1;    };  } else {#endif/* * On systems without /dev/ptmx, or if opening /dev/ptmx failed, * we open one master terminal after another, until one that isn't * in use by another program is found. * * Open the devices directory. */    dir = opendir(PTY_DEV_DIR);    if(!dir) {      fprintf(stderr, "%s: Couldn't open %s (%s)\n", prog, PTY_DEV_DIR,	      strerror(errno));      return 1;    };/* * Look for pseudo-terminal controller device files in the devices * directory. */    while(*cntrl < 0 && (file = readdir(dir))) {      if(strncmp(file->d_name, PTY_CNTRL, sizeof(PTY_CNTRL)-1) == 0) {/* * Get the common extension of the control and slave filenames. */	const char *ext = file->d_name + sizeof(PTY_CNTRL)-1;	if(strlen(ext) > PTY_MAX_SUFFIX)	  continue;/* * Attempt to open the control file. */	strcpy(master_name, PTY_DEV_DIR);	strcat(master_name, PTY_CNTRL);	strcat(master_name, ext);	*cntrl = open(master_name, O_RDWR);	if(*cntrl < 0)	  continue;/* * Attempt to open the matching slave file. */	strcpy(slave_name, PTY_DEV_DIR);	strcat(slave_name, PTY_SLAVE);	strcat(slave_name, ext);      };    };    closedir(dir);#if HAVE_SYSV_PTY  };#endif/* * Did we fail to find a pseudo-terminal pair that we could open? */  if(*cntrl < 0) {    fprintf(stderr, "%s: Unable to find a free pseudo-terminal.\n", prog);    return 1;  };/* * System V systems require the program that opens the master to * grant access to the slave side of the pseudo-terminal. */#ifdef HAVE_SYSV_PTY  if(grantpt(*cntrl) < 0 ||     unlockpt(*cntrl) < 0) {    fprintf(stderr, "%s: Unable to unlock terminal (%s).\n", prog,	    strerror(errno));    return 1;  };#endif/* * Success. */  return 0;}/*....................................................................... * Open the slave end of a pseudo-terminal. * * Input: *  prog   const char *  The name of this program. *  slave_name   char *  The filename of the slave device. * Output: *  return        int    The file descriptor of the successfully opened *                       slave device, or < 0 on error. */static int pty_open_slave(const char *prog, char *slave_name){  int fd;  /* The file descriptor of the slave device *//* * Place the process in its own process group. In system-V based * OS's, this ensures that when the pseudo-terminal is opened, it * becomes the controlling terminal of the process. */  if(setsid() < 0) {    fprintf(stderr, "%s: Unable to form new process group (%s).\n", prog,	    strerror(errno));    return -1;  };/* * Attempt to open the specified device. */  fd = open(slave_name, O_RDWR);  if(fd < 0) {    fprintf(stderr, "%s: Unable to open pseudo-terminal slave device (%s).\n",	    prog, strerror(errno));    return -1;  };/* * On system-V streams based systems, we need to push the stream modules * that implement pseudo-terminal and termio interfaces. At least on * Solaris, which pushes these automatically when a slave is opened, * this is redundant, so ignore errors when pushing the modules. */#if HAVE_SYSV_PTY

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
18成人在线视频| 精品国产一区二区精华| 1000精品久久久久久久久| 不卡av在线免费观看| 中文字幕中文字幕一区二区 | 午夜精品久久久久久久99水蜜桃| 成人av在线看| 一区二区在线电影| 欧美一级片在线| 国产麻豆视频精品| 亚洲天堂福利av| 欧美一级xxx| 成人网男人的天堂| 亚洲成人一区在线| 久久久国产精品午夜一区ai换脸| 成人免费视频一区| 亚洲精品国产a久久久久久| 欧美精品日韩综合在线| 国产一区二区免费在线| 樱花草国产18久久久久| 在线综合+亚洲+欧美中文字幕| 韩国毛片一区二区三区| 亚洲人成网站在线| 日韩免费视频一区二区| 99r国产精品| 日韩成人av影视| 国产精品情趣视频| 欧美日韩电影一区| 成人免费毛片aaaaa**| 日韩电影免费在线| 亚洲日本在线a| 久久综合九色综合97婷婷| 91精品福利视频| 国产在线精品不卡| 偷窥国产亚洲免费视频| 成人欧美一区二区三区白人| 日韩一区二区在线看片| 色偷偷成人一区二区三区91 | 欧美精品在线一区二区三区| 国产一区二区三区在线观看精品| 夜色激情一区二区| 国产婷婷精品av在线| 91精品国产入口在线| 96av麻豆蜜桃一区二区| 久久精品国产亚洲aⅴ| 亚洲九九爱视频| 欧美国产1区2区| 久久影音资源网| 欧美一区二区三区人| 在线影院国内精品| 99国产欧美久久久精品| 国产一区 二区 三区一级| 日本不卡一二三| 亚洲福利视频导航| 一区av在线播放| 亚洲天堂a在线| 中文字幕视频一区二区三区久| 久久久精品tv| 久久久久久久久久久久电影| 日韩欧美区一区二| 欧美人动与zoxxxx乱| 色婷婷激情久久| 99精品欧美一区二区三区综合在线| 久久精品av麻豆的观看方式| 天堂va蜜桃一区二区三区| 亚洲国产一区二区三区青草影视 | 亚洲精品视频免费看| 日本一区二区三级电影在线观看 | 国产精品另类一区| 国产欧美日产一区| 国产女同互慰高潮91漫画| 国产喂奶挤奶一区二区三区| 精品少妇一区二区三区视频免付费| 欧美精品一二三区| 日韩三级免费观看| 欧美精品一区二区三区一线天视频| 精品少妇一区二区三区在线视频| 欧美一卡2卡三卡4卡5免费| 91精品国产综合久久精品性色 | av亚洲精华国产精华| 成人午夜视频在线| 不卡av在线网| 色香蕉久久蜜桃| 欧美猛男gaygay网站| 欧美一区二区视频网站| 日韩女优毛片在线| 欧美国产精品久久| 亚洲少妇中出一区| 午夜影院在线观看欧美| 蜜桃视频在线观看一区| 狠狠色丁香婷婷综合| 国产iv一区二区三区| 91老司机福利 在线| 在线影院国内精品| 日韩精品自拍偷拍| 国产精品久久久一区麻豆最新章节| 亚洲日本va在线观看| 丝袜脚交一区二区| 国产精品香蕉一区二区三区| 9l国产精品久久久久麻豆| 欧美亚州韩日在线看免费版国语版| 欧美精品亚洲一区二区在线播放| 欧美videos中文字幕| 中文字幕在线观看一区| 亚洲风情在线资源站| 国产一区二区在线看| 91麻豆swag| 欧美成人欧美edvon| 国产精品国产三级国产aⅴ原创| 亚洲综合另类小说| 久久成人久久鬼色| 色琪琪一区二区三区亚洲区| 欧美一级高清大全免费观看| 中日韩免费视频中文字幕| 五月婷婷综合网| 国产露脸91国语对白| 欧美午夜理伦三级在线观看| 久久久综合网站| 天天综合色天天综合色h| 成人午夜激情视频| 欧美一区二区不卡视频| 亚洲美女视频在线观看| 韩国精品一区二区| 欧美日韩国产另类不卡| 国产区在线观看成人精品| 亚洲国产乱码最新视频| 成人一区二区三区视频在线观看 | 国产一区二区剧情av在线| 在线观看国产精品网站| 国产清纯在线一区二区www| 亚洲1区2区3区视频| 波多野结衣一区二区三区 | 亚洲精品一线二线三线无人区| 中文字幕字幕中文在线中不卡视频| 老鸭窝一区二区久久精品| 欧美视频一区二区三区在线观看| 中文字幕国产一区二区| 麻豆精品久久精品色综合| 91社区在线播放| 国产欧美一区二区精品婷婷| 久久精品国产一区二区| 4438亚洲最大| 亚洲一区中文在线| 91热门视频在线观看| 国产色婷婷亚洲99精品小说| 九色porny丨国产精品| 777精品伊人久久久久大香线蕉| 亚洲精品综合在线| 99精品欧美一区二区三区小说| 久久精品夜色噜噜亚洲a∨| 精品亚洲porn| 精品久久国产老人久久综合| 午夜精品视频在线观看| 欧美在线观看视频一区二区三区| 国产精品久久久久影院亚瑟| 国产精品一区专区| 久久精品视频一区二区三区| 久久99在线观看| 日韩欧美成人激情| 日本不卡一区二区三区 | 日本韩国欧美在线| 中文字幕一区二区三区四区| 成人午夜私人影院| 综合久久久久久| 91麻豆免费视频| 亚洲狠狠丁香婷婷综合久久久| 97精品国产露脸对白| 亚洲你懂的在线视频| 色综合一区二区三区| 一区二区三区**美女毛片| 欧美亚洲精品一区| 午夜精品视频在线观看| 日韩午夜激情电影| 国产一区二区伦理片| 日本一二三不卡| 91视频精品在这里| 洋洋av久久久久久久一区| 欧美精品v国产精品v日韩精品 | 性做久久久久久| 制服丝袜中文字幕一区| 日韩av不卡一区二区| 精品精品国产高清a毛片牛牛 | 久久精品一级爱片| 成人黄色777网| 亚洲国产一区二区三区| 日韩欧美国产一区二区在线播放| 国产麻豆一精品一av一免费| 国产精品伦一区二区三级视频| 色天使色偷偷av一区二区| 日韩激情在线观看| 久久色.com| 色国产综合视频| 免费观看日韩电影| 欧美国产精品劲爆| 欧美日韩国产精品自在自线| 久久99久久久久久久久久久| 国产精品情趣视频| 在线不卡中文字幕| www.亚洲人| 麻豆专区一区二区三区四区五区|