OSDN Git Service

cutils: add strpadcpy()
authorDmitry Fleytman <dmitry.fleytman@ravellosystems.com>
Mon, 9 Jul 2012 06:50:43 +0000 (08:50 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 26 Jul 2012 15:44:08 +0000 (17:44 +0200)
Signed-off-by: Yan Vugenfirer <yan@ravellosystems.com>
Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
cutils.c
qemu-common.h

index e2bc1b8..9d4c570 100644 (file)
--- a/cutils.c
+++ b/cutils.c
 #include "qemu_socket.h"
 #include "iov.h"
 
+void strpadcpy(char *buf, int buf_size, const char *str, char pad)
+{
+    int len = qemu_strnlen(str, buf_size);
+    memcpy(buf, str, len);
+    memset(buf + len, pad, buf_size - len);
+}
+
 void pstrcpy(char *buf, int buf_size, const char *str)
 {
     int c;
index 7c8dac8..d26ff39 100644 (file)
@@ -138,6 +138,7 @@ int qemu_timedate_diff(struct tm *tm);
 
 /* cutils.c */
 void pstrcpy(char *buf, int buf_size, const char *str);
+void strpadcpy(char *buf, int buf_size, const char *str, char pad);
 char *pstrcat(char *buf, int buf_size, const char *s);
 int strstart(const char *str, const char *val, const char **ptr);
 int stristart(const char *str, const char *val, const char **ptr);