#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
int main()
{
struct termios info;
int rv;
rv = tcgetattr( 0, &info ); /* read values from driver */
if ( rv == -1 ){
perror( "tcgetattr");
exit(1);
}
if ( info.c_lflag & ECHO )
printf(" echo is on , since its bit is 1
");
else
printf(" echo is OFF, since its bit is 0
");
return 0;
}
功能:用来实现显示文件信息
- finfo_buffer — 返回一个字符串缓冲区的信息
- finfo_close — 关闭 fileinfo 资源
- finfo_file — 返回一个文件的信息
- finfo_open — 创建一个 fileinfo 资源
- finfo_set_flags — 设置 libmagic 配置选项
- mime_content_type — 检测文件的 MIME 类型(已废弃)
例子
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
void show_stat_info(char *, struct stat *);
int main(int argc, char *argv[])
{
struct stat info;
if (argc>1)
{
if( stat(argv[1], &info) != -1 ){
show_stat_info( argv[1], &info );
return 0;
}
else
perror(argv[1]);
}
return 1;
}
void show_stat_info(char *fname, struct stat *buf)
{
printf(" mode: %o
", buf->st_mode);
printf(" links: %d
", buf->st_nlink);
printf(" user: %d
", buf->st_uid);
printf(" group: %d
", buf->st_gid);
printf(" size: %d
", (int)buf->st_size);
printf("modtime: %d
", (int)buf->st_mtime);
printf(" name: %s
", fname );
}
filesize() 函数返回指定文件的大小
若成功,则返回文件大小的字节数。若失败,则返回 false 并生成一条 E_WARNING 级的错误
语法
filesize(filename)
参数 | 描述 |
---|---|
filename | 必需。规定要检查的文件。 |
例子
#include <stdio.h>
#include <sys/stat.h>
int main()
{
struct stat infobuf;
if ( stat( "/etc/passwd", &infobuf) == -1 )
perror("/etc/passwd");
else
printf(" The size of /etc/passwd is %d
", infobuf.st_size );
}
setecho用来改变输入指令是否可见
set echo off; //显示start启动的脚本中的每个sql命令,缺省为on
set echo on //设置运行命令是是否显示语句
man