summaryrefslogtreecommitdiff
path: root/str.c
diff options
context:
space:
mode:
Diffstat (limited to 'str.c')
-rw-r--r--str.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/str.c b/str.c
index 532058a..1d3e7ac 100644
--- a/str.c
+++ b/str.c
@@ -160,3 +160,40 @@ int str2mac(const char *str, uint8_t *mac, size_t len)
return 0;
}
+
+char *str2fqdn(const char *str)
+{
+ size_t slen = strlen(str);
+ size_t flen = 0;
+ char *fqdn;
+ char *tmp;
+ char *dup;
+ int i = 0;
+ int c = 0;
+
+ dup = xstrdup(str);
+ tmp = dup;
+
+ fqdn = xzmalloc(slen + 2);
+
+ while (tmp <= dup + slen && c++ <= slen) {
+ if (tmp[i] == '.' || tmp[i] == '\0') {
+ size_t dlen;
+
+ tmp[i] = '\0';
+ dlen = strlen(tmp);
+ fqdn[flen] = dlen;
+ memcpy(&fqdn[flen + 1], tmp, dlen);
+ flen += dlen + 1;
+ tmp += dlen + 1;
+ i = 0;
+
+ continue;
+ }
+
+ i++;
+ }
+
+ xfree(dup);
+ return fqdn;
+}
for the device_link mechanism. ... and, of course, lots of typo fixes and small updates" * tag 'docs-4.10' of git://git.lwn.net/linux: (193 commits) dma-buf: Extract dma-buf.rst Update Documentation/00-INDEX docs: 00-INDEX: document directories/files with no docs docs: 00-INDEX: remove non-existing entries docs: 00-INDEX: add missing entries for documentation files/dirs docs: 00-INDEX: consolidate process/ and admin-guide/ description scripts: add a script to check if Documentation/00-INDEX is sane Docs: change sh -> awk in REPORTING-BUGS Documentation/core-api/device_link: Add initial documentation core-api: remove an unexpected unident ppc/idle: Add documentation for powersave=off Doc: Correct typo, "Introdution" => "Introduction" Documentation/atomic_ops.txt: convert to ReST markup Documentation/local_ops.txt: convert to ReST markup Documentation/assoc_array.txt: convert to ReST markup docs-rst: parse-headers.pl: cleanup the documentation docs-rst: fix media cleandocs target docs-rst: media/Makefile: reorganize the rules docs-rst: media: build SVG from graphviz files docs-rst: replace bayer.png by a SVG image ...
Diffstat (limited to 'tools/testing/selftests/networking')