技术标签: aosp android 操作系统 Android
Android源码中注册服务一般有两种,一种是通过Java实现,另外一种是通过C++实现;本文介绍Native实现方式,Java实现方式请移步 [Android源码添加自定义系统服务 - Java],网上基本上也都是通过Java来自定义实现的。
在./frameworks目录下是没有vendor目录的,vendor目录是新建用于调试的;可以在其它目录下创建测试目录。
aw@m:~/works/android/aosp/aosp11/frameworks/vendor$ tree .
.
└── service
├── aidl
│ └── android
│ └── sample
│ └── ISample.aidl
├── Android.bp
├── include
│ ├── aidl
│ │ ├── BnSample.h
│ │ ├── BpSample.h
│ │ └── ISample.h
│ └── SampleService.h
├── ISample.cpp
├── SampleService.cpp
└── test
├── SampleClient.cpp
└── SampleServer.cpp
7 directories, 10 files
aw@m:~/works/android/aosp/aosp11/frameworks/vendor$
1. 在./frameworks/目录下,创建vendor/service两级目录
2. 在service目录下创建aidl目录,并创建ISample.aidl文件,路径图如上图
aw@m:~/works/android/aosp/aosp11/frameworks/vendor/service/aidl/android/sample$ pwd
/home/aw/works/android/aosp/aosp11/frameworks/vendor/service/aidl/android/sample
aw@m:~/works/android/aosp/aosp11/frameworks/vendor/service/aidl/android/sample$ ls -lhia
总用量 12K
33951777 drwxrwxr-x 2 aw aw 4.0K 11月 20 19:29 .
33951776 drwxrwxr-x 3 aw aw 4.0K 11月 20 19:28 ..
33951779 -rw-rw-r-- 1 aw aw 98 11月 20 19:29 ISample.aidl
aw@m:~/works/android/aosp/aosp11/frameworks/vendor/service/aidl/android/sample$
package android.sample;
interface ISample {
void doSomething(int n, out List<String> output);
}
3. 生成对应的BnSample.cpp、BpSample.cpp、ISample.h、ISample.cpp,文件生成方式有两种:
$: aidl --lang=cpp ./aidl/IAudioSample.aidl -o . -h ./include/
在service目录下创建Android.bp文件,Android.bp
cc_library_shared {
name: "libsampleservice",
aidl: {
export_aidl_headers: true,
local_include_dirs: ["aidl"],
include_dirs: [
"frameworks/vendor/service/aidl",
],
},
srcs: [
":libsample_aidl",
],
shared_libs: [
"libbinder",
"libcutils",
"liblog",
"libutils",
],
export_shared_lib_headers: ["libbinder"],
local_include_dirs: [
"include",
"include/aidl",
"aidl",
],
include_dirs: [
"frameworks/native/include",
"system/core/base/include",
],
header_libs: [
"libbase_headers",
],
cflags: [
"-Werror",
"-Wno-error=deprecated-declarations",
],
}
filegroup {
name: "libsample_aidl",
srcs: [
"aidl/android/sample/ISample.aidl",
],
path: "aidl",
}
在./framworks/vendor下执行mm [Android编译命令],将会在out/soong/.intermediates/frameworks/vendor/service/libsampleservice下生成对应文件
aw@m:~/works/android/aosp/aosp11/out/soong/.intermediates/frameworks/vendor/service/libsampleservice$ ls
android_arm64_armv8-a_shared android_arm_armv8-a_shared
aw@m:~/works/android/aosp/aosp11/out/soong/.intermediates/frameworks/vendor/service/libsampleservice$ tree .
.
├── android_arm64_armv8-a_shared
│ ├── gen
│ │ └── aidl
│ │ ├── android
│ │ │ └── sample
│ │ │ ├── BnSample.h
│ │ │ ├── BpSample.h
│ │ │ └── ISample.h
│ │ └── frameworks
│ │ └── vendor
│ │ └── service
│ │ └── aidl
│ │ └── android
│ │ └── sample
│ │ ├── ISample.cpp
│ │ └── ISample.cpp.d
│ ├── libsampleservice.so
│ ├── libsampleservice.so.d
│ ├── libsampleservice.so.toc
│ ├── libsampleservice.so.toc.d
│ └── unstripped
│ ├── libsampleservice.so
│ └── libsampleservice.so.rsp
└── android_arm_armv8-a_shared
├── gen
│ └── aidl
│ ├── android
│ │ └── sample
│ │ ├── BnSample.h
│ │ ├── BpSample.h
│ │ └── ISample.h
│ └── frameworks
│ └── vendor
│ └── service
│ └── aidl
│ └── android
│ └── sample
│ ├── ISample.cpp
│ └── ISample.cpp.d
├── libsampleservice.so
├── libsampleservice.so.d
├── libsampleservice.so.toc
├── libsampleservice.so.toc.d
└── unstripped
├── libsampleservice.so
└── libsampleservice.so.rsp
取出对应BnSample.h、BpSample.h、ISample.h、ISample.cpp文件
BnSample.h
#ifndef AIDL_GENERATED_ANDROID_SAMPLE_BN_SAMPLE_H_
#define AIDL_GENERATED_ANDROID_SAMPLE_BN_SAMPLE_H_
#include <binder/IInterface.h>
#include <android/sample/ISample.h>
namespace android {
namespace sample {
class BnSample : public ::android::BnInterface<ISample> {
public:
explicit BnSample();
::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override;
}; // class BnSample
} // namespace sample
} // namespace android
#endif // AIDL_GENERATED_ANDROID_SAMPLE_BN_SAMPLE_H_
BpSample.h
#ifndef AIDL_GENERATED_ANDROID_SAMPLE_BP_SAMPLE_H_
#define AIDL_GENERATED_ANDROID_SAMPLE_BP_SAMPLE_H_
#include <binder/IBinder.h>
#include <binder/IInterface.h>
#include <utils/Errors.h>
#include <android/sample/ISample.h>
namespace android {
namespace sample {
class BpSample : public ::android::BpInterface<ISample> {
public:
explicit BpSample(const ::android::sp<::android::IBinder>& _aidl_impl);
virtual ~BpSample() = default;
::android::binder::Status doSomething(int32_t n, ::std::vector<::android::String16>* output) override;
}; // class BpSample
} // namespace sample
} // namespace android
#endif // AIDL_GENERATED_ANDROID_SAMPLE_BP_SAMPLE_H_
ISample.h
#ifndef AIDL_GENERATED_ANDROID_SAMPLE_I_SAMPLE_H_
#define AIDL_GENERATED_ANDROID_SAMPLE_I_SAMPLE_H_
#include <binder/IBinder.h>
#include <binder/IInterface.h>
#include <binder/Status.h>
#include <cstdint>
#include <utils/String16.h>
#include <utils/StrongPointer.h>
#include <vector>
namespace android {
namespace sample {
class ISample : public ::android::IInterface {
public:
DECLARE_META_INTERFACE(Sample)
virtual ::android::binder::Status doSomething(int32_t n, ::std::vector<::android::String16>* output) = 0;
}; // class ISample
class ISampleDefault : public ISample {
public:
::android::IBinder* onAsBinder() override {
return nullptr;
}
::android::binder::Status doSomething(int32_t, ::std::vector<::android::String16>*) override {
return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION);
}
}; // class ISampleDefault
} // namespace sample
} // namespace android
#endif // AIDL_GENERATED_ANDROID_SAMPLE_I_SAMPLE_H_
ISample.cpp
#include <aidl/ISample.h>
#include <aidl/BpSample.h>
namespace aidl {
DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(Sample, "aidl.ISample")
} // namespace aidl
#include <aidl/BpSample.h>
#include <aidl/BnSample.h>
#include <binder/Parcel.h>
#include <android-base/macros.h>
namespace aidl {
BpSample::BpSample(const ::android::sp<::android::IBinder>& _aidl_impl)
: BpInterface<ISample>(_aidl_impl){
}
::android::binder::Status BpSample::doSomething(int32_t n, ::std::vector<::android::String16>* output) {
::android::Parcel _aidl_data;
_aidl_data.markForBinder(remoteStrong());
::android::Parcel _aidl_reply;
::android::status_t _aidl_ret_status = ::android::OK;
::android::binder::Status _aidl_status;
_aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
if (((_aidl_ret_status) != (::android::OK))) {
goto _aidl_error;
}
_aidl_ret_status = _aidl_data.writeInt32(n);
if (((_aidl_ret_status) != (::android::OK))) {
goto _aidl_error;
}
_aidl_ret_status = remote()->transact(BnSample::TRANSACTION_doSomething, _aidl_data, &_aidl_reply, 0);
if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && ISample::getDefaultImpl())) {
return ISample::getDefaultImpl()->doSomething(n, output);
}
if (((_aidl_ret_status) != (::android::OK))) {
goto _aidl_error;
}
_aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
if (((_aidl_ret_status) != (::android::OK))) {
goto _aidl_error;
}
if (!_aidl_status.isOk()) {
return _aidl_status;
}
_aidl_ret_status = _aidl_reply.readString16Vector(output);
if (((_aidl_ret_status) != (::android::OK))) {
goto _aidl_error;
}
_aidl_error:
_aidl_status.setFromStatusT(_aidl_ret_status);
return _aidl_status;
}
} // namespace aidl
#include <aidl/BnSample.h>
#include <binder/Parcel.h>
#include <binder/Stability.h>
namespace aidl {
BnSample::BnSample()
{
::android::internal::Stability::markCompilationUnit(this);
}
::android::status_t BnSample::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) {
::android::status_t _aidl_ret_status = ::android::OK;
switch (_aidl_code) {
case BnSample::TRANSACTION_doSomething:
{
int32_t in_n;
::std::vector<::android::String16> out_output;
if (!(_aidl_data.checkInterface(this))) {
_aidl_ret_status = ::android::BAD_TYPE;
break;
}
_aidl_ret_status = _aidl_data.readInt32(&in_n);
if (((_aidl_ret_status) != (::android::OK))) {
break;
}
::android::binder::Status _aidl_status(doSomething(in_n, &out_output));
_aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
if (((_aidl_ret_status) != (::android::OK))) {
break;
}
if (!_aidl_status.isOk()) {
break;
}
_aidl_ret_status = _aidl_reply->writeString16Vector(out_output);
if (((_aidl_ret_status) != (::android::OK))) {
break;
}
}
break;
default:
{
_aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
}
break;
}
if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
_aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
}
return _aidl_ret_status;
}
} // namespace aidl
1. 创建SampleService.h
#ifndef SAMPLE_SERVICE_H
#define SAMPLE_SERVICE_H
#include <BnSample.h>
#include <vector>
namespace android {
class SampleService : public android::sample::BnSample {
public:
SampleService();
~SampleService();
virtual ::android::binder::Status doSomething(int32_t n, ::std::vector<::android::String16>* output);
};
}
#endif
2. 创建SampleService.cpp
#include <SampleService.h>
using namespace android;
SampleService::SampleService() {}
SampleService::~SampleService() {}
::android::binder::Status SampleService::doSomething(int32_t n, ::std::vector<::android::String16>* output) {
for (int i = 0; i < n; i++) {
output->push_back(String16("Hello"));
}
return ::android::binder::Status::ok();
}
3. 修改Android.bp,在srcs中补充了SampleService.cpp源文件
cc_library_shared {
name: "libsampleservice",
aidl: {
export_aidl_headers: true,
local_include_dirs: ["aidl"],
include_dirs: [
"frameworks/vendor/service/aidl",
],
},
srcs: [
":libsample_aidl",
"SampleService.cpp",
],
shared_libs: [
"libbinder",
"libcutils",
"liblog",
"libutils",
],
export_shared_lib_headers: ["libbinder"],
local_include_dirs: [
"include",
"include/aidl",
"aidl",
],
include_dirs: [
"frameworks/native/include",
"system/core/base/include",
],
header_libs: [
"libbase_headers",
],
cflags: [
"-Werror",
"-Wno-error=deprecated-declarations",
],
}
1. 在./framworks/vendor/service/test下创建SampleServer.cpp
#include <sys/types.h>
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <cutils/log.h>
#include <SampleService.h>
using namespace android;
int main(int argc, char** argv) {
sp<ProcessState> proc(ProcessState::self());
sp<IServiceManager> sm = defaultServiceManager();
ALOGI("ServiceManager: %p", sm.get());
sm->addService(String16("SampleService"), new SampleService());
ProcessState::self()->startThreadPool();
IPCThreadState::self()->joinThreadPool();
return 0;
}
1. 在./framworks/vendor/service/test下创建SampleClient.cpp
#include <binder/IServiceManager.h>
#include <binder/Parcel.h>
#include <utils/Errors.h>
#include <stdio.h>
#include <String16.h>
#include <String8.h>
#include <vector>
#include <iostream>
#include <SampleService.h>
using namespace android;
int main () {
sp<android::sample::ISample> sample_srv = interface_cast<android::sample::ISample>(defaultServiceManager()->getService(String16("SampleService")));
std::vector<String16> hellos;
sample_srv->doSomething(3, &hellos);
for (String16 s:hellos ) {
std::cout << String8(s.string()).string() << std::endl;
}
return 0;
}
2. 修改Android.bp
cc_library_shared {
name: "libsampleservice",
aidl: {
export_aidl_headers: true,
local_include_dirs: ["aidl"],
include_dirs: [
"frameworks/vendor/service/aidl",
],
},
srcs: [
":libsample_aidl",
"SampleService.cpp",
],
shared_libs: [
"libbinder",
"libcutils",
"liblog",
"libutils",
],
export_shared_lib_headers: ["libbinder"],
local_include_dirs: [
"include",
"include/aidl",
"aidl",
],
include_dirs: [
"frameworks/native/include",
"system/core/base/include",
],
header_libs: [
"libbase_headers",
],
cflags: [
"-Werror",
"-Wno-error=deprecated-declarations",
],
}
filegroup {
name: "libsample_aidl",
srcs: [
"aidl/android/sample/ISample.aidl",
],
path: "aidl",
}
// Server
cc_binary {
name: "sampleService",
srcs: [
"./test/SampleServer.cpp",
],
local_include_dirs: [
"include",
"include/aidl",
],
include_dirs: [
"frameworks/native/include",
"system/core/base/include",
],
header_libs: [
"libbase_headers",
],
cflags: [
"-Werror",
"-Wno-error=deprecated-declarations",
"-Wall",
"-Wno-unused-parameter",
],
shared_libs: [
"libbinder",
"libcutils",
"liblog",
"libutils",
"libsampleservice",
],
}
// Client
cc_binary {
name: "sampleClient",
srcs: [
"./test/SampleClient.cpp",
],
local_include_dirs: [
"include",
"include/aidl",
],
include_dirs: [
"frameworks/native/include",
"system/core/base/include",
"system/core/include/utils",
],
header_libs: [
"libbase_headers",
],
cflags: [
"-Werror",
"-Wno-error=deprecated-declarations",
"-Wall",
"-Wno-unused-parameter",
],
shared_libs: [
"libbinder",
"libcutils",
"liblog",
"libutils",
"libsampleservice",
],
}
我已经编译过,所以不会有什么生成日志,贴张图让大家知道在哪里执行mm指令 [Android编译命令]
aw@m:~/works/android/aosp/aosp11/frameworks/vendor$ mm
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=11
TARGET_PRODUCT=aosp_bonito
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv8-a
TARGET_2ND_CPU_VARIANT=generic
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.11.0-40-generic-x86_64-Ubuntu-20.04.3-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=RQ3A.210905.001
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/google/bonito hardware/google/av hardware/google/camera hardware/google/interfaces hardware/google/pixel hardware/qcom/sdm845 vendor/google/camera vendor/qcom/sdm845 vendor/google/interfaces vendor/qcom/bonito/proprietary
============================================
ninja: no work to do.
#### build completed successfully (2 seconds) ####
aw@m:~/works/android/aosp/aosp11/out/soong/.intermediates/frameworks/vendor$ tree .
.
└── service
├── libsampleservice
│ ├── android_arm64_armv8-a_shared
│ │ ├── gen
│ │ │ └── aidl
│ │ │ ├── android
│ │ │ │ └── sample
│ │ │ │ ├── BnSample.h
│ │ │ │ ├── BpSample.h
│ │ │ │ └── ISample.h
│ │ │ └── frameworks
│ │ │ └── vendor
│ │ │ └── service
│ │ │ └── aidl
│ │ │ └── android
│ │ │ └── sample
│ │ │ ├── ISample.cpp
│ │ │ └── ISample.cpp.d
│ │ ├── libsampleservice.so
│ │ ├── libsampleservice.so.d
│ │ ├── libsampleservice.so.toc
│ │ ├── libsampleservice.so.toc.d
│ │ ├── obj
│ │ │ └── frameworks
│ │ │ └── vendor
│ │ │ └── service
│ │ │ ├── SampleService.o
│ │ │ └── SampleService.o.d
│ │ └── unstripped
│ │ ├── libsampleservice.so
│ │ └── libsampleservice.so.rsp
│ └── android_arm_armv8-a_shared
│ ├── gen
│ │ └── aidl
│ │ ├── android
│ │ │ └── sample
│ │ │ ├── BnSample.h
│ │ │ ├── BpSample.h
│ │ │ └── ISample.h
│ │ └── frameworks
│ │ └── vendor
│ │ └── service
│ │ └── aidl
│ │ └── android
│ │ └── sample
│ │ ├── ISample.cpp
│ │ └── ISample.cpp.d
│ ├── libsampleservice.so
│ ├── libsampleservice.so.d
│ ├── libsampleservice.so.toc
│ ├── libsampleservice.so.toc.d
│ ├── obj
│ │ └── frameworks
│ │ └── vendor
│ │ └── service
│ │ ├── SampleService.o
│ │ └── SampleService.o.d
│ └── unstripped
│ ├── libsampleservice.so
│ └── libsampleservice.so.rsp
├── sampleClient
│ └── android_arm64_armv8-a
│ ├── obj
│ │ └── frameworks
│ │ └── vendor
│ │ └── service
│ │ └── test
│ │ ├── SampleClient.o
│ │ └── SampleClient.o.d
│ ├── sampleClient
│ ├── sampleClient.d
│ └── unstripped
│ ├── sampleClient
│ └── sampleClient.rsp
└── sampleService
└── android_arm64_armv8-a
├── obj
│ └── frameworks
│ └── vendor
│ └── service
│ └── test
│ ├── SampleServer.o
│ └── SampleServer.o.d
├── sampleService
├── sampleService.d
└── unstripped
├── sampleService
└── sampleService.rsp
50 directories, 38 files
将libsampleservice.so放到手机 [已root] 的system/lib64和system/lib目录下,重启设备
bonito:/system/lib64 # ls -lhia libsampleservice.so
86 -rwxrwxrwx 1 root root 33K 2021-11-20 20:05 libsampleservice.so
bonito:/system/lib64 # chmod 777 libsampleservice.so
bonito:/system/lib64 # exit
aw@m:~/Downloads$ adb reboot
将sampleService和sampleClient可执行文件放到/data/local/tmp目录下,执行测试,输出三遍Hello表示成功了
bonito:/data/local/tmp # ls
lldb-server localLogcat perfd sampleClient sampleService
bonito:/data/local/tmp # ./sampleService &
[1] 9389
bonito:/data/local/tmp # ./sampleClient
Hello
Hello
Hello
bonito:/data/local/tmp #
文章浏览阅读645次。这个肯定是末尾的IDAT了,因为IDAT必须要满了才会开始一下个IDAT,这个明显就是末尾的IDAT了。,对应下面的create_head()代码。,对应下面的create_tail()代码。不要考虑爆破,我已经试了一下,太多情况了。题目来源:UNCTF。_攻防世界困难模式攻略图文
文章浏览阅读2.9k次,点赞3次,收藏10次。偶尔会用到,记录、分享。1. 数据库导出1.1 切换到dmdba用户su - dmdba1.2 进入达梦数据库安装路径的bin目录,执行导库操作 导出语句:./dexp cwy_init/[email protected]:5236 file=cwy_init.dmp log=cwy_init_exp.log 注释: cwy_init/init_123..._达梦数据库导入导出
文章浏览阅读1.9k次。1. 在官网上下载KindEditor文件,可以删掉不需要要到的jsp,asp,asp.net和php文件夹。接着把文件夹放到项目文件目录下。2. 修改html文件,在页面引入js文件:<script type="text/javascript" src="./kindeditor/kindeditor-all.js"></script><script type="text/javascript" src="./kindeditor/lang/zh-CN.js"_kindeditor.js
文章浏览阅读2.3k次,点赞6次,收藏14次。SPI的详情简介不必赘述。假设我们通过SPI发送0xAA,我们的数据线就会变为10101010,通过修改不同的内容,即可修改SPI中0和1的持续时间。比如0xF0即为前半周期为高电平,后半周期为低电平的状态。在SPI的通信模式中,CPHA配置会影响该实验,下图展示了不同采样位置的SPI时序图[1]。CPOL = 0,CPHA = 1:CLK空闲状态 = 低电平,数据在下降沿采样,并在上升沿移出CPOL = 0,CPHA = 0:CLK空闲状态 = 低电平,数据在上升沿采样,并在下降沿移出。_stm32g431cbu6
文章浏览阅读1.2k次,点赞2次,收藏8次。数据链路层习题自测问题1.数据链路(即逻辑链路)与链路(即物理链路)有何区别?“电路接通了”与”数据链路接通了”的区别何在?2.数据链路层中的链路控制包括哪些功能?试讨论数据链路层做成可靠的链路层有哪些优点和缺点。3.网络适配器的作用是什么?网络适配器工作在哪一层?4.数据链路层的三个基本问题(帧定界、透明传输和差错检测)为什么都必须加以解决?5.如果在数据链路层不进行帧定界,会发生什么问题?6.PPP协议的主要特点是什么?为什么PPP不使用帧的编号?PPP适用于什么情况?为什么PPP协议不_接收方收到链路层数据后,使用crc检验后,余数为0,说明链路层的传输时可靠传输
文章浏览阅读587次。软件测试工程师移民加拿大 无证移民,未受过软件工程师的教育(第1部分) (Undocumented Immigrant With No Education to Software Engineer(Part 1))Before I start, I want you to please bear with me on the way I write, I have very little gen...
文章浏览阅读304次。Thinkpad X250笔记本电脑,装的是FreeBSD,进入BIOS修改虚拟化配置(其后可能是误设置了安全开机),保存退出后系统无法启动,显示:secure boot failed ,把自己惊出一身冷汗,因为这台笔记本刚好还没开始做备份.....根据错误提示,到bios里面去找相关配置,在Security里面找到了Secure Boot选项,发现果然被设置为Enabled,将其修改为Disabled ,再开机,终于正常启动了。_安装完系统提示secureboot failure
文章浏览阅读10w+次,点赞93次,收藏352次。1、用strtok函数进行字符串分割原型: char *strtok(char *str, const char *delim);功能:分解字符串为一组字符串。参数说明:str为要分解的字符串,delim为分隔符字符串。返回值:从str开头开始的一个个被分割的串。当没有被分割的串时则返回NULL。其它:strtok函数线程不安全,可以使用strtok_r替代。示例://借助strtok实现split#include <string.h>#include <stdio.h&_c++ 字符串分割
文章浏览阅读2.3k次。1 .高斯日记 大数学家高斯有个好习惯:无论如何都要记日记。他的日记有个与众不同的地方,他从不注明年月日,而是用一个整数代替,比如:4210后来人们知道,那个整数就是日期,它表示那一天是高斯出生后的第几天。这或许也是个好习惯,它时时刻刻提醒着主人:日子又过去一天,还有多少时光可以用于浪费呢?高斯出生于:1777年4月30日。在高斯发现的一个重要定理的日记_2013年第四届c a组蓝桥杯省赛真题解答
文章浏览阅读851次,点赞17次,收藏22次。摘要:本文利用供需算法对核极限学习机(KELM)进行优化,并用于分类。
文章浏览阅读1.1k次。一、系统弱密码登录1、在kali上执行命令行telnet 192.168.26.1292、Login和password都输入msfadmin3、登录成功,进入系统4、测试如下:二、MySQL弱密码登录:1、在kali上执行mysql –h 192.168.26.129 –u root2、登录成功,进入MySQL系统3、测试效果:三、PostgreSQL弱密码登录1、在Kali上执行psql -h 192.168.26.129 –U post..._metasploitable2怎么进入
文章浏览阅读257次。本文将为初学者提供Python学习的详细指南,从Python的历史、基础语法和数据类型到面向对象编程、模块和库的使用。通过本文,您将能够掌握Python编程的核心概念,为今后的编程学习和实践打下坚实基础。_python人工智能开发从入门到精通pdf