Lines Matching refs:context
48 static void init_context(android_log_context_internal* context, uint32_t tag) { in init_context() argument
49 context->tag = tag; in init_context()
50 context->read_write_flag = kAndroidLoggerWrite; in init_context()
52 if ((context->pos + needed) > MAX_EVENT_PAYLOAD) { in init_context()
53 context->overflow = true; in init_context()
56 context->storage[context->pos + 0] = EVENT_TYPE_LIST; in init_context()
57 context->list[0] = context->pos + 1; in init_context()
58 context->pos += needed; in init_context()
61 static void init_parser_context(android_log_context_internal* context, const char* msg, in init_parser_context() argument
64 context->len = len; in init_parser_context()
65 memcpy(context->storage, msg, len); in init_parser_context()
66 context->read_write_flag = kAndroidLoggerRead; in init_parser_context()
70 android_log_context_internal* context; in create_android_logger() local
72 context = in create_android_logger()
74 if (!context) { in create_android_logger()
77 init_context(context, tag); in create_android_logger()
79 return (android_log_context)context; in create_android_logger()
83 android_log_context_internal* context; in create_android_log_parser() local
85 context = in create_android_log_parser()
87 if (!context) { in create_android_log_parser()
90 init_parser_context(context, msg, len); in create_android_log_parser()
92 return (android_log_context)context; in create_android_log_parser()
96 android_log_context_internal* context; in android_log_destroy() local
98 context = (android_log_context_internal*)*ctx; in android_log_destroy()
99 if (!context) { in android_log_destroy()
102 memset(context, 0, sizeof(*context)); in android_log_destroy()
103 free(context); in android_log_destroy()
108 int android_log_reset(android_log_context context) { in android_log_reset() argument
111 if (!context || (kAndroidLoggerWrite != context->read_write_flag)) { in android_log_reset()
115 tag = context->tag; in android_log_reset()
116 memset(context, 0, sizeof(*context)); in android_log_reset()
117 init_context(context, tag); in android_log_reset()
122 int android_log_parser_reset(android_log_context context, const char* msg, size_t len) { in android_log_parser_reset() argument
123 if (!context || (kAndroidLoggerRead != context->read_write_flag)) { in android_log_parser_reset()
127 memset(context, 0, sizeof(*context)); in android_log_parser_reset()
128 init_parser_context(context, msg, len); in android_log_parser_reset()
133 int android_log_write_list_begin(android_log_context context) { in android_log_write_list_begin() argument
134 if (!context || (kAndroidLoggerWrite != context->read_write_flag)) { in android_log_write_list_begin()
137 if (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) { in android_log_write_list_begin()
138 context->overflow = true; in android_log_write_list_begin()
142 if ((context->pos + needed) > MAX_EVENT_PAYLOAD) { in android_log_write_list_begin()
143 context->overflow = true; in android_log_write_list_begin()
146 context->count[context->list_nest_depth]++; in android_log_write_list_begin()
147 context->list_nest_depth++; in android_log_write_list_begin()
148 if (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) { in android_log_write_list_begin()
149 context->overflow = true; in android_log_write_list_begin()
152 if (context->overflow) { in android_log_write_list_begin()
155 auto* event_list = reinterpret_cast<android_event_list_t*>(&context->storage[context->pos]); in android_log_write_list_begin()
158 context->list[context->list_nest_depth] = context->pos + 1; in android_log_write_list_begin()
159 context->count[context->list_nest_depth] = 0; in android_log_write_list_begin()
160 context->pos += needed; in android_log_write_list_begin()
164 int android_log_write_int32(android_log_context context, int32_t value) { in android_log_write_int32() argument
165 if (!context || (kAndroidLoggerWrite != context->read_write_flag)) { in android_log_write_int32()
168 if (context->overflow) { in android_log_write_int32()
172 if ((context->pos + needed) > MAX_EVENT_PAYLOAD) { in android_log_write_int32()
173 context->overflow = true; in android_log_write_int32()
176 context->count[context->list_nest_depth]++; in android_log_write_int32()
177 auto* event_int = reinterpret_cast<android_event_int_t*>(&context->storage[context->pos]); in android_log_write_int32()
180 context->pos += needed; in android_log_write_int32()
184 int android_log_write_int64(android_log_context context, int64_t value) { in android_log_write_int64() argument
185 if (!context || (kAndroidLoggerWrite != context->read_write_flag)) { in android_log_write_int64()
188 if (context->overflow) { in android_log_write_int64()
192 if ((context->pos + needed) > MAX_EVENT_PAYLOAD) { in android_log_write_int64()
193 context->overflow = true; in android_log_write_int64()
196 context->count[context->list_nest_depth]++; in android_log_write_int64()
197 auto* event_long = reinterpret_cast<android_event_long_t*>(&context->storage[context->pos]); in android_log_write_int64()
200 context->pos += needed; in android_log_write_int64()
204 int android_log_write_string8_len(android_log_context context, const char* value, size_t maxlen) { in android_log_write_string8_len() argument
205 if (!context || (kAndroidLoggerWrite != context->read_write_flag)) { in android_log_write_string8_len()
208 if (context->overflow) { in android_log_write_string8_len()
216 if ((context->pos + needed) > MAX_EVENT_PAYLOAD) { in android_log_write_string8_len()
218 len = MAX_EVENT_PAYLOAD - context->pos - 1 - sizeof(int32_t); in android_log_write_string8_len()
220 context->overflow = true; in android_log_write_string8_len()
224 context->count[context->list_nest_depth]++; in android_log_write_string8_len()
225 auto* event_string = reinterpret_cast<android_event_string_t*>(&context->storage[context->pos]); in android_log_write_string8_len()
231 context->pos += needed; in android_log_write_string8_len()
239 int android_log_write_float32(android_log_context context, float value) { in android_log_write_float32() argument
240 if (!context || (kAndroidLoggerWrite != context->read_write_flag)) { in android_log_write_float32()
243 if (context->overflow) { in android_log_write_float32()
247 if ((context->pos + needed) > MAX_EVENT_PAYLOAD) { in android_log_write_float32()
248 context->overflow = true; in android_log_write_float32()
251 context->count[context->list_nest_depth]++; in android_log_write_float32()
252 auto* event_float = reinterpret_cast<android_event_float_t*>(&context->storage[context->pos]); in android_log_write_float32()
255 context->pos += needed; in android_log_write_float32()
259 int android_log_write_list_end(android_log_context context) { in android_log_write_list_end() argument
260 if (!context || (kAndroidLoggerWrite != context->read_write_flag)) { in android_log_write_list_end()
263 if (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) { in android_log_write_list_end()
264 context->overflow = true; in android_log_write_list_end()
265 context->list_nest_depth--; in android_log_write_list_end()
268 if (!context->list_nest_depth) { in android_log_write_list_end()
269 context->overflow = true; in android_log_write_list_end()
272 if (context->list[context->list_nest_depth] <= 0) { in android_log_write_list_end()
273 context->list_nest_depth--; in android_log_write_list_end()
274 context->overflow = true; in android_log_write_list_end()
277 context->storage[context->list[context->list_nest_depth]] = in android_log_write_list_end()
278 context->count[context->list_nest_depth]; in android_log_write_list_end()
279 context->list_nest_depth--; in android_log_write_list_end()
286 int android_log_write_list(android_log_context context, log_id_t id) { in android_log_write_list() argument
294 if (!context || (kAndroidLoggerWrite != context->read_write_flag)) { in android_log_write_list()
297 if (context->list_nest_depth) { in android_log_write_list()
301 context->storage[1] = context->count[0]; in android_log_write_list()
302 len = context->len = context->pos; in android_log_write_list()
303 msg = (const char*)context->storage; in android_log_write_list()
305 if (context->count[0] <= 1) { in android_log_write_list()
313 ? __android_log_bwrite(context->tag, msg, len) in android_log_write_list()
314 : ((id == LOG_ID_STATS) ? __android_log_stats_bwrite(context->tag, msg, len) in android_log_write_list()
315 : __android_log_security_bwrite(context->tag, msg, len)); in android_log_write_list()
318 int android_log_write_list_buffer(android_log_context context, const char** buffer) { in android_log_write_list_buffer() argument
322 if (!context || (kAndroidLoggerWrite != context->read_write_flag)) { in android_log_write_list_buffer()
325 if (context->list_nest_depth) { in android_log_write_list_buffer()
332 context->storage[1] = context->count[0]; in android_log_write_list_buffer()
333 len = context->len = context->pos; in android_log_write_list_buffer()
334 msg = (const char*)context->storage; in android_log_write_list_buffer()
336 if (context->count[0] <= 1) { in android_log_write_list_buffer()
354 static android_log_list_element android_log_read_next_internal(android_log_context context, in android_log_read_next_internal() argument
362 if (!context || (kAndroidLoggerRead != context->read_write_flag) || in android_log_read_next_internal()
363 (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) || in android_log_read_next_internal()
364 (context->count[context->list_nest_depth] >= in android_log_read_next_internal()
367 if (context && in android_log_read_next_internal()
368 (context->list_stop || ((context->list_nest_depth <= ANDROID_MAX_LIST_NEST_DEPTH) && in android_log_read_next_internal()
369 !context->count[context->list_nest_depth]))) { in android_log_read_next_internal()
380 pos = context->pos; in android_log_read_next_internal()
381 if (context->list_stop) { in android_log_read_next_internal()
383 elem.complete = !context->count[0] && (!context->list_nest_depth || in android_log_read_next_internal()
384 ((context->list_nest_depth == 1) && !context->count[1])); in android_log_read_next_internal()
387 if (context->storage[pos] == EVENT_TYPE_LIST_STOP) { in android_log_read_next_internal()
388 context->pos = pos + 1; in android_log_read_next_internal()
390 if (context->list_nest_depth) { in android_log_read_next_internal()
391 --context->list_nest_depth; in android_log_read_next_internal()
392 if (context->count[context->list_nest_depth]) { in android_log_read_next_internal()
393 context->list_stop = false; in android_log_read_next_internal()
396 context->list_stop = false; in android_log_read_next_internal()
401 if ((pos + 1) > context->len) { in android_log_read_next_internal()
407 elem.type = static_cast<AndroidEventLogType>(context->storage[pos]); in android_log_read_next_internal()
414 if ((pos + sizeof(android_event_int_t)) > context->len) { in android_log_read_next_internal()
419 auto* event_int = reinterpret_cast<android_event_int_t*>(&context->storage[pos]); in android_log_read_next_internal()
423 elem.complete = !context->list_nest_depth && !context->count[0]; in android_log_read_next_internal()
425 if (!context->count[context->list_nest_depth] || in android_log_read_next_internal()
426 !--(context->count[context->list_nest_depth])) { in android_log_read_next_internal()
427 context->list_stop = true; in android_log_read_next_internal()
429 context->pos = pos; in android_log_read_next_internal()
436 if ((pos + sizeof(android_event_long_t)) > context->len) { in android_log_read_next_internal()
441 auto* event_long = reinterpret_cast<android_event_long_t*>(&context->storage[pos]); in android_log_read_next_internal()
445 elem.complete = !context->list_nest_depth && !context->count[0]; in android_log_read_next_internal()
447 if (!context->count[context->list_nest_depth] || in android_log_read_next_internal()
448 !--(context->count[context->list_nest_depth])) { in android_log_read_next_internal()
449 context->list_stop = true; in android_log_read_next_internal()
451 context->pos = pos; in android_log_read_next_internal()
457 if ((pos + sizeof(android_event_string_t)) > context->len) { in android_log_read_next_internal()
462 auto* event_string = reinterpret_cast<android_event_string_t*>(&context->storage[pos]); in android_log_read_next_internal()
470 if ((pos + elem.len) > context->len) { in android_log_read_next_internal()
471 elem.len = context->len - pos; /* truncate string */ in android_log_read_next_internal()
481 elem.complete = !context->list_nest_depth && !context->count[0]; in android_log_read_next_internal()
483 if (!context->count[context->list_nest_depth] || in android_log_read_next_internal()
484 !--(context->count[context->list_nest_depth])) { in android_log_read_next_internal()
485 context->list_stop = true; in android_log_read_next_internal()
487 context->pos = pos; in android_log_read_next_internal()
493 if ((pos + sizeof(android_event_list_t)) > context->len) { in android_log_read_next_internal()
498 auto* event_list = reinterpret_cast<android_event_list_t*>(&context->storage[pos]); in android_log_read_next_internal()
500 elem.complete = context->list_nest_depth >= ANDROID_MAX_LIST_NEST_DEPTH; in android_log_read_next_internal()
504 if (context->count[context->list_nest_depth]) { in android_log_read_next_internal()
505 context->count[context->list_nest_depth]--; in android_log_read_next_internal()
507 context->list_stop = event_list->element_count == 0; in android_log_read_next_internal()
508 context->list_nest_depth++; in android_log_read_next_internal()
509 if (context->list_nest_depth <= ANDROID_MAX_LIST_NEST_DEPTH) { in android_log_read_next_internal()
510 context->count[context->list_nest_depth] = event_list->element_count; in android_log_read_next_internal()
512 context->pos = pos; in android_log_read_next_internal()
519 context->pos = pos; in android_log_read_next_internal()
522 elem.complete = !context->list_nest_depth; in android_log_read_next_internal()
523 if (context->list_nest_depth > 0) { in android_log_read_next_internal()
526 context->list_nest_depth--; in android_log_read_next_internal()