1 | *** bins/unzzip.c.orig Sun Apr 23 20:46:28 2017 |
---|
2 | --- bins/unzzip.c Fri May 26 07:35:59 2017 |
---|
3 | *************** |
---|
4 | *** 14,19 **** |
---|
5 | --- 14,36 ---- |
---|
6 | extern int unzzip_print(int argc, char** argv); |
---|
7 | extern int unzzip_extract(int argc, char** argv); |
---|
8 | |
---|
9 | + size_t strnlen(const char *s, size_t len) |
---|
10 | + { |
---|
11 | + size_t i; |
---|
12 | + for(i=0; i<len && *(s+i); i++); |
---|
13 | + return i; |
---|
14 | + } |
---|
15 | + |
---|
16 | + char* strndup (char const *s, size_t n) |
---|
17 | + { |
---|
18 | + size_t len = strnlen (s, n); |
---|
19 | + char *new = malloc (len + 1); |
---|
20 | + if (new == NULL) |
---|
21 | + return NULL; |
---|
22 | + new[len] = '\0'; |
---|
23 | + return memcpy (new, s, len); |
---|
24 | + } |
---|
25 | + |
---|
26 | static const char usage[] = |
---|
27 | { |
---|
28 | "unzzip <dir>.. \n" |
---|