summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-09-14 17:07:37 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-10-07 11:54:23 +0200
commit1d7e3d0b713371fc5c8ebd805a9679bbd7a416bb (patch)
tree6425f7c53ed02cc756dfda45be0d17b65025b34a
parent9edee0a8e65cf7a1621082a05a5130b5005c82ca (diff)
eolian gen2: include guard func
-rw-r--r--src/bin/eolian2/main.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/bin/eolian2/main.c b/src/bin/eolian2/main.c
index 6d74a7e9c4..aa3da0b70f 100644
--- a/src/bin/eolian2/main.c
+++ b/src/bin/eolian2/main.c
@@ -107,6 +107,31 @@ static void _fill_all_outs(char **outs, const char *val)
107 } 107 }
108} 108}
109 109
110static Eina_Strbuf *
111_include_guard(const char *fname, const char *gname, Eina_Strbuf *buf)
112{
113 if (!buf || !eina_strbuf_string_get(buf))
114 return buf;
115
116 if (!gname)
117 gname = "";
118
119 char iname[256] = {0};
120 strncpy(iname, fname, sizeof(iname) - 1);
121 char *inamep = iname;
122 eina_str_toupper(&inamep);
123
124 Eina_Strbuf *g = eina_strbuf_new();
125 eina_strbuf_append_printf(g, "#ifndef _%s_%s\n", iname, gname);
126 eina_strbuf_append_printf(g, "#define _%s_%s\n\n", iname, gname);
127
128 eina_strbuf_replace_all(g, ".", "_");
129 eina_strbuf_append(g, eina_strbuf_string_get(buf));
130 eina_strbuf_append(g, "\n#endif\n");
131 eina_strbuf_free(buf);
132 return g;
133}
134
110static Eina_Bool 135static Eina_Bool
111_write_file(const char *fname, const Eina_Strbuf *buf, Eina_Bool append) 136_write_file(const char *fname, const Eina_Strbuf *buf, Eina_Bool append)
112{ 137{