1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HISYSEVENT_INTERFACES_NATIVE_INNERKITS_HISYSEVENT_INCLUDE_INNER_WRITER_H 17 #define HISYSEVENT_INTERFACES_NATIVE_INNERKITS_HISYSEVENT_INCLUDE_INNER_WRITER_H 18 19 #include <iostream> 20 #include <memory> 21 #include <string> 22 #include <sstream> 23 #include <vector> 24 25 #include "encoded_param.h" 26 #include "def.h" 27 #include "hisysevent_c.h" 28 #include "raw_data_builder.h" 29 #include "raw_data.h" 30 #include "stringfilter.h" 31 32 namespace OHOS { 33 namespace HiviewDFX { 34 using namespace Encoded; 35 class InnerWriter { 36 friend class HiSysEvent; 37 friend class NapiHiSysEventAdapter; 38 39 private: 40 class EventBase { 41 public: 42 EventBase(const std::string& domain, const std::string& eventName, int type); 43 ~EventBase() = default; 44 45 public: 46 RawDataBuilder& GetEventBuilder(); 47 int GetRetCode(); 48 void SetRetCode(int retCode); 49 size_t GetParamCnt(); 50 std::shared_ptr<RawData> GetEventRawData(); 51 52 private: 53 int retCode_; 54 RawDataBuilder builder_; 55 }; 56 57 private: 58 template<typename... Types> InnerWrite(const std::string & domain,const std::string & eventName,int type,Types...keyValues)59 static int InnerWrite(const std::string& domain, const std::string& eventName, 60 int type, Types... keyValues) 61 { 62 EventBase eventBase(domain, eventName, type); 63 WritebaseInfo(eventBase); 64 if (IsError(eventBase)) { 65 ExplainRetCode(eventBase); 66 return eventBase.GetRetCode(); 67 } 68 69 InnerWrite(eventBase, keyValues...); 70 if (IsError(eventBase)) { 71 ExplainRetCode(eventBase); 72 return eventBase.GetRetCode(); 73 } 74 75 SendSysEvent(eventBase); 76 return eventBase.GetRetCode(); 77 } 78 CheckParamValidity(EventBase & eventBase,const std::string & key)79 static bool CheckParamValidity(EventBase& eventBase, const std::string &key) 80 { 81 if (IsWarnAndUpdate(CheckKey(key), eventBase)) { 82 return false; 83 } 84 if (UpdateAndCheckKeyNumIsOver(eventBase)) { 85 return false; 86 } 87 return true; 88 } 89 90 template<typename T> CheckArrayValidity(EventBase & eventBase,const T * array)91 static bool CheckArrayValidity(EventBase& eventBase, const T* array) 92 { 93 if (array == nullptr) { 94 eventBase.SetRetCode(ERR_VALUE_INVALID); 95 return false; 96 } 97 return true; 98 } 99 100 template<typename T> CheckArrayParamsValidity(EventBase & eventBase,const std::string & key,const std::vector<T> & value)101 static bool CheckArrayParamsValidity(EventBase& eventBase, const std::string& key, const std::vector<T>& value) 102 { 103 if (!CheckParamValidity(eventBase, key)) { 104 return false; 105 } 106 if (value.empty()) { 107 std::vector<bool> boolArrayValue; 108 eventBase.GetEventBuilder().AppendValue(std::make_shared<SignedVarintEncodedArrayParam<bool>>(key, 109 boolArrayValue)); 110 return false; 111 } 112 IsWarnAndUpdate(CheckArraySize(value.size()), eventBase); 113 return true; 114 } 115 116 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,bool value,Types...keyValues)117 static void InnerWrite(EventBase& eventBase, const std::string& key, bool value, Types... keyValues) 118 { 119 if (CheckParamValidity(eventBase, key)) { 120 eventBase.GetEventBuilder().AppendValue(std::make_shared<SignedVarintEncodedParam<bool>>(key, value)); 121 } 122 InnerWrite(eventBase, keyValues...); 123 } 124 125 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const char value,Types...keyValues)126 static void InnerWrite(EventBase& eventBase, const std::string& key, const char value, Types... keyValues) 127 { 128 if (CheckParamValidity(eventBase, key)) { 129 eventBase.GetEventBuilder().AppendValue(std::make_shared<SignedVarintEncodedParam<int8_t>>(key, 130 static_cast<int8_t>(value))); 131 } 132 InnerWrite(eventBase, keyValues...); 133 } 134 135 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const unsigned char value,Types...keyValues)136 static void InnerWrite(EventBase& eventBase, const std::string& key, const unsigned char value, 137 Types... keyValues) 138 { 139 if (CheckParamValidity(eventBase, key)) { 140 eventBase.GetEventBuilder().AppendValue(std::make_shared<UnsignedVarintEncodedParam<uint8_t>>(key, 141 static_cast<uint8_t>(value))); 142 } 143 InnerWrite(eventBase, keyValues...); 144 } 145 146 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const short value,Types...keyValues)147 static void InnerWrite(EventBase& eventBase, const std::string& key, const short value, Types... keyValues) 148 { 149 if (CheckParamValidity(eventBase, key)) { 150 eventBase.GetEventBuilder().AppendValue(std::make_shared<SignedVarintEncodedParam<int16_t>>(key, 151 static_cast<int16_t>(value))); 152 } 153 InnerWrite(eventBase, keyValues...); 154 } 155 156 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const unsigned short value,Types...keyValues)157 static void InnerWrite(EventBase& eventBase, const std::string& key, const unsigned short value, 158 Types... keyValues) 159 { 160 if (CheckParamValidity(eventBase, key)) { 161 eventBase.GetEventBuilder().AppendValue(std::make_shared<UnsignedVarintEncodedParam<uint16_t>>(key, 162 static_cast<uint16_t>(value))); 163 } 164 InnerWrite(eventBase, keyValues...); 165 } 166 167 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const int value,Types...keyValues)168 static void InnerWrite(EventBase& eventBase, const std::string& key, const int value, Types... keyValues) 169 { 170 if (CheckParamValidity(eventBase, key)) { 171 eventBase.GetEventBuilder().AppendValue(std::make_shared<SignedVarintEncodedParam<int32_t>>(key, value)); 172 } 173 InnerWrite(eventBase, keyValues...); 174 } 175 176 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const unsigned int value,Types...keyValues)177 static void InnerWrite(EventBase& eventBase, const std::string& key, const unsigned int value, 178 Types... keyValues) 179 { 180 if (CheckParamValidity(eventBase, key)) { 181 eventBase.GetEventBuilder().AppendValue(std::make_shared<UnsignedVarintEncodedParam<uint32_t>>(key, 182 value)); 183 } 184 InnerWrite(eventBase, keyValues...); 185 } 186 187 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const long value,Types...keyValues)188 static void InnerWrite(EventBase& eventBase, const std::string& key, const long value, Types... keyValues) 189 { 190 if (CheckParamValidity(eventBase, key)) { 191 eventBase.GetEventBuilder().AppendValue(std::make_shared<SignedVarintEncodedParam<int64_t>>(key, 192 static_cast<int64_t>(value))); 193 } 194 InnerWrite(eventBase, keyValues...); 195 } 196 197 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const unsigned long value,Types...keyValues)198 static void InnerWrite(EventBase& eventBase, const std::string& key, const unsigned long value, 199 Types... keyValues) 200 { 201 if (CheckParamValidity(eventBase, key)) { 202 eventBase.GetEventBuilder().AppendValue(std::make_shared<UnsignedVarintEncodedParam<uint64_t>>(key, 203 static_cast<uint64_t>(value))); 204 } 205 InnerWrite(eventBase, keyValues...); 206 } 207 208 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const long long value,Types...keyValues)209 static void InnerWrite(EventBase& eventBase, const std::string& key, const long long value, Types... keyValues) 210 { 211 if (CheckParamValidity(eventBase, key)) { 212 eventBase.GetEventBuilder().AppendValue(std::make_shared<SignedVarintEncodedParam<int64_t>>(key, 213 static_cast<int64_t>(value))); 214 } 215 InnerWrite(eventBase, keyValues...); 216 } 217 218 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const unsigned long long value,Types...keyValues)219 static void InnerWrite(EventBase& eventBase, const std::string& key, const unsigned long long value, 220 Types... keyValues) 221 { 222 if (CheckParamValidity(eventBase, key)) { 223 eventBase.GetEventBuilder().AppendValue(std::make_shared<UnsignedVarintEncodedParam<uint64_t>>(key, 224 static_cast<uint64_t>(value))); 225 } 226 InnerWrite(eventBase, keyValues...); 227 } 228 229 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const float value,Types...keyValues)230 static void InnerWrite(EventBase& eventBase, const std::string& key, const float value, Types... keyValues) 231 { 232 if (CheckParamValidity(eventBase, key)) { 233 eventBase.GetEventBuilder().AppendValue(std::make_shared<FloatingNumberEncodedParam<float>>(key, value)); 234 } 235 InnerWrite(eventBase, keyValues...); 236 } 237 238 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const double value,Types...keyValues)239 static void InnerWrite(EventBase& eventBase, const std::string& key, const double value, Types... keyValues) 240 { 241 if (CheckParamValidity(eventBase, key)) { 242 eventBase.GetEventBuilder().AppendValue(std::make_shared<FloatingNumberEncodedParam<double>>(key, value)); 243 } 244 InnerWrite(eventBase, keyValues...); 245 } 246 247 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const std::string & value,Types...keyValues)248 static void InnerWrite(EventBase& eventBase, const std::string& key, const std::string& value, 249 Types... keyValues) 250 { 251 if (CheckParamValidity(eventBase, key)) { 252 IsWarnAndUpdate(CheckValue(value), eventBase); 253 auto rawStr = StringFilter::GetInstance().EscapeToRaw(value); 254 eventBase.GetEventBuilder().AppendValue(std::make_shared<StringEncodedParam>(key, rawStr)); 255 } 256 InnerWrite(eventBase, keyValues...); 257 } 258 259 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const char * value,Types...keyValues)260 static void InnerWrite(EventBase& eventBase, const std::string& key, const char* value, Types... keyValues) 261 { 262 if (CheckParamValidity(eventBase, key)) { 263 IsWarnAndUpdate(CheckValue(std::string(value)), eventBase); 264 auto rawStr = StringFilter::GetInstance().EscapeToRaw(std::string(value)); 265 eventBase.GetEventBuilder().AppendValue(std::make_shared<StringEncodedParam>(key, std::string(rawStr))); 266 } 267 InnerWrite(eventBase, keyValues...); 268 } 269 270 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const std::vector<bool> & value,Types...keyValues)271 static void InnerWrite(EventBase& eventBase, const std::string& key, const std::vector<bool>& value, 272 Types... keyValues) 273 { 274 if (CheckArrayParamsValidity(eventBase, key, value)) { 275 eventBase.GetEventBuilder().AppendValue(std::make_shared<SignedVarintEncodedArrayParam<bool>>(key, 276 value)); 277 } 278 InnerWrite(eventBase, keyValues...); 279 } 280 281 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const std::vector<char> & value,Types...keyValues)282 static void InnerWrite(EventBase& eventBase, const std::string& key, const std::vector<char>& value, 283 Types... keyValues) 284 { 285 if (CheckArrayParamsValidity(eventBase, key, value)) { 286 std::vector<int8_t> translated; 287 for (auto item : value) { 288 translated.emplace_back(static_cast<int8_t>(item)); 289 } 290 eventBase.GetEventBuilder().AppendValue(std::make_shared<SignedVarintEncodedArrayParam<int8_t>>(key, 291 translated)); 292 } 293 InnerWrite(eventBase, keyValues...); 294 } 295 296 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const std::vector<unsigned char> & value,Types...keyValues)297 static void InnerWrite(EventBase& eventBase, const std::string& key, const std::vector<unsigned char>& value, 298 Types... keyValues) 299 { 300 if (CheckArrayParamsValidity(eventBase, key, value)) { 301 std::vector<uint8_t> translated; 302 for (auto item : value) { 303 translated.emplace_back(static_cast<uint8_t>(item)); 304 } 305 eventBase.GetEventBuilder().AppendValue(std::make_shared<UnsignedVarintEncodedArrayParam<uint8_t>>(key, 306 translated)); 307 } 308 InnerWrite(eventBase, keyValues...); 309 } 310 311 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const std::vector<short> & value,Types...keyValues)312 static void InnerWrite(EventBase& eventBase, const std::string& key, const std::vector<short>& value, 313 Types... keyValues) 314 { 315 if (CheckArrayParamsValidity(eventBase, key, value)) { 316 std::vector<int16_t> translated; 317 for (auto item : value) { 318 translated.emplace_back(static_cast<int16_t>(item)); 319 } 320 eventBase.GetEventBuilder().AppendValue(std::make_shared<SignedVarintEncodedArrayParam<int16_t>>(key, 321 translated)); 322 } 323 InnerWrite(eventBase, keyValues...); 324 } 325 326 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const std::vector<unsigned short> & value,Types...keyValues)327 static void InnerWrite(EventBase& eventBase, const std::string& key, const std::vector<unsigned short>& value, 328 Types... keyValues) 329 { 330 if (CheckArrayParamsValidity(eventBase, key, value)) { 331 std::vector<uint16_t> translated; 332 for (auto item : value) { 333 translated.emplace_back(static_cast<uint16_t>(item)); 334 } 335 eventBase.GetEventBuilder().AppendValue(std::make_shared<UnsignedVarintEncodedArrayParam<uint16_t>>(key, 336 translated)); 337 } 338 InnerWrite(eventBase, keyValues...); 339 } 340 341 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const std::vector<int> & value,Types...keyValues)342 static void InnerWrite(EventBase& eventBase, const std::string& key, const std::vector<int>& value, 343 Types... keyValues) 344 { 345 if (CheckArrayParamsValidity(eventBase, key, value)) { 346 eventBase.GetEventBuilder().AppendValue(std::make_shared<SignedVarintEncodedArrayParam<int32_t>>(key, 347 value)); 348 } 349 InnerWrite(eventBase, keyValues...); 350 } 351 352 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const std::vector<unsigned int> & value,Types...keyValues)353 static void InnerWrite(EventBase& eventBase, const std::string& key, const std::vector<unsigned int>& value, 354 Types... keyValues) 355 { 356 if (CheckArrayParamsValidity(eventBase, key, value)) { 357 eventBase.GetEventBuilder().AppendValue(std::make_shared<UnsignedVarintEncodedArrayParam<uint32_t>>(key, 358 value)); 359 } 360 InnerWrite(eventBase, keyValues...); 361 } 362 363 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const std::vector<long> & value,Types...keyValues)364 static void InnerWrite(EventBase& eventBase, const std::string& key, const std::vector<long>& value, 365 Types... keyValues) 366 { 367 if (CheckArrayParamsValidity(eventBase, key, value)) { 368 std::vector<int64_t> translated; 369 for (auto item : value) { 370 translated.emplace_back(static_cast<int64_t>(item)); 371 } 372 eventBase.GetEventBuilder().AppendValue(std::make_shared<SignedVarintEncodedArrayParam<int64_t>>(key, 373 translated)); 374 } 375 InnerWrite(eventBase, keyValues...); 376 } 377 378 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const std::vector<unsigned long> & value,Types...keyValues)379 static void InnerWrite(EventBase& eventBase, const std::string& key, const std::vector<unsigned long>& value, 380 Types... keyValues) 381 { 382 if (CheckArrayParamsValidity(eventBase, key, value)) { 383 std::vector<uint64_t> translated; 384 for (auto item : value) { 385 translated.emplace_back(static_cast<uint64_t>(item)); 386 } 387 eventBase.GetEventBuilder().AppendValue(std::make_shared<UnsignedVarintEncodedArrayParam<uint64_t>>(key, 388 translated)); 389 } 390 InnerWrite(eventBase, keyValues...); 391 } 392 393 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const std::vector<long long> & value,Types...keyValues)394 static void InnerWrite(EventBase& eventBase, const std::string& key, const std::vector<long long>& value, 395 Types... keyValues) 396 { 397 if (CheckArrayParamsValidity(eventBase, key, value)) { 398 std::vector<int64_t> translated; 399 for (auto item : value) { 400 translated.emplace_back(static_cast<int64_t>(item)); 401 } 402 eventBase.GetEventBuilder().AppendValue(std::make_shared<SignedVarintEncodedArrayParam<int64_t>>(key, 403 translated)); 404 } 405 InnerWrite(eventBase, keyValues...); 406 } 407 408 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const std::vector<unsigned long long> & value,Types...keyValues)409 static void InnerWrite(EventBase& eventBase, const std::string& key, const std::vector<unsigned long long>& value, 410 Types... keyValues) 411 { 412 if (CheckArrayParamsValidity(eventBase, key, value)) { 413 std::vector<uint64_t> translated; 414 for (auto item : value) { 415 translated.emplace_back(static_cast<uint64_t>(item)); 416 } 417 eventBase.GetEventBuilder().AppendValue(std::make_shared<UnsignedVarintEncodedArrayParam<uint64_t>>(key, 418 translated)); 419 } 420 InnerWrite(eventBase, keyValues...); 421 } 422 423 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const std::vector<float> & value,Types...keyValues)424 static void InnerWrite(EventBase& eventBase, const std::string& key, const std::vector<float>& value, 425 Types... keyValues) 426 { 427 if (CheckArrayParamsValidity(eventBase, key, value)) { 428 eventBase.GetEventBuilder().AppendValue(std::make_shared<FloatingNumberEncodedArrayParam<float>>(key, 429 value)); 430 } 431 InnerWrite(eventBase, keyValues...); 432 } 433 434 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const std::vector<double> & value,Types...keyValues)435 static void InnerWrite(EventBase& eventBase, const std::string& key, const std::vector<double>& value, 436 Types... keyValues) 437 { 438 if (CheckArrayParamsValidity(eventBase, key, value)) { 439 eventBase.GetEventBuilder().AppendValue(std::make_shared<FloatingNumberEncodedArrayParam<double>>(key, 440 value)); 441 } 442 InnerWrite(eventBase, keyValues...); 443 } 444 445 template<typename... Types> InnerWrite(EventBase & eventBase,const std::string & key,const std::vector<std::string> & value,Types...keyValues)446 static void InnerWrite(EventBase& eventBase, const std::string& key, const std::vector<std::string>& value, 447 Types... keyValues) 448 { 449 if (CheckArrayParamsValidity(eventBase, key, value)) { 450 std::vector<std::string> rawStrs; 451 for (auto& item : value) { 452 IsWarnAndUpdate(CheckValue(item), eventBase); 453 rawStrs.emplace_back(StringFilter::GetInstance().EscapeToRaw(item)); 454 } 455 eventBase.GetEventBuilder().AppendValue(std::make_shared<StringEncodedArrayParam>(key, rawStrs)); 456 } 457 InnerWrite(eventBase, keyValues...); 458 } 459 460 private: 461 static void InnerWrite(EventBase& eventBase); 462 static void InnerWrite(EventBase& eventBase, const HiSysEventParam params[], size_t size); 463 static void WritebaseInfo(EventBase& eventBase); 464 static void AppendHexData(EventBase& eventBase, const std::string& key, uint64_t value); 465 466 static int CheckKey(const std::string& key); 467 static int CheckValue(const std::string& value); 468 static int CheckArraySize(const size_t size); 469 static bool IsErrorAndUpdate(int retCode, EventBase& eventBase); 470 static bool IsWarnAndUpdate(int retCode, EventBase& eventBase); 471 static bool UpdateAndCheckKeyNumIsOver(EventBase& eventBase); 472 static bool IsError(EventBase& eventBase); 473 static void ExplainRetCode(EventBase& eventBase); 474 475 static void SendSysEvent(EventBase& eventBase); 476 477 static void AppendInvalidParam(EventBase& eventBase, const HiSysEventParam& param); 478 static void AppendBoolParam(EventBase& eventBase, const HiSysEventParam& param); 479 static void AppendInt8Param(EventBase& eventBase, const HiSysEventParam& param); 480 static void AppendUint8Param(EventBase& eventBase, const HiSysEventParam& param); 481 static void AppendInt16Param(EventBase& eventBase, const HiSysEventParam& param); 482 static void AppendUint16Param(EventBase& eventBase, const HiSysEventParam& param); 483 static void AppendInt32Param(EventBase& eventBase, const HiSysEventParam& param); 484 static void AppendUint32Param(EventBase& eventBase, const HiSysEventParam& param); 485 static void AppendInt64Param(EventBase& eventBase, const HiSysEventParam& param); 486 static void AppendUint64Param(EventBase& eventBase, const HiSysEventParam& param); 487 static void AppendFloatParam(EventBase& eventBase, const HiSysEventParam& param); 488 static void AppendDoubleParam(EventBase& eventBase, const HiSysEventParam& param); 489 static void AppendStringParam(EventBase& eventBase, const HiSysEventParam& param); 490 491 static void AppendBoolArrayParam(EventBase& eventBase, const HiSysEventParam& param); 492 static void AppendInt8ArrayParam(EventBase& eventBase, const HiSysEventParam& param); 493 static void AppendUint8ArrayParam(EventBase& eventBase, const HiSysEventParam& param); 494 static void AppendInt16ArrayParam(EventBase& eventBase, const HiSysEventParam& param); 495 static void AppendUint16ArrayParam(EventBase& eventBase, const HiSysEventParam& param); 496 static void AppendInt32ArrayParam(EventBase& eventBase, const HiSysEventParam& param); 497 static void AppendUint32ArrayParam(EventBase& eventBase, const HiSysEventParam& param); 498 static void AppendInt64ArrayParam(EventBase& eventBase, const HiSysEventParam& param); 499 static void AppendUint64ArrayParam(EventBase& eventBase, const HiSysEventParam& param); 500 static void AppendFloatArrayParam(EventBase& eventBase, const HiSysEventParam& param); 501 static void AppendDoubleArrayParam(EventBase& eventBase, const HiSysEventParam& param); 502 static void AppendStringArrayParam(EventBase& eventBase, const HiSysEventParam& param); 503 static void AppendParam(EventBase& eventBase, const HiSysEventParam& param); 504 }; 505 } // namespace HiviewDFX 506 } // namespace OHOS 507 508 #endif // HISYSEVENT_INTERFACES_NATIVE_INNERKITS_HISYSEVENT_INCLUDE_INNER_WRITER_H 509 510