]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: move strlcat() to util/strbuf.c
authorLai Jiangshan <laijs@cn.fujitsu.com>
Mon, 12 Dec 2011 07:15:52 +0000 (15:15 +0800)
committerPekka Enberg <penberg@kernel.org>
Mon, 12 Dec 2011 21:35:36 +0000 (23:35 +0200)
strlcat() is a string related function.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/builtin-run.c
tools/kvm/include/kvm/strbuf.h
tools/kvm/include/kvm/util.h
tools/kvm/util/strbuf.c
tools/kvm/util/util.c

index 50452786f42049bbb9161aecf25cbbf244496a84..35245ff98182e6f03a48f2b1eadd18ca1779b143 100644 (file)
@@ -21,6 +21,7 @@
 #include "kvm/mutex.h"
 #include "kvm/term.h"
 #include "kvm/util.h"
+#include "kvm/strbuf.h"
 #include "kvm/vesa.h"
 #include "kvm/irq.h"
 #include "kvm/kvm.h"
index e67ca20f355d7316f74323df0461c1290cadef44..8fdef7e003afdff3dd67215c78843a2150e2e555 100644 (file)
@@ -1,6 +1,19 @@
 #ifndef __STRBUF_H__
 #define __STRBUF_H__
 
+#include <sys/types.h>
+#include <string.h>
+
 int prefixcmp(const char *str, const char *prefix);
 
+extern size_t strlcat(char *dest, const char *src, size_t count);
+
+/* some inline functions */
+
+static inline const char *skip_prefix(const char *str, const char *prefix)
+{
+       size_t len = strlen(prefix);
+       return strncmp(str, prefix, len) ? NULL : str + len;
+}
+
 #endif
index dc2e0b9f77908bdc7da448105934f9c65dd57604..3e382fc766494a33fac576a389bcd91b8c19a735 100644 (file)
@@ -58,16 +58,6 @@ do {                                                         \
                __stringify(cnd) "\n");                         \
 } while (0)
 
-extern size_t strlcat(char *dest, const char *src, size_t count);
-
-/* some inline functions */
-
-static inline const char *skip_prefix(const char *str, const char *prefix)
-{
-       size_t len = strlen(prefix);
-       return strncmp(str, prefix, len) ? NULL : str + len;
-}
-
 #define MSECS_TO_USECS(s) ((s) * 1000)
 
 /* Millisecond sleep */
index ec77ab1ec91d17a2c5c90e10916bb4fff0741df5..6632a1449165461f879051fffc0e30b03509092e 100644 (file)
@@ -1,5 +1,6 @@
 
 /* user defined headers */
+#include <kvm/util.h>
 #include <kvm/strbuf.h>
 
 int prefixcmp(const char *str, const char *prefix)
@@ -11,3 +12,28 @@ int prefixcmp(const char *str, const char *prefix)
                        return (unsigned char)*prefix - (unsigned char)*str;
        }
 }
+
+/**
+ * strlcat - Append a length-limited, %NUL-terminated string to another
+ * @dest: The string to be appended to
+ * @src: The string to append to it
+ * @count: The size of the destination buffer.
+ */
+size_t strlcat(char *dest, const char *src, size_t count)
+{
+       size_t dsize = strlen(dest);
+       size_t len = strlen(src);
+       size_t res = dsize + len;
+
+       DIE_IF(dsize >= count);
+
+       dest += dsize;
+       count -= dsize;
+       if (len >= count)
+               len = count - 1;
+
+       memcpy(dest, src, len);
+       dest[len] = 0;
+
+       return res;
+}
index 4efbce9e25b47aeb8b6d4052f111e280d51aa604..682ed6c2337a1d870ac5e0644e327ee72c94574f 100644 (file)
@@ -74,28 +74,3 @@ void die_perror(const char *s)
        perror(s);
        exit(1);
 }
-
-/**
- * strlcat - Append a length-limited, %NUL-terminated string to another
- * @dest: The string to be appended to
- * @src: The string to append to it
- * @count: The size of the destination buffer.
- */
-size_t strlcat(char *dest, const char *src, size_t count)
-{
-       size_t dsize = strlen(dest);
-       size_t len = strlen(src);
-       size_t res = dsize + len;
-
-       DIE_IF(dsize >= count);
-
-       dest += dsize;
-       count -= dsize;
-       if (len >= count)
-               len = count - 1;
-
-       memcpy(dest, src, len);
-       dest[len] = 0;
-
-       return res;
-}