LINUX C 链表封装
main.c
//初始化队列
void InitQueue(LiQueue *q)
{
q=(LiQueue*)malloc(sizeof(LiQueue));
q->front=q->rear=NULL;
}
//判断是否为空
int QueueEmpty(LiQueue *q)
{
if(q->rear==NULL)
{
return 1;
}
else
{
return 0;
}
}
//释放
void ClearQueue(LiQueue *q)
{
QNode *p=q->front,*r;
if(p!=NULL)
{
r=p->next;
while(r!=NULL)
{
free(p);
p=r;
r=p->next;
}
}
free(q);
}
//实现队列的入队
void enQueue(LiQueue *q,struct TCPMASSAGE stTcpSendBuff)
{
//封装结点
QNode *s;
s=(QNode*)malloc(sizeof(QNode));
memcpy(&s->data , &stTcpSendBuff , sizeof(stTcpSendBuff));
//s->data =e;
s->next=NULL;
if(q->rear==NULL)
{
q->front =s;
q->rear =s;
}
else
{
q->rear->next =s;
q->rear =s;
}
}
//出队函数
int deQueue(LiQueue *q,struct TCPMASSAGE stTcpSendBuff)
{
QNode *t;
if(q->rear ==NULL)
{
return 0;
}
if(q->front ==q->rear )//只有一个结点
{
t=q->front;
q->front =NULL;
q->rear =NULL;
}
else
{
t=q->front;
q->front=q->front->next;
}
memcpy(stTcpSendBuff.cTcpBuff,t->data.cTcpBuff,t->data.len);
stTcpSendBuff.len = t->data.len;
free(t);
return 1;
}
/*
//出队函数
int deQueue(LiQueue *q,char *pstbuff,int *lenth)
{
QNode *t;
if(q->rear ==NULL)
{
return 0;
}
if(q->front ==q->rear )//只有一个结点
{
t=q->front;
q->front =NULL;
q->r
相关文档:
; break;
}
if (type != EV_SYN)
&nbs ......
The Linux USB input subsystem is a single, harmonized way to manage all input devices. This is a relatively new approach for Linux, with the system being partly incorporated in kernel version 2.4 and fully integrated in the 2.5 development series.
This article covers four basic areas: a descripti ......
先用who命令查看所有登陆终端
#who -uH
输出如下:
NAME LINE TIME IDLE PID COMMENT
root :0 2010-03-01 19:13 ? & ......
-----------------------------
Based on Fedora 8 version:
-----------------------------
1. No common command like ifconfig in os?
Root cause is the standard search path not include /sbin and /usr/sbin. Try to include them in /etc/profile. As belows:
#Kenny add /sbin and /usr/sbin here.
&n ......
本例是冯国进的 《嵌入式Linux 驱动程序设计从入门到精通》的第一个例子
感觉真是好书 强烈推荐
注释是deep_pro加的 转载请注明!我的特点是文不加点!
这个驱动是在内存中分配一个256字节的空间,供用户态应用程序读写。
先是头文件 demo.h
#ifndef _DEMO_H_
#define _DEMO_H_
#include <linux/ioct ......