随笔分类 -  Linux程序设计(红皮经典书)

看书的学习记录
5.5.3使用terminfo功能标志
摘要:当使用terminfo时,需要做的第一件事就是调用函数setupterm来设置终端类型。这将为当前的终端类型初始化一个TERMINAL结构。然后,你就可以查看当前终端的功能标志并使用他们的功能了。 #include <term.h> int setupterm(char *term, in fd, 阅读全文
posted @ 2016-03-31 15:42 邶风 阅读(1451) 评论(0) 推荐(0)
5.4.1 termios结构,关闭回显功能,一键入字符fgetc立刻返回,不用按下回车键
摘要:Linux提供了一组编程接口,用来控制终端驱动程序的行为。这样我们可以更精细的来控制终端。 例如: 回显:允许控制字符的回显,例如读取密码时。 使用termios结构的密码程序 #include <stdio.h>#include <termios.h>#include <unistd.h> #de 阅读全文
posted @ 2016-03-30 17:12 邶风 阅读(1075) 评论(0) 推荐(0)
5.2与终端进行对话
摘要:Linux提供了一个特殊的设备 /dev/tty ,该设备始终是指向当前终端或者当前的登录会话。 FILE* output = fopen("/dev/tty", "w"); //向终端写入字符串 fprintf(output, "%s\n", "world"); FILE* input = fop 阅读全文
posted @ 2016-03-30 14:19 邶风 阅读(228) 评论(0) 推荐(0)
5.1对终端进行读写
摘要:几个小知识点: 字符串数组作为参数。 fileno(stdout)的使用。 标准输出是否被重定向了 isatty( fileno(stdout) ); 回车符的过滤方法。 #include <stdio.h>#include <stdlib.h> char *menu[] = { "a add", 阅读全文
posted @ 2016-03-25 15:32 邶风 阅读(285) 评论(0) 推荐(0)
4.8资源和限制
摘要:#include <stdio.h>#include <stdlib.h>#include <math.h>#include <sys/time.h>#include <sys/resource.h>#include <sys/types.h>#include <unistd.h> static v 阅读全文
posted @ 2016-03-24 18:02 邶风 阅读(302) 评论(0) 推荐(0)
4.7日志
摘要:简单的几个函数的使用方法: http://blog.csdn.net/ixidof/article/details/5961621 这几个函数的使用比较简单。 手动测试下代码。 我的系统是ubuntu 12.04 修改日志的配置文件 /etc/rsyslog.d/50-default.conf us 阅读全文
posted @ 2016-03-24 14:29 邶风 阅读(167) 评论(0) 推荐(0)