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