aboutsummaryrefslogtreecommitdiffstats
path: root/tools/prog2c
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2015-10-12 10:16:57 +0200
committerDmitry Vyukov <dvyukov@google.com>2015-10-12 10:16:57 +0200
commit874c5754bb22dbf77d6b600ff91f0f4f1fc5073a (patch)
tree0075fbd088046ad5c86e6e972235701d68b3ce7c /tools/prog2c
initial commit
Diffstat (limited to 'tools/prog2c')
-rw-r--r--tools/prog2c/prog2c.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/prog2c/prog2c.go b/tools/prog2c/prog2c.go
new file mode 100644
index 000000000..9b8e58efa
--- /dev/null
+++ b/tools/prog2c/prog2c.go
@@ -0,0 +1,31 @@
+// Copyright 2015 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+package main
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+
+ "github.com/google/syzkaller/prog"
+)
+
+func main() {
+ if len(os.Args) != 2 {
+ fmt.Fprintf(os.Stderr, "usage: prog2c prog_file\n")
+ os.Exit(1)
+ }
+ data, err := ioutil.ReadFile(os.Args[1])
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "failed to read prog file: %v\n", err)
+ os.Exit(1)
+ }
+ p, err := prog.Deserialize(data)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "failed to deserialize the program: %v\n", err)
+ os.Exit(1)
+ }
+ src := p.WriteCSource()
+ os.Stdout.Write(src)
+}