From 4dec18b3bde2eb72214e0be953c2eb224008a8b7 Mon Sep 17 00:00:00 2001 From: hcj_ <1224667075@qq.com> Date: Tue, 30 Apr 2024 14:07:48 +0800 Subject: [PATCH] =?utf8?q?=E5=B0=86strtok=E6=94=B9=E4=B8=BAstrtok=5Fr?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../msg_center/src/msg_center_customer.cpp | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 366c2a0cf..476463ee1 100755 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -380,14 +380,21 @@ void MsgCenterNotifyCardProc(const Topic topic, Request* req) //green,red,ir int green,red,ir; char* str= (char *)req->data; + char *pchStrTmpIn = NULL; WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",str); char *tokbuf=NULL; - tokbuf=strtok(str,","); + tokbuf=strtok_r(str,",",&pchStrTmpIn); + if(tokbuf!=NULL) green=atoi(tokbuf); - tokbuf=strtok(NULL,","); - red=atoi(tokbuf); - tokbuf=strtok(NULL,"\0"); + + tokbuf=strtok_r(NULL,",",&pchStrTmpIn); + if(tokbuf!=NULL) + red=atoi(tokbuf); + + tokbuf=strtok_r(NULL,"\0",&pchStrTmpIn); + if(tokbuf!=NULL) ir=atoi(tokbuf); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d,%d,%d",green,red,ir); testhrsenson1View * t= testhrsenson1View::GetInstance(); @@ -406,14 +413,23 @@ void MsgCenterNotifyleaklightProc(const Topic topic, Request* req) //green,red,ir int green,red,ir; char* str= (char *)req->data; + char *pchStrTmpIn = NULL; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",str); + char *tokbuf=NULL; - tokbuf=strtok(str,","); + tokbuf=strtok_r(str,",",&pchStrTmpIn); + if(tokbuf!=NULL) green=atoi(tokbuf); - tokbuf=strtok(NULL,","); - red=atoi(tokbuf); - tokbuf=strtok(NULL,"\0"); + + tokbuf=strtok_r(NULL,",",&pchStrTmpIn); + if(tokbuf!=NULL) + red=atoi(tokbuf); + + tokbuf=strtok_r(NULL,"\0",&pchStrTmpIn); + if(tokbuf!=NULL) ir=atoi(tokbuf); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d,%d,%d",green,red,ir); testhrsenson1View * t= testhrsenson1View::GetInstance(); -- 2.17.1