⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.h

📁 USb in User space, a kernel module that use usb layer
💻 H
字号:
/* * usu.c * * Author : Lionetti Salvatore <salvatorelionetti@yahoo.it> * License: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#ifndef __UTIL_USU__#define __UTIL_USU__#include<linux/errno.h>#ifdef __KERNEL__#include<linux/kernel.h>/* <1> in printk("<1>...") is considered only on new line. * So in !new line we see <1> with dmesg. */#define PRINT printk/*int printk(char *fmt,...);*/#else/*#include<stdio.h>*/#define PRINT printf#endif#ifdef __KERNEL__#include<linux/string.h>	/* To have memcpy(), memset().	*//*#include<linux/kernel.h>	 To have scnprintf().		*/#include<asm/uaccess.h>		/* To have copy_{to,from}_user()*/#define Snprintf(format, args...) if (l<len) l+=scnprintf(buf+l,len-l,format,##args); #define CopyToUser(to,from,n)	copy_to_user(to,from,n)#define CopyFromUser(to,from,n)	copy_from_user(to,from,n)#else#include<string.h>#include<stdio.h>		/* To have snprintf().		*/#define Snprintf(format, args...) if (l<len) l+=snprintf(buf+l,len-l,format,##args); #define CopyToUser(to,from,n)	(memcpy(to,from,n)?0:-EFAULT)#define CopyFromUser(to,from,n)	(memcpy(to,from,n)?0:-EFAULT)#endif#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -