Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: third_party/hwcplus/src/hwcplus_util.c

Issue 252583002: Make it possible to build libhardware. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hwc2
Patch Set: add copyright Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/hwcplus/src/hardware.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « third_party/hwcplus/src/hardware.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698