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

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

Issue 252583002: Make it possible to build libhardware. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hwc2
Patch Set: clean up more lint 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
OLDNEW
(Empty)
1 #include "stub.h"
2
3 #include <stdarg.h>
4 #include <stdio.h>
5 #include <string.h>
6
7 #include <cutils/properties.h>
8
9 size_t
10 strlcpy(char* dst, const char* src, size_t siz) {
11 char* d = dst;
12 const char* s = src;
13 size_t n = siz;
14
15 /* Copy as many bytes as will fit */
16 if (n != 0) {
17 while (--n != 0) {
18 if ((*d++ = *s++) == '\0')
19 break;
20 }
21 }
22
23 /* Not enough room in dst, add NUL and traverse rest of src */
24 if (n == 0) {
25 if (siz != 0)
26 *d = '\0'; /* NUL-terminate dst */
27 while (*s++) {
28 }
29 }
30
31 return(s - src - 1); /* count does not include NUL */
32 }
33
34 int __android_log_print(int prio, const char* tag, const char* fmt, ...) {
35 char buf[999];
36 int pos = 0;
37 va_list args;
38
39 va_start(args, fmt);
40 pos += snprintf(buf+pos, sizeof(buf)-pos, "android_log %d %s: ", prio, tag);
41 pos += vsnprintf(buf+pos, sizeof(buf)-pos, fmt, args);
42 va_end(args);
43 buf[sizeof(buf)-1] = 0;
44 fprintf(stderr, "%s\n", buf);
45 return pos;
46 }
47
48 int property_get(const char* key, char* value, const char* default_value) {
49 printf("property_get %s\n", key);
50 const char* r = default_value;
51 if (!r)
52 r = "";
53 strncpy(value, r, PROPERTY_VALUE_MAX);
54 return strlen(r);
55 }
56
OLDNEW
« third_party/hwcplus/src/hardware.c ('K') | « third_party/hwcplus/src/hardware.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698