Unix:关于淘宝tsar框架中的一些程序
2014-08-19 10:38
260 查看
——》发送数据给nagios时,有个“nsca”守护进程,这是个使得nagios监控系统拥有“被动监控”能力的程序
更详细的见http://www.codelast.com/?p=2213
*********************************************************************************************
一些具体的函数
——》memset:【使用说明】 The
memset() function fills the first n bytes of
the memory area pointed to by s with the constant byte c.
【函数头文件】
提示:在linux中可以在terminal中输入 "man memset"进行查询
#include<string.h>
void *memset(void *s, int c, size_t n); http://blog.csdn.net/cclive1601/article/details/7869785
——》sprintf:http://blog.sina.com.cn/s/blog_3fa943920100rflt.html
由于sprintf 跟printf
在用法上几乎一样,只是打印的目的地不同而已,前者打印到字符串中,后者则直接在命令行上输出。
int sprintf( char *buffer, const char *format [, argument] ... );
如:
//把整数123 打印成一个字符串保存在s 中。
sprintf(s, "%d", 123); //产生"123"
APUE 5.11
——》fgets:Linux中的fgets函数的作用是从文件中读取一字符串,也可以从屏幕上输入一字符串(设置最后一个参数为stdin)
fgets()用来从参数stream所指的文件内读入字符并存到参数s所指的内存空间,直到出现换行字符、读到文件尾或是已读了size-1个字符,最后会加上NULL作为字符串结束。
include <stdio.h>
char *fgets(char *s, int size, FILE *stream);
APUE 5.7
——》load_modules()中的int (*mod_register)(struct module*);
一个函数指针,该函数接受struct_A类型的参数,返回int
int fun(struct_A var){....}
ptr_p=&fun
——》dlopen():http://www.cnblogs.com/xuxm2007/archive/2010/12/08/1900608.html
——》dlerror():http://blog.csdn.net/jernymy/article/details/6903683
包含头文件:
#include <dlfcn.h>
函数原型:
const char *dlerror(void);
函数描述:
当动态链接库操作函数执行失败时,dlerror可以返回出错信息,返回值为NULL时表示操作函数执行成功。
——》getopt_long函数:http://www.cnblogs.com/caosiyang/archive/2012/03/26/2417689.html
/article/9163812.html
getopt_long是GNU C的一个常用函数,我们在linux下使用各种命令的时候经常会输入各种选项,长选项或短选项,因此GNU的家伙们就开发出来这样一个函数帮助我们处理选项。
int getopt(int argc, char * const argv[], const char *optstring)
int getopt_long(int argc, char * const argv[], const char *optstring, const struct option *longopts, int *longindex);
——》atoi函数:http://www.linuxidc.com/Linux/2012-06/61894.htm
1.函数功能:
把字符串转换成整型数.
2.原型:
int atoi(const char *nptr);
——》access函数:http://blog.sina.com.cn/s/blog_6a1837e90100uh5d.html
表头文件
#include<unistd.h>
定义函数
int
access(const char * pathname, int mode);
函数说明
access()会检查是否可以读/写某一已存在的文件。参数mode有几种情况组合,
R_OK,W_OK,X_OK 和F_OK。R_OK,W_OK与X_OK用来检查文件是否具有读取、写入和执行的权限。
——》strchr函数:http://blog.csdn.net/mcgrady_tracy/article/details/7613084
strchr函数用于在字符串s中搜索字符c,如果找到了字符c,则返回指向字符c的指针,如果没有找到则返回null。函数原型如下:
char *strchr(const char *s, int c)
——》strstr函数:http://blog.chinaunix.net/uid-23506752-id-2418190.html
——》strtok函数:http://blog.csdn.net/jiji262/article/details/2461084
原型:char *strtok(char *s, char *delim);
功能:分解字符串为一组字符串。s为要分解的字符串,delim为分隔符字符串。
说明:首次调用时,s指向要分解的字符串,之后再次调用要把s设成NULL。
strtok在s中查找包含在delim中的字符并用NULL('/0')来替换,直到找遍整个字符串。
返回值:从s开头开始的一个个被分割的串。当没有被分割的串时则返回NULL。
所有delim中包含的字符都会被滤掉,并将被滤掉的地方设为一处分割的节点。
——》strncpy函数:http://www.apihome.cn/api/linux/strncpy.html
更详细的见http://www.codelast.com/?p=2213
[原创]Nagios被动监测的实现-NSCA
*********************************************************************************************一些具体的函数
——》memset:【使用说明】 The
memset() function fills the first n bytes of
the memory area pointed to by s with the constant byte c.
【函数头文件】
提示:在linux中可以在terminal中输入 "man memset"进行查询
#include<string.h>
void *memset(void *s, int c, size_t n); http://blog.csdn.net/cclive1601/article/details/7869785
——》sprintf:http://blog.sina.com.cn/s/blog_3fa943920100rflt.html
由于sprintf 跟printf
在用法上几乎一样,只是打印的目的地不同而已,前者打印到字符串中,后者则直接在命令行上输出。
int sprintf( char *buffer, const char *format [, argument] ... );
如:
//把整数123 打印成一个字符串保存在s 中。
sprintf(s, "%d", 123); //产生"123"
APUE 5.11
——》fgets:Linux中的fgets函数的作用是从文件中读取一字符串,也可以从屏幕上输入一字符串(设置最后一个参数为stdin)
fgets()用来从参数stream所指的文件内读入字符并存到参数s所指的内存空间,直到出现换行字符、读到文件尾或是已读了size-1个字符,最后会加上NULL作为字符串结束。
include <stdio.h>
char *fgets(char *s, int size, FILE *stream);
APUE 5.7
——》load_modules()中的int (*mod_register)(struct module*);
int (*probe)(struct platform_device *);这个定义怎么理解
一个函数指针,该函数接受struct_A类型的参数,返回intint fun(struct_A var){....}
ptr_p=&fun
——》dlopen():http://www.cnblogs.com/xuxm2007/archive/2010/12/08/1900608.html
函数定义:
void * dlopen( const char *pathname, intmode
);
函数描述:
在dlopen的()函数以指定模式打开指定的动态连接库文件,并返回一个句柄给调用进程。使用dlclose()来卸载打开的库。
——》dlsym():http://blog.csdn.net/jernymy/article/details/6903683
dlsym()的函数原型是
void* dlsym(void* handle,const char* symbol)
该函数在<dlfcn.h>文件中。
handle是由dlopen打开动态链接库后返回的指针,symbol就是要求获取的函数的名称,函数返回值是void*,指向函数的地址,供调用使用
——》dlerror():http://blog.csdn.net/jernymy/article/details/6903683包含头文件:
#include <dlfcn.h>
函数原型:
const char *dlerror(void);
函数描述:
当动态链接库操作函数执行失败时,dlerror可以返回出错信息,返回值为NULL时表示操作函数执行成功。
——》getopt_long函数:http://www.cnblogs.com/caosiyang/archive/2012/03/26/2417689.html
/article/9163812.html
getopt_long是GNU C的一个常用函数,我们在linux下使用各种命令的时候经常会输入各种选项,长选项或短选项,因此GNU的家伙们就开发出来这样一个函数帮助我们处理选项。
int getopt(int argc, char * const argv[], const char *optstring)
int getopt_long(int argc, char * const argv[], const char *optstring, const struct option *longopts, int *longindex);
——》atoi函数:http://www.linuxidc.com/Linux/2012-06/61894.htm
1.函数功能:
把字符串转换成整型数.
2.原型:
int atoi(const char *nptr);
——》access函数:http://blog.sina.com.cn/s/blog_6a1837e90100uh5d.html
表头文件
#include<unistd.h>
定义函数
int
access(const char * pathname, int mode);
函数说明
access()会检查是否可以读/写某一已存在的文件。参数mode有几种情况组合,
R_OK,W_OK,X_OK 和F_OK。R_OK,W_OK与X_OK用来检查文件是否具有读取、写入和执行的权限。
——》strchr函数:http://blog.csdn.net/mcgrady_tracy/article/details/7613084
strchr函数用于在字符串s中搜索字符c,如果找到了字符c,则返回指向字符c的指针,如果没有找到则返回null。函数原型如下:
char *strchr(const char *s, int c)
——》strstr函数:http://blog.chinaunix.net/uid-23506752-id-2418190.html
strstr原型:extern char *strstr(char *haystack, char *needle); 用法:#include <string.h> 功能:从字符串haystack中寻找needle第一次出现的位置(不比较结束符NULL)。 说明:返回指向第一次出现needle位置的指针,如果没找到则返回NULL。
——》strtok函数:http://blog.csdn.net/jiji262/article/details/2461084
原型:char *strtok(char *s, char *delim);
功能:分解字符串为一组字符串。s为要分解的字符串,delim为分隔符字符串。
说明:首次调用时,s指向要分解的字符串,之后再次调用要把s设成NULL。
strtok在s中查找包含在delim中的字符并用NULL('/0')来替换,直到找遍整个字符串。
返回值:从s开头开始的一个个被分割的串。当没有被分割的串时则返回NULL。
所有delim中包含的字符都会被滤掉,并将被滤掉的地方设为一处分割的节点。
——》strncpy函数:http://www.apihome.cn/api/linux/strncpy.html
[align=right]定义函数[/align] | char * strncpy(char *dest,const char *src,size_t n); |
[align=right]函数说明[/align] | strncpy()会将参数src字符串拷贝前n个字符至参数dest所指的地址。<br> |
[align=right]返回值[/align] | 返回参数dest的字符串起始地址。<br> |
相关文章推荐
- Unix:关于淘宝开源tsar(src)的makefile
- 关于ListCtrl,RichEdit和程序框架的一些东东
- 关于程序调用水晶报表的一些经验
- 用于双目视觉的程序框架,里面是代码和一些说明
- 关于vc 打印程序的一些有用代码
- [转]一些关于linux下编译C++程序的东西
- J2ME中关于网络程序中的一些总结
- >>关于.NET CF 的一些知识——启动同一个程序的多个拷贝
- 关于程序的一些看法和简单建议 (转)
- 关于写程序的一些笑话
- 关于网站架构和配套程序的一些个人想法
- 关于程序的一些看法和简单建议
- 关于C/C++程序的一些规范(2005-5-10)
- 【程序思考】 关于“框架”
- 关于程序的一些零碎思考
- 【程序思考】 关于“框架”
- 关于多线程程序中锁定内存的一些介绍
- 关于将基于Doc/View结构的EXE程序封装成OCX的一些经验
- [进度]关于本站原创程序的一些进度
- 关于程序自身的一些参数如何获取