OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <stdarg.h> |
| 6 #include <stdio.h> |
| 7 #include <string.h> |
| 8 |
| 9 #include <hardware/hardware.h> |
| 10 #include <cutils/properties.h> |
| 11 |
| 12 #define LOG_BUF_SIZE 1024 |
| 13 |
| 14 static int default_log_fn(int prio, const char* tag, const char* msg); |
| 15 |
| 16 static hwcplus_log_fn_t hwcplus_log_fn = default_log_fn; |
| 17 |
| 18 void hwcplus_set_log_fn(hwcplus_log_fn_t fn) { |
| 19 hwcplus_log_fn = fn; |
| 20 } |
| 21 |
| 22 #ifndef HAVE_STRLCPY |
| 23 size_t strlcpy(char* dst, const char* src, size_t siz) { |
| 24 char* d = dst; |
| 25 const char* s = src; |
| 26 size_t n = siz; |
| 27 |
| 28 /* Copy as many bytes as will fit */ |
| 29 if (n != 0) { |
| 30 while (--n != 0) { |
| 31 if ((*d++ = *s++) == '\0') |
| 32 break; |
| 33 } |
| 34 } |
| 35 |
| 36 /* Not enough room in dst, add NUL and traverse rest of src */ |
| 37 if (n == 0) { |
| 38 if (siz != 0) |
| 39 *d = '\0'; /* NUL-terminate dst */ |
| 40 while (*s++) { |
| 41 } |
| 42 } |
| 43 |
| 44 return(s - src - 1); /* count does not include NUL */ |
| 45 } |
| 46 #endif |
| 47 |
| 48 static int default_log_fn(int prio, const char* tag, const char* msg) { |
| 49 fprintf(stderr, "<%d> %s %s\n", prio, tag, msg); |
| 50 } |
| 51 |
| 52 int __android_log_write(int prio, const char* tag, const char* msg) { |
| 53 hwcplus_log_fn(prio, tag, msg); |
| 54 } |
| 55 |
| 56 int __android_log_print(int prio, const char* tag, const char* fmt, ...) { |
| 57 va_list ap; |
| 58 char buf[LOG_BUF_SIZE]; |
| 59 |
| 60 va_start(ap, fmt); |
| 61 vsnprintf(buf, LOG_BUF_SIZE, fmt, ap); |
| 62 va_end(ap); |
| 63 |
| 64 return __android_log_write(prio, tag, buf); |
| 65 } |
| 66 |
| 67 int property_get(const char* key, char* value, const char* default_value) { |
| 68 printf("property_get %s\n", key); |
| 69 const char* r = default_value; |
| 70 if (!r) |
| 71 r = ""; |
| 72 strncpy(value, r, PROPERTY_VALUE_MAX); |
| 73 return strlen(r); |
| 74 } |
| 75 |
OLD | NEW |