1. /****************************************************************************
  2. * Linux kernel scriptes bin2c "\x"
  3. * 声明:
  4. * 早上在阅读Linux kernel scriptes中的源代码的时候发现bin2c的源代码,
  5. * 于是打算看一下,结果发现"\x"的写法,于是查了点资料,看了一下它的用法。
  6. *
  7. * 2015-12-29 深圳 南山平山村 曾剑锋
  8. ***************************************************************************/
  9.  
  10. 一、参考资料:
  11. . \x49\x51\x5a\x56\x54\ 这种是什么编码?
  12. http://zhidao.baidu.com/link?url=tDpw0M4dsxvnldOAzJg0HiS25vYl3ebTBwJOF0ULHxBGEF-0nYLiewaX29d870N5cro-yv2blYWgG2Kx4xFPXK
  13. . \XC语言里表示什么意思?
  14. http://zhidao.baidu.com/link?url=HC1lXt3Cv2yE1gQaLchbyhlaAwU9X9hVEQNz_dRqqvP4lTO1dTypMFnKT7rI8mmH9lUsSAjNPgo_fyzJYngcLa
  15.  
  16. 二、Linux内核scripts/bin2c.c
  17. /*
  18. * Unloved program to convert a binary on stdin to a C include on stdout
  19. *
  20. * Jan 1999 Matt Mackall <mpm@selenic.com>
  21. *
  22. * This software may be used and distributed according to the terms
  23. * of the GNU General Public License, incorporated herein by reference.
  24. */
  25.  
  26. #include <stdio.h>
  27.  
  28. /**
  29. * 1. 程序将第二个参数作为数组的名字;
  30. * 2. 程序通过读取标输入数据,并将数据转换成十六进制输出到标准输出;
  31. * 3. 由于是通过标准入获取数据,那么常用的方式应该是采用管道进行数据传输;
  32. * 4. 目前没搞懂下面这条语句为什么要转成"\x":
  33. * printf("\\x%02x",ch);
  34. */
  35. int main(int argc, char *argv[])
  36. {
  37. int ch, total=;
  38.  
  39. if (argc > )
  40. printf("const char %s[] %s=\n",
  41. argv[], argc > ? argv[] : "");
  42.  
  43. do {
  44. printf("\t\"");
  45. while ((ch = getchar()) != EOF)
  46. {
  47. total++;
  48. printf("\\x%02x",ch);
  49. if (total % == )
  50. break;
  51. }
  52. printf("\"\n");
  53. } while (ch != EOF);
  54.  
  55. if (argc > )
  56. printf("\t;\n\nconst int %s_size = %d;\n", argv[], total);
  57.  
  58. return ;
  59. }
  60.  
  61. 三、"\x"数据测试代码:
  62. #include <stdio.h>
  63.  
  64. int main (int argc, char **argv) {
  65. printf("%c, %s.\n", '\x30', "\x31\x32");
  66. }

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 1247 Hat’s Words(map,STL,字符处理,string运用)

    题目 用map写超便捷 也可以用字典树来写 我以前是用map的: #include<stdio.h> #include<string.h> #include<algori ...

  2. jquery select处理

    JQuery 绑定select标签的onchange事件,弹出选择的值,并实现跳转.传参 js 处理 select :选中,删除,更改等 http://blog.csdn.net/wust_star/ ...

  3. Oracle MySQL

    http://blog.jobbole.com/46510/ http://blackproof.iteye.com/blog/1570456 http://blog.csdn.net/yzsind/ ...

  4. ZOJ 1610 Count the Colors (线段树区间更新)

    题目链接 题意 : 一根木棍,长8000,然后分别在不同的区间涂上不同的颜色,问你最后能够看到多少颜色,然后每个颜色有多少段,颜色大小从头到尾输出. 思路 :线段树区间更新一下,然后标记一下,最后从头 ...

  5. 使用ADO连接oracle数据库“未找到提供程序。该程序可能未正确安装”解决方案

    问题描述:VS2010开发的C++程序,在一台Win7旗舰版的已安装Oracle客户端的PC上连接不上Oracle,提示“未找到提供程序.该程序可能未正确安装”,其他语言编写的程序比如C#是可以成功连 ...

  6. hdu 4111 Alice and Bob(中档博弈题)

    copy VS study 1.每堆部是1的时候,是3的倍数时输否则赢: 2.只有一堆2其他全是1的时候,1的堆数是3的倍数时输否则赢: 3.其他情况下,计算出总和+堆数-1,若为偶数,且1的堆数是偶 ...

  7. iOS开发-网易滚动导航栏

    HACursor,是一个对横向ScrollView中的视图进行管理的UI控件.只要几行代码就可以集成类似于网易新闻对主题页面进行排序,删除操作的功能.主srollview参考iOS原生的UITable ...

  8. 阿里云centos6搭建vpn

    下载脚本 wget http://latrell.me/wp-content/uploads/vpn_centos6.sh 运行脚本 chmod a+x vpn_centos6.sh ./vpn_ce ...

  9. DB2操作流程

    DB2如何创建表空间 如何创建数据库 如何创建缓冲池标签: db2数据库system脚本linuxwindows2012-06-13 19:16 8411人阅读 评论(0) 收藏 举报 版权声明:本文 ...

  10. c++ 在客户端的GCC使用

    c++ 在客户端的GCC使用 翻译自: GCC是GNU工具箱的一个功能,GNU还包括如下功能: GNU compiler collection (GCC) GNU make GNU Debugger ...