/****************************************************************************
* 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"的更多相关文章

  1. Linux kernel make 常用选项介绍

    Linux kernel 编译方法大全记录 一.这是一个我自己写的自动make脚本: #!/bin/sh export ARCH=arm export CROSS_COMPILE=arm-linux- ...

  2. Linux Kernel代码艺术——系统调用宏定义

    我们习惯在SI(Source Insight)中阅读Linux内核,SI会建立符号表数据库,能非常方便地跳转到变量.宏.函数等的定义处.但在处理系统调用的函数时,却会遇到一些麻烦:我们知道系统调用函数 ...

  3. Linux Kernel 代码艺术——编译时断言

    本系列文章主要写我在阅读Linux内核过程中,关注的比较难以理解但又设计巧妙的代码片段(不关注OS的各个模块的设计思想,此部分我准备写在“深入理解Linux Kernel” 系列文章中),一来通过内核 ...

  4. linux kernel的中断子系统 softirq

    linux kernel的中断子系统之(八):softirq http://www.wowotech.net/irq_subsystem/soft-irq.html http://www.ibm.co ...

  5. 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. 程序功能概述 ...

  6. linux kernel 字符设备详解

    有关Linux kernel 字符设备分析: 参考:http://blog.jobbole.com/86531/ 一.linux kernel 将设备分为3大类,字符设备,块设备,网络设备. 字符设备 ...

  7. linux kernel 杂谈

    首先介绍一下背景吧,工作三个星期了.复习了一波u-boot,跟了一下事件上报,搞了下平台设备,扣了一个内存检查代码. 想想生活是不是有点无聊.对啊,真的很无聊!!!! 无聊也没有办法啊,所以找点方法去 ...

  8. 与您共享Linux Kernel 4.8分支首个维护版本

    导读 Linux Kernel 4.8正式版于10月2日由Linus Torvalds发布,带来了包括AMDGPU OverDrive支持.NVIDIA Pascal支持.AMDGPU PowerPl ...

  9. Linux Kernel Version Numbering

    Because there are numerous revisions and releases of the Linux kernel and new ones are developed at ...

随机推荐

  1. HDU 4006 The kth great number(multiset(或者)优先队列)

    题目 询问第K大的数 //这是我最初的想法,用multiset,AC了——好吧,也许是数据弱也有可能 //multiset运用——不去重,边插入边排序 //iterator的运用,插入的时候,如果是相 ...

  2. Javascript format方法

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  3. OpenGL程序运行提示glut32.dll丢失问题

    转: http://blog.csdn.net/liufeng520/article/details/8064170 今天调试OpenGl的源程序,编译通过,但一运行就提示,计算机丢失 glut32. ...

  4. jmeter 异步子请求测试随笔

    好久没写技术类的博客了,都不知道自己都在忙啥.... 最近陆续遇到了一些异步子请求的测试需求,比如打开某一个页面A,A页面里的js会再调用B,C,D,E等请求,针对这个页面的测试,我最近做了一些思考: ...

  5. C#打开得到路径

    FolderBrowserDialog path = new FolderBrowserDialog(); path.ShowDialog(); MessageBox.Show(path.Select ...

  6. 一站式学习Wireshark(五):TCP窗口与拥塞处理

    https://community.emc.com/message/821593#821593 介绍 TCP通过滑动窗口机制检测丢包,并在丢包发生时调整数据传输速率.滑动窗口机制利用数据接收端的接收窗 ...

  7. static和const关键字

    C#与C++的static有两种用法:面向过程程序设计中的static和面向对象程序设计中的static.前者应用于普通变量和函数,不涉及类   面向过程 静态全局变量 静态全局变量在声明它的整个文件 ...

  8. http://biancheng.dnbcw.info/java/138631.html

    http://biancheng.dnbcw.info/java/138631.html

  9. SQL Server ->> 生成Numbers辅助表

    if object_id('MyDB.dbo.Numbers') is not null drop table MyDB.dbo.Numbers go use [MyDB] go create tab ...

  10. 蓝缘管理系统第三版推出。springMVC4.0+shiro1.2.3+spring4.x+Mybaits3.2.8

    blog.csdn.net/mmm333zzz/article/details/42059349 http://blog.csdn.net/zoutongyuan/article/details/41 ...