summaryrefslogtreecommitdiff
path: root/source/aparser/util.awk
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-05-14 14:05:10 +0000
committerAndrew Tridgell <tridge@samba.org>2000-05-14 14:05:10 +0000
commit14ded82dc92ae6eff7639351f391a33b9cc31c0d (patch)
tree566cd9d1dd92aec553168f00d2d0ba78f592c883 /source/aparser/util.awk
parent6790d6c589620f4d0f7aa67a3253c52b0b36c0f7 (diff)
downloadsamba-14ded82dc92ae6eff7639351f391a33b9cc31c0d.tar.gz
vastly improved awk based code generator
now handles recursive function definitions, unions etc it is sufficient for some basic types like UNISTR2 and BUFFER5 to be defined in the *.struct file and used successfully this generator uses templates (in *.tpl files) for all code generation, allowing easy replacement of the backend functions
Diffstat (limited to 'source/aparser/util.awk')
-rw-r--r--source/aparser/util.awk33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/aparser/util.awk b/source/aparser/util.awk
new file mode 100644
index 00000000000..93f9a4dcd27
--- /dev/null
+++ b/source/aparser/util.awk
@@ -0,0 +1,33 @@
+function isaptr(elem)
+{
+ if (substr(elem, 1, 1) == "*") {
+ return 1;
+ }
+ return 0;
+}
+
+function noptr(elem)
+{
+ if (!isaptr(elem)) return elem;
+ return substr(elem, 2);
+}
+
+function xprintf(f, fmt, v1, v2, v3, v4, v5, v6, v7)
+{
+ printf(fmt, v1, v2, v3, v4, v5, v6) > f;
+}
+
+function fatal(why)
+{
+ printf("FATAL: %s\n", why);
+ exit 1;
+}
+
+function numlines(fname,
+ LOCAL, line, count)
+{
+ count=0;
+ while ((getline line < fname) > 0) count++;
+ close(fname);
+ return count;
+}