Linux kernel scriptes bin2c "\x"
/****************************************************************************
* Linux kernel scriptes bin2c "\x"
* 声明:
* 早上在阅读Linux kernel scriptes中的源代码的时候发现bin2c的源代码,
* 于是打算看一下,结果发现"\x"的写法,于是查了点资料,看了一下它的用法。
*
* 2015-12-29 深圳 南山平山村 曾剑锋
***************************************************************************/ 一、参考资料:
. \x49\x51\x5a\x56\x54\ 这种是什么编码?
http://zhidao.baidu.com/link?url=tDpw0M4dsxvnldOAzJg0HiS25vYl3ebTBwJOF0ULHxBGEF-0nYLiewaX29d870N5cro-yv2blYWgG2Kx4xFPXK
. \X在C语言里表示什么意思?
http://zhidao.baidu.com/link?url=HC1lXt3Cv2yE1gQaLchbyhlaAwU9X9hVEQNz_dRqqvP4lTO1dTypMFnKT7rI8mmH9lUsSAjNPgo_fyzJYngcLa 二、Linux内核scripts/bin2c.c
/*
* Unloved program to convert a binary on stdin to a C include on stdout
*
* Jan 1999 Matt Mackall <mpm@selenic.com>
*
* This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference.
*/ #include <stdio.h> /**
* 1. 程序将第二个参数作为数组的名字;
* 2. 程序通过读取标输入数据,并将数据转换成十六进制输出到标准输出;
* 3. 由于是通过标准入获取数据,那么常用的方式应该是采用管道进行数据传输;
* 4. 目前没搞懂下面这条语句为什么要转成"\x":
* printf("\\x%02x",ch);
*/
int main(int argc, char *argv[])
{
int ch, total=; if (argc > )
printf("const char %s[] %s=\n",
argv[], argc > ? argv[] : ""); do {
printf("\t\"");
while ((ch = getchar()) != EOF)
{
total++;
printf("\\x%02x",ch);
if (total % == )
break;
}
printf("\"\n");
} while (ch != EOF); if (argc > )
printf("\t;\n\nconst int %s_size = %d;\n", argv[], total); return ;
} 三、"\x"数据测试代码:
#include <stdio.h> int main (int argc, char **argv) {
printf("%c, %s.\n", '\x30', "\x31\x32");
}
Linux kernel scriptes bin2c "\x"的更多相关文章
- Linux kernel make 常用选项介绍
Linux kernel 编译方法大全记录 一.这是一个我自己写的自动make脚本: #!/bin/sh export ARCH=arm export CROSS_COMPILE=arm-linux- ...
- Linux Kernel代码艺术——系统调用宏定义
我们习惯在SI(Source Insight)中阅读Linux内核,SI会建立符号表数据库,能非常方便地跳转到变量.宏.函数等的定义处.但在处理系统调用的函数时,却会遇到一些麻烦:我们知道系统调用函数 ...
- Linux Kernel 代码艺术——编译时断言
本系列文章主要写我在阅读Linux内核过程中,关注的比较难以理解但又设计巧妙的代码片段(不关注OS的各个模块的设计思想,此部分我准备写在“深入理解Linux Kernel” 系列文章中),一来通过内核 ...
- linux kernel的中断子系统 softirq
linux kernel的中断子系统之(八):softirq http://www.wowotech.net/irq_subsystem/soft-irq.html http://www.ibm.co ...
- karottc A Simple linux-virus Analysis、Linux Kernel <= 2.6.37 - Local Privilege Escalation、CVE-2010-4258、CVE-2010-3849、CVE-2010-3850
catalog . 程序功能概述 . 感染文件 . 前置知识 . 获取ROOT权限: Linux Kernel <= - Local Privilege Escalation 1. 程序功能概述 ...
- linux kernel 字符设备详解
有关Linux kernel 字符设备分析: 参考:http://blog.jobbole.com/86531/ 一.linux kernel 将设备分为3大类,字符设备,块设备,网络设备. 字符设备 ...
- linux kernel 杂谈
首先介绍一下背景吧,工作三个星期了.复习了一波u-boot,跟了一下事件上报,搞了下平台设备,扣了一个内存检查代码. 想想生活是不是有点无聊.对啊,真的很无聊!!!! 无聊也没有办法啊,所以找点方法去 ...
- 与您共享Linux Kernel 4.8分支首个维护版本
导读 Linux Kernel 4.8正式版于10月2日由Linus Torvalds发布,带来了包括AMDGPU OverDrive支持.NVIDIA Pascal支持.AMDGPU PowerPl ...
- Linux Kernel Version Numbering
Because there are numerous revisions and releases of the Linux kernel and new ones are developed at ...
随机推荐
- POJ 2464 Brownie Points II (树状数组,难题)
题意:在平面直角坐标系中给你N个点,stan和ollie玩一个游戏,首先stan在竖直方向上画一条直线,该直线必须要过其中的某个点,然后ollie在水平方向上画一条直线,该直线的要求是要经过一个sta ...
- nginx规则和ci的支持
CI框架下nginx重写规则,不再404 http://blog.csdn.net/EI__Nino/article/details/8599304 server { listen 80; serve ...
- jquery ajax post 传递数组 ,多checkbox 取值
jquery ajax post 传递数组 ,多checkbox 取值 http://w8700569.iteye.com/blog/1954396 使用$.each(function(){});可以 ...
- mvc5 @RenderSection("scripts", required: false) 什么意思
在模板中 相当于占位符 使用方法如下 @section scripts{ //coding }
- linux中的磁盘的MBR记录详解
在硬盘中,硬盘的0柱面0磁头第一个1扇区称为主引导扇区,也叫主引导记录-MBR(main boot record),其中MBR是以下三个部分组成 1.Bootloader,主引导程序---446个字节 ...
- 李洪强iOS开发之OC点语法和变量作用域
OC点语法和变量作用域 一.点语法 (一)认识点语法 声明一个Person类: 1 #import <Foundation/Foundation.h> 2 3 @interface Per ...
- 【转】SIP初步
1.什么是SIP SIP(会话发起协议)属于IP应用层协议,用于在IP网上为用户提供会话应用.会话(Session)指两方或多方用户之间的语音.视频.及其他媒体形式的通信,具体可能是IP电话.会议.即 ...
- JVM垃圾回收机制总结(3) :按代垃圾收集器
为什么要分代 分代的垃圾回收策略,是基于这样一个事实:不同的对象的生命周期是不一样的 . 因此,不同生命周期的对象可以采取不同的收集方式,以便提高回收效率. 在Java程序运行的过程中,会产生大量的对 ...
- 278. First Bad Version
题目: You are a product manager and currently leading a team to develop a new product. Unfortunately, ...
- HDU5092——Seam Carving(动态规划+回溯)(2014上海邀请赛重现)
Seam Carving DescriptionFish likes to take photo with his friends. Several days ago, he found that s ...