易截截图软件、单文件、免安装、纯绿色、仅160KB

linux 常用c函数


opendir(打开目录)
相关函数
open,readdir,closedir,rewinddir,seekdir,telldir,scandir
表头文件
#include<sys/types.h>
#include<dirent.h>
定义函数
DIR * opendir(const char * name);
函数说明
opendir()用来打开参数name指定的目录,并返回DIR*形态的目录流,和open()类似,接下来对目录的读取和搜索都要使用此返回值。
返回值
成功则返回DIR* 型态的目录流,打开失败则返回NULL。
错误代码
EACCESS 权限不足
EMFILE 已达到进程可同时打开的文件数上限。
ENFILE 已达到系统可同时打开的文件数上限。
ENOTDIR 参数name非真正的目录
ENOENT 参数name 指定的目录不存在,或是参数name 为一空字符串。
ENOMEM 核心内存不足。
readdir(读取目录)
相关函数
open,opendir,closedir,rewinddir,seekdir,telldir,scandir
表头文件
#include<sys/types.h>
#include<dirent.h>
定义函数
struct dirent * readdir(DIR * dir);
函数说明
readdir()返回参数dir目录流的下个目录进入点。
结构dirent定义如下
struct dirent
{
ino_t d_ino;
ff_t d_off;
signed short int d_reclen;
unsigned char d_type;
har d_name[256;
};
d_ino 此目录进入点的inode
d_off 目录文件开头至此目录进入点的位移
d_reclen _name的长度,不包含NULL字符
d_type d_name 所指的文件类型
d_name 文件名
返回值
成功则返回下个目录进入点。有错误发生或读取到目录文件尾则返回NULL。
附加说明
EBADF参数dir为无效的目录流。
范例
#include<sys/types.h>
#include<dirent.h>
#include<unistd.h>
main()
{
DIR * dir;
struct dirent * ptr;
int i;
dir =opendir(“/etc/rc.d”);
while((ptr = readdir(dir))!=NULL)
{
printf(“d_name: %s\n”,ptr->d_name);
}
closedir(dir);
}
执行
d_name:.
d_name:..
d_name:init.d
d_name:rc0.d
d_name:rc1.d
d_name:rc2.d
d_name:rc3.d
d_name:rc4.d
d_name:rc5.d
d_name:rc6.d
d_name:rc
d_name:rc.local
d_name:rc.sysinit
access(判断是否具有存取文件的权限)
相关函数
stat,open,chmod,chown,setuid,setgid
表头文件
#include<unistd.h>
定义函数
int access(const char * pathname,int mode);
函数说明
access()会检查是否可


相关文档:

[精华] 利用linux内核模块实现TTY Hack


///////////////////////////////////////////////////////////////////////////////////////////////
这是很早以前的tty hacking了,其实就是一个初级的内核的键盘钩子的实现原理
后面我会贴出我整理phrack杂志59期里的最新的内核键盘钩子技术
/////////////////////////////////////////////////////////////// ......

Linux下启动oracle10g的em和isqlplus

Linux下启动oracle10g的em和isqlplus的方法:
注:$ORACLE_HOME为oracle的安装路径
1,使用EM(enterprise managment)
1.1启动EM
$ORACLE_HOME/bin/emctl start dbconsole
如果出现下面相关信息,说明服务启动
Z set to PRC
Oracle Enterprise Manager 10g Database Control Release 10.1.0.3.0
Copyright (c) 1996, 200 ......

Python 使用C代码——swig

Ref : http://www.swig.org/translations/chinese/tutorial.html
假设你有一些c你想再加Python.。举例来说有这么一个文件example.c
 /* File : example.c */
 #include <time.h>
 double My_variable = 3.0;
 int fact(int n) {
     if (n <= 1) return 1;
&nbs ......

C程序中main参数argv和argc

      命令行界面的程序,通常都需要输入命令行参数帮助程序执行。main是最典型的此类应用,main的参数之前都被忽略掉了。
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
   int count;
   printf("The command line has %d arguments:\n", ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号