diff options
author | Lennart Poettering <lennart@poettering.net> | 2005-07-30 14:03:22 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2005-07-30 14:03:22 +0000 |
commit | 3c4e0db3a35b851398eac7c598009e42e3ea7843 (patch) | |
tree | 07c39a10d0e53a46437b71fda31331af5c369f88 /avahi-daemon/embedd-file.py | |
parent | 5b5d01cabfcca8cd50d053aa56714cb0eb2f611e (diff) |
* hide generate init scripts from SVN
* DBUS: implement introspection for Server object
* fix avahi-daemon build (missing stdio.h inclusion)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@199 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-daemon/embedd-file.py')
-rw-r--r-- | avahi-daemon/embedd-file.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/avahi-daemon/embedd-file.py b/avahi-daemon/embedd-file.py new file mode 100644 index 0000000..eaa250f --- /dev/null +++ b/avahi-daemon/embedd-file.py @@ -0,0 +1,56 @@ +#!/usr/bin/python + +import os, sys + +def usage(ret = 0): + print "%s [-s] <file> <symbol>" % sys.argv[0] + sys.exit(ret) + +args = sys.argv[1:] + +use_static = False + +if len(args) >= 1 and args[0] == '-s': + use_static = True + args = args[1:] + +if len(args) >= 1 and args[0] == '-h': + usage() + +if len(args) != 2: + sys.stderr("Wrong number of arguments") + usage(1) + +f = file(args[0]) +t = f.read() +f.close() + +out = sys.stdout + +if use_static: + out.write("static ") + +out.write('const char %s[] = \n"' % args[1]); + +n = 0 + +for c in t: + if c == '\n': + out.write('\\n"\n"') + n = 0 + elif c == '"': + out.write('\\"') + n += 2 + elif ord(c) < 32 or ord(c) >= 127: + out.write('\\x%02x' % ord(c)) + n += 4 + else: + out.write(c) + n += 1 + + if n >= 76: + out.write('"\n"') + n = 0 + +out.write('";\n'); + |