
c
Brickie-liu
这个作者很懒,什么都没留下…
展开
-
linux 内核自组报文发送 3.10版本
这个问题纠结了一个星期,终于搞定了。原创 2014-04-11 17:10:52 · 1833 阅读 · 0 评论 -
程序过程流 调试信息代码 --1
//写入一个固定的文件里#define DEBUG(str, args...) \{\FILE *tfp;\if ((tfp = fopen("./debug.log", "a")) != NULL)\{\fprintf(tfp, "%s, %d: ", __FUNCTION__, __LINE__);\fprintf(tfp, str, ##args);\fcl翻译 2014-03-24 11:51:05 · 687 阅读 · 0 评论 -
程序过程流 调试信息代码 --2
inline void g_debug_set(int module){ g_debug_switch |= module;}inline void g_debug_clear(int module){ g_debug_switch &= ~module;}inline char *g_debug_module_name(int module){ swi...原创 2014-03-24 11:52:57 · 570 阅读 · 0 评论 -
c 语言模块接口函数在main之前注册
在工程中有多个模块,每个模块功能的自己的初始化函数。如何在程序启动的时候不经过main调用初始化各个模块?原创 2016-05-19 14:50:28 · 944 阅读 · 0 评论 -
多线程变量 pthread_key_t 自查文档
相关接口:#include <pthread.h>// init_routine函数在多线程环境中只执行一次int pthread_once(pthread_once_t *once_control, void (*init_routine)(void));pthread_once_t once_control = PTHREAD_ONCE_INIT; //新建 key,一个key只能执行一转载 2016-05-19 16:29:32 · 585 阅读 · 0 评论 -
linux 程序动态调用.so文件中的函数
相关接口:#include <dlfcn.h>void *dlopen(const char *filename, int flag);char *dlerror(void);void *dlsym(void *handle, const char *symbol);int dlclose(void *handle);eg: dlapi.c/*[root@localhost eg]# gcc原创 2016-05-19 16:50:38 · 2185 阅读 · 0 评论 -
linux tcp select 超时 自查文档
tcp.c#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <fcntl.h>#inclu原创 2016-05-19 17:06:30 · 3904 阅读 · 0 评论 -
c/c++原子操作 接口函数 自查文档
C:type __sync_fetch_and_add (type *ptr, type value);type __sync_fetch_and_sub (type *ptr, type value);type __sync_fetch_and_or (type *ptr, type value);type __sync_fetch_and_and (type *ptr, type valu原创 2016-05-19 17:42:35 · 841 阅读 · 0 评论 -
多线程变量 __thread 自查文档
相关接口: __thread 修饰符The __thread specifier may be applied to any global, file-scoped static, function-scoped static, or static data member of a class. It may not be applied to block-scoped automatic or转载 2016-05-19 16:34:26 · 603 阅读 · 0 评论 -
c 语言进度条,获取终端大小
////////////////////////进度条显示///////////////////////////////////*#include <stdio.h>#include <string.h>void displayProgress(int progress){ int k = 0; for (k=0; k<106; k++)转载 2016-06-28 16:01:12 · 2039 阅读 · 0 评论 -
读取CSV文件内容-笔记
1、每一次只能读取同一种数据类型,不能读取字符串。 2、第次读取会返回一个 CSV数据结构,有源数据和二维数组,行列数信息 3、可以转换二维数组,但总大小不能变原创 2017-11-22 13:51:10 · 3520 阅读 · 0 评论 -
致命错误:libconfig.h++:没有那个文件或目录
centosyum install libconfig libconfig-develubunto sudo apt-get install libconfig libconfig++-dev libconfig-dev使用样例: http://www.cnblogs.com/dj0325/p/9197215.html官网 https://hyperrealm.github...翻译 2018-08-09 11:32:55 · 3997 阅读 · 0 评论 -
std::ref 作用
#include <functional>#include <iostream>void f(int& n1, int& n2, int& n3){ std::cout << "In function: " << n1 << ' ' << n2 <翻译 2018-08-01 22:00:21 · 3088 阅读 · 0 评论 -
c 性能评测工具
性能评测工具gprof+kprof+gprof2dot.pyGprof是GNU gnu binutils工具之一,默认情况下linux系统当中都带有这个工具。编译时添加 -pg 选项程序结束时生成 gmon.out (是循环程序 ctrl+z 结束)生成分析报告 gprof –b 二进制程序 gmon.out >report.txthttps://...原创 2018-08-07 14:25:11 · 368 阅读 · 0 评论 -
虚函数调用
#include <vector>#include <string>#include <iostream>using namespace std;class A{public: virtual void func(int i=1){ cout<<"A->"<<i<<end翻译 2018-10-01 20:56:23 · 375 阅读 · 0 评论 -
参数传递和返回值,并不进行类拷贝
#include <vector>#include <string>#include <iostream>using namespace std;class Test{public: static int i; Test(){ i++; cout<<i<<endl; }...翻译 2018-10-01 20:58:34 · 200 阅读 · 0 评论 -
ping 测试程序
#include #include #include #include #include #include //ip#include //tcp#include #include #include #include struct hc_icmp_packet{ struct icmphdr head; char * data[32];};u_short原创 2014-03-24 11:17:54 · 783 阅读 · 0 评论 -
linux 动态调用 .so 库文件中的函数
使用字符串函数名在linux环境下动态调用 .so库中函数翻译 2016-05-05 17:17:28 · 3006 阅读 · 0 评论 -
Linux协议栈报文收发流程记录
RX流程1. 非NAPI的RXdriver的isr调用eth_type_trans //确定skb->pkt_type和skb->protocoldriver的isr调用netif_rx //可查看返回值,NET_RX_DROP表示丢包,__skb_queue_tail(&queue->input_pkt_queue, skb); //input_pkt_queue最大值为netd转载 2014-04-07 12:26:09 · 1765 阅读 · 0 评论 -
setitimer设置定时器测试---2
#include #include #include #include #include int n = 0;void operate(int sig) /* 定时事件代码 */{ printf("do operate! n=%d\n",n++);}void main(){ struct itimerval value; value.it_val转载 2014-03-24 17:50:32 · 696 阅读 · 0 评论 -
setitimer设置定时器测试---1
/*我们在使用signal和时钟相关的结构体之前,需要包含这两个头文件*/#include #include /*声明信号处理函数,这个函数是在进程收到信号的时候调用就可以了*/#include #include #include static void sig_handler(int signo);long lastsec,countsec; /*这两个变量分别用来保存上一秒转载 2014-03-24 17:49:03 · 795 阅读 · 0 评论 -
hash key list 哈希表测试(对tcp fragment报文建立会话信息生成哈希表,老化)
#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #原创 2014-03-24 17:29:06 · 1173 阅读 · 0 评论 -
出接口snat配置和配置恢复
系统启动调用脚本:oldeth=`sed -n '1,1p' /usr/config/.fit_snat_eth.conf` #oldeth先读取老的配置,if [ -z $oldeth ];then #没有配置默认oldeth=vlan409原创 2014-03-12 14:37:45 · 983 阅读 · 0 评论 -
http 重定向 302报文
我这里的重定向环境是对客户端的请求直接截断重定向到其他页面。以太头和Ip头想应数据对调。Tcp头flags标记和序号问题。主要问题数据内容主要的就两条:"HTTP/1.1 302 Moved Temporarily""Location: 路径"一、以太头结构在帧结构里我用到的有MAC源和目的地址,以太类型。至于802.1Q标签,如果加了,对...原创 2013-12-24 11:03:33 · 17563 阅读 · 1 评论 -
c http报文头字段内容解析小函数
#include #include #include #define ABS(x) ((x)?(x):(x))#define SET_TMP_END(tmpc,tmpp,src) {(tmpc)=*(src);(tmpp)=(src);*(src)='\0';}#define RESTOR_TMP_END(tmpc,tmpp) {*(tmpp)=(tmpc);}/*假设为原创 2013-12-09 15:01:29 · 4240 阅读 · 0 评论 -
linux 正则应用例子。
#include #include #include #include int main(int argc, char** argv){ regex_t one_t; const char * pRegex = "[0-9]"; int cflags = REG_EXTENDED;原创 2013-12-02 17:19:49 · 692 阅读 · 0 评论 -
内存池 实现源码--版本三
实现长度不固定 ,可分配,可回收,只用于学习,性能太差,分配大小时查找使用的是链式,下个版本收为红黑树查找list.h// Copyright 2012 Tilera Corporation. All Rights Reserved.//// The source code contained or described herein and all document原创 2014-12-05 22:03:36 · 607 阅读 · 0 评论 -
memcpy 优化源码
/*主要是利用了,系统一次可处理最大位file:///F:/utils/memcpy%E4%BC%98%E5%8C%96-src/memcpy%E7%9A%84%E4%BC%98%E5%8C%96%20-%20jeason%E7%9A%84%E6%97%A5%E5%BF%97%20-%20%E7%BD%91%E6%98%93%E5%8D%9A%E5%AE%A2.htm这个同样也是一个思路,原创 2014-12-05 21:45:33 · 1033 阅读 · 0 评论 -
cp直接覆盖不提示按Y/N的方法
cp覆盖时,无论加什么参数-f之类的还是提示是否覆盖,当文件比较少的时候还可以按Y确认,当很多文件的时候就不好说了。用下面的方法可以解决覆盖提示的问题。例如:把zongguofeng目录下的文件复制到linuxzgf目录 [root@linuxzgf ~]# cp zongguofeng/* linuxzgfcp:是否覆盖“linuxzgf/1.txt”? 执转载 2014-05-13 13:41:49 · 3934 阅读 · 0 评论 -
linux 下获取默认网关的方法
本帖最后由 Sevk 于 2012-12-04 05:29 编辑open("/proc/net/route",'r')或 ip_route_output_key(&init_net, &rt, &fl); 或socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE)http://blog.youkuaiyun.com/zyq2007/art转载 2014-04-24 11:30:55 · 4089 阅读 · 0 评论 -
无符号整型随机数 curl 实现
curl_rand.c#include <time.h>#include "curl_rand.h"/* Private pseudo-random number seed. Unsigned integer >= 32bit. Threads mutual exclusion is not implemented to acess it since we do not require翻译 2016-05-25 20:44:21 · 971 阅读 · 0 评论 -
c语言函数可变参数 例
c语言函数可变参数 例#include "stdio.h" #include "stdarg.h" void simple_va_fun(int num, void *start, ...) { va_list arg_ptr; int i; void *nArgValue =start; printf("num = %d\n", num); va原创 2016-05-04 09:06:56 · 375 阅读 · 0 评论 -
socket select 超时设置/select 集合
socket select 超时设置原创 2016-05-04 23:25:56 · 2381 阅读 · 0 评论 -
函数参数执行顺序 在mingw 32中是从右到左的。
#include <vector>#include <string>#include <iostream>using namespace std;class Test{public: static int i; Test(){ i++; cout<<i<<endl; }...翻译 2018-10-01 21:02:39 · 344 阅读 · 0 评论