char函数

cm-14.1 Android系统启动过程分析(一)-init进程的启动、rc脚本解析、zygote启动、属性服务

时间秒杀一切 提交于 2020-01-12 01:46:14
声明 前阶段在项目中涉及到了Android系统定制任务,Android系统定制前提要知道Android系统是如何启动的。 本文参考了一些书籍的若干章节,比如《Android进阶解密-第2章-Android系统启动》、《深入理解Android虚拟机-第8/9/10章-init进程详解/Dalvik VM的进程系统/Dalvik VM运作流程详解》、《深入理解Android系统-第6/7/8章-init启动进程详解/Zygote进程详解/System进程详解》等 本文使用的代码是LineageOS的cm-14.1,对应Android 7.1.2,可以参考我的另一篇博客: 如何下载Nexus5的LineageOS14.1(cm-14.1)系统源码并编译、刷机 很多代码注释待详细写 1 init进程     init进程在Linux系统中是内核启动后启动的1号进程,init进程在Android系统中依然是内核初始化完成后首先启动的1号进程。init进程主要作用是: 创建、挂载启动所需的文件目录,包括:tmpfs、devpts、proc、sys、selinuxfs; 解析、处理init.rc等脚本文件中的命令; 创建Zygote和属性服务; 使用while(true)循环创建子进程;     其源码位置在: vim ~/LineageOS/system/core/init/init.cpp

boost 字符串处理

此生再无相见时 提交于 2020-01-11 23:44:15
#include <iostream> using namespace std; //进行字符串、整数/浮点数之间的字面转换 #include <boost/lexical_cast.hpp> void test_lexical_cast() { int a = lexical_cast<int>("123");//<>中的为目标类型 double b = lexical_cast<double>("123.0123456789"); // unsigned int a1 = lexical_cast<unsigned int>("4294967296");// 超出范围报错 unsigned int a2 = lexical_cast<unsigned int>("-1");// 4294967295 double b1 = lexical_cast<double>("123.0123456789",6);// 参数2指定长度,超过参数1长度则抛出异常,b1 = 123.01 lexical_cast<bool>("1");// 转换为bool时参数只能是0/1,其他均报错 string s0 = lexical_cast<string>(a); string s1 = lexical_cast<string>(b); cout << "number: " << a << " "

Linux字符串函数集

戏子无情 提交于 2020-01-11 22:31:51
//Linux字符串函数集: 头文件:string.h   函数名: strstr   函数原型: extern char *strstr( char *str1, char *str2);   功能:找出str2字符串在str1字符串中第一次出现的位置(不包括str2的串结束符)。   返回值:返回该位置的指针,如找不到,返回空指针。 包含文件:string.h   函数名: strstr   函数原型:extern char *strstr(char *str1, char *str2);   功能:找出str2字符串在str1字符串中第一次出现的位置(不包括str2的串结束符)。   返回值:返回该位置的指针,如找不到,返回空指针。 原型: extern char *strchr( const char *s, char c);    const char *strchr( const char* _Str, int _Val)    char *strchr( char* _Str, int _Ch)   头文件:#include <string.h>   功能:查找字符串s中首次出现字符c的位置   说明:返回首次出现c的位置的指针,如果s中不存在c则返回NULL。   返回值:Returns the address of the first occurrence of

strcpy和strncpy用法和区别

旧时模样 提交于 2020-01-11 22:16:01
strcpy和strncpy用法和区别 1. strcpy函数:顾名思义字符串复制函数:原型:extern char *strcpy(char *dest,char *src); 功能:把从src地址开始且含有NULL结束符的字符串赋值到以dest开始的地址空间,返回dest(地址中存储的为复制后的新值)。要求:src和dest所指内存区域不可以重叠且dest必须有足够的空间来容纳src的字符串。   一般函数原型实现方式:   char * strcpy(char * strDest,const char * strSrc)   {   char * strDestCopy=strDest; //[3]   if ((strDest==NULL)||(strSrc==NULL)) //[1]   throw "Invalid argument(s)"; //[2]   while ((*strDest++=*strSrc++)!='\0'); //[4]   return strDestCopy;   }   该函数的参数是字符指针,也就是可以是字符串变量和字符数组,因为它们的变量名代表首字符地址。字符串默认有一个null结束符,字符数组没有。所以此处需要注意:因为src要求有null结束符,所以字符数组的长度必须大于等于src包含null结束符的总长度。例如,char* src

nginx源码解析之常用数据结构

不问归期 提交于 2020-01-11 15:56:07
  1、基础数据结构(src/core目录)   1)ngx_list_t(ngx_list.h) typedef struct ngx_list_part_s ngx_list_part_t; // 描述链表的一个元素(数组) struct ngx_list_part_s { void *elts; // 数组的起始地址 ngx_uint_t nelts; // 数组当前已使用了多少容量 ngx_list_part_t *next; // 下一个链表元素ngx_list_part_t的地址 }; typedef struct { ngx_list_part_t *last; // 指向链表的最后一个数组元素 ngx_list_part_t part; // 链表的首个数组元素 size_t size; // 存储的每个数据的字节数必须小于或等于size ngx_uint_t nalloc; // 每个ngx_list_part_t数组的容量 ngx_pool_t *pool; // 链表中管理内存分配的内存池对象 } ngx_list_t; // 描述整个链表   相关接口:   ngx_list_create(): 创建新的链表。   ngx_list_init(): 初始化一个已有的链表。返回 NGX_OK 表示成功,返回 NGX_ERROR 表示失败。   ngx_list

C#执行批处理命令

被刻印的时光 ゝ 提交于 2020-01-11 15:22:04
http://blog.csdn.net/jing_xin/article/details/41444063 针对BEIYANG收据打印机 BTP-R580测试通过。 操作说明: http://www.docin.com/p-395110672.html 1、一般的打印 static Font printFont; //打印使用的字体 public static void PrintEventPage(object sender, PrintPageEventArgs e) { float yPos = 0; int count = 0; float leftMargin = e.MarginBounds.Left; float topMargin = e.MarginBounds.Top; //string line = null; //string subs = " "; string context = null; //打印字体 printFont = new Font("宋体", 14F, FontStyle.Bold | FontStyle.Underline); //打印内容 context = "收银小票"; //打印的位置 yPos = topMargin + (count * printFont.GetHeight(e.Graphics)); e.Graphics

kobject系统分析

五迷三道 提交于 2020-01-11 10:33:17
1 概述 要说kobject不得不说sysfs sysfs 是一个最初基于 ramfs 且位于内存的文件系统。它提供导出内核 数据结构及其属性,以及它们之间的关联到用户空间的方法。 sysfs 始终与 kobject 的底层结构紧密相关。 任何 kobject 在系统中注册,就会有一个目录在 sysfs 中被创建。这个目录是作为该 kobject 的父对象所在目录的子目录创建的,以准确地传递内核的对象层次到用户空间。sysfs 中的顶层目录代表着内核对象层次的共同祖先;例如:某些对象属于某个子系统。 kobject 的属性可在文件系统中以普通文件的形式导出。Sysfs 为属性定义了面向文件 I/O 操作的方法,以提供对内核属性的读写。 上面这段话是从内核文档Documentation/zh_CN/filesystems/sysfs.txt 中摘抄的, 主要说明了kobject的作用, 对于注册kobject其实就是在sysfs中创建目录。 在目录中添加属性则用于在sysfs中创建普通文件,读写这些属性文件将会调用内核中为该属性设置的读写回调函数. 所以属性文件用于内核空间和用户空间通信。了解linux系统的人都应该知道sysfs文件一般用于动态配置内核。这段文档没有说明属性组的概念,属性组就是一组属性,这组属性创建的文件在所属属性组目录下。(sysfs的根目录一般问/sys)。

JavaSE-常用API

自古美人都是妖i 提交于 2020-01-11 09:01:09
目录 第一章:API概述 第二章:Scanner类 第三章:Random类 第四章:ArrayList类 第五章:String类 第六章:Arrays类 第七章:Math类 第八章:Object类 第九章:Date类 第十章:System类 第十一章:StringBuilder类 第十二章:包装类 第一章:API概述 什么是API? ​ API(Application Programming Interface), 应用程序编程接口 。Java API是一本程序员的 字典 ,是JDK中提供给 我们使用的类的说明文档。这些类将底层的代码实现封装了起来,我们不需要关心这些类是如何实现的,只需要学 习这些类如何使用即可。所以我们可以通过查询API的方式,来学习Java提供的类,并得知如何使用它们。 API使用步骤 打开帮助文档。 点击显示,找到索引,看到输入框。 你要找谁?在输入框里输入,然后回车。 看包。java.lang下的类不需要导包,其他需要。 看类的解释和说明。 学习构造方法。 使用成员方法 第二章:Scanner类 Scanner类介绍 一个可以解析基本类型和字符串的简单文本扫描器 使用步骤 导包: import java.util.Scanner; 构造函数: public Scanner(InputStream source) 常用方法: public String

PHP 小知识

白昼怎懂夜的黑 提交于 2020-01-11 07:38:16
PHP 加密解密 <?php//加密 function encrypt($data, $key) { $key = md5($key); $x = 0; $len = strlen($data); $l = strlen($key); $char = ''; for ($i = 0; $i < $len; $i++) { if ($x == $l) { $x = 0; } $char .= $key{$x}; $x++; } $str = ''; for ($i = 0; $i < $len; $i++) { $str .= chr(ord($data{$i}) + (ord($char{$i})) % 256); } return base64_encode($str); } //解密 function decrypt($data, $key) { $key = md5($key); $x = 0; $data = base64_decode($data); $len = strlen($data); $l = strlen($key); $char = ''; for ($i = 0; $i < $len; $i++) { if ($x == $l) { $x = 0; } $char .= substr($key, $x, 1); $x++; } $str = ''; for

用openssl库RSA加密解密

倖福魔咒の 提交于 2020-01-11 03:41:12
1 #include <stdio.h> 2 #include <openssl/rsa.h> 3 #include <openssl/pem.h> 4 #include <openssl/err.h> 5 6 //加密 7 int my_encrypt(const char *input, int input_len, char *output, int *output_len, const char *pri_key_fn) 8 { 9 RSA *p_rsa = NULL; 10 FILE *file = NULL; 11 int ret = 0; 12 13 if((file = fopen(pri_key_fn, "rb")) == NULL) 14 { 15 ret = -1; 16 goto End; 17 } 18 19 if((p_rsa = PEM_read_RSAPrivateKey(file, NULL,NULL,NULL )) == NULL) 20 { 21 ret = -2; 22 goto End; 23 } 24 25 if((*output_len = RSA_private_encrypt(input_len, (unsigned char*)input, (unsigned char*)output, p_rsa, RSA_PKCS1