On Fri, Jul 19, 2013 at 03:56:05PM +0200, Manuel VIVES wrote:
---
src/libvirt_private.syms | 1 +
src/util/virstring.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++
src/util/virstring.h | 6 +++
3 files changed, 136 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 57a1b50..65e85d4 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1901,6 +1901,7 @@ virStringListLength;
virStringSplit;
virStrncpy;
virStrndup;
+virStrReplace;
virStrToDouble;
virStrToLong_i;
virStrToLong_l;
diff --git a/src/util/virstring.c b/src/util/virstring.c
index 1f4850e..81a3a4d 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -613,3 +613,132 @@ size_t virStringListLength(char **strings)
return i;
}
+
+/*
+ virStrReplace(haystack, haystacksize, oldneedle, newneedle) --
+ Search haystack and replace all occurences of oldneedle with newneedle.
+ Resulting haystack contains no more than haystacksize characters (including the
'\0').
+ If haystacksize is too small to make the replacements, do not modify haystack at all.
+
+ RETURN VALUES
+ virStrReplace() returns haystack on success and NULL on failure.
+ Failure means there was not enough room to replace all occurences of oldneedle.
+ Success is returned otherwise, even if no replacement is made.
+Methods found here:
http://stackoverflow.com/a/12546318, author: Brandin
NACK, you can't copy code from
stackoverflow.com into libvirt. The stackoverflow
user contributions are creative-commons-by-sa licensed, which is not compatible
with Libvirt LGPLv2 license.
From the
stackoverflow.com page footer:
"site design / logo © 2013 stack exchange inc; user contributions licensed
under cc-wiki with attribution required" (Links to cc-by-sa license)
http://www.gnu.org/licenses/license-list.html#NonFreeDocumentationLicenses
"Creative Commons Attribution-Sharealike 2.0 license (a.k.a. CC BY-SA) (#ccbysa)
This is a copyleft free license that is good for artistic and entertainment
works, and educational works. Please don't use it for software or
documentation, since it is incompatible with the GNU GPL and with the GNU
FDL."
Please throw away this code & write a new implementation from scratch
*without referencing* this stackoverflow code at all.
Regards,
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|